[PATCH v3 2/2] mm/alloc_tag: add the CONFIG_ARCH_NEEDS_WEAK_PER_CPU macro when statically defining the percpu variable _shared_alloc_tag
From: Hao Ge
Date: Sun Jun 15 2025 - 22:30:50 EST
From: Hao Ge <gehao@xxxxxxxxxx>
Given the introduction of the CONFIG_ARCH_NEEDS_WEAK_PER_CPU macro,
we can now conditionally define the perpcu variable _shared_alloc_tag
based on its value. 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.
Suggested-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>
Signed-off-by: Hao Ge <gehao@xxxxxxxxxx>
---
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;
static struct codetag_type *alloc_tag_cttype;
+#ifdef CONFIG_ARCH_NEEDS_WEAK_PER_CPU
DEFINE_PER_CPU(struct alloc_tag_counters, _shared_alloc_tag);
EXPORT_SYMBOL(_shared_alloc_tag);
+#endif
DEFINE_STATIC_KEY_MAYBE(CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT,
mem_alloc_profiling_key);
--
2.25.1