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 69C80C71155 for ; Tue, 17 Jun 2025 07:11:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF2E86B007B; Tue, 17 Jun 2025 03:11:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA3D36B0088; Tue, 17 Jun 2025 03:11:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB9806B0089; Tue, 17 Jun 2025 03:11:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AD11F6B007B for ; Tue, 17 Jun 2025 03:11:57 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EA95D12034A for ; Tue, 17 Jun 2025 07:11:56 +0000 (UTC) X-FDA: 83564023032.20.644037D Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) by imf28.hostedemail.com (Postfix) with ESMTP id 22BA2C0004 for ; Tue, 17 Jun 2025 07:11:54 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=umkYV1WU; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf28.hostedemail.com: domain of hao.ge@linux.dev designates 91.218.175.180 as permitted sender) smtp.mailfrom=hao.ge@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750144315; a=rsa-sha256; cv=none; b=JPHDHn73OhQttw9SP+/2Z50bnH13F+8tPT6Q1ivo4/SxjwYfZ3tIflgse/t3Zl89Ui0Mas 70RxsEqssviDlj0Ctp90Vs4L495BSZWWqKcbv1xVrGN09TkbVhGMuAs99G1QQqfOoRttl3 8utpGJpCGWrDwS4bASOoOBWJyR2HY+c= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=umkYV1WU; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf28.hostedemail.com: domain of hao.ge@linux.dev designates 91.218.175.180 as permitted sender) smtp.mailfrom=hao.ge@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750144315; 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=wi3cd5Kmrpjh06Tdyw4IbO6I5Ww4NWJ5Q/peG+jrHlo=; b=UgJiuPn22m+V8MLc49WQzUtkLkMF2GO1Q/8uuiZQPB652kV+58zzyiqQxTpLWkJEXOWDen j5o9FQMeEJKK1+qteX5DOkHuEXUXJGf1XJ8n/5YfDg+mVxMFx7kMADiRd/7NL28+gcutk3 doMV2LdWFd+akDujhWuvk94KwenEjvk= 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=1750144312; 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=wi3cd5Kmrpjh06Tdyw4IbO6I5Ww4NWJ5Q/peG+jrHlo=; b=umkYV1WUksMByRsQKfhalBwWGC437/K/+eHfu1cbDr88+Xev/LaD2iGn79M1O8mRqsCPM1 JrqMFFZUyzA+hH/MLX6OmcDvyctYw3t/+msnKjrkZpmuKKK/OuN6PqyAPWvuD22/5epesl ebpF13mDAPWpp3jsiuy90tVQxHSzZt4= 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 v5 0/1] mm: Restrict _shared_alloc_tag static definition to CONFIG_ARCH_MODULE_NEEDS_WEAK_PER_CPU Date: Tue, 17 Jun 2025 15:10:51 +0800 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam01 X-Stat-Signature: qmo3q7pigzmf9f36x83adcerm3h5ctu3 X-Rspamd-Queue-Id: 22BA2C0004 X-Rspam-User: X-HE-Tag: 1750144314-793905 X-HE-Meta: U2FsdGVkX1+8VBuLEd3aVB4H0sMbDBDHL/RcG2k88J2sc+AJBFu6QgvlPMkTEV/VOjejXZVPJ0jnvloXzSk6LljpI4ufR9bdBH88zeXWwVAwFLbRjBvfQPsYT0M3osUc+eBYF9EEmZWtA6z/c0nJfHLvqzbeqAf/qZYTxQN1F8F1/nfR5e7BouWYOzKacICRqsf0cs5P9duhgWwyjN2s4VE2eEik45mxsxxRLCX4ID3YkR9881eJR0wUz9E8RyCgdypb3AH4sj0Y+CON8nTnTjHYYGTklBl+vZecX+0eyW6dgrfwQYZVvhtCUTus+Fsic6JfxZ4Gs5VjPaDTzVzse80Yk4UFwU0zulFipKdQexT08H41ZeZ3vylBvySJlnUjYOqwF5wepkE2hvyc11dsTAEF0kCITAkIM9qW3ygOdYwBHP/R+W8LIxgBaZEfIzLta4LVDU/2Jj5HDxZcSBjOkUeDtUUOkP6a3aKPTNdQsHlpHaAFZd2k/G/xj9rvlrWBGmNSJcaElcCTPxL9NO90lmQPO5PB7/UhHYduFaNgwa8cw4kxosjxRDPwoW0Af993QGax9rxVfi6KvZRxSkmQciUVABZRKIQl726CpgG5MTt41nMpkJDo0KAM+ECMHJASU0Sut7xglB84xO+oY4qcp65L1sJhv/ufFNNtvVXTrx+dqOjX/hiKkM05lMlJ7F08Jcsz47azlccWIqSZxHltslLTp3uYnmA8iKpWCzE8K01agyJem5Bf6UmG+CLEGfhg4R7oVmpBypke/6tZKNIEI4qB8aHVuRhYAmTRSdAs0VV1sqxyqxuV63no3RAgBS5mLfHZSZlFAQSA1fr221u2F0Mtr+fhTBW+WRqRD8HQwn/LBvpFkk4Wa36vo/5zinrTOZqD7FsEHeat2jPm5Qxi/P5/L5VYH+xt7hti+FhxVcUxwvHNquTMdQ4y4kUGw7esuAC8en1Bja8QTmUb2x/ +zwaopBL dXNioOd+1kOVfg6t2+ONpcrmWn7XRWU9xhuh6wxWDTiwjTjf/wINtFSh73lmKhqgNlPaWxlh5vTUp3Vfj4c41KfNgtznYyVsZmcaSYmmNtoLDlf3lO1OY1OdQRaiId6yzwKGDdFdT4pxjO4wDqMMZJ9HrPCbZA6vQ84O5Et3uAn5vkCuH7BeuOtqJlIqbBfShZN9pac5LUF8VqsCvdFftopb8poRe14KQkiqG7UwRTmMwiSogbJg3FRFDyg== 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 v5: Regarding the omission of defined(MODULE) in alloc_tag.h where only #ifdef CONFIG_ARCH_MODULE_NEEDS_WEAK_PER_CPU was used, I apologize for this error. Please find version 5 attached to address this issue. 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