Messages in this thread | | | From | Song Liu <> | Subject | Re: [PATCH v12] perf: Sharing PMU counters across compatible events | Date | Thu, 9 Apr 2020 20:40:25 +0000 |
| |
Hi Peter,
> On Mar 31, 2020, at 12:55 AM, Song Liu <songliubraving@fb.com> wrote: > > This patch tries to enable PMU sharing. When multiple perf_events are > counting the same metric, they can share the hardware PMU counter. We > call these events as "compatible events". > > The PMU sharing are limited to events within the same perf_event_context > (ctx). When a event is installed or enabled, search the ctx for compatible > events. This is implemented in perf_event_setup_dup(). One of these > compatible events are picked as the master (stored in event->dup_master). > Similarly, when the event is removed or disabled, perf_event_remove_dup() > is used to clean up sharing. > > If the master event is a cgroup event or a event in a group, it is > possible that some slave events are ACTIVE, but the master event is not. > To handle this scenario, we introduced PERF_EVENT_STATE_ENABLED. Also, > since PMU drivers write into event->count, master event needs another > variable (master_count) for the reading of this event. > > On the critical paths (add, del read), sharing PMU counters doesn't > increase the complexity. Helper functions event_pmu_[add|del|read]() are > introduced to cover these cases. All these functions have O(1) time > complexity. > > Cc: Peter Zijlstra <peterz@infradead.org> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com> > Cc: Jiri Olsa <jolsa@kernel.org> > Cc: Alexey Budankov <alexey.budankov@linux.intel.com> > Cc: Namhyung Kim <namhyung@kernel.org> > Cc: Tejun Heo <tj@kernel.org> > Reported-by: kernel test robot <rong.a.chen@intel.com> > Signed-off-by: Song Liu <songliubraving@fb.com>
Could you please share your comments on this version?
Thanks, Song
| |