Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.1.
 1/* SPDX-License-Identifier: GPL-2.0 */
 2/*
 3 * BPF extensible scheduler class: Documentation/scheduler/sched-ext.rst
 4 *
 5 * Copyright (c) 2022 Meta Platforms, Inc. and affiliates.
 6 * Copyright (c) 2022 Tejun Heo <tj@kernel.org>
 7 * Copyright (c) 2022 David Vernet <dvernet@meta.com>
 8 */
 9#ifdef CONFIG_SCHED_CLASS_EXT
10
11void scx_tick(struct rq *rq);
12void init_scx_entity(struct sched_ext_entity *scx);
13void scx_pre_fork(struct task_struct *p);
14int scx_fork(struct task_struct *p);
15void scx_post_fork(struct task_struct *p);
16void scx_cancel_fork(struct task_struct *p);
17bool scx_can_stop_tick(struct rq *rq);
18void scx_rq_activate(struct rq *rq);
19void scx_rq_deactivate(struct rq *rq);
20int scx_check_setscheduler(struct task_struct *p, int policy);
21bool task_should_scx(int policy);
22void init_sched_ext_class(void);
23
24static inline u32 scx_cpuperf_target(s32 cpu)
25{
26	if (scx_enabled())
27		return cpu_rq(cpu)->scx.cpuperf_target;
28	else
29		return 0;
30}
31
32static inline bool task_on_scx(const struct task_struct *p)
33{
34	return scx_enabled() && p->sched_class == &ext_sched_class;
35}
36
37#ifdef CONFIG_SCHED_CORE
38bool scx_prio_less(const struct task_struct *a, const struct task_struct *b,
39		   bool in_fi);
40#endif
41
42#else	/* CONFIG_SCHED_CLASS_EXT */
43
44static inline void scx_tick(struct rq *rq) {}
45static inline void scx_pre_fork(struct task_struct *p) {}
46static inline int scx_fork(struct task_struct *p) { return 0; }
47static inline void scx_post_fork(struct task_struct *p) {}
48static inline void scx_cancel_fork(struct task_struct *p) {}
49static inline u32 scx_cpuperf_target(s32 cpu) { return 0; }
50static inline bool scx_can_stop_tick(struct rq *rq) { return true; }
51static inline void scx_rq_activate(struct rq *rq) {}
52static inline void scx_rq_deactivate(struct rq *rq) {}
53static inline int scx_check_setscheduler(struct task_struct *p, int policy) { return 0; }
54static inline bool task_on_scx(const struct task_struct *p) { return false; }
55static inline void init_sched_ext_class(void) {}
56
57#endif	/* CONFIG_SCHED_CLASS_EXT */
58
59#if defined(CONFIG_SCHED_CLASS_EXT) && defined(CONFIG_SMP)
60void __scx_update_idle(struct rq *rq, bool idle, bool do_notify);
61
62static inline void scx_update_idle(struct rq *rq, bool idle, bool do_notify)
63{
64	if (scx_enabled())
65		__scx_update_idle(rq, idle, do_notify);
66}
67#else
68static inline void scx_update_idle(struct rq *rq, bool idle, bool do_notify) {}
69#endif
70
71#ifdef CONFIG_CGROUP_SCHED
72#ifdef CONFIG_EXT_GROUP_SCHED
73int scx_tg_online(struct task_group *tg);
74void scx_tg_offline(struct task_group *tg);
75int scx_cgroup_can_attach(struct cgroup_taskset *tset);
76void scx_cgroup_move_task(struct task_struct *p);
77void scx_cgroup_finish_attach(void);
78void scx_cgroup_cancel_attach(struct cgroup_taskset *tset);
79void scx_group_set_weight(struct task_group *tg, unsigned long cgrp_weight);
80void scx_group_set_idle(struct task_group *tg, bool idle);
81#else	/* CONFIG_EXT_GROUP_SCHED */
82static inline int scx_tg_online(struct task_group *tg) { return 0; }
83static inline void scx_tg_offline(struct task_group *tg) {}
84static inline int scx_cgroup_can_attach(struct cgroup_taskset *tset) { return 0; }
85static inline void scx_cgroup_move_task(struct task_struct *p) {}
86static inline void scx_cgroup_finish_attach(void) {}
87static inline void scx_cgroup_cancel_attach(struct cgroup_taskset *tset) {}
88static inline void scx_group_set_weight(struct task_group *tg, unsigned long cgrp_weight) {}
89static inline void scx_group_set_idle(struct task_group *tg, bool idle) {}
90#endif	/* CONFIG_EXT_GROUP_SCHED */
91#endif	/* CONFIG_CGROUP_SCHED */