
From: Tengda Wu <wutengda2@huawei.com> hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICAOAT -------------------------------- The kernel test robot reported a compilation warning regarding sched_task_is_throttled: /root/repository/olk-6.6/kernel/sched/core.c:158:5: warning: no previous prototype for function 'sched_task_is_throttled' [-Wmissing-prototypes] 158 | int sched_task_is_throttled(struct task_struct *p, int cpu) | ^ /root/repository/olk-6.6/kernel/sched/core.c:158:1: note: declare 'static' if the function is not intended to be used outside of this translation unit 158 | int sched_task_is_throttled(struct task_struct *p, int cpu) | ^ | static This was caused by the incorrect definition of sched_task_is_throttled under the CONFIG_CGROUP_SCHED option. When CONFIG_CGROUP_SCHED=n, regardless of whether CONFIG_SCHED_CORE or CONFIG_CGROUP_IFS is enabled, sched_task_is_throttled will not be declared, leading to the warning. Fix this by moving the declaration of sched_task_is_throttled outside the CONFIG_CGROUP_SCHED option block. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202505301346.VRD8YS7H-lkp@intel.com/ Signed-off-by: Tengda Wu <wutengda2@huawei.com> Signed-off-by: Pu Lehui <pulehui@huawei.com> --- kernel/sched/sched.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 6b8aa78272e3..3f514b215bc1 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -560,15 +560,6 @@ extern void sched_release_group(struct task_group *tg); extern void sched_move_task(struct task_struct *tsk); -#if defined(CONFIG_SCHED_CORE) || defined(CONFIG_CGROUP_IFS) -extern int sched_task_is_throttled(struct task_struct *p, int cpu); -#else -static inline int sched_task_is_throttled(struct task_struct *p, int cpu) -{ - return 0; -} -#endif - #ifdef CONFIG_QOS_SCHED_SMART_GRID extern void start_auto_affinity(struct auto_affinity *auto_affi); extern void stop_auto_affinity(struct auto_affinity *auto_affi); @@ -606,6 +597,15 @@ static inline bool cfs_task_bw_constrained(struct task_struct *p) { return false #endif /* CONFIG_CGROUP_SCHED */ +#if defined(CONFIG_SCHED_CORE) || defined(CONFIG_CGROUP_IFS) +extern int sched_task_is_throttled(struct task_struct *p, int cpu); +#else +static inline int sched_task_is_throttled(struct task_struct *p, int cpu) +{ + return 0; +} +#endif + extern void unregister_rt_sched_group(struct task_group *tg); extern void free_rt_sched_group(struct task_group *tg); extern int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent); -- 2.34.1