linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tick-sched: avoid a maybe-uninitialized warning
@ 2018-04-09 12:23 Arnd Bergmann
  2018-04-09 16:18 ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2018-04-09 12:23 UTC (permalink / raw)
  To: Frederic Weisbecker, Thomas Gleixner, Ingo Molnar
  Cc: Arnd Bergmann, Peter Zijlstra, Rafael J. Wysocki,
	Paul E. McKenney, linux-kernel

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.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85301
Fixes: 1cae544d42d2 ("nohz: Gather tick_sched booleans under a common flag field")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/time/tick-sched.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 7eef9431ca24..646645e981f9 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -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();
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tick-sched: avoid a maybe-uninitialized warning
  2018-04-09 12:23 [PATCH] tick-sched: avoid a maybe-uninitialized warning Arnd Bergmann
@ 2018-04-09 16:18 ` Ingo Molnar
  2018-04-09 17:53   ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2018-04-09 16:18 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Frederic Weisbecker, Thomas Gleixner, Peter Zijlstra,
	Rafael J. Wysocki, Paul E. McKenney, linux-kernel


* Arnd Bergmann <arnd@arndb.de> wrote:

> 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.
> 
> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85301
> Fixes: 1cae544d42d2 ("nohz: Gather tick_sched booleans under a common flag field")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Which tree is this against? There's no such commit either in -tip, upstream or in 
-next AFAICS.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tick-sched: avoid a maybe-uninitialized warning
  2018-04-09 16:18 ` Ingo Molnar
@ 2018-04-09 17:53   ` Arnd Bergmann
  2018-04-10  7:16     ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2018-04-09 17:53 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Frederic Weisbecker, Thomas Gleixner, Peter Zijlstra,
	Rafael J. Wysocki, Paul E. McKenney, Linux Kernel Mailing List

On Mon, Apr 9, 2018 at 6:18 PM, Ingo Molnar <mingo@kernel.org> wrote:
>
> * Arnd Bergmann <arnd@arndb.de> wrote:
>
>> 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.
>>
>> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85301
>> Fixes: 1cae544d42d2 ("nohz: Gather tick_sched booleans under a common flag field")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tick-sched: avoid a maybe-uninitialized warning
  2018-04-09 17:53   ` Arnd Bergmann
@ 2018-04-10  7:16     ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2018-04-10  7:16 UTC (permalink / raw)
  To: Arnd Bergmann, Ingo Molnar, Paul E. McKenney
  Cc: Frederic Weisbecker, Thomas Gleixner, Peter Zijlstra,
	Linux Kernel Mailing List

On Monday, April 9, 2018 7:53:30 PM CEST Arnd Bergmann wrote:
> On Mon, Apr 9, 2018 at 6:18 PM, Ingo Molnar <mingo@kernel.org> wrote:
> >
> > * Arnd Bergmann <arnd@arndb.de> wrote:
> >
> >> 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.
> >>
> >> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85301
> >> Fixes: 1cae544d42d2 ("nohz: Gather tick_sched booleans under a common flag field")
> >> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> >
> > 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-10  7:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-09 12:23 [PATCH] tick-sched: avoid a maybe-uninitialized warning Arnd Bergmann
2018-04-09 16:18 ` Ingo Molnar
2018-04-09 17:53   ` Arnd Bergmann
2018-04-10  7:16     ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).