perf/core: Use min_heap in visit_groups_merge()
authorIan Rogers <irogers@google.com>
Fri, 14 Feb 2020 07:51:30 +0000 (23:51 -0800)
committerIngo Molnar <mingo@kernel.org>
Fri, 6 Mar 2020 10:56:59 +0000 (11:56 +0100)
commit6eef8a7116deae0706ba6d897c0d7dd887cd2be2
tree6cda474f41d421306fb7fee30418f12ec31d839f
parent6e24628d78e4785385876125cba62315ca3b04b9
perf/core: Use min_heap in visit_groups_merge()

visit_groups_merge will pick the next event based on when it was
inserted in to the context (perf_event group_index). Events may be per CPU
or for any CPU, but in the future we'd also like to have per cgroup events
to avoid searching all events for the events to schedule for a cgroup.
Introduce a min heap for the events that maintains a property that the
earliest inserted event is always at the 0th element. Initialize the heap
with per-CPU and any-CPU events for the context.

Based-on-work-by: Peter Zijlstra (Intel) <peterz@infradead.org>
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/20200214075133.181299-4-irogers@google.com
kernel/events/core.c