Skip to content

Commit

Permalink
sched: Fix DEBUG && !SCHEDSTATS warn
Browse files Browse the repository at this point in the history
commit 769fdf8 upstream.

When !SCHEDSTATS schedstat_enabled() is an unconditional 0 and the
whole block doesn't exist, however GCC figures the scoped variable
'stats' is unused and complains about it.

Upgrade the warning from -Wunused-variable to -Wunused-but-set-variable
by writing it in two statements. This fixes the build because the new
warning is in W=1.

Given that whole if(0) {} thing, I don't feel motivated to change
things overly much and quite strongly feel this is the compiler being
daft.

Fixes: cb3e971c435d ("sched: Make struct sched_statistics independent of fair sched class")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Peter Zijlstra authored and Greg Kroah-Hartman committed May 11, 2023
1 parent 21c2a45 commit 0a008c5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/sched/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group
PN(se->sum_exec_runtime);

if (schedstat_enabled()) {
struct sched_statistics *stats = __schedstats_from_se(se);
struct sched_statistics *stats;
stats = __schedstats_from_se(se);

PN_SCHEDSTAT(wait_start);
PN_SCHEDSTAT(sleep_start);
Expand Down

0 comments on commit 0a008c5

Please sign in to comment.