Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rv: Fix multiple definition of __pcpu_unique_da_mon_this

The refactoring in commit 30984ccf31b7 ("rv: Refactor da_monitor to
minimise macros") replaced per-monitor unique variable names
(da_mon_##name) with a fixed name (da_mon_this).

While this works for 'static' variables (each translation unit gets its
own copy), DEFINE_PER_CPU internally generates a non-static dummy
variable __pcpu_unique_<n> for each per-cpu definition. The requirement
for this variable to be unique although static exists for modules on
specific architectures (alpha) and if the kernel is built with
CONFIG_DEBUG_FORCE_WEAK_PER_CPU (e.g. Fedora's debug kernel).

When multiple per-cpu monitors (e.g. sco and sts) are built-in
simultaneously, they all produce the same __pcpu_unique_da_mon_this
symbol, causing a link error:

ld: kernel/trace/rv/monitors/sts/sts.o: multiple definition of
`__pcpu_unique_da_mon_this';
kernel/trace/rv/monitors/sco/sco.o: first defined here

Fix this by introducing a DA_MON_NAME macro that expands to a
per-monitor unique name (da_mon_<MONITOR_NAME>) via the existing
CONCATENATE helper. This restores the uniqueness that was present
before the refactoring.

Fixes: 30984ccf31b7 ("rv: Refactor da_monitor to minimise macros")
Reviewed-by: Gabriele Monaco <gmonaco@redhat.com>
Signed-off-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Link: https://lore.kernel.org/r/20260216172707.1441516-1-mikhail.v.gavrilov@gmail.com
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>

authored by

Mikhail Gavrilov and committed by
Gabriele Monaco
75f3cf0d 403faa57

+11 -5
+11 -5
include/rv/da_monitor.h
··· 20 20 #include <linux/bug.h> 21 21 #include <linux/sched.h> 22 22 23 + /* 24 + * Per-cpu variables require a unique name although static in some 25 + * configurations (e.g. CONFIG_DEBUG_FORCE_WEAK_PER_CPU or alpha modules). 26 + */ 27 + #define DA_MON_NAME CONCATENATE(da_mon_, MONITOR_NAME) 28 + 23 29 static struct rv_monitor rv_this; 24 30 25 31 static void react(enum states curr_state, enum events event) ··· 189 183 /* 190 184 * global monitor (a single variable) 191 185 */ 192 - static struct da_monitor da_mon_this; 186 + static struct da_monitor DA_MON_NAME; 193 187 194 188 /* 195 189 * da_get_monitor - return the global monitor address 196 190 */ 197 191 static struct da_monitor *da_get_monitor(void) 198 192 { 199 - return &da_mon_this; 193 + return &DA_MON_NAME; 200 194 } 201 195 202 196 /* ··· 229 223 /* 230 224 * per-cpu monitor variables 231 225 */ 232 - static DEFINE_PER_CPU(struct da_monitor, da_mon_this); 226 + static DEFINE_PER_CPU(struct da_monitor, DA_MON_NAME); 233 227 234 228 /* 235 229 * da_get_monitor - return current CPU monitor address 236 230 */ 237 231 static struct da_monitor *da_get_monitor(void) 238 232 { 239 - return this_cpu_ptr(&da_mon_this); 233 + return this_cpu_ptr(&DA_MON_NAME); 240 234 } 241 235 242 236 /* ··· 248 242 int cpu; 249 243 250 244 for_each_cpu(cpu, cpu_online_mask) { 251 - da_mon = per_cpu_ptr(&da_mon_this, cpu); 245 + da_mon = per_cpu_ptr(&DA_MON_NAME, cpu); 252 246 da_monitor_reset(da_mon); 253 247 } 254 248 }