linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH peterz-queue:sched/core] sched: fix build warning with W=1
@ 2021-09-11  8:25 Yafang Shao
  2021-09-11 11:57 ` Peter Zijlstra
  2021-09-11 12:22 ` Peter Zijlstra
  0 siblings, 2 replies; 4+ messages in thread
From: Yafang Shao @ 2021-09-11  8:25 UTC (permalink / raw)
  To: peterz; +Cc: lkp, kbuild-all, linux-kernel, Yafang Shao

kernel test robot reported some build warnings with W=1 as below,

kernel/sched/fair.c:892:34: warning: variable 'stats' set but not used
kernel/sched/core.c:10238:42: warning: variable 'stats' set but not used
kernel/sched/fair.c:893:29: warning: variable 'p' set but not used
kernel/sched/rt.c:1292:29: warning: variable 'p' set but not used
kernel/sched/deadline.c:1486:34: warning: variable 'stats' set but not used
arch/nds32/include/asm/current.h:10:13: warning: variable '$r25' set but not used

These warnings happen when CONFIG_SCHEDSTATS is not set, in which
case the schedstat_* functions will be none. We should add
'__maybe_unused' to fix it

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 kernel/sched/core.c     |  4 ++--
 kernel/sched/deadline.c |  6 +++---
 kernel/sched/fair.c     | 12 ++++++------
 kernel/sched/rt.c       |  6 +++---
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 85e212d3c7ff..7c3476f284d8 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3462,7 +3462,7 @@ static inline bool rq_has_pinned_tasks(struct rq *rq)
 static void
 ttwu_stat(struct task_struct *p, int cpu, int wake_flags)
 {
-	struct rq *rq;
+	struct rq __maybe_unused *rq;
 
 	if (!schedstat_enabled())
 		return;
@@ -10235,7 +10235,7 @@ static int cpu_cfs_stat_show(struct seq_file *sf, void *v)
 	seq_printf(sf, "throttled_time %llu\n", cfs_b->throttled_time);
 
 	if (schedstat_enabled() && tg != &root_task_group) {
-		struct sched_statistics *stats;
+		struct sched_statistics __maybe_unused *stats;
 		u64 ws = 0;
 		int i;
 
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index d2c072b0ef01..f6ececf11725 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1483,7 +1483,7 @@ __schedstats_from_dl_se(struct sched_dl_entity *dl_se)
 static inline void
 update_stats_wait_start_dl(struct dl_rq *dl_rq, struct sched_dl_entity *dl_se)
 {
-	struct sched_statistics *stats;
+	struct sched_statistics __maybe_unused *stats;
 
 	if (!schedstat_enabled())
 		return;
@@ -1495,7 +1495,7 @@ update_stats_wait_start_dl(struct dl_rq *dl_rq, struct sched_dl_entity *dl_se)
 static inline void
 update_stats_wait_end_dl(struct dl_rq *dl_rq, struct sched_dl_entity *dl_se)
 {
-	struct sched_statistics *stats;
+	struct sched_statistics __maybe_unused *stats;
 
 	if (!schedstat_enabled())
 		return;
@@ -1507,7 +1507,7 @@ update_stats_wait_end_dl(struct dl_rq *dl_rq, struct sched_dl_entity *dl_se)
 static inline void
 update_stats_enqueue_sleeper_dl(struct dl_rq *dl_rq, struct sched_dl_entity *dl_se)
 {
-	struct sched_statistics *stats;
+	struct sched_statistics __maybe_unused *stats;
 
 	if (!schedstat_enabled())
 		return;
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index ea13d3d9e540..4d985d0364bc 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -889,8 +889,8 @@ static void update_curr_fair(struct rq *rq)
 static inline void
 update_stats_wait_start_fair(struct cfs_rq *cfs_rq, struct sched_entity *se)
 {
-	struct sched_statistics *stats;
-	struct task_struct *p = NULL;
+	struct sched_statistics __maybe_unused *stats;
+	struct task_struct __maybe_unused *p = NULL;
 
 	if (!schedstat_enabled())
 		return;
@@ -906,8 +906,8 @@ update_stats_wait_start_fair(struct cfs_rq *cfs_rq, struct sched_entity *se)
 static inline void
 update_stats_wait_end_fair(struct cfs_rq *cfs_rq, struct sched_entity *se)
 {
-	struct sched_statistics *stats;
-	struct task_struct *p = NULL;
+	struct sched_statistics __maybe_unused *stats;
+	struct task_struct __maybe_unused *p = NULL;
 
 	if (!schedstat_enabled())
 		return;
@@ -932,8 +932,8 @@ update_stats_wait_end_fair(struct cfs_rq *cfs_rq, struct sched_entity *se)
 static inline void
 update_stats_enqueue_sleeper_fair(struct cfs_rq *cfs_rq, struct sched_entity *se)
 {
-	struct sched_statistics *stats;
-	struct task_struct *tsk = NULL;
+	struct sched_statistics __maybe_unused *stats;
+	struct task_struct __maybe_unused *tsk = NULL;
 
 	if (!schedstat_enabled())
 		return;
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index bb945f8faeca..e19d1e7190cc 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1288,8 +1288,8 @@ __schedstats_from_rt_se(struct sched_rt_entity *rt_se)
 static inline void
 update_stats_wait_start_rt(struct rt_rq *rt_rq, struct sched_rt_entity *rt_se)
 {
+	struct task_struct __maybe_unused *p = NULL;
 	struct sched_statistics *stats;
-	struct task_struct *p = NULL;
 
 	if (!schedstat_enabled())
 		return;
@@ -1307,8 +1307,8 @@ update_stats_wait_start_rt(struct rt_rq *rt_rq, struct sched_rt_entity *rt_se)
 static inline void
 update_stats_enqueue_sleeper_rt(struct rt_rq *rt_rq, struct sched_rt_entity *rt_se)
 {
+	struct task_struct __maybe_unused *p = NULL;
 	struct sched_statistics *stats;
-	struct task_struct *p = NULL;
 
 	if (!schedstat_enabled())
 		return;
@@ -1337,8 +1337,8 @@ update_stats_enqueue_rt(struct rt_rq *rt_rq, struct sched_rt_entity *rt_se,
 static inline void
 update_stats_wait_end_rt(struct rt_rq *rt_rq, struct sched_rt_entity *rt_se)
 {
+	struct task_struct __maybe_unused *p = NULL;
 	struct sched_statistics *stats;
-	struct task_struct *p = NULL;
 
 	if (!schedstat_enabled())
 		return;
-- 
2.17.1


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

* Re: [PATCH peterz-queue:sched/core] sched: fix build warning with W=1
  2021-09-11  8:25 [PATCH peterz-queue:sched/core] sched: fix build warning with W=1 Yafang Shao
@ 2021-09-11 11:57 ` Peter Zijlstra
  2021-09-11 12:22 ` Peter Zijlstra
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2021-09-11 11:57 UTC (permalink / raw)
  To: Yafang Shao; +Cc: lkp, kbuild-all, linux-kernel

On Sat, Sep 11, 2021 at 08:25:05AM +0000, Yafang Shao wrote:
> kernel test robot reported some build warnings with W=1 as below,
> 
> kernel/sched/fair.c:892:34: warning: variable 'stats' set but not used
> kernel/sched/core.c:10238:42: warning: variable 'stats' set but not used
> kernel/sched/fair.c:893:29: warning: variable 'p' set but not used
> kernel/sched/rt.c:1292:29: warning: variable 'p' set but not used
> kernel/sched/deadline.c:1486:34: warning: variable 'stats' set but not used
> arch/nds32/include/asm/current.h:10:13: warning: variable '$r25' set but not used

Yeah, I got the mails... :-)

I'll need it per patch tho, so that I can fix the individual commits.
Let me go do that. Thanks for looking at this.

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

* Re: [PATCH peterz-queue:sched/core] sched: fix build warning with W=1
  2021-09-11  8:25 [PATCH peterz-queue:sched/core] sched: fix build warning with W=1 Yafang Shao
  2021-09-11 11:57 ` Peter Zijlstra
@ 2021-09-11 12:22 ` Peter Zijlstra
  2021-09-11 14:47   ` Yafang Shao
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2021-09-11 12:22 UTC (permalink / raw)
  To: Yafang Shao; +Cc: lkp, kbuild-all, linux-kernel

On Sat, Sep 11, 2021 at 08:25:05AM +0000, Yafang Shao wrote:
> kernel test robot reported some build warnings with W=1 as below,
> 
> kernel/sched/fair.c:892:34: warning: variable 'stats' set but not used
> kernel/sched/core.c:10238:42: warning: variable 'stats' set but not used
> kernel/sched/fair.c:893:29: warning: variable 'p' set but not used
> kernel/sched/rt.c:1292:29: warning: variable 'p' set but not used
> kernel/sched/deadline.c:1486:34: warning: variable 'stats' set but not used
> arch/nds32/include/asm/current.h:10:13: warning: variable '$r25' set but not used
> 
> These warnings happen when CONFIG_SCHEDSTATS is not set, in which
> case the schedstat_* functions will be none. We should add
> '__maybe_unused' to fix it

I really hate all of this, I think the compiler is just being unhelpful
in the extreme. Also, I spupose the warning is in W=1 for a reason,
let's just completely ignore all of this.

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

* Re: [PATCH peterz-queue:sched/core] sched: fix build warning with W=1
  2021-09-11 12:22 ` Peter Zijlstra
@ 2021-09-11 14:47   ` Yafang Shao
  0 siblings, 0 replies; 4+ messages in thread
From: Yafang Shao @ 2021-09-11 14:47 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: kbuild test robot, kbuild-all, LKML

On Sat, Sep 11, 2021 at 8:22 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Sat, Sep 11, 2021 at 08:25:05AM +0000, Yafang Shao wrote:
> > kernel test robot reported some build warnings with W=1 as below,
> >
> > kernel/sched/fair.c:892:34: warning: variable 'stats' set but not used
> > kernel/sched/core.c:10238:42: warning: variable 'stats' set but not used
> > kernel/sched/fair.c:893:29: warning: variable 'p' set but not used
> > kernel/sched/rt.c:1292:29: warning: variable 'p' set but not used
> > kernel/sched/deadline.c:1486:34: warning: variable 'stats' set but not used
> > arch/nds32/include/asm/current.h:10:13: warning: variable '$r25' set but not used
> >
> > These warnings happen when CONFIG_SCHEDSTATS is not set, in which
> > case the schedstat_* functions will be none. We should add
> > '__maybe_unused' to fix it
>
> I really hate all of this, I think the compiler is just being unhelpful
> in the extreme. Also, I spupose the warning is in W=1 for a reason,
> let's just completely ignore all of this.

Got it.
Thanks for the review.

-- 
Thanks
Yafang

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

end of thread, other threads:[~2021-09-11 14:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-11  8:25 [PATCH peterz-queue:sched/core] sched: fix build warning with W=1 Yafang Shao
2021-09-11 11:57 ` Peter Zijlstra
2021-09-11 12:22 ` Peter Zijlstra
2021-09-11 14:47   ` Yafang Shao

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).