2023-05-22 20:15:56

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 0/5] sched: address missing-prototype warnings

From: Arnd Bergmann <[email protected]>

I sent out a lot of -Wmissing-prototype warnings already, but noticed that
I missed some of the patches I did for the scheduler.

Addressing this is mainly useful in order to allow turning the
warning on by default in the future, but I also tried to
improe the code where possible.

Arnd Bergmann (5):
sched: hide unused sched_update_scaling()
sched: add schedule_user() declaration
sched: fair: hide unused init_cfs_bandwidth() stub
sched: make task_vruntime_update() prototype visible
sched: fair: move unused stub functions to header

kernel/sched/core.c | 2 --
kernel/sched/fair.c | 19 +++----------------
kernel/sched/sched.h | 13 +++++++++++++
3 files changed, 16 insertions(+), 18 deletions(-)

--
2.39.2

Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Juri Lelli <[email protected]>
Cc: Vincent Guittot <[email protected]>
Cc: Dietmar Eggemann <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Ben Segall <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Daniel Bristot de Oliveira <[email protected]>
Cc: Valentin Schneider <[email protected]>
Cc: [email protected]



2023-05-22 20:16:51

by Arnd Bergmann

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

From: Arnd Bergmann <[email protected]>

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 <[email protected]>
---
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


2023-05-22 20:17:05

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 2/5] sched: add schedule_user() declaration

From: Arnd Bergmann <[email protected]>

The schedule_user() function is used on powerpc and sparc architectures, but
only ever called from assembler, so it has no prototype, causing a harmless W=1
warning:

kernel/sched/core.c:6730:35: error: no previous prototype for 'schedule_user' [-Werror=missing-prototypes]

Add a prototype in sched/sched.h to shut up the warning.

Signed-off-by: Arnd Bergmann <[email protected]>
---
kernel/sched/sched.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 1704763897d0..44b34836bb60 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -2376,6 +2376,7 @@ 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);
--
2.39.2


2023-05-22 20:17:25

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 3/5] sched: fair: hide unused init_cfs_bandwidth() stub

From: Arnd Bergmann <[email protected]>

init_cfs_bandwidth() is only used when CONFIG_FAIR_GROUP_SCHED is
enabled, and without this causes a W=1 warning for the missing prototype:

kernel/sched/fair.c:6131:6: error: no previous prototype for 'init_cfs_bandwidth'

The normal implementation is only defined for CONFIG_CFS_BANDWIDTH,
so the stub exists when CFS_BANDWIDTH is disabled but FAIR_GROUP_SCHED
is enabled.

Signed-off-by: Arnd Bergmann <[email protected]>
---
kernel/sched/fair.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2c1b345c3b8d..a7a8ccde3bd7 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6169,9 +6169,8 @@ static inline int throttled_lb_pair(struct task_group *tg,
return 0;
}

-void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b) {}
-
#ifdef CONFIG_FAIR_GROUP_SCHED
+void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b) {}
static void init_cfs_rq_runtime(struct cfs_rq *cfs_rq) {}
#endif

--
2.39.2


2023-05-22 20:18:28

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH 0/5] sched: address missing-prototype warnings

On Mon, May 22, 2023 at 09:50:16PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
>
> I sent out a lot of -Wmissing-prototype warnings already, but noticed that
> I missed some of the patches I did for the scheduler.
>
> Addressing this is mainly useful in order to allow turning the
> warning on by default in the future, but I also tried to
> improe the code where possible.
>
> Arnd Bergmann (5):
> sched: hide unused sched_update_scaling()
> sched: add schedule_user() declaration
> sched: fair: hide unused init_cfs_bandwidth() stub
> sched: make task_vruntime_update() prototype visible
> sched: fair: move unused stub functions to header
>

Thanks!

2023-05-23 07:01:37

by Vincent Guittot

[permalink] [raw]
Subject: Re: [PATCH 0/5] sched: address missing-prototype warnings

On Mon, 22 May 2023 at 21:50, Arnd Bergmann <[email protected]> wrote:
>
> From: Arnd Bergmann <[email protected]>
>
> I sent out a lot of -Wmissing-prototype warnings already, but noticed that
> I missed some of the patches I did for the scheduler.
>
> Addressing this is mainly useful in order to allow turning the
> warning on by default in the future, but I also tried to
> improe the code where possible.
>
> Arnd Bergmann (5):
> sched: hide unused sched_update_scaling()
> sched: add schedule_user() declaration
> sched: fair: hide unused init_cfs_bandwidth() stub
> sched: make task_vruntime_update() prototype visible
> sched: fair: move unused stub functions to header

For the whole serie

Reviewed-by: Vincent Guittot <[email protected]>

>
> kernel/sched/core.c | 2 --
> kernel/sched/fair.c | 19 +++----------------
> kernel/sched/sched.h | 13 +++++++++++++
> 3 files changed, 16 insertions(+), 18 deletions(-)
>
> --
> 2.39.2
>
> Cc: Ingo Molnar <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Juri Lelli <[email protected]>
> Cc: Vincent Guittot <[email protected]>
> Cc: Dietmar Eggemann <[email protected]>
> Cc: Steven Rostedt <[email protected]>
> Cc: Ben Segall <[email protected]>
> Cc: Mel Gorman <[email protected]>
> Cc: Daniel Bristot de Oliveira <[email protected]>
> Cc: Valentin Schneider <[email protected]>
> Cc: [email protected]
>

2023-05-23 07:15:57

by Mukesh Ojha

[permalink] [raw]
Subject: Re: [PATCH 5/5] sched: fair: move unused stub functions to header



On 5/23/2023 1:20 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
>
> 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 <[email protected]>

LGTM.

Reviewed-by: Mukesh Ojha <[email protected]>

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

2023-05-23 07:31:22

by Mukesh Ojha

[permalink] [raw]
Subject: Re: [PATCH 3/5] sched: fair: hide unused init_cfs_bandwidth() stub



On 5/23/2023 1:20 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
>
> init_cfs_bandwidth() is only used when CONFIG_FAIR_GROUP_SCHED is
> enabled, and without this causes a W=1 warning for the missing prototype:
>
> kernel/sched/fair.c:6131:6: error: no previous prototype for 'init_cfs_bandwidth'
>
> The normal implementation is only defined for CONFIG_CFS_BANDWIDTH,
> so the stub exists when CFS_BANDWIDTH is disabled but FAIR_GROUP_SCHED
> is enabled.
>
> Signed-off-by: Arnd Bergmann <[email protected]>


Reviewed-by: Mukesh Ojha <[email protected]>

-- Mukesh

> ---
> kernel/sched/fair.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 2c1b345c3b8d..a7a8ccde3bd7 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6169,9 +6169,8 @@ static inline int throttled_lb_pair(struct task_group *tg,
> return 0;
> }
>
> -void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b) {}
> -
> #ifdef CONFIG_FAIR_GROUP_SCHED
> +void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b) {}
> static void init_cfs_rq_runtime(struct cfs_rq *cfs_rq) {}
> #endif
>

Subject: [tip: sched/core] sched/fair: Hide unused init_cfs_bandwidth() stub

The following commit has been merged into the sched/core branch of tip:

Commit-ID: c0bdfd72fbfb7319581bd5bb09b4f10979385bac
Gitweb: https://git.kernel.org/tip/c0bdfd72fbfb7319581bd5bb09b4f10979385bac
Author: Arnd Bergmann <[email protected]>
AuthorDate: Mon, 22 May 2023 21:50:19 +02:00
Committer: Peter Zijlstra <[email protected]>
CommitterDate: Tue, 30 May 2023 22:46:25 +02:00

sched/fair: Hide unused init_cfs_bandwidth() stub

init_cfs_bandwidth() is only used when CONFIG_FAIR_GROUP_SCHED is
enabled, and without this causes a W=1 warning for the missing prototype:

kernel/sched/fair.c:6131:6: error: no previous prototype for 'init_cfs_bandwidth'

The normal implementation is only defined for CONFIG_CFS_BANDWIDTH,
so the stub exists when CFS_BANDWIDTH is disabled but FAIR_GROUP_SCHED
is enabled.

Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Vincent Guittot <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
kernel/sched/fair.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2c1b345..a7a8ccd 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6169,9 +6169,8 @@ static inline int throttled_lb_pair(struct task_group *tg,
return 0;
}

-void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b) {}
-
#ifdef CONFIG_FAIR_GROUP_SCHED
+void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b) {}
static void init_cfs_rq_runtime(struct cfs_rq *cfs_rq) {}
#endif


Subject: [tip: sched/core] sched: Add schedule_user() declaration

The following commit has been merged into the sched/core branch of tip:

Commit-ID: 378be384e01f13fc44d0adc70873de525586ad74
Gitweb: https://git.kernel.org/tip/378be384e01f13fc44d0adc70873de525586ad74
Author: Arnd Bergmann <[email protected]>
AuthorDate: Mon, 22 May 2023 21:50:18 +02:00
Committer: Peter Zijlstra <[email protected]>
CommitterDate: Tue, 30 May 2023 22:46:25 +02:00

sched: Add schedule_user() declaration

The schedule_user() function is used on powerpc and sparc architectures, but
only ever called from assembler, so it has no prototype, causing a harmless W=1
warning:

kernel/sched/core.c:6730:35: error: no previous prototype for 'schedule_user' [-Werror=missing-prototypes]

Add a prototype in sched/sched.h to shut up the warning.

Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Vincent Guittot <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
kernel/sched/sched.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 6784462..192e781 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -2376,6 +2376,7 @@ 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);

Subject: [tip: sched/core] sched/fair: Move unused stub functions to header

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 <[email protected]>
AuthorDate: Mon, 22 May 2023 21:50:21 +02:00
Committer: Peter Zijlstra <[email protected]>
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 <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Vincent Guittot <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
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);