[PATCH 5/5] sched: fair: move unused stub functions to header

Arnd Bergmann posted 5 patches 2 years, 8 months ago
[PATCH 5/5] sched: fair: move unused stub functions to header
Posted by Arnd Bergmann 2 years, 8 months ago
From: Arnd Bergmann <arnd@arndb.de>

These four functions have a normal definition for CONFIG_FAIR_GROUP_SCHED,
and empty one that is only referenced when FAIR_GROUP_SCHED is disabled
but CGROUP_SCHED is still enabled. If both are turned off, the functions
are still defined but the misisng prototype causes a W=1 warning:

kernel/sched/fair.c:12544:6: error: no previous prototype for 'free_fair_sched_group'
kernel/sched/fair.c:12546:5: error: no previous prototype for 'alloc_fair_sched_group'
kernel/sched/fair.c:12553:6: error: no previous prototype for 'online_fair_sched_group'
kernel/sched/fair.c:12555:6: error: no previous prototype for 'unregister_fair_sched_group'

Move the alternatives into the header as static inline functions with
the correct combination of #ifdef checks to avoid the warning without
adding even more complexity.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/sched/fair.c  | 13 -------------
 kernel/sched/sched.h | 11 +++++++++++
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a7a8ccde3bd7..bae8907c1635 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -12602,19 +12602,6 @@ int sched_group_set_idle(struct task_group *tg, long idle)
 	return 0;
 }
 
-#else /* CONFIG_FAIR_GROUP_SCHED */
-
-void free_fair_sched_group(struct task_group *tg) { }
-
-int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
-{
-	return 1;
-}
-
-void online_fair_sched_group(struct task_group *tg) { }
-
-void unregister_fair_sched_group(struct task_group *tg) { }
-
 #endif /* CONFIG_FAIR_GROUP_SCHED */
 
 
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index d5ac0af1eede..0584fa15ffeb 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -453,10 +453,21 @@ static inline int walk_tg_tree(tg_visitor down, tg_visitor up, void *data)
 
 extern int tg_nop(struct task_group *tg, void *data);
 
+#ifdef CONFIG_FAIR_GROUP_SCHED
 extern void free_fair_sched_group(struct task_group *tg);
 extern int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent);
 extern void online_fair_sched_group(struct task_group *tg);
 extern void unregister_fair_sched_group(struct task_group *tg);
+#else
+static inline void free_fair_sched_group(struct task_group *tg) { }
+static inline int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
+{
+       return 1;
+}
+static inline void online_fair_sched_group(struct task_group *tg) { }
+static inline void unregister_fair_sched_group(struct task_group *tg) { }
+#endif
+
 extern void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
 			struct sched_entity *se, int cpu,
 			struct sched_entity *parent);
-- 
2.39.2
Re: [PATCH 5/5] sched: fair: move unused stub functions to header
Posted by Mukesh Ojha 2 years, 8 months ago

On 5/23/2023 1:20 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> These four functions have a normal definition for CONFIG_FAIR_GROUP_SCHED,
> and empty one that is only referenced when FAIR_GROUP_SCHED is disabled
> but CGROUP_SCHED is still enabled. If both are turned off, the functions
> are still defined but the misisng prototype causes a W=1 warning:

missing ?

> 
> kernel/sched/fair.c:12544:6: error: no previous prototype for 'free_fair_sched_group'
> kernel/sched/fair.c:12546:5: error: no previous prototype for 'alloc_fair_sched_group'
> kernel/sched/fair.c:12553:6: error: no previous prototype for 'online_fair_sched_group'
> kernel/sched/fair.c:12555:6: error: no previous prototype for 'unregister_fair_sched_group'
> 
> Move the alternatives into the header as static inline functions with
> the correct combination of #ifdef checks to avoid the warning without
> adding even more complexity.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

LGTM.

Reviewed-by: Mukesh Ojha <quic_mojha@quicinc.com>

-- Mukesh

> ---
>   kernel/sched/fair.c  | 13 -------------
>   kernel/sched/sched.h | 11 +++++++++++
>   2 files changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index a7a8ccde3bd7..bae8907c1635 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -12602,19 +12602,6 @@ int sched_group_set_idle(struct task_group *tg, long idle)
>   	return 0;
>   }
>   
> -#else /* CONFIG_FAIR_GROUP_SCHED */
> -
> -void free_fair_sched_group(struct task_group *tg) { }
> -
> -int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
> -{
> -	return 1;
> -}
> -
> -void online_fair_sched_group(struct task_group *tg) { }
> -
> -void unregister_fair_sched_group(struct task_group *tg) { }
> -
>   #endif /* CONFIG_FAIR_GROUP_SCHED */
>   
>   
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index d5ac0af1eede..0584fa15ffeb 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -453,10 +453,21 @@ static inline int walk_tg_tree(tg_visitor down, tg_visitor up, void *data)
>   
>   extern int tg_nop(struct task_group *tg, void *data);
>   
> +#ifdef CONFIG_FAIR_GROUP_SCHED
>   extern void free_fair_sched_group(struct task_group *tg);
>   extern int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent);
>   extern void online_fair_sched_group(struct task_group *tg);
>   extern void unregister_fair_sched_group(struct task_group *tg);
> +#else
> +static inline void free_fair_sched_group(struct task_group *tg) { }
> +static inline int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
> +{
> +       return 1;
> +}
> +static inline void online_fair_sched_group(struct task_group *tg) { }
> +static inline void unregister_fair_sched_group(struct task_group *tg) { }
> +#endif
> +
>   extern void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
>   			struct sched_entity *se, int cpu,
>   			struct sched_entity *parent);
[tip: sched/core] sched/fair: Move unused stub functions to header
Posted by tip-bot2 for Arnd Bergmann 2 years, 8 months ago
The following commit has been merged into the sched/core branch of tip:

Commit-ID:     7aa55f2a5902646a19db89dab9961867724b27b8
Gitweb:        https://git.kernel.org/tip/7aa55f2a5902646a19db89dab9961867724b27b8
Author:        Arnd Bergmann <arnd@arndb.de>
AuthorDate:    Mon, 22 May 2023 21:50:21 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 30 May 2023 22:46:26 +02:00

sched/fair: Move unused stub functions to header

These four functions have a normal definition for CONFIG_FAIR_GROUP_SCHED,
and empty one that is only referenced when FAIR_GROUP_SCHED is disabled
but CGROUP_SCHED is still enabled. If both are turned off, the functions
are still defined but the misisng prototype causes a W=1 warning:

kernel/sched/fair.c:12544:6: error: no previous prototype for 'free_fair_sched_group'
kernel/sched/fair.c:12546:5: error: no previous prototype for 'alloc_fair_sched_group'
kernel/sched/fair.c:12553:6: error: no previous prototype for 'online_fair_sched_group'
kernel/sched/fair.c:12555:6: error: no previous prototype for 'unregister_fair_sched_group'

Move the alternatives into the header as static inline functions with
the correct combination of #ifdef checks to avoid the warning without
adding even more complexity.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://lore.kernel.org/r/20230522195021.3456768-6-arnd@kernel.org
---
 kernel/sched/fair.c  | 6 +++---
 kernel/sched/sched.h | 2 --
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a7a8ccd..48b6f0c 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -684,7 +684,7 @@ struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)
 /**************************************************************
  * Scheduling class statistics methods:
  */
-#ifdef CONFIG_SMP
+
 int sched_update_scaling(void)
 {
 	unsigned int factor = get_update_sysctl_factor();
@@ -702,7 +702,6 @@ int sched_update_scaling(void)
 	return 0;
 }
 #endif
-#endif
 
 /*
  * delta /= w
@@ -6169,8 +6168,9 @@ static inline int throttled_lb_pair(struct task_group *tg,
 	return 0;
 }
 
-#ifdef CONFIG_FAIR_GROUP_SCHED
 void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b) {}
+
+#ifdef CONFIG_FAIR_GROUP_SCHED
 static void init_cfs_rq_runtime(struct cfs_rq *cfs_rq) {}
 #endif
 
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index ce07782..6784462 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1245,7 +1245,6 @@ static inline raw_spinlock_t *__rq_lockp(struct rq *rq)
 
 bool cfs_prio_less(const struct task_struct *a, const struct task_struct *b,
 			bool fi);
-void task_vruntime_update(struct rq *rq, struct task_struct *p, bool in_fi);
 
 /*
  * Helpers to check if the CPU's core cookie matches with the task's cookie
@@ -2377,7 +2376,6 @@ static inline struct cpuidle_state *idle_get_state(struct rq *rq)
 #endif
 
 extern void schedule_idle(void);
-asmlinkage void schedule_user(void);
 
 extern void sysrq_sched_debug_show(void);
 extern void sched_init_granularity(void);