From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45DB0C2BD09 for ; Sat, 6 Jul 2024 06:12:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C59126B0085; Sat, 6 Jul 2024 02:12:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C08A86B0088; Sat, 6 Jul 2024 02:12:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA8966B0089; Sat, 6 Jul 2024 02:12:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 88D1D6B0085 for ; Sat, 6 Jul 2024 02:12:41 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1C1F61C0B0D for ; Sat, 6 Jul 2024 06:12:41 +0000 (UTC) X-FDA: 82308308922.01.B1029AC Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by imf19.hostedemail.com (Postfix) with ESMTP id 19F2B1A0002 for ; Sat, 6 Jul 2024 06:12:38 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JU5la5Ng; spf=pass (imf19.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.45 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720246333; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FDbSGOTT29nUQuDrfA04vbxY/zhE1PwPtnbE9KH53Hw=; b=wTIitPm0rM0k7YKvP9rHbbJxhKLr4BsR9dyLxSXOL6NyaLjL1m2gAmNiXYNxlTn91/+CNb Pb/qqstxJqP8hwUYuWfOTHExolZaV7U8cuFYBe8vlhj/HxylPQsGt0746YLWs5N5XT7n5m nWygZX8RPl/bkXTj4LqCT/7sJD59v9g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720246333; a=rsa-sha256; cv=none; b=1qHNuQtP3Jx09wEffoIqMV3TvRhv0z1+Ur01txCt5nRGDS3DVGBzjJFBGELnhIfqPx5aD9 jc7GTRvKuDvsIPP2o6h2TlcUPBAX7kE2ywEPOzIOxbQbCyjF4zF5w0BdGxropvcuSpN6Fz wGiL4O9jGz5+EGDXNFSyY/RBnn+jAa4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JU5la5Ng; spf=pass (imf19.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.45 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a77c349bb81so184891766b.3 for ; Fri, 05 Jul 2024 23:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720246357; x=1720851157; darn=kvack.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=FDbSGOTT29nUQuDrfA04vbxY/zhE1PwPtnbE9KH53Hw=; b=JU5la5NgrFiGcrwuItf8Sfafs1Ec/c2tuE085YrXfxHAZbtsMKnPQlSqquoQNBtEXJ 81HrGqgF5uI6pUcITgfamIX8DXokVOmPXNN/283pG8jwVg+Aa5T//23pq0m84QDMRWE2 u8GqF4cWu39DZkoIF/aIl1uzR9culpr7TkP1Z/zzsKtKr4fsB6FZu20AaNhKy5T0Z2UO 39JrfyA8ZVcusDsgaPobJ7q/mkPn/r6wdL9C2ZeoVwO2KGzFvv+tCOEcvf51GpIv2qD8 NWOLuMweS9gp4FRwobIpr6O1jubnctz9/v9WdDw/YyXOeYvtAgDTbW+f8qUK7qBNBCSI 5GsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720246357; x=1720851157; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FDbSGOTT29nUQuDrfA04vbxY/zhE1PwPtnbE9KH53Hw=; b=i2A1Me3L4qrZYV4eVWjvVOVClpxt5AMFt6d8cPuZjqq01r/0C+tU4cyV+0z6BxFwCm hkOolePYSLCHlbZ08Px4V25XnlycXnPHOpW7DWfBnUq+fJWVQG+fbLEBhw+4zg3UVAPH Ezv7pKdNTJvKL8Gs83Wp27j1z97+gU/m7xlnBLfqGb+wr0HgNPNjMxd844L2QzJj733R 4cDX7UOrmPvh3g0YhIRLTpf7HehQ/8iPZmHrlfNTlTWEtvXUMVxmQ6ls/A2eW/IF9Fvp URqQ44fFuG2KOP/EvIdxZ3H+DAJ8g1AD1drSa84hbbCqRfizmZJMuvNbCocauf7gLSc3 R2Vw== X-Forwarded-Encrypted: i=1; AJvYcCWdsa5l3CXVgWPNE3nb+nqBPrJcIzPWktVfm5Gp0I43wkMPaCiOOTJz7h/CACKDLV1fB4r4dnccT4DXckYd1oOt4r4= X-Gm-Message-State: AOJu0YwnruWLDOYEvj/y/5NtebmJKt9BtSZmSq/Rw/++2B41RswlD67f zIaN9jdi83d9ttercXzBt9+nqoLlpuYJmmHBDnfaB6lyTdlegmfV X-Google-Smtp-Source: AGHT+IFQGo+Vs5pdkor1uOiOtgu7cQVjKdGdWWlD+aVNznwVI9BiGzRyrVGIoVnnnwlHjSZMnv1bOw== X-Received: by 2002:a17:907:7da0:b0:a77:cf9d:f496 with SMTP id a640c23a62f3a-a77cf9df66bmr257510066b.39.1720246357279; Fri, 05 Jul 2024 23:12:37 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a77b6f7649bsm196884466b.193.2024.07.05.23.12.36 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jul 2024 23:12:36 -0700 (PDT) Date: Sat, 6 Jul 2024 06:12:36 +0000 From: Wei Yang To: Wei Yang Cc: Masahiro Yamada , akpm@linux-foundation.org, nathan@kernel.org, nicolas@fjasle.eu, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Mike Rapoport Subject: Re: [PATCH 2/3] modpost: .meminit.* is not in init section when CONFIG_MEMORY_HOTPLUG set Message-ID: <20240706061236.snp4r2tixx3h7hfe@master> Reply-To: Wei Yang References: <20240702234008.19101-1-richard.weiyang@gmail.com> <20240702234008.19101-2-richard.weiyang@gmail.com> <20240705065456.dogycpd37jun44p5@master> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240705065456.dogycpd37jun44p5@master> User-Agent: NeoMutt/20170113 (1.7.2) X-Rspamd-Queue-Id: 19F2B1A0002 X-Stat-Signature: h9zsjghnbok18x4jupiyp7dsoyrb4ep9 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1720246358-128809 X-HE-Meta: U2FsdGVkX18+DB9CLZBCTWtvNgcs+4WcZvqKiBJj0q/JOH2j/8JfRHAexAfr1R4Ku2JB8iGLz+La6ZKVwFU+0NR+HHSIjPHOWArug10s7+R136R3iIgMVyQwWMS4qsAJwSsjVF4NNzGVOTeI8x51gSg1xj2oaFAPj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0dhLr72YKi9Geij4dmH9ZgLc5OOorOUEd8eoaRdhBuBOYFdVUY53DpHYJgsYGtz05DrWd62ZPhMjZujWYyWfz9bVeYZgpwQXcAWer52ihfElXHg0aSUpF170BlSPw2JXJ9KeSNv1VtoUO6nQOeeGCITUHMUAwWEJnfGBsss1/1Nv1WRl3TqXRPa1+SN1FX3niua0up6Jm7ctsezJw5bidonMpxxibHQ7mFi4+a4zqRrbtcRgF6pNIDmrSO+u0K2vtmlhScrnQBm+bsJjYHAkgwtY3gYVQttLA0mWzG+RHxUwQhZNc8fpAJs3mTnrhA6T4e1OhUG9AwQDLf+EiAnW0SxqrC8PU7I6BFtFvoxjDeyyzTEREmRXMnK8aH+fFqpLmFYlLHNarHgE0dde3Lo9wjNqS3AUsXafeDlsMBB44YhabtidxIC3vmDostldm3yuxIoO7Vpkw0m8zlsfH7InzJIVKqsrtQ8ZaKAqXRV8+l3MghewS57HYylMdu5xII7pYqaR02N6w25MVjpMIVv7tXY0L4J3JclVnT708A3Ho+UJvekFLQoLiWYbU8yFqMxqHlHuO0VhWYqQotKne5YFloZD4KyQ9EhuXEbe8XYfyclpT5jF5bEW2IOUowU9S589gtajQeiR8GdkAxSHFYOdH8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Jul 05, 2024 at 06:54:56AM +0000, Wei Yang wrote: >On Wed, Jul 03, 2024 at 11:44:38PM +0900, Masahiro Yamada wrote: >>On Wed, Jul 3, 2024 at 8:40 AM Wei Yang wrote: >>> >>> .meminit.* is not put into init section when CONFIG_MEMORY_HOTPLUG is >>> set, since we define MEM_KEEP()/MEM_DISCARD() according to >>> CONFIG_MEMORY_HOTPLUG. >>> >>> Signed-off-by: Wei Yang >>> CC: Mike Rapoport (IBM) >>> --- >>> scripts/mod/modpost.c | 10 ++++++++++ >>> 1 file changed, 10 insertions(+) >> >> >> >>NACK. >> >> >>The section mismatch is performed _unconditionally_. >> >> >> >>In the old days, we did this depending on relevant CONFIG options. >>It was more than 15 years ago that we stopped doing that. >> >> >>See this: >> >> >>commit eb8f689046b857874e964463619f09df06d59fad >>Author: Sam Ravnborg >>Date: Sun Jan 20 20:07:28 2008 +0100 >> >> Use separate sections for __dev/__cpu/__mem code/data >> >> >> >> >>So, if you wanted to check this only when CONFIG_MEMORY_HOTPLUG=n, >>you would need to add #ifdef CONFIG_MEMORY_HOTPLUG to include/linux/init.h >> >>That is what we did in the Linux 2.6.* era, which had much worse >>section mismatch coverage. >> > >Masahiro > >If you would give me some suggestions, I'd appreciate it a lot. > >The original thing I want to do is to put function __free_pages_core() in >__meminit section, since this function is only used by __init functions and >in memory_hotplug.c. This means it is save to release it if >CONFIG_MEMORY_HOTPLUG is set. > >Then I add __meminit to function __free_pages_core() and face the warning from >modpost. > > WARNING: modpost: vmlinux: section mismatch in reference: generic_online_page+0xa (section: .text) -> __free_pages_core (section: .meminit.text) > >A .text function calls init code is not proper. Then I add __meminit to >generic_online_page too. Then I face this warning from modpost. > > WARNING: modpost: vmlinux: generic_online_page: EXPORT_SYMBOL used for init symbol. Remove __init or EXPORT_SYMBOL. > I guess I found the correct way. Add __ref to generic_online_page to not issue a warning. >Function generic_online_page() is exported and be used in some modules. And is >not allowed to use init tag. > >When looking into the code, this warning is printed by this code: > > #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS > > if (match(secname, PATTERNS(ALL_INIT_SECTIONS))) > warn("%s: %s: EXPORT_SYMBOL used for init symbol. Remove __init or EXPORT_SYMBOL.\n", > mod->name, name); > >If my understanding is correct, the code means we can't use a function in init >section, since the code will be released after bootup. > >But for this case, when CONFIG_MEMORY_HOTPLUG is set, the section .meminit.* >is not put into the real init sections. So the functions are not released and >could be used by modules. This behavior is introduced in commit >eb8f689046b8(the one you mentioned above). > >So the check here is not proper to me. We should exclude .meminit.* from >ALL_INIT_SECTIONS. > >Looking forward your suggestion and a proper way to handle this. > >-- >Wei Yang >Help you, Help me -- Wei Yang Help you, Help me