Re: [PATCH v1 1/1] sched/fair: Mark cfs_bandwidth_used() and m*_vruntime() with __maybe_unused
From: Valentin Schneider
Date: Tue Nov 12 2024 - 06:49:06 EST
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) {}