Skip to contentSkip to conversation

sched: rt.c: kernel-doc warning

Question Manuel Ebner 2 participants 2 messages Oct 5 – Oct 12 Scheduler

lore
Share & tools
lore
#0 lore raw

Hi,

I'm trying to fix built warning and stumbled over this one:

$make W=1 -j8 > make_output.txt
In file included from kernel/sched/build_policy.c:52:
kernel/sched/rt.c:12:18: warning: ‘max_rt_runtime’ defined but not used [-Wunused-const-variable=]

   12 | static const u64 max_rt_runtime = MAX_BW;
      |                  ^~~~~~~~~~~~~~

I just can't make sense of this, because max_rt_runtime is used later in the file - see diff.
What am I missing?

Thanks
Manuel Ebner

---
 kernel/sched/rt.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
kernel/sched/rt.c +14 -0
index 1535046a2..4d15f5c47 100644
@@ -10,6 +10,14 @@
 int sched_rr_timeslice = RR_TIMESLICE;
 /* More than 4 hours if BW_SHIFT equals 20. */
 static const u64 max_rt_runtime = MAX_BW;
+/* When I build a tinyconfig this warning is triggered
+ *
+ * $make W=1 -j8 > make_output.txt
+ * In file included from kernel/sched/build_policy.c:52:
+ * kernel/sched/rt.c:12:18: warning: ‘max_rt_runtime’ defined but not used [-Wunused-const-variable=]
+ *   12 | static const u64 max_rt_runtime = MAX_BW;
+ *      |                  ^~~~~~~~~~~~~~
+ */
 
 /*
  * period over which we measure -rt task CPU usage in us.
@@ -2766,6 +2774,9 @@ static int tg_set_rt_bandwidth(struct task_group *tg,
 	 * Bound quota to defend quota against overflow during bandwidth shift.
 	 */
 	if (rt_runtime != RUNTIME_INF && rt_runtime > max_rt_runtime)
+/* 
+ * here max_rt_runtime is obviosly used
+ */
 		return -EINVAL;
 
 	mutex_lock(&rt_constraints_mutex);
@@ -2857,6 +2868,9 @@ static int sched_rt_global_validate(void)
 		((sysctl_sched_rt_runtime > sysctl_sched_rt_period) ||
 		 ((u64)sysctl_sched_rt_runtime *
 			NSEC_PER_USEC > max_rt_runtime)))
+/*
+ * here it is used again
+ */
 		return -EINVAL;
 
 #ifdef CONFIG_RT_GROUP_SCHED
Signature · 1 line
2.55.0
#1 lore raw

Hello Manuel,

Quoted 9 lines · Manuel Ebner

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Hi,

I'm trying to fix built warning and stumbled over this one:

$make W=1 -j8 > make_output.txt
In file included from kernel/sched/build_policy.c:52:
kernel/sched/rt.c:12:18: warning: ‘max_rt_runtime’ defined but not used [-Wunused-const-variable=]

Quoted 6 lines
   12 | static const u64 max_rt_runtime = MAX_BW;
      |                  ^~~~~~~~~~~~~~

I just can't make sense of this, because max_rt_runtime is used later in the file - see diff.
What am I missing?

Any chance you have both CONFIG_RT_GROUP_SCHED and CONFIG_SYSCTL disabled in your .config?

In that case, max_rt_runtime is never used by anything that gets built in and the compiler complains. You can annotate it with __maybe_unused to keep the build happy in those cases.

Signature · 2 lines
Thanks and Regards,
Prateek