OSDN Git Service

perf/cgroup: Order events in RB tree by cgroup id
authorIan Rogers <irogers@google.com>
Fri, 14 Feb 2020 07:51:33 +0000 (23:51 -0800)
committerIngo Molnar <mingo@kernel.org>
Fri, 6 Mar 2020 10:57:01 +0000 (11:57 +0100)
commit95ed6c707f26a727a29972b60469630ae10d579c
tree51f7dd9dc333d8e486d477e11f7110335c3d3781
parentc2283c9368d41063f2077cb58def02217360526d
perf/cgroup: Order events in RB tree by cgroup id

If one is monitoring 6 events on 20 cgroups the per-CPU RB tree will
hold 120 events. The scheduling in of the events currently iterates
over all events looking to see which events match the task's cgroup or
its cgroup hierarchy. If a task is in 1 cgroup with 6 events, then 114
events are considered unnecessarily.

This change orders events in the RB tree by cgroup id if it is present.
This means scheduling in may go directly to events associated with the
task's cgroup if one is present. The per-CPU iterator storage in
visit_groups_merge is sized sufficent for an iterator per cgroup depth,
where different iterators are needed for the task's cgroup and parent
cgroups. By considering the set of iterators when visiting, the lowest
group_index event may be selected and the insertion order group_index
property is maintained. This also allows event rotation to function
correctly, as although events are grouped into a cgroup, rotation always
selects the lowest group_index event to rotate (delete/insert into the
tree) and the min heap of iterators make it so that the group_index order
is maintained.

Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lkml.kernel.org/r/20190724223746.153620-3-irogers@google.com
kernel/events/core.c