tick-sched: avoid a maybe-uninitialized warning
PATCH 1/1 tick-sched: avoid a maybe-uninitialized warning
The use of bitfields seems to confuse gcc, leading to a false-positive warning in all compiler versions:
kernel/time/tick-sched.c: In function 'tick_nohz_idle_exit':kernel/time/tick-sched.c:538:2: error: 'now' may be used uninitialized in this function [-Werror=maybe-uninitialized]
This introduces a temporary variable to track the flags so gcc doesn't have to evaluate twice, eliminating the code path that leads to the warning.
--- kernel/time/tick-sched.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
kernel/time/tick-sched.c +6 -3
@@ -1143,6 +1143,7 @@ void tick_nohz_idle_restart_tick(void)void tick_nohz_idle_exit (void ) {struct tick_sched *ts =this_cpu_ptr (&tick_cpu_sched); +bool idle_active, tick_stopped;ktime_t now;local_irq_disable ();
@@ -1151,14 +1152,16 @@ void tick_nohz_idle_exit(void)WARN_ON_ONCE (ts->timer_expires_base); ts->inidle =0 ; + idle_active = ts->idle_active; + tick_stopped = ts->tick_stopped; -if (ts->idle_active || ts->tick_stopped) +if (idle_active || tick_stopped) now =ktime_get (); -if (ts->idle_active) +if (idle_active)tick_nohz_stop_idle (ts, now); -if (ts->tick_stopped) +if (tick_stopped)__tick_nohz_idle_restart_tick (ts, now);local_irq_enable ();
Signature · 1 line
2.9.0
Ingo Molnar
maintainerQuoted 6 lines · Arnd Bergmann
The use of bitfields seems to confuse gcc, leading to a false-positive warning in all compiler versions:
kernel/time/tick-sched.c: In function 'tick_nohz_idle_exit':kernel/time/tick-sched.c:538:2: error: 'now' may be used uninitialized in this function [-Werror=maybe-uninitialized]
Quoted 7 lines
This introduces a temporary variable to track the flags so gcc doesn't have to evaluate twice, eliminating the code path that leads to the warning.
Fixes 1cae544d42d2 ("nohz: Gather tick_sched booleans under a common flag field")Signed-off-by Arnd Bergmann <[email protected]>
Which tree is this against? There's no such commit either in -tip, upstream or in -next AFAICS.
Thanks,
Ingo
Quoted 13 lines · Ingo Molnar
Quoted 10 lines · Arnd Bergmann
The use of bitfields seems to confuse gcc, leading to a false-positive warning in all compiler versions:
kernel/time/tick-sched.c: In function 'tick_nohz_idle_exit':kernel/time/tick-sched.c:538:2: error: 'now' may be used uninitialized in this function [-Werror=maybe-uninitialized]This introduces a temporary variable to track the flags so gcc doesn't have to evaluate twice, eliminating the code path that leads to the warning.
Quoted 6 lines
Quoted 3 lines
Fixes 1cae544d42d2 ("nohz: Gather tick_sched booleans under a common flag field")Signed-off-by Arnd Bergmann <[email protected]>Which tree is this against? There's no such commit either in -tip, upstream or in -next AFAICS.
It's in today's linux-next. I found that it came in through Rafael's pm/linux-next tree.
Arnd
Quoted 18 lines · CEST Arnd Bergmann
Quoted 17 lines · Ingo Molnar
Quoted 13 lines · Arnd Bergmann
The use of bitfields seems to confuse gcc, leading to a false-positive warning in all compiler versions:
kernel/time/tick-sched.c: In function 'tick_nohz_idle_exit':kernel/time/tick-sched.c:538:2: error: 'now' may be used uninitialized in this function [-Werror=maybe-uninitialized]This introduces a temporary variable to track the flags so gcc doesn't have to evaluate twice, eliminating the code path that leads to the warning.
Fixes 1cae544d42d2 ("nohz: Gather tick_sched booleans under a common flag field")Signed-off-by Arnd Bergmann <[email protected]>
Quoted 5 lines
Quoted 2 lines
Which tree is this against? There's no such commit either in -tip, upstream or in -next AFAICS.
It's in today's linux-next. I found that it came in through Rafael's pm/linux-next tree.
That's the idle loop rework series.
I'll add this patch on top of that if there are no objections.
Thanks,
Rafael