From nobody Sat Oct 11 00:30:47 2025 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 818452147EA; Thu, 12 Jun 2025 08:27:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749716880; cv=none; b=XK76JZg5sEtvoQAkjW6kwRJ4oBWujBHzNntOPPpN8YOrNmEMw7jWcun1w65Pc0XXh9pNh+0NTgcvZd4kYcIQTZ88kboSXoq7vVkAw+anPeKan+giW+/7g0Vo5MCb4f0gjk2f/uzpXk+I5HxkShasFyh0PJoHuq+hVw80HTT+zME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749716880; c=relaxed/simple; bh=Nz1hoxeCVid4KDiYsbry1h75tkpxToMSbYYTBDfpWX0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EOAwscAGVW9/h/ZI3jdDpdqpsT2xsoEQN6uRcgpmkBtC8U13+ket4xffqQ6PqHNbV6SfQr+xIPSHP3SA6+3rA3ULjYf+90RthtGVQMiKXEsyi1AqqhbwAfgs2EJRf4S0F3Ow1/L5IukgfVy7UdFJsH6Kk2Y6TuFK0wJPllXtutE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=nmPzjN15; arc=none smtp.client-ip=95.215.58.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="nmPzjN15" 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=1749716876; 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: in-reply-to:in-reply-to:references:references; bh=DkwHp5gNVL4KbrY8qJCfk1r1LfLJg5q3t6hNJxRz8qU=; b=nmPzjN15kNg2zZxVlReQNakgS5TF3ho91Ph6hVAfiA4oJKSrWfJCp+pQEPZJtlhCTA4Lyu 0cRw1Owdsye3SJJjmFPVqo6b2hHxZzWDOoiQ3NswjOECaZ5DWipIDY5grB5UAaXWwwG2ly 2xJVBI8AEgg5oaEnRvQhSiqvPS/z6Mc= 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 1/5] mm/Kconfig: add ARCH_NEEDS_WEAK_PER_CPU option Date: Thu, 12 Jun 2025 16:27:26 +0800 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" 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. As the number of CPUs increases,the wasted memory will grow correspondingly. 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 need to make ARCH_NEEDS_WEAK_PER_CPU a Kconfig option. And replace all instances of ARCH_NEEDS_WEAK_PER_CPU in the kernel code with MODULE_NEEDS_WEAK_PER_CPU,gated by #ifdef CONFIG_ARCH_NEEDS_WEAK_PER_CPU.Then,when defining the percpu variable _shared_alloc_tag,wrap it with the CONFIG_ARCH_NEEDS_WEAK_PER_CPU condition. Therefore,we should add the ARCH_NEEDS_WEAK_PER_CPU option to the mm Kconfig file. Suggested-by: Suren Baghdasaryan Signed-off-by: Hao Ge --- mm/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/Kconfig b/mm/Kconfig index e113f713b493..36bb4d6fd360 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -929,6 +929,10 @@ config ARCH_SUPPORTS_PUD_PFNMAP def_bool y depends on ARCH_SUPPORTS_HUGE_PFNMAP && HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD =20 +# s390 and alpha be enabled,see comments for DECLARE_PER_CPU_SECTION +config ARCH_NEEDS_WEAK_PER_CPU + bool + # # UP and nommu archs use km based percpu allocator # --=20 2.25.1 From nobody Sat Oct 11 00:30:47 2025 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAD80223DFF for ; Thu, 12 Jun 2025 08:28:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749716890; cv=none; b=WxTN1Gd2cRCOX/ppGUFG7E6iWXXRKPxHMvvisWWy+EiXbGbMGrKWVxz64/W8JkilbvPJRvkQrwOBQlnKL2NIK64cvMm0DTELMsnfm4BYe/Dvol/K7z1DS1XzxyhCpKhqop0AN9J8EZUCng788eC46CNs08/qA88P6AFaWHMemHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749716890; c=relaxed/simple; bh=wa3NJsPEjZo2b/QKbicW0EiI4fSq+OLPcvk7PO4wrSQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aKmPWakYaOMGt5Ju5XqIf5hvOufK1LEW6isV1G+K/vopLxqgSmMoWt/IbDAIyORJkXTLKG4GQUvGMKWNwhwLslFnOSVkaK4fppG/jCsDEchsLM4Egjsr4EVy0r7E0NL4lPANXZV6iXzx+Kp64xopw3NTNx7ZudBdM7G/9zWq4P0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=lC689Via; arc=none smtp.client-ip=95.215.58.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="lC689Via" 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=1749716885; 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: in-reply-to:in-reply-to:references:references; bh=1+SMqaJRr2gw7tiajb6Lxu2Z2z8tbEjCcRQA4pFVOF8=; b=lC689Viaz/2NV57fIl0BJ1lVZVPTi4rseVn5hKRgU9tieWXVdp4iqPcGcsbWmAFMS9wQK8 3feriPh5QlfbgT6OtRljSbkKI2MtbpLkU1WYvKdb/9nvHpz6olrwacdtPA3wZRdvvQxB1S evIAzeIU/aX82uOb2THJm4a/3/IAThU= 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 2/5] alpha: Modify the definition logic of WEAK_PER_CPU Date: Thu, 12 Jun 2025 16:27:27 +0800 Message-Id: <4d78498def57e0df4c768ad9eb672cac68fb51dc.1749715979.git.gehao@kylinos.cn> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Hao Ge As stated in the first patch of this patch series, we make ARCH_NEEDS_WEAK_PER_CPU a Kconfig option, and replace all instances of ARCH_NEEDS_WEAK_PER_CPU in the kernel code with MODULE_NEEDS_WEAK_PER_CPU, gated by #ifdef CONFIG_ARCH_NEEDS_WEAK_PER_CPU. We'll make corresponding changes for the alpha architecture. Suggested-by: Suren Baghdasaryan Signed-off-by: Hao Ge --- arch/alpha/Kconfig | 1 + arch/alpha/include/asm/percpu.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 109a4cddcd13..ce9bc842e384 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -7,6 +7,7 @@ config ALPHA select ARCH_HAS_DMA_OPS if PCI select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO + select ARCH_NEEDS_WEAK_PER_CPU select ARCH_NO_PREEMPT select ARCH_NO_SG_CHAIN select ARCH_USE_CMPXCHG_LOCKREF diff --git a/arch/alpha/include/asm/percpu.h b/arch/alpha/include/asm/percp= u.h index 6923249f2d49..5d8b75ec3bf2 100644 --- a/arch/alpha/include/asm/percpu.h +++ b/arch/alpha/include/asm/percpu.h @@ -10,8 +10,8 @@ * * Always use weak definitions for percpu variables in modules. */ -#if defined(MODULE) && defined(CONFIG_SMP) -#define ARCH_NEEDS_WEAK_PER_CPU +#if defined(MODULE) && defined(CONFIG_SMP) && defined(CONFIG_ARCH_NEEDS_WE= AK_PER_CPU) +#define MODULE_NEEDS_WEAK_PER_CPU #endif =20 #include --=20 2.25.1 From nobody Sat Oct 11 00:30:47 2025 Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26F9B222561 for ; Thu, 12 Jun 2025 08:28:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749716896; cv=none; b=sQdg4cVdypzKervAZPGpSln6OdmGWm6Jo7/vn2FFIu9Pz464PZ96ixqdnFAzoQVADjBm1BsQgX49PcEfYu0mJh3I+2UqbCyQ6UPGewfRsVstPoP8DOvBmlPxvimIB49z3tnWtNCw3NrsPGujqk0eDm/9p2KnI/jPoByW4NxUAdc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749716896; c=relaxed/simple; bh=LvsURw/nqMWRXkm+nrhQDBaJHU6fMAmmLXpVcAQ1/T0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F1nq7OsVvy+fa1vEzk/111byQ2QeUZRr+rGJnl53w91S/LZw4LHKWpuJids5IXWXbOF+3k/TnzYJNEQ9kbINMUz36KatyTOpfWxWoHqlTUjNXXoOGkJncih6/2k9z+LvLPTRmAS6DEoP/UAWL04eZjqRCkcIIDymxxQ3yhI8a34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=kyGJZhrQ; arc=none smtp.client-ip=95.215.58.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="kyGJZhrQ" 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=1749716893; 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: in-reply-to:in-reply-to:references:references; bh=q9di4IfgIfQZ0n6KWtQk6/b40WsXW7j7pcH/DrSfee4=; b=kyGJZhrQrniGsFhmlDOfmIcwdCwzLroPX7NLDuuw9E4yS0eeKDCnyyGZfNn9PYrekuCFCq UZZCsAgplLBiwIj72HQnDxKNlUU1MjQURJ3mXs+kkmafXVfkZg0c1SH5z6rehMyfDlXvPZ AsNgV51iAuoVo9aMfcbkRVmUgjuxiUM= 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 3/5] s390: Modify the definition logic of WEAK_PER_CPU Date: Thu, 12 Jun 2025 16:27:28 +0800 Message-Id: <1baad81a8033eec2927f8a3ac6b792e930766724.1749715979.git.gehao@kylinos.cn> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Hao Ge As stated in the first patch of this patch series, we make ARCH_NEEDS_WEAK_PER_CPU a Kconfig option, and replace all instances of ARCH_NEEDS_WEAK_PER_CPU in the kernel code with MODULE_NEEDS_WEAK_PER_CPU, gated by #ifdef CONFIG_ARCH_NEEDS_WEAK_PER_CPU. We'll make corresponding changes for the s390 architecture. Suggested-by: Suren Baghdasaryan Signed-off-by: Hao Ge --- arch/s390/Kconfig | 1 + arch/s390/include/asm/percpu.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 0c16dc443e2f..716031d22346 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -132,6 +132,7 @@ config S390 select ARCH_INLINE_WRITE_UNLOCK_IRQ select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE + select ARCH_NEEDS_WEAK_PER_CPU select ARCH_STACKWALK select ARCH_SUPPORTS_ATOMIC_RMW select ARCH_SUPPORTS_DEBUG_PAGEALLOC diff --git a/arch/s390/include/asm/percpu.h b/arch/s390/include/asm/percpu.h index 84f6b8357b45..a202baef86fb 100644 --- a/arch/s390/include/asm/percpu.h +++ b/arch/s390/include/asm/percpu.h @@ -17,8 +17,8 @@ * per cpu area, use weak definitions to force the compiler to * generate external references. */ -#if defined(MODULE) -#define ARCH_NEEDS_WEAK_PER_CPU +#if defined(MODULE) && defined(CONFIG_ARCH_NEEDS_WEAK_PER_CPU) +#define MODULE_NEEDS_WEAK_PER_CPU #endif =20 /* --=20 2.25.1 From nobody Sat Oct 11 00:30:47 2025 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 683C7225397 for ; Thu, 12 Jun 2025 08:28:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749716905; cv=none; b=n9iZpNdm1m+i3Yn/jBntuOvFPm8ygO5K21ueKLHyHLXWAdecttCQ9uTStVs3KW4XhEMeyPIu6IkxUGPW2p2SPJuC6ZwnDIHP9qgtGrZvHZ2vUkB4UZEdSBeOgSTWMCQGqilV0LJ7lhKK1Mwdnm6pm1rB11gWNYYV+RP2aP6Uwiw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749716905; c=relaxed/simple; bh=+KqSikubmTwLv67VH07QK1YJvLomsd5Sw3lt8h/T5Tg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pNRqfMrccixWa02A601jt0PdK3VMnzoQsRe4UydNwxkNi/il/PWttTtVAjkkxGvk2Pmd0DWneRngbVB4Y5AIWbedFTU9EAfBtJJrX89JxYWv9atJuKuWs6d4O8ikjWQapjCw2RtxBBhUN9mzdXNLrg95pL6y433Sono8me8u/jc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=SxZh/hf4; arc=none smtp.client-ip=95.215.58.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="SxZh/hf4" 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=1749716901; 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: in-reply-to:in-reply-to:references:references; bh=AuO6LfcqvanLNT/SurJr0xI1g963JuVICLigVyy7BYQ=; b=SxZh/hf4lH88e4FaL8K+3BNhAEzEFijYRtOukTko/SGVWs6GQrh99fqfUPdf+INg7j7QX1 qjMuhUmdqbl3JyDw46gFlfCdpt6p7B2AWPRJ6Msv/eFP2/tDcWm/GVfITHnN8X7XEamL1t PEWkz3cdalwDXwvqhlxmnhXUGWXndZc= 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 4/5] mm: use MODULE_NEEDS_WEAK_PER_CPU instead of ARCH_NEEDS_WEAK_PER_CPU Date: Thu, 12 Jun 2025 16:27:29 +0800 Message-Id: <7c3402b5860385e7898f1f854a5cf83d4c5dcf65.1749715979.git.gehao@kylinos.cn> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Hao Ge We have made ARCH_NEEDS_WEAK_PER_CPU a Kconfig option and introduced MODULE_NEEDS_WEAK_PER_CPU,so we should use MODULE_NEEDS_WEAK_PER_CPU instead of ARCH_NEEDS_WEAK_PER_CPU in all current places within the mm/ module. Suggested-by: Suren Baghdasaryan Signed-off-by: Hao Ge --- include/linux/alloc_tag.h | 6 +++--- include/linux/percpu-defs.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/alloc_tag.h b/include/linux/alloc_tag.h index 8f7931eb7d16..f349cca0ebed 100644 --- a/include/linux/alloc_tag.h +++ b/include/linux/alloc_tag.h @@ -88,7 +88,7 @@ static inline struct alloc_tag *ct_to_alloc_tag(struct co= detag *ct) return container_of(ct, struct alloc_tag, ct); } =20 -#ifdef ARCH_NEEDS_WEAK_PER_CPU +#ifdef MODULE_NEEDS_WEAK_PER_CPU /* * When percpu variables are required to be defined as weak, static percpu * variables can't be used inside a function (see comments for DECLARE_PER= _CPU_SECTION). @@ -102,7 +102,7 @@ DECLARE_PER_CPU(struct alloc_tag_counters, _shared_allo= c_tag); .ct =3D CODE_TAG_INIT, \ .counters =3D &_shared_alloc_tag }; =20 -#else /* ARCH_NEEDS_WEAK_PER_CPU */ +#else /* MODULE_NEEDS_WEAK_PER_CPU */ =20 #ifdef MODULE =20 @@ -123,7 +123,7 @@ DECLARE_PER_CPU(struct alloc_tag_counters, _shared_allo= c_tag); =20 #endif /* MODULE */ =20 -#endif /* ARCH_NEEDS_WEAK_PER_CPU */ +#endif /* MODULE_NEEDS_WEAK_PER_CPU */ =20 DECLARE_STATIC_KEY_MAYBE(CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT, mem_alloc_profiling_key); diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 0aeb0e276a3e..b4ecfc3a7b2b 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -64,13 +64,13 @@ * 2. Static percpu variables cannot be defined inside a function. * * Archs which need weak percpu definitions should define - * ARCH_NEEDS_WEAK_PER_CPU in asm/percpu.h when necessary. + * MODULE_NEEDS_WEAK_PER_CPU in asm/percpu.h when necessary. * * To ensure that the generic code observes the above two * restrictions, if CONFIG_DEBUG_FORCE_WEAK_PER_CPU is set weak * definition is used for all cases. */ -#if defined(ARCH_NEEDS_WEAK_PER_CPU) || defined(CONFIG_DEBUG_FORCE_WEAK_PE= R_CPU) +#if defined(MODULE_NEEDS_WEAK_PER_CPU) || defined(CONFIG_DEBUG_FORCE_WEAK_= PER_CPU) /* * __pcpu_scope_* dummy variable is used to enforce scope. It * receives the static modifier when it's used in front of --=20 2.25.1 From nobody Sat Oct 11 00:30:47 2025 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4649C1B043E for ; Thu, 12 Jun 2025 08:28:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749716912; cv=none; b=A7p/JMUcsCMELCwrPmYy3XjS+/viYNOakWvE4x0GqW+K/1uEbw9pg0bJ8PQQzIvwkovKbuhFEUlRPANwN45JVYMkj5vXhMh6yvYyrm4EQc0RUSGgsgYQx/i86YNumei8GdFypRy+/vKGGVJN8IuDulLenJOy4fwgdJjH6audKJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749716912; c=relaxed/simple; bh=w5lvnxdf7nXQzABIUueKfM2G7ZWWXlgNS18Oez8SQuk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=k5bB5/9U4k2M06T2738/6Fo77lOPZHMXHTRD+0wFTQeQenzKFubmhbnwwxD3jPxdLoG48ElA8wRpWO4Rg502i3VgXCf17tZbC0ysaPwzSKYjinhXTVH0NLgdgU/z+SWjVyEwr3eTQZ1VtqMIi8bgrCZG5kas4uqiLt98T3rTkqs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=K/ia8tsa; arc=none smtp.client-ip=95.215.58.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="K/ia8tsa" 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=1749716909; 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: in-reply-to:in-reply-to:references:references; bh=FK5GViGeaS0eKXb1CGklOs8Lcazv9ig1sTbfs/WnUDs=; b=K/ia8tsaN5YSVwzcZ7cSw6MtYYEdAZL9pCWwtEBdCG53ZTxJTtSEirziliq4lO65RcDcXH cWaXE6uKdHS0P0oc/dpDtfPnvsIIDISGN9MtmFylu+E8VSo1FfDvr5PMJUe8vnBkAhTP9c WNWZV4ihnhgxf5TOOu61Q2VzdSWRVoE= 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 5/5] mm/alloc_tag: add the CONFIG_ARCH_NEEDS_WEAK_PER_CPU macro when statically defining the percpu variable _shared_alloc_tag Date: Thu, 12 Jun 2025 16:27:30 +0800 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Hao Ge Recently discovered this entry while checking kallsyms on ARM64: ffff800083e509c0 D _shared_alloc_tag If CONFIG_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. As the number of CPUs increases,the wasted memory will grow correspondingly. Enclose the definition of _shared_alloc_tag within the CONFIG_ARCH_NEEDS_WEAK_PER_CPU condition. Suggested-by: Suren Baghdasaryan Signed-off-by: Hao Ge --- lib/alloc_tag.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c index c7f602fa7b23..14fd66f26e42 100644 --- a/lib/alloc_tag.c +++ b/lib/alloc_tag.c @@ -24,8 +24,10 @@ static bool mem_profiling_support; =20 static struct codetag_type *alloc_tag_cttype; =20 +#ifdef CONFIG_ARCH_NEEDS_WEAK_PER_CPU DEFINE_PER_CPU(struct alloc_tag_counters, _shared_alloc_tag); EXPORT_SYMBOL(_shared_alloc_tag); +#endif =20 DEFINE_STATIC_KEY_MAYBE(CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT, mem_alloc_profiling_key); --=20 2.25.1