Skip to contentSkip to conversation

linux-next: build warning after merge of the tip tree

DISCUSSION Stephen Rothwell 3 participants 7 messages Sep 20, 2021 – Oct 6, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

After merging the tip tree, today's linux-next build (powerpc_ppc64 defconfig) produced this warning:

kernel/sched/debug.c: In function 'print_cfs_group_stats':
kernel/sched/debug.c:460:41: warning: unused variable 'stats' [-Wunused-variable]
460 | struct sched_statistics *stats = __schedstats_from_se(se);
| ^~~~~

Caused by commit

cb3e971c435d ("sched: Make struct sched_statistics independent of fair sched class")

# CONFIG_SCHEDSTATS is not set

Signature · 2 lines
Cheers,
Stephen Rothwell
#1 lore raw
Quoted 11 lines · Stephen Rothwell

Hi all,

After merging the tip tree, today's linux-next build (powerpc_ppc64 defconfig) produced this warning:

kernel/sched/debug.c: In function 'print_cfs_group_stats':
kernel/sched/debug.c:460:41: warning: unused variable 'stats' [-Wunused-variable]
460 | struct sched_statistics *stats = __schedstats_from_se(se);
| ^~~~~

Quoted 6 lines

Caused by commit

cb3e971c435d ("sched: Make struct sched_statistics independent of fair sched class")

# CONFIG_SCHEDSTATS is not set

Hi Stephen,

Thanks for the report.

We have discussed this issue before[1].
This warning happens when CONFIG_SCHEDSTATS is not set and schedstat_enabled() is 0, so the whole scope should be not compiled. It seems that we don't need to fix this warning.

[1]. https://lore.kernel.org/lkml/[email protected]/

Signature · 2 lines
Thanks
Yafang
#2 lore raw

Hi Yafang,

Quoted 20 lines · On Mon, 20 Sep 2021 14:55:29 +0800 Yafang Shao <[email protected]> wrote:
Quoted 11 lines · Stephen Rothwell

Hi all,

After merging the tip tree, today's linux-next build (powerpc_ppc64 defconfig) produced this warning:

kernel/sched/debug.c: In function 'print_cfs_group_stats':
kernel/sched/debug.c:460:41: warning: unused variable 'stats' [-Wunused-variable]
460 | struct sched_statistics *stats = __schedstats_from_se(se);
| ^~~~~

Quoted 6 lines

Caused by commit

cb3e971c435d ("sched: Make struct sched_statistics independent of fair sched class")

# CONFIG_SCHEDSTATS is not set

Quoted 8 lines

Thanks for the report.

We have discussed this issue before[1].
This warning happens when CONFIG_SCHEDSTATS is not set and schedstat_enabled() is 0, so the whole scope should be not compiled. It seems that we don't need to fix this warning.

[1]. https://lore.kernel.org/lkml/[email protected]/

Clearly it will be compiled if CONFIG_SCHEDSTATS is not set as that is exactly what this build has ... even sections of code guarded by "if (0)" are compiled, they may just not produce any output in the binary.

Also, I do not have W=1 for this build.

If you turned schedstat_val() into a static inline function, then this warning would go away. That also means that argument types and return values will be better checked.

So, please fix this.

Signature · 2 lines
Cheers,
Stephen Rothwell
#3 lore raw

Hi all,

Quoted 33 lines · On Mon, 20 Sep 2021 18:30:16 +1000 Stephen Rothwell <[email protected]>…
Quoted 18 lines · On Mon, 20 Sep 2021 14:55:29 +0800 Yafang Shao <[email protected]> wrote:
Quoted 9 lines · Stephen Rothwell

After merging the tip tree, today's linux-next build (powerpc_ppc64 defconfig) produced this warning:

kernel/sched/debug.c: In function 'print_cfs_group_stats':
kernel/sched/debug.c:460:41: warning: unused variable 'stats' [-Wunused-variable]
460 | struct sched_statistics *stats = __schedstats_from_se(se);
| ^~~~~

Quoted 6 lines

Caused by commit

cb3e971c435d ("sched: Make struct sched_statistics independent of fair sched class")

# CONFIG_SCHEDSTATS is not set

Quoted 8 lines

Thanks for the report.

We have discussed this issue before[1].
This warning happens when CONFIG_SCHEDSTATS is not set and schedstat_enabled() is 0, so the whole scope should be not compiled. It seems that we don't need to fix this warning.

[1]. https://lore.kernel.org/lkml/[email protected]/

Clearly it will be compiled if CONFIG_SCHEDSTATS is not set as that is exactly what this build has ... even sections of code guarded by "if (0)" are compiled, they may just not produce any output in the binary.

Quoted 5 lines

Also, I do not have W=1 for this build.

If you turned schedstat_val() into a static inline function, then this warning would go away. That also means that argument types and return values will be better checked.

I take it back, that won't work :-(

Quoted 1 line

So, please fix this.

Still it needs to be fixed to keep unnecessary warnings out of our builds.

Signature · 2 lines
Cheers,
Stephen Rothwell
maintainer
#4 lore raw
In reply to Stephen Rothwell
Quoted 10 lines · Stephen Rothwell

Hi all,

After merging the tip tree, today's linux-next build (powerpc_ppc64 defconfig) produced this warning:

kernel/sched/debug.c: In function 'print_cfs_group_stats':
kernel/sched/debug.c:460:41: warning: unused variable 'stats' [-Wunused-variable]
460 | struct sched_statistics *stats = __schedstats_from_se(se);
| ^~~~~

So I've not seen that one *yet*, I've dont a bunch of SCHEDSTAT=n builds. I do think GCC is being quite stupid for giving it, seeing how the whole thing is within if (0). The GCC people seem to disagree when I brought it up.

Anyway, what I did in other parts was the below; that seems to 'upgrade' the warnings from -Wunused-variable to -Wunused-but-set-variable, and that latter *is* in W=1, and I'm arguing it should be promoted to W=2 or thereabout.

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.

---

kernel/sched/debug.c +2 -1
index 935dad7dffb7..ef71de01e4d7 100644
@@ -457,7 +457,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);
#5 lore raw

Hi Peter,

Quoted 31 lines · On Mon, 20 Sep 2021 13:18:53 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 8 lines · Stephen Rothwell

After merging the tip tree, today's linux-next build (powerpc_ppc64 defconfig) produced this warning:

kernel/sched/debug.c: In function 'print_cfs_group_stats':
kernel/sched/debug.c:460:41: warning: unused variable 'stats' [-Wunused-variable]
460 | struct sched_statistics *stats = __schedstats_from_se(se);
| ^~~~~

So I've not seen that one *yet*, I've dont a bunch of SCHEDSTAT=n builds. I do think GCC is being quite stupid for giving it, seeing how the whole thing is within if (0). The GCC people seem to disagree when I brought it up.

Anyway, what I did in other parts was the below; that seems to 'upgrade' the warnings from -Wunused-variable to -Wunused-but-set-variable, and that latter *is* in W=1, and I'm arguing it should be promoted to W=2 or thereabout.

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.

---

kernel/sched/debug.c +0 -0
index 935dad7dffb7..ef71de01e4d7 100644

kernel/sched/debug.c static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group · line 464

Quoted 9 lines
kernel/sched/debug.c +2 -1
@@ -457,7 +457,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);

Any progress on this? I am still getting the warning.

Signature · 2 lines
Cheers,
Stephen Rothwell
maintainer
#6 lore raw
Quoted 41 lines · Stephen Rothwell

Hi Peter,

Quoted 38 lines · On Mon, 20 Sep 2021 13:18:53 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 8 lines · Stephen Rothwell

After merging the tip tree, today's linux-next build (powerpc_ppc64 defconfig) produced this warning:

kernel/sched/debug.c: In function 'print_cfs_group_stats':
kernel/sched/debug.c:460:41: warning: unused variable 'stats' [-Wunused-variable]
460 | struct sched_statistics *stats = __schedstats_from_se(se);
| ^~~~~

So I've not seen that one *yet*, I've dont a bunch of SCHEDSTAT=n builds. I do think GCC is being quite stupid for giving it, seeing how the whole thing is within if (0). The GCC people seem to disagree when I brought it up.

Anyway, what I did in other parts was the below; that seems to 'upgrade' the warnings from -Wunused-variable to -Wunused-but-set-variable, and that latter *is* in W=1, and I'm arguing it should be promoted to W=2 or thereabout.

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.

---

kernel/sched/debug.c +2 -1
index 935dad7dffb7..ef71de01e4d7 100644
@@ -457,7 +457,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);
 
Quoted 4 lines

kernel/sched/debug.c static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group · line 464

Quoted 2 lines
kernel/sched/debug.c +0 -0
 		PN_SCHEDSTAT(wait_start);
 		PN_SCHEDSTAT(sleep_start);

Any progress on this? I am still getting the warning.

Urgh, sorry, fell through cracks. Will commit fixup in a few.