Commit 6a09c24
Revert "sched/core: Reduce cost of sched_move_task when config autogroup"
commit 76f970c upstream.
This reverts commit eff6c8c.
Hazem reported a 30% drop in UnixBench spawn test with commit
eff6c8c ("sched/core: Reduce cost of sched_move_task when config
autogroup") on a m6g.xlarge AWS EC2 instance with 4 vCPUs and 16 GiB RAM
(aarch64) (single level MC sched domain):
https://lkml.kernel.org/r/[email protected]
There is an early bail from sched_move_task() if p->sched_task_group is
equal to p's 'cpu cgroup' (sched_get_task_group()). E.g. both are
pointing to taskgroup '/user.slice/user-1000.slice/session-1.scope'
(Ubuntu '22.04.5 LTS').
So in:
do_exit()
sched_autogroup_exit_task()
sched_move_task()
if sched_get_task_group(p) == p->sched_task_group
return
/* p is enqueued */
dequeue_task() \
sched_change_group() |
task_change_group_fair() |
detach_task_cfs_rq() | (1)
set_task_rq() |
attach_task_cfs_rq() |
enqueue_task() /
(1) isn't called for p anymore.
Turns out that the regression is related to sgs->group_util in
group_is_overloaded() and group_has_capacity(). If (1) isn't called for
all the 'spawn' tasks then sgs->group_util is ~900 and
sgs->group_capacity = 1024 (single CPU sched domain) and this leads to
group_is_overloaded() returning true (2) and group_has_capacity() false
(3) much more often compared to the case when (1) is called.
I.e. there are much more cases of 'group_is_overloaded' and
'group_fully_busy' in WF_FORK wakeup sched_balance_find_dst_cpu() which
then returns much more often a CPU != smp_processor_id() (5).
This isn't good for these extremely short running tasks (FORK + EXIT)
and also involves calling sched_balance_find_dst_group_cpu() unnecessary
(single CPU sched domain).
Instead if (1) is called for 'p->flags & PF_EXITING' then the path
(4),(6) is taken much more often.
select_task_rq_fair(..., wake_flags = WF_FORK)
cpu = smp_processor_id()
new_cpu = sched_balance_find_dst_cpu(..., cpu, ...)
group = sched_balance_find_dst_group(..., cpu)
do {
update_sg_wakeup_stats()
sgs->group_type = group_classify()
if group_is_overloaded() (2)
return group_overloaded
if !group_has_capacity() (3)
return group_fully_busy
return group_has_spare (4)
} while group
if local_sgs.group_type > idlest_sgs.group_type
return idlest (5)
case group_has_spare:
if local_sgs.idle_cpus >= idlest_sgs.idle_cpus
return NULL (6)
Unixbench Tests './Run -c 4 spawn' on:
(a) VM AWS instance (m7gd.16xlarge) with v6.13 ('maxcpus=4 nr_cpus=4')
and Ubuntu 22.04.5 LTS (aarch64).
Shell & test run in '/user.slice/user-1000.slice/session-1.scope'.
w/o patch w/ patch
21005 27120
(b) i7-13700K with tip/sched/core ('nosmt maxcpus=8 nr_cpus=8') and
Ubuntu 22.04.5 LTS (x86_64).
Shell & test run in '/A'.
w/o patch w/ patch
67675 88806
CONFIG_SCHED_AUTOGROUP=y & /sys/proc/kernel/sched_autogroup_enabled equal
0 or 1.
Reported-by: Hazem Mohamed Abuelfotoh <[email protected]>
Signed-off-by: Dietmar Eggemann <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Reviewed-by: Vincent Guittot <[email protected]>
Tested-by: Hagar Hemdan <[email protected]>
Cc: Linus Torvalds <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent 8c90d43 commit 6a09c24
1 file changed
+3
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9010 | 9010 | | |
9011 | 9011 | | |
9012 | 9012 | | |
9013 | | - | |
| 9013 | + | |
9014 | 9014 | | |
9015 | 9015 | | |
9016 | 9016 | | |
| |||
9022 | 9022 | | |
9023 | 9023 | | |
9024 | 9024 | | |
9025 | | - | |
9026 | | - | |
9027 | | - | |
9028 | | - | |
9029 | | - | |
9030 | | - | |
9031 | | - | |
| 9025 | + | |
9032 | 9026 | | |
9033 | 9027 | | |
9034 | 9028 | | |
| |||
9049 | 9043 | | |
9050 | 9044 | | |
9051 | 9045 | | |
9052 | | - | |
9053 | 9046 | | |
9054 | 9047 | | |
9055 | 9048 | | |
9056 | 9049 | | |
9057 | 9050 | | |
9058 | | - | |
9059 | | - | |
9060 | | - | |
9061 | | - | |
9062 | | - | |
9063 | | - | |
9064 | | - | |
9065 | | - | |
9066 | 9051 | | |
9067 | 9052 | | |
9068 | 9053 | | |
| |||
9073 | 9058 | | |
9074 | 9059 | | |
9075 | 9060 | | |
9076 | | - | |
| 9061 | + | |
9077 | 9062 | | |
9078 | 9063 | | |
9079 | 9064 | | |
| |||
0 commit comments