2024-06-18 10:09:17 -10:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2024-06-18 10:09:17 -10:00
|
|
|
/*
|
2024-06-18 10:09:21 -10:00
|
|
|
* BPF extensible scheduler class: Documentation/scheduler/sched-ext.rst
|
|
|
|
|
*
|
2024-06-18 10:09:17 -10:00
|
|
|
* Copyright (c) 2022 Meta Platforms, Inc. and affiliates.
|
|
|
|
|
* Copyright (c) 2022 Tejun Heo <tj@kernel.org>
|
|
|
|
|
* Copyright (c) 2022 David Vernet <dvernet@meta.com>
|
|
|
|
|
*/
|
2024-06-18 10:09:17 -10:00
|
|
|
#ifdef CONFIG_SCHED_CLASS_EXT
|
2024-06-18 10:09:17 -10:00
|
|
|
|
2024-06-18 10:09:18 -10:00
|
|
|
void scx_tick(struct rq *rq);
|
2024-06-18 10:09:17 -10:00
|
|
|
void init_scx_entity(struct sched_ext_entity *scx);
|
|
|
|
|
void scx_pre_fork(struct task_struct *p);
|
2026-03-06 07:58:02 -10:00
|
|
|
int scx_fork(struct task_struct *p, struct kernel_clone_args *kargs);
|
2024-06-18 10:09:17 -10:00
|
|
|
void scx_post_fork(struct task_struct *p);
|
|
|
|
|
void scx_cancel_fork(struct task_struct *p);
|
2024-06-18 10:09:19 -10:00
|
|
|
bool scx_can_stop_tick(struct rq *rq);
|
2024-06-18 10:09:20 -10:00
|
|
|
void scx_rq_activate(struct rq *rq);
|
|
|
|
|
void scx_rq_deactivate(struct rq *rq);
|
2024-06-18 10:09:18 -10:00
|
|
|
int scx_check_setscheduler(struct task_struct *p, int policy);
|
2024-10-26 00:20:20 +05:30
|
|
|
bool task_should_scx(int policy);
|
2025-04-09 09:06:00 -10:00
|
|
|
bool scx_allow_ttwu_queue(const struct task_struct *p);
|
2024-06-18 10:09:17 -10:00
|
|
|
void init_sched_ext_class(void);
|
|
|
|
|
|
2024-06-21 12:37:22 -10:00
|
|
|
static inline u32 scx_cpuperf_target(s32 cpu)
|
|
|
|
|
{
|
|
|
|
|
if (scx_enabled())
|
|
|
|
|
return cpu_rq(cpu)->scx.cpuperf_target;
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-08 09:39:48 -10:00
|
|
|
static inline bool task_on_scx(const struct task_struct *p)
|
|
|
|
|
{
|
|
|
|
|
return scx_enabled() && p->sched_class == &ext_sched_class;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-18 10:09:20 -10:00
|
|
|
#ifdef CONFIG_SCHED_CORE
|
|
|
|
|
bool scx_prio_less(const struct task_struct *a, const struct task_struct *b,
|
|
|
|
|
bool in_fi);
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-06-18 10:09:17 -10:00
|
|
|
#else /* CONFIG_SCHED_CLASS_EXT */
|
|
|
|
|
|
2024-06-18 10:09:18 -10:00
|
|
|
static inline void scx_tick(struct rq *rq) {}
|
2024-06-18 10:09:17 -10:00
|
|
|
static inline void scx_pre_fork(struct task_struct *p) {}
|
2026-03-06 07:58:02 -10:00
|
|
|
static inline int scx_fork(struct task_struct *p, struct kernel_clone_args *kargs) { return 0; }
|
2024-06-18 10:09:17 -10:00
|
|
|
static inline void scx_post_fork(struct task_struct *p) {}
|
|
|
|
|
static inline void scx_cancel_fork(struct task_struct *p) {}
|
2024-06-21 12:37:22 -10:00
|
|
|
static inline u32 scx_cpuperf_target(s32 cpu) { return 0; }
|
2024-06-18 10:09:19 -10:00
|
|
|
static inline bool scx_can_stop_tick(struct rq *rq) { return true; }
|
2024-06-18 10:09:20 -10:00
|
|
|
static inline void scx_rq_activate(struct rq *rq) {}
|
|
|
|
|
static inline void scx_rq_deactivate(struct rq *rq) {}
|
2024-06-18 10:09:18 -10:00
|
|
|
static inline int scx_check_setscheduler(struct task_struct *p, int policy) { return 0; }
|
2024-06-18 10:09:17 -10:00
|
|
|
static inline bool task_on_scx(const struct task_struct *p) { return false; }
|
2025-02-12 13:08:31 -10:00
|
|
|
static inline bool scx_allow_ttwu_queue(const struct task_struct *p) { return true; }
|
2024-06-18 10:09:17 -10:00
|
|
|
static inline void init_sched_ext_class(void) {}
|
|
|
|
|
|
|
|
|
|
#endif /* CONFIG_SCHED_CLASS_EXT */
|
|
|
|
|
|
2025-06-11 21:54:02 +08:00
|
|
|
#ifdef CONFIG_SCHED_CLASS_EXT
|
2025-01-10 23:16:31 +01:00
|
|
|
void __scx_update_idle(struct rq *rq, bool idle, bool do_notify);
|
2024-06-18 10:09:17 -10:00
|
|
|
|
2025-01-10 23:16:31 +01:00
|
|
|
static inline void scx_update_idle(struct rq *rq, bool idle, bool do_notify)
|
2024-06-18 10:09:17 -10:00
|
|
|
{
|
|
|
|
|
if (scx_enabled())
|
2025-01-10 23:16:31 +01:00
|
|
|
__scx_update_idle(rq, idle, do_notify);
|
2024-06-18 10:09:17 -10:00
|
|
|
}
|
2024-06-18 10:09:17 -10:00
|
|
|
#else
|
2025-01-10 23:16:31 +01:00
|
|
|
static inline void scx_update_idle(struct rq *rq, bool idle, bool do_notify) {}
|
2024-06-18 10:09:17 -10:00
|
|
|
#endif
|
2024-09-04 10:24:59 -10:00
|
|
|
|
|
|
|
|
#ifdef CONFIG_CGROUP_SCHED
|
|
|
|
|
#ifdef CONFIG_EXT_GROUP_SCHED
|
2025-06-16 10:13:25 -10:00
|
|
|
void scx_tg_init(struct task_group *tg);
|
2024-09-04 10:24:59 -10:00
|
|
|
int scx_tg_online(struct task_group *tg);
|
|
|
|
|
void scx_tg_offline(struct task_group *tg);
|
|
|
|
|
int scx_cgroup_can_attach(struct cgroup_taskset *tset);
|
2025-01-24 12:22:12 -10:00
|
|
|
void scx_cgroup_move_task(struct task_struct *p);
|
2024-09-04 10:24:59 -10:00
|
|
|
void scx_cgroup_cancel_attach(struct cgroup_taskset *tset);
|
|
|
|
|
void scx_group_set_weight(struct task_group *tg, unsigned long cgrp_weight);
|
|
|
|
|
void scx_group_set_idle(struct task_group *tg, bool idle);
|
2025-06-13 15:34:22 -10:00
|
|
|
void scx_group_set_bandwidth(struct task_group *tg, u64 period_us, u64 quota_us, u64 burst_us);
|
2024-09-04 10:24:59 -10:00
|
|
|
#else /* CONFIG_EXT_GROUP_SCHED */
|
2025-06-16 10:13:25 -10:00
|
|
|
static inline void scx_tg_init(struct task_group *tg) {}
|
2024-09-04 10:24:59 -10:00
|
|
|
static inline int scx_tg_online(struct task_group *tg) { return 0; }
|
|
|
|
|
static inline void scx_tg_offline(struct task_group *tg) {}
|
|
|
|
|
static inline int scx_cgroup_can_attach(struct cgroup_taskset *tset) { return 0; }
|
2025-01-24 12:22:12 -10:00
|
|
|
static inline void scx_cgroup_move_task(struct task_struct *p) {}
|
2024-09-04 10:24:59 -10:00
|
|
|
static inline void scx_cgroup_cancel_attach(struct cgroup_taskset *tset) {}
|
|
|
|
|
static inline void scx_group_set_weight(struct task_group *tg, unsigned long cgrp_weight) {}
|
|
|
|
|
static inline void scx_group_set_idle(struct task_group *tg, bool idle) {}
|
2025-06-13 15:34:22 -10:00
|
|
|
static inline void scx_group_set_bandwidth(struct task_group *tg, u64 period_us, u64 quota_us, u64 burst_us) {}
|
2024-09-04 10:24:59 -10:00
|
|
|
#endif /* CONFIG_EXT_GROUP_SCHED */
|
|
|
|
|
#endif /* CONFIG_CGROUP_SCHED */
|