lkml.org 
[lkml]   [2018]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] kernel/sched/core.c: Avoid unused variable on non-SMP configs
On Sat, Sep 08, 2018 at 09:05:53PM +0200, Miguel Ojeda wrote:
> On non-SMP configs, when only one of CONFIG_{PARAVIRT,IRQ_TIME}_ACCOUNTING
> is defined, we are declaring a variable (irq_delta or steal) which
> is not used:
>
> kernel/sched/core.c: In function ‘update_rq_clock_task’:
> kernel/sched/core.c:139:17: warning: unused variable ‘irq_delta’ [-Wunused-variable]
> s64 steal = 0, irq_delta = 0;
>
> The reason is that CONFIG_SMP guards HAVE_SCHED_AVG_IRQ, which in turn
> disables the code guarded by HAVE_SCHED_AVG_IRQ.
>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> ---
> kernel/sched/core.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 625bc9897f62..d662d1e11843 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -135,8 +135,11 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
> * In theory, the compile should just see 0 here, and optimize out the call
> * to sched_rt_avg_update. But I don't trust it...
> */
> -#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
> - s64 steal = 0, irq_delta = 0;
> +#if defined(HAVE_SCHED_AVG_IRQ) || defined(CONFIG_IRQ_TIME_ACCOUNTING)
> + s64 irq_delta = 0;
> +#endif
> +#if defined(HAVE_SCHED_AVG_IRQ) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
> + s64 steal = 0;
> #endif
> #ifdef CONFIG_IRQ_TIME_ACCOUNTING
> irq_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time;
> --

Alternatively, if you don't want to let the crazy ifdeffery in that
function grow even more, you can simply do:

---
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 625bc9897f62..1728743360d4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -136,7 +136,7 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
* to sched_rt_avg_update. But I don't trust it...
*/
#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
- s64 steal = 0, irq_delta = 0;
+ s64 steal __maybe_unused = 0, irq_delta = 0;
#endif
#ifdef CONFIG_IRQ_TIME_ACCOUNTING
irq_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time;
--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

\
 
 \ /
  Last update: 2018-09-09 11:37    [W:0.067 / U:10.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site