[PATCH] sched/rt: Fix unused-const-variable W=1 warning and style issue

Anuradha Weeraman posted 1 patch 2 years, 7 months ago
There is a newer version of this series
kernel/sched/rt.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] sched/rt: Fix unused-const-variable W=1 warning and style issue
Posted by Anuradha Weeraman 2 years, 7 months ago
Compiler warning with W=1 due to unused constant in
    kernel/sched/rt.c:9:18: warning: ‘max_rt_runtime’ defined but not used

Fix by wrapping the variable in an #if check for CONFIG_SYSCTL and
CONFIG_RT_GROUP_SCHED, which are the only blocks where this variable
is referenced from.

Also, fix style issue for "else should follow close brace '}'".

Signed-off-by: Anuradha Weeraman <anuradha@debian.org>
---
 kernel/sched/rt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index ed2a47e4ddae..e46e76893a0c 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -5,8 +5,11 @@
  */
 
 int sched_rr_timeslice = RR_TIMESLICE;
+
+#if defined(CONFIG_SYSCTL) || defined(CONFIG_RT_GROUP_SCHED)
 /* More than 4 hours if BW_SHIFT equals 20. */
 static const u64 max_rt_runtime = MAX_BW;
+#endif
 
 static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun);
 
@@ -604,8 +607,7 @@ static void sched_rt_rq_dequeue(struct rt_rq *rt_rq)
 		dequeue_top_rt_rq(rt_rq, rt_rq->rt_nr_running);
 		/* Kick cpufreq (see the comment in kernel/sched/sched.h). */
 		cpufreq_update_util(rq_of_rt_rq(rt_rq), 0);
-	}
-	else if (on_rt_rq(rt_se))
+	} else if (on_rt_rq(rt_se))
 		dequeue_rt_entity(rt_se, 0);
 }
 
-- 
2.39.0

Re: [PATCH] sched/rt: Fix unused-const-variable W=1 warning and style issue
Posted by Steven Rostedt 2 years, 7 months ago
On Thu, 19 Jan 2023 21:52:32 +0530
Anuradha Weeraman <anuradha@debian.org> wrote:

> Compiler warning with W=1 due to unused constant in
>     kernel/sched/rt.c:9:18: warning: ‘max_rt_runtime’ defined but not used
> 
> Fix by wrapping the variable in an #if check for CONFIG_SYSCTL and
> CONFIG_RT_GROUP_SCHED, which are the only blocks where this variable
> is referenced from.
> 
> Also, fix style issue for "else should follow close brace '}'".
> 
> Signed-off-by: Anuradha Weeraman <anuradha@debian.org>
> ---
>  kernel/sched/rt.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index ed2a47e4ddae..e46e76893a0c 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -5,8 +5,11 @@
>   */
>  
>  int sched_rr_timeslice = RR_TIMESLICE;
> +
> +#if defined(CONFIG_SYSCTL) || defined(CONFIG_RT_GROUP_SCHED)
>  /* More than 4 hours if BW_SHIFT equals 20. */
>  static const u64 max_rt_runtime = MAX_BW;

As keeping track of which config needs this can get difficult in the
future, why not just make it:

static const u64 __maybe_unused max_rt_runtime = MAX_BW;

?

-- Steve

> +#endif
>  
>  static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun);
>  
> @@ -604,8 +607,7 @@ static void sched_rt_rq_dequeue(struct rt_rq *rt_rq)
>  		dequeue_top_rt_rq(rt_rq, rt_rq->rt_nr_running);
>  		/* Kick cpufreq (see the comment in kernel/sched/sched.h). */
>  		cpufreq_update_util(rq_of_rt_rq(rt_rq), 0);
> -	}
> -	else if (on_rt_rq(rt_se))
> +	} else if (on_rt_rq(rt_se))
>  		dequeue_rt_entity(rt_se, 0);
>  }
>  

[PATCH v2] sched/rt: Fix unused-const-variable W=1 warning and style issue
Posted by Anuradha Weeraman 2 years, 6 months ago
Compiler warning with W=1 due to unused constant in
    kernel/sched/rt.c:9:18: warning: ‘max_rt_runtime’ defined but not used

Fix by adding __maybe_unused attribute to max_rt_runtime.

Also, fix style issue for "else should follow close brace '}'".

Signed-off-by: Anuradha Weeraman <anuradha@debian.org>
---
 kernel/sched/rt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index ed2a47e4ddae..8cd2e1203a81 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -6,7 +6,7 @@
 
 int sched_rr_timeslice = RR_TIMESLICE;
 /* More than 4 hours if BW_SHIFT equals 20. */
-static const u64 max_rt_runtime = MAX_BW;
+static const u64 __maybe_unused max_rt_runtime = MAX_BW;
 
 static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun);
 
@@ -604,8 +604,7 @@ static void sched_rt_rq_dequeue(struct rt_rq *rt_rq)
 		dequeue_top_rt_rq(rt_rq, rt_rq->rt_nr_running);
 		/* Kick cpufreq (see the comment in kernel/sched/sched.h). */
 		cpufreq_update_util(rq_of_rt_rq(rt_rq), 0);
-	}
-	else if (on_rt_rq(rt_se))
+	} else if (on_rt_rq(rt_se))
 		dequeue_rt_entity(rt_se, 0);
 }
 
-- 
2.39.0

[PATCH v2] sched/rt: Fix unused-const-variable W=1 warning and style issue
Posted by Anuradha Weeraman 2 years, 7 months ago
Compiler warning with W=1 due to unused constant in
    kernel/sched/rt.c:9:18: warning: ‘max_rt_runtime’ defined but not used

Fix by adding __maybe_unused attribute to max_rt_runtime.

Also, fix style issue for "else should follow close brace '}'".

Signed-off-by: Anuradha Weeraman <anuradha@debian.org>
---
 kernel/sched/rt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index ed2a47e4ddae..8cd2e1203a81 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -6,7 +6,7 @@
 
 int sched_rr_timeslice = RR_TIMESLICE;
 /* More than 4 hours if BW_SHIFT equals 20. */
-static const u64 max_rt_runtime = MAX_BW;
+static const u64 __maybe_unused max_rt_runtime = MAX_BW;
 
 static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun);
 
@@ -604,8 +604,7 @@ static void sched_rt_rq_dequeue(struct rt_rq *rt_rq)
 		dequeue_top_rt_rq(rt_rq, rt_rq->rt_nr_running);
 		/* Kick cpufreq (see the comment in kernel/sched/sched.h). */
 		cpufreq_update_util(rq_of_rt_rq(rt_rq), 0);
-	}
-	else if (on_rt_rq(rt_se))
+	} else if (on_rt_rq(rt_se))
 		dequeue_rt_entity(rt_se, 0);
 }
 
-- 
2.39.0