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 11539C7114A for ; Tue, 17 Jun 2025 05:34:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E1626B0093; Tue, 17 Jun 2025 01:34:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8916B6B0095; Tue, 17 Jun 2025 01:34:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 780456B0096; Tue, 17 Jun 2025 01:34:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 665056B0093 for ; Tue, 17 Jun 2025 01:34:48 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DA8D01A1977 for ; Tue, 17 Jun 2025 05:34:47 +0000 (UTC) X-FDA: 83563778214.19.46C3EDF Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) by imf26.hostedemail.com (Postfix) with ESMTP id 28A9914000C for ; Tue, 17 Jun 2025 05:34:45 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=AVO+PWn2; spf=pass (imf26.hostedemail.com: domain of hao.ge@linux.dev designates 95.215.58.173 as permitted sender) smtp.mailfrom=hao.ge@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750138486; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=F+F/i0GG3dVaWoc6Zw5lkvRKM42zxYRYhgbTG6NPSyI=; b=4deqDbLMvnP4oPB+R4SDdLWJHyP3Zu1RgRsCYMSLqDSr7Wdbar564zMCjAonlmd7ky0ipM Q2VHHNnsv5NfOtC2Bb9W/WTAGTFHUxZugScg/vDRTlWdMtAiVgD+Q13VsFbnXHM0o3o9zK lC2j1f57WkPy4c5OIqQLE55Re8Rxers= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=AVO+PWn2; spf=pass (imf26.hostedemail.com: domain of hao.ge@linux.dev designates 95.215.58.173 as permitted sender) smtp.mailfrom=hao.ge@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750138486; a=rsa-sha256; cv=none; b=E9EeU3EXo0f+kmufyhjYcb/YJ7N3KKCKC331qlC4WnY0S/M7DOIoWTnq6pgU0GrZtCN8pZ vWuJ4Qy/HLIX/YZhlwLwUYiFoBbKrx5K05rrJ107jcULGFCbDlRIXlfj0QtrVlidcqk2Fh mcxTkmg8WG5B2M3/gFswgP2NC6QbHuY= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1750138483; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=F+F/i0GG3dVaWoc6Zw5lkvRKM42zxYRYhgbTG6NPSyI=; b=AVO+PWn2MjSqlrTfqCn6GB6PWkM5olCb6tdA4kIqhcFmDEVN9HOP9316WkrHYjcqg4fAsW 0csoLYXWDguChd6XilAEeX1vfFDjzyGcfaUPGdTvAv7DR0X3s2D4FcIUAekvs6HvnpzbH3 vDisOewdHOnG2R2rw2OC/Oqo5ZNrdA0= From: Hao Ge To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Suren Baghdasaryan , Mike Rapoport , Richard Henderson , Matt Turner , Dennis Zhou , Tejun Heo , Christoph Lameter , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Kent Overstreet Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-s390@vger.kernel.org, Hao Ge , Hao Ge Subject: [PATCH v4 0/1] mm: Restrict _shared_alloc_tag static definition to CONFIG_ARCH_MODULE_NEEDS_WEAK_PER_CPU Date: Tue, 17 Jun 2025 13:33:56 +0800 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 28A9914000C X-Stat-Signature: 1kerjcrify3z55wiwoqui9ufunstog31 X-Rspam-User: X-HE-Tag: 1750138485-953425 X-HE-Meta: U2FsdGVkX19DQ19zIWHsFdxx0ErzmWMywR73JC2mPhKrdxeMzM7N3C5XgJvyo6jX2M91PyGeStBp0TfdDB8u863wYvkKvqfDXQO80Trq14a7hTkLe2JRyXV83UaqU2z6Rgl5mLk8fn5EzmJTPDQIxp4zlDd3YkuOC/1Bc7j1kxCIiWAbhO+gcDxdSSbSevcN7KAFSl+MEvuUVqF0KVXwRSRFWpN+5mASsHou3LIrzbQbiM7chzTnjgxebLNBHB0om4sq+u2yPZHMtejbfhjsCiA0WY1/JH3kxzvDzOBFyqzr9dJ3tZj4KVMGFc/23f+a8nfEnMPj7sw7J+QZAbnIZ9z8Qwsu/J6EPZ+9WNYuxz2c1GS3TnrJl9lrgMkPjP8GL81ZzZq/fXWcnQyqjUlLiuGIRfmtWZThW5SbSye/pmGe6R2OSUxG1GGfVqGQe8TdLZg6gociRreuJmdxN+3tBLIMax80b3k7IZto4WO4aia7uJZtb8malj3FwVIfos23HX0MEV5tX7WNV4angVkTSkMIrrXgzo7KBU/INqKSOWqjQZx3Q1odin5vgmbpDA9QWdQWaRwFJbL8XdrlmuSPfaCAHwAhSBgFGFSfW/FDMd1Ne/WgjlJyGsAJUZxLzCtvGsC7M6g6zVAuiEPwFqnBhEJgzcbKopQ8n7YKsJFqezrB6rXymuJM2HAkfZ+KWWxmGAfz7qVY5Ja+hmted9g4uxgoSoPVzp5auLvHlpMFJNTEaY2KYrlf2apZxgXztEIGcvPXHmUXy5Ag0UaVv/rr1PTWBzhXQjndX34MdlGsRS3889URRXG8A5kKZjnkFy+1c4YmM7qTIJEpPrrJPkvgm+dBkrnrHyWTkbe1uRBqSQQZ297gQjvu+GMt8H2BS3Rd/iXWhTy/N5AdHKGs9cVeaPbfKhu5BCmSntZckQDgJ7PMEboYpKp5F4khctQBpadszZbdxSsi6J1kt3Cn+sc n8Q0xhdN 9cAwCARRfWk3WA8XfRod6pHZ8t7KCCYHzREn+BXsRP4W7ryRO5CyOcvct7EzA+bAFYnQF9rqO0FFOdxiK9lMsFh0XapVebQzAJWJ0paXU5eEimI1RoTKKxrkza3yhWdC1VlDTbGvEvkeJG5ZbgeJyEMUoOh45sa/v9I8nw9NTGRC6fUVjM/3UBDdh3xKvBZkU8KEHAxrKc2ElUcPwUWm2AKMVObtO+P0K1KBdEfvjk07GyKHcTglS2l+Kbg== 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: From: Hao Ge Recently discovered this entry while checking kallsyms on ARM64: ffff800083e509c0 D _shared_alloc_tag If ARCH_NEEDS_WEAK_PER_CPU is not defined(it is only defined for s390 and alpha architectures), there's no need to statically define the percpu variable _shared_alloc_tag. Therefore, we need to implement isolation for this purpose. However, currently ARCH_NEEDS_WEAK_PER_CPU is a #define and is enclosed within the #if defined(MODULE) conditional block. When building the core kernel code for s390 or alpha architectures, ARCH_NEEDS_WEAK_PER_CPU remains undefined (as it is gated by #if defined(MODULE)). However, when building modules for these architectures, the macro is explicitly defined. Therefore, we remove all instances of ARCH_NEEDS_WEAK_PER_CPU from the code and introduced CONFIG_ARCH_MODULE_NEEDS_WEAK_PER_CPU to replace the relevant logic. We can now conditionally define the perpcu variable _shared_alloc_tag based on CONFIG_ARCH_MODULE_NEEDS_WEAK_PER_CPU. This allows architectures (such as s390/alpha) that require weak definitions for percpu variables in modules to include the definition, while others can omit it via compile-time exclusion. The following version can be regarded as the most original version: https://lore.kernel.org/all/20250529073537.563107-1-hao.ge@linux.dev/ But unfortunately, it caused build errors on s390. Based on Suren's guidance and suggestions, I've refined it into this patch series. Many thanks to Suren for his patient instruction. Verify: 1. On Arm64: nm vmlinux | grep "_shared_alloc_tag",no output is returned. 2. On S390: Compile tested. nm vmlinux | grep "_shared_alloc_tag" 00000000015605b4 r __crc__shared_alloc_tag 0000000001585fef r __kstrtab__shared_alloc_tag 0000000001586897 r __kstrtabns__shared_alloc_tag 00000000014f6548 r __ksymtab__shared_alloc_tag 0000000001a8fa28 D _shared_alloc_tag nm net/ceph/libceph.ko | grep "_shared" U _shared_alloc_tag 3. On alpha Compile tested. nm vmlinux | grep "_shared_alloc_tag" fffffc0000b080fa r __kstrtab__shared_alloc_tag fffffc0000b07ee7 r __kstrtabns__shared_alloc_tag fffffc0000adee98 r __ksymtab__shared_alloc_tag fffffc0000b83d38 D _shared_alloc_tag nm crypto/cryptomgr.ko | grep "_share" U _shared_alloc_tag v4: Merge previous patches into a single patch. Remove all instances of ARCH_MODULE_NEEDS_WEAK_PER_CPU from v3 and use CONFIG_ARCH_MODULE_NEEDS_WEAK_PER_CPU to replace the relevant logic. Replace CONFIG_ARCH_NEEDS_WEAK_PER_CPU with CONFIG_ARCH_MODULE_NEEDS_WEAK_PER_CPU in v3, as weak percpu support is only required for modules ,making the name more semantically accurate. David, Mike, Matthew, Kent, Heiko and Suren have all provided valuable input. Thanks for this. v3: Suren pointed out that patches 1-2 can be merged into a single patch in version 2. And the commit message for patch 3 can be made more concise.Make corresponding modifications based on the pointed-out issues and update the corresponding commit message. v2: Heiko pointed out that when defining MODULE_NEEDS_WEAK_PER_CPU, the CONFIG_ARCH_NEEDS_WEAK_PER_CPU condition in the v1 version should be removed,as it is always true for s390 and alpha architectures.And He also pointed out that patches 2-4 need to be merged into one patch. Modify the code according to the suggestions and update the corresponding commit message Hao Ge (1): mm/percpu: Conditionally define _shared_alloc_tag via CONFIG_ARCH_MODULE_NEEDS_WEAK_PER_CPU arch/alpha/Kconfig | 1 + arch/alpha/include/asm/percpu.h | 5 ++--- arch/s390/Kconfig | 1 + arch/s390/include/asm/percpu.h | 5 ++--- include/linux/alloc_tag.h | 6 +++--- include/linux/percpu-defs.h | 7 ++++--- lib/alloc_tag.c | 2 ++ mm/Kconfig | 7 +++++++ 8 files changed, 22 insertions(+), 12 deletions(-) -- 2.25.1