Commit 2c503ec
sched/fair: do not scan twice in detach_tasks()
detach_tasks() uses struct lb_env.loop_max as an env.src_rq->cfs_tasks
iteration count limit. It is however set without the source RQ lock held.
This means that env.loop_max and the actual length of env.src_rq->cfs_tasks
as observed within detach_tasks() can differ. This can cause some tasks to
be unnecessarily iterated over more than once, for instance:
env.loop_max := 4
detach_tasks()
// Here env.src->cfs_tasks only contains two tasks which can't be
// migrated anywhere, so they're put back in the list each time.
env.src->cfs_tasks := [p1, p0]
// The iteration goes:
p0; cfs_tasks := [p0, p1]
p1; cfs_tasks := [p1, p0]
p0; cfs_tasks := [p0, p1]
p1; cfs_tasks := [p1, p0]
// IOW we iterate over each task twice
In the Specjbb test, the similar issues can be caught many times.
(Over 330,000 times in a 30-minites Specjbb test)
This patch sets env.loop_max only once RQ lock is taken,
and uses busiest->cfs.h_nr_queued for setting the env.loop_max.
After this patch, I cannot catch any above issue in the Specjbb test.
Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: Valentin Schneider <vschneid@redhat.com>1 parent c80ed4e commit 2c503ec
1 file changed
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11932 | 11932 | | |
11933 | 11933 | | |
11934 | 11934 | | |
11935 | | - | |
11936 | | - | |
11937 | 11935 | | |
11938 | 11936 | | |
11939 | 11937 | | |
11940 | 11938 | | |
| 11939 | + | |
| 11940 | + | |
| 11941 | + | |
| 11942 | + | |
| 11943 | + | |
11941 | 11944 | | |
11942 | 11945 | | |
11943 | 11946 | | |
| |||
0 commit comments