Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched: Add sched_class->reweight_task()

Currently, during a task weight change, sched core directly calls
reweight_task() defined in fair.c if @p is on CFS. Let's make it a proper
sched_class operation instead. CFS's reweight_task() is renamed to
reweight_task_fair() and now called through sched_class.

While it turns a direct call into an indirect one, set_load_weight() isn't
called from a hot path and this change shouldn't cause any noticeable
difference. This will be used to implement reweight_task for a new BPF
extensible sched_class so that it can keep its cached task weight
up-to-date.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: David Vernet <dvernet@meta.com>
Acked-by: Josh Don <joshdon@google.com>
Acked-by: Hao Luo <haoluo@google.com>
Acked-by: Barret Rhoden <brho@google.com>

+6 -5
+2 -2
kernel/sched/core.c
··· 1343 1343 * SCHED_OTHER tasks have to update their load when changing their 1344 1344 * weight 1345 1345 */ 1346 - if (update_load && p->sched_class == &fair_sched_class) { 1347 - reweight_task(p, prio); 1346 + if (update_load && p->sched_class->reweight_task) { 1347 + p->sched_class->reweight_task(task_rq(p), p, prio); 1348 1348 } else { 1349 1349 load->weight = scale_load(sched_prio_to_weight[prio]); 1350 1350 load->inv_weight = sched_prio_to_wmult[prio];
+2 -1
kernel/sched/fair.c
··· 3835 3835 } 3836 3836 } 3837 3837 3838 - void reweight_task(struct task_struct *p, int prio) 3838 + static void reweight_task_fair(struct rq *rq, struct task_struct *p, int prio) 3839 3839 { 3840 3840 struct sched_entity *se = &p->se; 3841 3841 struct cfs_rq *cfs_rq = cfs_rq_of(se); ··· 13221 13221 .task_tick = task_tick_fair, 13222 13222 .task_fork = task_fork_fair, 13223 13223 13224 + .reweight_task = reweight_task_fair, 13224 13225 .prio_changed = prio_changed_fair, 13225 13226 .switched_from = switched_from_fair, 13226 13227 .switched_to = switched_to_fair,
+2 -2
kernel/sched/sched.h
··· 2324 2324 */ 2325 2325 void (*switched_from)(struct rq *this_rq, struct task_struct *task); 2326 2326 void (*switched_to) (struct rq *this_rq, struct task_struct *task); 2327 + void (*reweight_task)(struct rq *this_rq, struct task_struct *task, 2328 + int newprio); 2327 2329 void (*prio_changed) (struct rq *this_rq, struct task_struct *task, 2328 2330 int oldprio); 2329 2331 ··· 2510 2508 extern void init_sched_dl_class(void); 2511 2509 extern void init_sched_rt_class(void); 2512 2510 extern void init_sched_fair_class(void); 2513 - 2514 - extern void reweight_task(struct task_struct *p, int prio); 2515 2511 2516 2512 extern void resched_curr(struct rq *rq); 2517 2513 extern void resched_cpu(int cpu);