From nobody Thu Mar 5 06:32:39 2026 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE2042DAFA9 for ; Mon, 16 Feb 2026 17:27:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771262837; cv=none; b=en/u/hFsik3Dn2Z5CGo9XiT2/cpY+JnipRL3RmZ7HePaGWZK+oPCaHcqATTWdO3EEDZwh8QtFRANSbW/El4kxYA4hwmtsHb/O3NP9NWFp2+SO93meVnOhZVdfu6b8m2IhFl5UuS85yZYLuOgTRESez1bxeurnwntNNVjDc/hy/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771262837; c=relaxed/simple; bh=ekHiVyjqiaGWoE6RXaxfHJcPuigOMr+k1bVFfn5BEgw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=hD5AgVrTRpj2pGon48lR7SE7fAOTgcL+v/1rtCsME9BkmDOgFkvVoTkw/DHftapUsLlXiV2mcXa7Yh2WpSp+Fw1q4+XLZ2eI2H7aN8kIEtE4OiLtVImkIXPnv7Xg8DlTqJmdLO7i58UXWtqUR4/qhohbe+uUiJ5kcQuQcKJucvQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Wp5D+yBI; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Wp5D+yBI" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-59e5bfa4f33so2875319e87.1 for ; Mon, 16 Feb 2026 09:27:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771262834; x=1771867634; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=f3LfzZMm5dzBOXfXpr+wyEgw8UjxM0o7eUchqH58TlY=; b=Wp5D+yBIgHVQSCantxJItfvS01Dm28smNHlZKImim+JvaSI7Nqs9Bes+gnnhesSjUx c/Grto65zCAb4Zr50arCvUiquIbCEdeeT5oTl6MsJQCiR0XpwigG+iR76MXJ7A+zDP8a 6/7hatSVC61dPAmYI3R707I2ChvFrpMg+ubTNZYpQedA0i+3KOfyUV019CpiYh6LmvM5 H48hxMUKwbynbSZZlu8g+CrSpvLMjex341HEjtR1XvFqMHD0Ci0qIi8AqViOZG8fU4N3 iWR3Lz98M9Tc9Dp/qEJz4ySV/1JLEn+oJn3RmwGI8HcTST9y6YgRMZ/1+xd3b5A8RkPv 3R+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771262834; x=1771867634; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=f3LfzZMm5dzBOXfXpr+wyEgw8UjxM0o7eUchqH58TlY=; b=oACLQGDOxq2blay7e1pkxF0r/wLVVSUVSyz3FXLPxarFIN3KI2fcu23j6gaE37n7kt UqGWgPr1qdx1PlT6m2XHx6ByQM64LSMDT44kUEh9fedwU60Pf8ek6jUWm5cd5VdHhssq q9/9Qqj35Rz/Mzl7iIhiiOOpL3PgfhuEjCAdLvBPMyulYJZ98/xttNDpwKQYG5dHPJC9 gf1TJVEvYuUVvaNOS0kdTkrKdQOGc8bpB0h6Bv1zAyaSEpRnXAdlBDvF5nk+vmepAg0H r3fYGw6q/YBDeXi6qa0CwOyg+koG5xEM4wp0fQtFKkXtKGVK/8NA6aQRu9PUooDZu9V+ fayQ== X-Forwarded-Encrypted: i=1; AJvYcCU6hAq4138gdY5nQIw4tXI1VDCETIK3bcH0jhJyVBi5AFXg6y5rNWGSTYnqfMcUlAOQX89BQR5CgqESen4=@vger.kernel.org X-Gm-Message-State: AOJu0YzU6UTSn35r+aS8OR6MmrXNBAOsk0ipHIqRVm3SaVe+A45Lhcxy Jk9E1EXucv1X9GqhYGNHpTcu517bsLVUdmnZ0DFel/fmeKdJ0A70Uf9p X-Gm-Gg: AZuq6aKhySA6pNQJQkl9iIfkOLlqyiLytogirIqXvVpGcRZGAmJbcE1Oki7ddk2vHod aFNTue3Jis8vd5xhd6X81ki9/G1yk4UyXVryy5z0IgnRkO6oartoiDCYWcWHVEzVzvUEQbf39Et nvGooErXgDDcR7Mop4L98X5hzOFCR62PTCk+Mv+YPSMhLhJ0sE/tPod9QG8Qwi7Zm3BcFXyvBQZ CWg7HeSAuTIGmekz0UJIoPySuVJK7lmDqJCX8YdoFxVsUraQdtMGPuoBBGX6oRf4umRfYT6GA8j 6rcAKCwZcsqWDhJBDP8vogS412e1U3++YZu7fxwu74sxcdggFcCOMMPBqT1AabDBA3+Ixv4FwAy ngS42qcrjKdjxxy2UaKuCQs6V06Fy3tKmQil7smFJB/cKmJhweEbdceos+zAZRpXHdkVCsNgVoE H6WvBFxmh1XsrErKepu/juaPUdPHK+4Cq2P6QPl9HAQ667 X-Received: by 2002:a05:6512:224d:b0:59d:e7b1:419e with SMTP id 2adb3069b0e04-59f6d34cf47mr2685656e87.11.1771262833724; Mon, 16 Feb 2026 09:27:13 -0800 (PST) Received: from localhost ([188.234.148.119]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-59e5f5b062asm3322901e87.73.2026.02.16.09.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Feb 2026 09:27:11 -0800 (PST) From: Mikhail Gavrilov To: Gabriele Monaco , Daniel Bristot de Oliveira , Steven Rostedt Cc: Nam Cao , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, Mikhail Gavrilov Subject: [PATCH v3] rv: Fix multiple definition of __pcpu_unique_da_mon_this Date: Mon, 16 Feb 2026 22:27:07 +0500 Message-ID: <20260216172707.1441516-1-mikhail.v.gavrilov@gmail.com> X-Mailer: git-send-email 2.53.0 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 Content-Type: text/plain; charset="utf-8" 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_ 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_) 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 Signed-off-by: Mikhail Gavrilov --- Changes since v1: https://lore.kernel.org/all/20260216074727.47292-1-mikhai= l.v.gavrilov@gmail.com/ - Updated commit message with details on when __pcpu_unique_ uniqueness is required (alpha modules, CONFIG_DEBUG_FORCE_WEAK_PER_CPU) - Added code comment above DA_MON_NAME explaining the rationale include/rv/da_monitor.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index db11d41bb438..7511f5464c48 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -20,6 +20,12 @@ #include #include =20 +/* + * Per-cpu variables require a unique name although static in some + * configurations (e.g. CONFIG_DEBUG_FORCE_WEAK_PER_CPU or alpha modules). + */ +#define DA_MON_NAME CONCATENATE(da_mon_, MONITOR_NAME) + static struct rv_monitor rv_this; =20 static void react(enum states curr_state, enum events event) @@ -183,14 +189,14 @@ static inline bool da_event(struct da_monitor *da_mon= , struct task_struct *tsk, /* * global monitor (a single variable) */ -static struct da_monitor da_mon_this; +static struct da_monitor DA_MON_NAME; =20 /* * da_get_monitor - return the global monitor address */ static struct da_monitor *da_get_monitor(void) { - return &da_mon_this; + return &DA_MON_NAME; } =20 /* @@ -223,14 +229,14 @@ static inline void da_monitor_destroy(void) { } /* * per-cpu monitor variables */ -static DEFINE_PER_CPU(struct da_monitor, da_mon_this); +static DEFINE_PER_CPU(struct da_monitor, DA_MON_NAME); =20 /* * da_get_monitor - return current CPU monitor address */ static struct da_monitor *da_get_monitor(void) { - return this_cpu_ptr(&da_mon_this); + return this_cpu_ptr(&DA_MON_NAME); } =20 /* @@ -242,7 +248,7 @@ static void da_monitor_reset_all(void) int cpu; =20 for_each_cpu(cpu, cpu_online_mask) { - da_mon =3D per_cpu_ptr(&da_mon_this, cpu); + da_mon =3D per_cpu_ptr(&DA_MON_NAME, cpu); da_monitor_reset(da_mon); } } --=20 2.53.0