Skip to contentSkip to conversation

perf_events: sysctl: Avoid unused one_thousand definition

PATCH In review Palmer Dabbelt 2 participants 2 messages Jan 19, 2022 – Jan 20, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf_events: sysctl: Avoid unused one_thousand definition

From: Palmer Dabbelt <[email protected]>

The variable "one_thousand" is only used under CONFIG_PERF_EVENTS=y, but is unconditionally defined. This can fire a warning.

---

I went with an #ifdef instead of a __maybe_unused because that's what the other code is using, and I left the one_thousand in order despite that requiring another #ifdef.

---
 kernel/sysctl.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/sysctl.c +2 -0
index ef77be575d87..81a6f2d47f77 100644
@@ -122,7 +122,9 @@ static unsigned long one_ul = 1;
 static unsigned long long_max = LONG_MAX;
 static int one_hundred = 100;
 static int two_hundred = 200;
+#ifdef CONFIG_PERF_EVENTS
 static int one_thousand = 1000;
+#endif
 static int three_thousand = 3000;
 #ifdef CONFIG_PRINTK
 static int ten_thousand = 10000;
Signature · 1 line
2.32.0
#1 lore raw
Quoted 21 lines · Palmer Dabbelt

From: Palmer Dabbelt <[email protected]>

The variable "one_thousand" is only used under CONFIG_PERF_EVENTS=y, but is unconditionally defined. This can fire a warning.

---

I went with an #ifdef instead of a __maybe_unused because that's what the other code is using, and I left the one_thousand in order despite that requiring another #ifdef.

---
 kernel/sysctl.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/sysctl.c +0 -0
index ef77be575d87..81a6f2d47f77 100644

kernel/sysctl.c static unsigned long one_ul = 1; · line 127

Quoted 6 lines
kernel/sysctl.c +2 -0
@@ -122,7 +122,9 @@ static unsigned long one_ul = 1;
 static unsigned long long_max = LONG_MAX;
 static int one_hundred = 100;
 static int two_hundred = 200;
+#ifdef CONFIG_PERF_EVENTS
 static int one_thousand = 1000;
+#endif

Please use linux-next, this has changed quite a bit there. You can git grep for SYSCTL_ONE_THOUSAND.

Luis