public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] sched/fair: Mark cfs_bandwidth_used() and m*_vruntime() with __maybe_unused
@ 2024-09-05 17:12 Andy Shevchenko
  2024-11-08  9:30 ` Andy Shevchenko
  2024-11-12 11:48 ` Valentin Schneider
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-09-05 17:12 UTC (permalink / raw)
  To: Ingo Molnar, linux-kernel, llvm
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Andy Shevchenko

When cfs_bandwidth_used() is unused, it prevents kernel builds
with clang, `make W=1` and CONFIG_WERROR=y:

kernel/sched/fair.c:526:19: error: unused function 'max_vruntime' [-Werror,-Wunused-function]
  526 | static inline u64 max_vruntime(u64 max_vruntime, u64 vruntime)
      |                   ^~~~~~~~~~~~
kernel/sched/fair.c:6580:20: error: unused function 'cfs_bandwidth_used' [-Werror,-Wunused-function]
 6580 | static inline bool cfs_bandwidth_used(void)
      |                    ^~~~~~~~~~~~~~~~~~

Fix this by marking them with __maybe_unused (all cases for the sake of
symmetry).

See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static
inline functions for W=1 build").

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 kernel/sched/fair.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9057584ec06d..b9d35675db50 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -523,7 +523,7 @@ void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec);
  * Scheduling class tree data structure manipulation methods:
  */
 
-static inline u64 max_vruntime(u64 max_vruntime, u64 vruntime)
+static inline __maybe_unused u64 max_vruntime(u64 max_vruntime, u64 vruntime)
 {
 	s64 delta = (s64)(vruntime - max_vruntime);
 	if (delta > 0)
@@ -532,7 +532,7 @@ static inline u64 max_vruntime(u64 max_vruntime, u64 vruntime)
 	return max_vruntime;
 }
 
-static inline u64 min_vruntime(u64 min_vruntime, u64 vruntime)
+static inline __maybe_unused u64 min_vruntime(u64 min_vruntime, u64 vruntime)
 {
 	s64 delta = (s64)(vruntime - min_vruntime);
 	if (delta < 0)
@@ -5547,7 +5547,7 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued)
 #ifdef CONFIG_JUMP_LABEL
 static struct static_key __cfs_bandwidth_used;
 
-static inline bool cfs_bandwidth_used(void)
+static inline __maybe_unused bool cfs_bandwidth_used(void)
 {
 	return static_key_false(&__cfs_bandwidth_used);
 }
@@ -5562,7 +5562,7 @@ void cfs_bandwidth_usage_dec(void)
 	static_key_slow_dec_cpuslocked(&__cfs_bandwidth_used);
 }
 #else /* CONFIG_JUMP_LABEL */
-static bool cfs_bandwidth_used(void)
+static inline __maybe_unused bool cfs_bandwidth_used(void)
 {
 	return true;
 }
@@ -6577,7 +6577,7 @@ static void sched_fair_update_stop_tick(struct rq *rq, struct task_struct *p)
 
 #else /* CONFIG_CFS_BANDWIDTH */
 
-static inline bool cfs_bandwidth_used(void)
+static inline __maybe_unused bool cfs_bandwidth_used(void)
 {
 	return false;
 }
-- 
2.43.0.rc1.1336.g36b5255a03ac


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

* Re: [PATCH v1 1/1] sched/fair: Mark cfs_bandwidth_used() and m*_vruntime() with __maybe_unused
  2024-09-05 17:12 [PATCH v1 1/1] sched/fair: Mark cfs_bandwidth_used() and m*_vruntime() with __maybe_unused Andy Shevchenko
@ 2024-11-08  9:30 ` Andy Shevchenko
  2024-11-12 11:48 ` Valentin Schneider
  1 sibling, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-11-08  9:30 UTC (permalink / raw)
  To: Ingo Molnar, linux-kernel, llvm
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt

On Thu, Sep 05, 2024 at 08:12:10PM +0300, Andy Shevchenko wrote:
> When cfs_bandwidth_used() is unused, it prevents kernel builds
> with clang, `make W=1` and CONFIG_WERROR=y:
> 
> kernel/sched/fair.c:526:19: error: unused function 'max_vruntime' [-Werror,-Wunused-function]
>   526 | static inline u64 max_vruntime(u64 max_vruntime, u64 vruntime)
>       |                   ^~~~~~~~~~~~
> kernel/sched/fair.c:6580:20: error: unused function 'cfs_bandwidth_used' [-Werror,-Wunused-function]
>  6580 | static inline bool cfs_bandwidth_used(void)
>       |                    ^~~~~~~~~~~~~~~~~~
> 
> Fix this by marking them with __maybe_unused (all cases for the sake of
> symmetry).
> 
> See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static
> inline functions for W=1 build").

Any comments on this? Can it be eventually applied, please?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/1] sched/fair: Mark cfs_bandwidth_used() and m*_vruntime() with __maybe_unused
  2024-09-05 17:12 [PATCH v1 1/1] sched/fair: Mark cfs_bandwidth_used() and m*_vruntime() with __maybe_unused Andy Shevchenko
  2024-11-08  9:30 ` Andy Shevchenko
@ 2024-11-12 11:48 ` Valentin Schneider
  2024-11-12 15:18   ` Andy Shevchenko
  1 sibling, 1 reply; 5+ messages in thread
From: Valentin Schneider @ 2024-11-12 11:48 UTC (permalink / raw)
  To: Andy Shevchenko, Ingo Molnar, linux-kernel, llvm
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Andy Shevchenko

On 05/09/24 20:12, Andy Shevchenko wrote:
> When cfs_bandwidth_used() is unused, it prevents kernel builds
> with clang, `make W=1` and CONFIG_WERROR=y:
>
> kernel/sched/fair.c:526:19: error: unused function 'max_vruntime' [-Werror,-Wunused-function]
>   526 | static inline u64 max_vruntime(u64 max_vruntime, u64 vruntime)
>       |                   ^~~~~~~~~~~~
> kernel/sched/fair.c:6580:20: error: unused function 'cfs_bandwidth_used' [-Werror,-Wunused-function]
>  6580 | static inline bool cfs_bandwidth_used(void)
>       |                    ^~~~~~~~~~~~~~~~~~
>
> Fix this by marking them with __maybe_unused (all cases for the sake of
> symmetry).
>

I assume that's with CONFIG_CFS_BANDWIDTH=n? Looks like
cfs_bandwidth_used() uses are tucked away under helpers that themselves
only really do something for CONFIG_CFS_BANDWIDTH=y, so you could remove
the CONFIG_CFS_BANDWIDTH=n definition of cfs_bandwidth_used() directly.

This compiles:
---
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2d16c8545c71e..57abb4ae8af39 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5373,8 +5373,6 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
 static void check_enqueue_throttle(struct cfs_rq *cfs_rq);
 static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq);
 
-static inline bool cfs_bandwidth_used(void);
-
 static void
 requeue_delayed_entity(struct sched_entity *se);
 
@@ -6754,11 +6752,6 @@ static void sched_fair_update_stop_tick(struct rq *rq, struct task_struct *p)
 
 #else /* CONFIG_CFS_BANDWIDTH */
 
-static inline bool cfs_bandwidth_used(void)
-{
-	return false;
-}
-
 static void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec) {}
 static bool check_cfs_rq_runtime(struct cfs_rq *cfs_rq) { return false; }
 static void check_enqueue_throttle(struct cfs_rq *cfs_rq) {}


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

* Re: [PATCH v1 1/1] sched/fair: Mark cfs_bandwidth_used() and m*_vruntime() with __maybe_unused
  2024-11-12 11:48 ` Valentin Schneider
@ 2024-11-12 15:18   ` Andy Shevchenko
  2024-11-12 19:36     ` Valentin Schneider
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2024-11-12 15:18 UTC (permalink / raw)
  To: Valentin Schneider
  Cc: Ingo Molnar, linux-kernel, llvm, Ingo Molnar, Peter Zijlstra,
	Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
	Ben Segall, Mel Gorman, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt

On Tue, Nov 12, 2024 at 12:48:42PM +0100, Valentin Schneider wrote:
> On 05/09/24 20:12, Andy Shevchenko wrote:
> > When cfs_bandwidth_used() is unused, it prevents kernel builds
> > with clang, `make W=1` and CONFIG_WERROR=y:
> >
> > kernel/sched/fair.c:526:19: error: unused function 'max_vruntime' [-Werror,-Wunused-function]
> >   526 | static inline u64 max_vruntime(u64 max_vruntime, u64 vruntime)
> >       |                   ^~~~~~~~~~~~
> > kernel/sched/fair.c:6580:20: error: unused function 'cfs_bandwidth_used' [-Werror,-Wunused-function]
> >  6580 | static inline bool cfs_bandwidth_used(void)
> >       |                    ^~~~~~~~~~~~~~~~~~
> >
> > Fix this by marking them with __maybe_unused (all cases for the sake of
> > symmetry).
> >
> 
> I assume that's with CONFIG_CFS_BANDWIDTH=n? Looks like
> cfs_bandwidth_used() uses are tucked away under helpers that themselves
> only really do something for CONFIG_CFS_BANDWIDTH=y, so you could remove
> the CONFIG_CFS_BANDWIDTH=n definition of cfs_bandwidth_used() directly.

Thanks for looking into this!

> This compiles:

okay, consider then my patch as a report. Can you submit your version as you
seems much more familiar with this code than me?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/1] sched/fair: Mark cfs_bandwidth_used() and m*_vruntime() with __maybe_unused
  2024-11-12 15:18   ` Andy Shevchenko
@ 2024-11-12 19:36     ` Valentin Schneider
  0 siblings, 0 replies; 5+ messages in thread
From: Valentin Schneider @ 2024-11-12 19:36 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Ingo Molnar, linux-kernel, llvm, Ingo Molnar, Peter Zijlstra,
	Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
	Ben Segall, Mel Gorman, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt

On 12/11/24 17:18, Andy Shevchenko wrote:
> On Tue, Nov 12, 2024 at 12:48:42PM +0100, Valentin Schneider wrote:
>> On 05/09/24 20:12, Andy Shevchenko wrote:
>> > When cfs_bandwidth_used() is unused, it prevents kernel builds
>> > with clang, `make W=1` and CONFIG_WERROR=y:
>> >
>> > kernel/sched/fair.c:526:19: error: unused function 'max_vruntime' [-Werror,-Wunused-function]
>> >   526 | static inline u64 max_vruntime(u64 max_vruntime, u64 vruntime)
>> >       |                   ^~~~~~~~~~~~
>> > kernel/sched/fair.c:6580:20: error: unused function 'cfs_bandwidth_used' [-Werror,-Wunused-function]
>> >  6580 | static inline bool cfs_bandwidth_used(void)
>> >       |                    ^~~~~~~~~~~~~~~~~~
>> >
>> > Fix this by marking them with __maybe_unused (all cases for the sake of
>> > symmetry).
>> >
>> 
>> I assume that's with CONFIG_CFS_BANDWIDTH=n? Looks like
>> cfs_bandwidth_used() uses are tucked away under helpers that themselves
>> only really do something for CONFIG_CFS_BANDWIDTH=y, so you could remove
>> the CONFIG_CFS_BANDWIDTH=n definition of cfs_bandwidth_used() directly.
>
> Thanks for looking into this!
>
>> This compiles:
>
> okay, consider then my patch as a report. Can you submit your version as you
> seems much more familiar with this code than me?

Sure, I'll add this to my todolist.


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

end of thread, other threads:[~2024-11-12 19:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-05 17:12 [PATCH v1 1/1] sched/fair: Mark cfs_bandwidth_used() and m*_vruntime() with __maybe_unused Andy Shevchenko
2024-11-08  9:30 ` Andy Shevchenko
2024-11-12 11:48 ` Valentin Schneider
2024-11-12 15:18   ` Andy Shevchenko
2024-11-12 19:36     ` Valentin Schneider

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox