Commit eff6c8c
sched/core: Reduce cost of sched_move_task when config autogroup
Some sched_move_task calls are useless because that
task_struct->sched_task_group maybe not changed (equals task_group
of cpu_cgroup) when system enable autogroup. So do some checks in
sched_move_task.
sched_move_task eg:
task A belongs to cpu_cgroup0 and autogroup0, it will always belong
to cpu_cgroup0 when do_exit. So there is no need to do {de|en}queue.
The call graph is as follow.
do_exit
sched_autogroup_exit_task
sched_move_task
dequeue_task
sched_change_group
A.sched_task_group = sched_get_task_group (=cpu_cgroup0)
enqueue_task
Performance results:
===========================
1. env
cpu: bogomips=4600.00
kernel: 6.3.0-rc3
cpu_cgroup: 6:cpu,cpuacct:/user.slice
2. cmds
do_exit script:
for i in {0..10000}; do
sleep 0 &
done
wait
Run the above script, then use the following bpftrace cmd to get
the cost of sched_move_task:
bpftrace -e 'k:sched_move_task { @ts[tid] = nsecs; }
kr:sched_move_task /@ts[tid]/
{ @ns += nsecs - @ts[tid]; delete(@ts[tid]); }'
3. cost time(ns):
without patch: 43528033
with patch: 18541416
diff:-24986617 -57.4%
As the result show, the patch will save 57.4% in the scenario.
Signed-off-by: wuchi <wuchi.zero@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20230321064459.39421-1-wuchi.zero@gmail.com1 parent 530bfad commit eff6c8c
1 file changed
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10351 | 10351 | | |
10352 | 10352 | | |
10353 | 10353 | | |
10354 | | - | |
| 10354 | + | |
10355 | 10355 | | |
10356 | 10356 | | |
10357 | 10357 | | |
| |||
10363 | 10363 | | |
10364 | 10364 | | |
10365 | 10365 | | |
10366 | | - | |
| 10366 | + | |
| 10367 | + | |
| 10368 | + | |
| 10369 | + | |
| 10370 | + | |
| 10371 | + | |
| 10372 | + | |
10367 | 10373 | | |
10368 | 10374 | | |
10369 | 10375 | | |
| |||
10384 | 10390 | | |
10385 | 10391 | | |
10386 | 10392 | | |
| 10393 | + | |
10387 | 10394 | | |
10388 | 10395 | | |
10389 | 10396 | | |
10390 | 10397 | | |
| 10398 | + | |
| 10399 | + | |
| 10400 | + | |
| 10401 | + | |
| 10402 | + | |
| 10403 | + | |
| 10404 | + | |
| 10405 | + | |
10391 | 10406 | | |
10392 | 10407 | | |
10393 | 10408 | | |
| |||
10398 | 10413 | | |
10399 | 10414 | | |
10400 | 10415 | | |
10401 | | - | |
| 10416 | + | |
10402 | 10417 | | |
10403 | 10418 | | |
10404 | 10419 | | |
| |||
10412 | 10427 | | |
10413 | 10428 | | |
10414 | 10429 | | |
| 10430 | + | |
10415 | 10431 | | |
10416 | 10432 | | |
10417 | 10433 | | |
| |||
0 commit comments