From: Song Liu <songliubraving@fb.com>
To: open list <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Cc: Kernel Team <Kernel-team@fb.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Jiri Olsa <jolsa@kernel.org>,
Alexey Budankov <alexey.budankov@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>, Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH v6] perf: Sharing PMU counters across compatible events
Date: Mon, 30 Sep 2019 05:36:55 +0000 [thread overview]
Message-ID: <9FD34CD1-E8C4-48EE-90EE-F0ACABEE5909@fb.com> (raw)
In-Reply-To: <20190919052314.2925604-1-songliubraving@fb.com>
Hi Peter,
> On Sep 18, 2019, at 10:23 PM, Song Liu <songliubraving@fb.com> wrote:
>
> This patch tries to enable PMU sharing. To make perf event scheduling
> fast, we use special data structures.
>
> An array of "struct perf_event_dup" is added to the perf_event_context,
> to remember all the duplicated events under this ctx. All the events
> under this ctx has a "dup_id" pointing to its perf_event_dup. Compatible
> events under the same ctx share the same perf_event_dup. The following
> figure shows a simplified version of the data structure.
>
> ctx -> perf_event_dup -> master
> ^
> |
> perf_event /|
> |
> perf_event /
>
> Connection among perf_event and perf_event_dup are built when events are
> added or removed from the ctx. So these are not on the critical path of
> schedule or perf_rotate_context().
>
> 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.
>
> We allocate a separate perf_event for perf_event_dup->master. This needs
> extra attention, because perf_event_alloc() may sleep. To allocate the
> master event properly, a new pointer, tmp_master, is added to perf_event.
> tmp_master carries a separate perf_event into list_[add|del]_event().
> The master event has valid ->ctx and holds ctx->refcount.
>
> Details about the handling of the master event is added to
> include/linux/perf_event.h, before struct perf_event_dup.
Could you please share your comments/suggestions on this work?
Thanks,
Song
next prev parent reply other threads:[~2019-09-30 5:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 5:23 [PATCH v6] perf: Sharing PMU counters across compatible events Song Liu
2019-09-30 5:36 ` Song Liu [this message]
2019-10-31 12:43 ` Peter Zijlstra
2019-10-31 16:29 ` Song Liu
2019-11-05 17:11 ` Song Liu
2019-11-05 20:16 ` Peter Zijlstra
2019-11-05 23:06 ` Song Liu
2019-11-06 9:14 ` Peter Zijlstra
2019-11-06 17:40 ` Song Liu
2019-11-06 20:44 ` Peter Zijlstra
2019-11-06 22:23 ` Song Liu
2019-11-05 23:51 ` Song Liu
2019-11-06 8:56 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9FD34CD1-E8C4-48EE-90EE-F0ACABEE5909@fb.com \
--to=songliubraving@fb.com \
--cc=Kernel-team@fb.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=alexey.budankov@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).