lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 10 Nov 2023 16:47:33 -1000
From:   Tejun Heo <>
Cc:,,, Tejun Heo <>,
        kernel test robot <>
Subject: [PATCH 07/36] sched: Expose css_tg() and __setscheduler_prio()

These will be used by a new BPF extensible sched_class.

css_tg() will be used in the init and exit paths to visit all task_groups by
walking cgroups.

__setscheduler_prio() is used to pick the sched_class matching the current
prio of the task. For the new BPF extensible sched_class, the mapping from
the task configuration to sched_class isn't static and depends on a few
factors - e.g. whether the BPF progs implementing the scheduler are loaded
and in a serviceable state. That mapping logic will be added to

When the BPF scheduler progs get loaded and unloaded, the mapping changes
and the new sched_class will walk the tasks applying the new mapping using

v3: Dropped SCHED_CHANGE_BLOCK() as upstream is adding more generic cleanup

v2: Expose SCHED_CHANGE_BLOCK() too and update the description.

Signed-off-by: Tejun Heo <>
Reviewed-by: David Vernet <>
Acked-by: Josh Don <>
Acked-by: Hao Luo <>
Acked-by: Barret Rhoden <>
Reported-by: kernel test robot <>
 kernel/sched/core.c  | 7 +------
 kernel/sched/sched.h | 7 +++++++
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 05131ad4b5d5..ce646cdd87dc 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7038,7 +7038,7 @@ int default_wake_function(wait_queue_entry_t *curr, unsigned mode, int wake_flag
-static void __setscheduler_prio(struct task_struct *p, int prio)
+void __setscheduler_prio(struct task_struct *p, int prio)
 	if (dl_prio(prio))
 		p->sched_class = &dl_sched_class;
@@ -10496,11 +10496,6 @@ void sched_move_task(struct task_struct *tsk)
-static inline struct task_group *css_tg(struct cgroup_subsys_state *css)
-	return css ? container_of(css, struct task_group, css) : NULL;
 static struct cgroup_subsys_state *
 cpu_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index a6d073a56c2d..97f6e8a28387 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -452,6 +452,11 @@ static inline int walk_tg_tree(tg_visitor down, tg_visitor up, void *data)
 	return walk_tg_tree_from(&root_task_group, down, up, data);
+static inline struct task_group *css_tg(struct cgroup_subsys_state *css)
+	return css ? container_of(css, struct task_group, css) : NULL;
 extern int tg_nop(struct task_group *tg, void *data);
 extern void free_fair_sched_group(struct task_group *tg);
@@ -2437,6 +2442,8 @@ extern void init_sched_dl_class(void);
 extern void init_sched_rt_class(void);
 extern void init_sched_fair_class(void);
+extern void __setscheduler_prio(struct task_struct *p, int prio);
 extern void resched_curr(struct rq *rq);
 extern void resched_cpu(int cpu);

Powered by blists - more mailing lists