Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp99993rwb; Wed, 18 Jan 2023 14:47:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXtjNDquHbnTZCEAEwWstRMboN4ozkQr8twc20ijWP2IWI2zmhFEFDcF+bdrhyVBSjngDxBb X-Received: by 2002:a05:6402:27cf:b0:46b:4011:9863 with SMTP id c15-20020a05640227cf00b0046b40119863mr12139976ede.39.1674082062512; Wed, 18 Jan 2023 14:47:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674082062; cv=none; d=google.com; s=arc-20160816; b=r5JCNyVpvh2KcSCt5CxLQadAY6q6B9lxKGhPItrwwbdA0zy+DOAl+3C3J+DtCeBJnz EdRrvkIHtQCgdhh6jionHmcVoYhfPHmHNrNm6sGdL7bUvODtUuwFz754smaAFbzF3Ckj beVmTMwRdAlMlko6qwQMQVhk+pXkvIo2+oa4C/30qHLiWjvC9jocfrwyKJAqtVpb1ZaI f3AK5vry26gvCzaf4mEeg7+pMXU8NcCLceaVOI0GXj9Q6wQ6QPM4dHjViQMnVENNGEiA ptsuJLsRMeaA2wgpdQ3nQtCSdW8L7hAGpJPVr18AVWGN4CF5c1LEjlVdRS57i+e2NtHJ drwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=if9LVLBEvYmJWN4jKZu8pk8Y7ITE4TYspxK4bofN7ZQ=; b=rvR2CQEfUfa9LmBLNnKUnRX1y1sNNxY1daZIE0h8pD9osaDelJikfSe0+V8/Tuqskc ce2TCRiC1dtgX0OY3glTiCTmCg45krMmnQmtYKXJrOpt2Oe3dKeIY+DtGThTlJIWbEfR SgZy5QrpoRFO4Jp7nTF+P/4tQskJ22YrFrx/WQ6irVUjNU6gObE2RRSfcw38RjUJ7hUc F8GdSAjrxF/MRFbyfZqr+SnnUCFZnrjyy+X2iQyYsTieCLBz0Vtlc7Sk4t+gwfyJ8KHG AeAv1Lqmb575sARtSHbJRySLN83sfBVtX3NAria70qAYAI6Sisr0mobYlmNycekYUFBX c4RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=h7S4iKaM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j12-20020aa7c0cc000000b0048fac1755bbsi6655864edp.168.2023.01.18.14.47.31; Wed, 18 Jan 2023 14:47:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=h7S4iKaM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229708AbjARVx1 (ORCPT + 44 others); Wed, 18 Jan 2023 16:53:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjARVxJ (ORCPT ); Wed, 18 Jan 2023 16:53:09 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CB385EF8C; Wed, 18 Jan 2023 13:53:07 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DC8CD619E3; Wed, 18 Jan 2023 21:53:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CBDFC433F2; Wed, 18 Jan 2023 21:53:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674078786; bh=odow2u7c9P22z89GlE8wddINSjSouNXYUoKkWII7NXs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=h7S4iKaMBVhXD6Mid/6Pu30NLvr5uMEY79CRxCk71ReJWT1+IcfTxD73tCd0r1ErB Fgvs4h2CjbLLCZY+w8FTSGYrgg/IVq2CMWwk3udpa6WNaidpuTOMuVKkyZ8QpkcC7U Jc8jE86jy3R6c/i0K39ITC/ZVSqDcME5qpQcvRQ+iktW+ekT48JhUD/jkjIuJOxBZC jIbxzqV0Zr0wD/nDWOnmHNnlPWjkI2gpHZBwMmcJE+tvC8I5pzCErBHEDKIC6nnNeo YbWO9RWctpvm4UZHjuLd9h6SZcl5UL9JL24gitS1atcmFhCNj3qZM9w8totlDZylrv Qe1GNOoHEQVug== Received: by mail-lf1-f43.google.com with SMTP id a11so480505lfg.0; Wed, 18 Jan 2023 13:53:06 -0800 (PST) X-Gm-Message-State: AFqh2kqSyVQcasDJ9X7gdur83yf+VgEIBighmcAvShvtoHzx+08ZDwah XoWxorI+szHJq6Nm3yXx5eUR9qu0vwIASWLJRug= X-Received: by 2002:a05:6512:2115:b0:4cb:1d3e:685b with SMTP id q21-20020a056512211500b004cb1d3e685bmr476566lfr.126.1674078784233; Wed, 18 Jan 2023 13:53:04 -0800 (PST) MIME-Version: 1.0 References: <20230106220959.3398792-1-song@kernel.org> <20230118074047.GA27385@lst.de> In-Reply-To: <20230118074047.GA27385@lst.de> From: Song Liu Date: Wed, 18 Jan 2023 13:52:51 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH/RFC] module: replace module_layout with module_memory To: Christoph Hellwig Cc: Thomas Gleixner , Luis Chamberlain , Christophe Leroy , songliubraving@fb.com, Peter Zijlstra , linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 17, 2023 at 11:40 PM Christoph Hellwig wrote: > > On Tue, Jan 17, 2023 at 10:50:55AM -0800, Song Liu wrote: > > Hi Thomas and Luis, > > > > Could you please share your comments on this? Specifically, is this on > > the right direction? And, what's your preference with Christophe's > > suggestions? > > > > "I dislike how it looks with enums, things like > > mod->mod_mem[MOD_MEM_TYPE_INIT > > _TEXT] are odd and don't read nicely. > > Could we have something nicer like mod->mod_mem_init_text ? > > I know it will complicate your for_each_mod_mem_type() but it would look > > nicer." > > FYI, I don't particularly like the array either. But if it makes > the code much simpler I can live with it. How about we do something like this struct module { ... /* rbtree is accessed frequently, so keep together. */ union { struct module_memory mod_mem[MOD_MEM_NUM_TYPES] __module_memory_align; struct { /* keep the same order as enum mod_mem_type */ struct module_memory core_text; struct module_memory core_data; struct module_memory core_rodata; struct module_memory core_ro_after_init; struct module_memory init_text; struct module_memory init_data; struct module_memory init_rodata; }; }; ... }; In this way we can use the array in the for loops, and use mod->core_text, etc. when we only need to access one of them. Thanks, Song PS: Do we need __no_randomize_layout somewhere?