Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3078482rwb; Fri, 20 Jan 2023 10:54:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXuIITWuDm9qTVeA8D4var6TdO8lUioksZTIAHGhHsC4qAK9D0T39b6TOM9PHxElbBNpyzK2 X-Received: by 2002:aa7:cd59:0:b0:494:912d:303b with SMTP id v25-20020aa7cd59000000b00494912d303bmr14997671edw.17.1674240845559; Fri, 20 Jan 2023 10:54:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674240845; cv=none; d=google.com; s=arc-20160816; b=q5dFqsNhDbn3BgtdsiQm72wOngdpCFZDWTDcFm2jATYGfVeC27rGZSa7SDJCg/8Mrl GHk9m0mUkGyAhM/JuTrqElJkuK8m6DCDNLyLT9UmFR22YTiKJAwWSlZrQObcUNChzlr9 NcyxIZRFXsepjSBqMJa9yDa1VHGjytMoWwOM9cKPzTg7fxRSUeIf1GFAQdSeWeCBg4cz rXXDzyphFOEOx/8AL0fdamyWfUcA+FYmnV+ftL+WNApms4hh4CWz9EjuqCb6Q620uRlS S2CBd+xtF7lv6jRLi+X5t1sumi5nplXfauw6qIh2B2Ug1Q5SIjuCh4bFGw+4s1Ruy4oC 09sw== 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=DqK+WprXwPa7u+CdeiotwxckK+UdzKz1rncU/6qCCN0=; b=MYUElAFxORhmmmmG+pgLr4MU3pGo5zb1hcOTwBIofpHhE+jPNxBbm2dtVHMSqY2qz+ 9+eTfg/1O+aOeloOvin84EukWri1Xm8xBvA5Z1gfyF9+0v63oseXrxXtP+DZkKw4Lg4c 96DG67pOqqOdDCS9uOonCfn15hWBdf9IkW/jZAyGvn9YnZdGHlODA2TWck5KdvfQPtg/ dpubKloCxhiGxH/zud8E+tfU3rUKf9vLL+CQ8Lm5ggKN/hUEqHgcYEStlIyP2CU9oJGp wpupDTci2DXz/fh0UAPZgwcBmVzjs78hL+FmTG7GMf+dBYInaN83vGPD+rcwpZwGV9IS 1fIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=guFUxnOC; 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 ey1-20020a0564022a0100b0049e6e1a2de7si6557917edb.83.2023.01.20.10.53.53; Fri, 20 Jan 2023 10:54:05 -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=guFUxnOC; 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 S230321AbjATRms (ORCPT + 50 others); Fri, 20 Jan 2023 12:42:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230305AbjATRmq (ORCPT ); Fri, 20 Jan 2023 12:42:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 164454F849; Fri, 20 Jan 2023 09:42:41 -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 8C69962013; Fri, 20 Jan 2023 17:42:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E57C3C433A1; Fri, 20 Jan 2023 17:42:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674236560; bh=WMahhW6oUd2zW6eBCstPrXu22SWG93RzbfOHBsyIEW8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=guFUxnOCFuHNzVn+ojSHmkOO6vd50slt/V26hSoreOwzXTTcrXI9Ba69r7cXs4eg7 qI/wt/u9gI0+o3i5/eBONpoa0TtTsENloBmouzjnH9raWWt6wxgKBJ+rqbd1pW4l33 2oKDcq61uIYNcBCccKZVYUILvcknqp4KXIMIg7aWNa3c3W43+cm+6Z4GQTMvpmnA16 EynmVv7buelQO3zfpXHrQDWhWhJm+Xm+dHdjRIKXDZchSTPISoToBdc96R40LKnYro IjDfkblDblozrSMHnwTnJLpuGlxF43gWG7u8Y7C0pyDKBtaEZjuUb/8sFPhTzfBURg Z2NPCOasa/fOg== Received: by mail-lj1-f175.google.com with SMTP id e16so6297722ljn.3; Fri, 20 Jan 2023 09:42:40 -0800 (PST) X-Gm-Message-State: AFqh2kr3lNF1X/vDmjd21iv+TyhbNw26LgNR/2XaWkj7dpCk5PpI2hYA g0a2X+WuHtBLYQts+BLSfXbDziN7kI3QppQUpKg= X-Received: by 2002:a2e:a5c4:0:b0:289:1305:680d with SMTP id n4-20020a2ea5c4000000b002891305680dmr843375ljp.421.1674236558924; Fri, 20 Jan 2023 09:42:38 -0800 (PST) MIME-Version: 1.0 References: <20230106220959.3398792-1-song@kernel.org> <20230118074047.GA27385@lst.de> <20230119053545.GA16775@lst.de> In-Reply-To: From: Song Liu Date: Fri, 20 Jan 2023 09:42:26 -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 Thu, Jan 19, 2023 at 12:29 AM Song Liu wrote: > > On Wed, Jan 18, 2023 at 9:35 PM Christoph Hellwig wrote: > > > > On Wed, Jan 18, 2023 at 01:52:51PM -0800, Song Liu wrote: > > > 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. > > > > Just use the array please instead of making it too ugly. If that > > is the only sensible way to iterate we have a good argument for the > > array and can live with it. > > Hmm.. I think it won't be ugly outside of the struct definition... > Alternatively, how about use something like > > #define core_text mod_mem[MOD_MEM_TYPE_TEXT] > ... > > which is similar to > > struct sock { > /* > * Now struct inet_timewait_sock also uses sock_common, so please just > * don't add nothing before this first member (__sk_common) --acme > */ > struct sock_common __sk_common; > #define sk_node __sk_common.skc_node > #define sk_nulls_node __sk_common.skc_nulls_node > ... > }; So here are the two versions, both with secondary addr_[min|max] for CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC. v2. Just use mod_mem array: https://git.kernel.org/pub/scm/linux/kernel/git/song/md.git/commit/?h=remotes/song-md/new_module_alloc_build_test_v2 v3. mod_mem array and the defines: #define mod_core_text mod_mem[MOD_MEM_TYPE_TEXT] #define mod_core_data mod_mem[MOD_MEM_TYPE_DATA] etc. https://git.kernel.org/pub/scm/linux/kernel/git/song/md.git/commit/?h=remotes/song-md/new_module_alloc_build_test_v3 I personally like the v3 better. Please share you comments on this. Thanks, Song