Files
kernel_xiaomi_raphael/kernel
Chengming Zhou 0531c338da psi: Optimize task switch inside shared cgroups
The commit 36b238d57172 ("psi: Optimize switching tasks inside shared
cgroups") only update cgroups whose state actually changes during a
task switch only in task preempt case, not in task sleep case.

We actually don't need to clear and set TSK_ONCPU state for common cgroups
of next and prev task in sleep case, that can save many psi_group_change
especially when most activity comes from one leaf cgroup.

sleep before:
psi_dequeue()
  while ((group = iterate_groups(prev)))  # all ancestors
    psi_group_change(prev, .clear=TSK_RUNNING|TSK_ONCPU)
psi_task_switch()
  while ((group = iterate_groups(next)))  # all ancestors
    psi_group_change(next, .set=TSK_ONCPU)

sleep after:
psi_dequeue()
  nop
psi_task_switch()
  while ((group = iterate_groups(next)))  # until (prev & next)
    psi_group_change(next, .set=TSK_ONCPU)
  while ((group = iterate_groups(prev)))  # all ancestors
    psi_group_change(prev, .clear=common?TSK_RUNNING:TSK_RUNNING|TSK_ONCPU)

When a voluntary sleep switches to another task, we remove one call of
psi_group_change() for every common cgroup ancestor of the two tasks.

Co-developed-by: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Link: https://lkml.kernel.org/r/20210303034659.91735-5-zhouchengming@bytedance.com
2022-07-25 07:08:03 +00:00
..
2022-05-27 08:51:18 +00:00
2022-07-18 06:38:16 +00:00
2022-01-22 14:28:43 +00:00
2022-05-27 08:51:18 +00:00
2019-12-01 09:14:03 +01:00
2022-04-18 11:35:55 +00:00
2020-01-13 19:40:11 +00:00
2022-01-22 14:28:43 +00:00
2022-05-27 08:51:18 +00:00
2020-04-02 16:34:20 +02:00
2019-08-12 13:29:46 -04:00
2022-04-28 07:15:46 +00:00
2021-02-07 14:47:41 +01:00
2022-04-28 07:14:51 +00:00
2022-01-22 14:28:43 +00:00
2022-01-22 14:28:43 +00:00
2018-04-12 13:00:33 -07:00