linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Gainey <Ben.Gainey@arm.com>
To: "namhyung@kernel.org" <namhyung@kernel.org>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"acme@kernel.org" <acme@kernel.org>
Cc: "alexander.shishkin@linux.intel.com"
	<alexander.shishkin@linux.intel.com>,
	Mark Rutland <Mark.Rutland@arm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	James Clark <James.Clark@arm.com>,
	"adrian.hunter@intel.com" <adrian.hunter@intel.com>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	"jolsa@kernel.org" <jolsa@kernel.org>,
	"irogers@google.com" <irogers@google.com>
Subject: Re: [PATCH v5 0/4] perf: Support PERF_SAMPLE_READ with inherit
Date: Thu, 9 May 2024 09:05:24 +0000	[thread overview]
Message-ID: <76bfb0dbee9347a43ef88d3712c30aa7b24fde9e.camel@arm.com> (raw)
In-Reply-To: <20240415081448.123789-1-ben.gainey@arm.com>

Hello folks

I appreciate you're all busy, but any feedback on this one?

Thanks
Ben




On Mon, 2024-04-15 at 09:14 +0100, Ben Gainey wrote:
> This change allows events to use PERF_SAMPLE READ with inherit so
> long
> as PERF_SAMPLE_TID is also set.
>
> Currently it is not possible to use PERF_SAMPLE_READ with inherit.
> This
> restriction assumes the user is interested in collecting aggregate
> statistics as per `perf stat`. It prevents a user from collecting
> per-thread samples using counter groups from a multi-threaded or
> multi-process application, as with `perf record -e '{....}:S'`.
> Instead
> users must use system-wide mode, or forgo the ability to sample
> counter
> groups. System-wide mode is often problematic as it requires specific
> permissions (no CAP_PERFMON / root access), or may lead to capture of
> significant amounts of extra data from other processes running on the
> system.
>
> This patch changes `perf_event_alloc` relaxing the restriction
> against
> combining `inherit` with `PERF_SAMPLE_READ` so that the combination
> will be allowed so long as `PERF_SAMPLE_TID` is enabled. It modifies
> sampling so that only the count associated with the active thread is
> recorded into the buffer. It modifies the context switch handling so
> that perf contexts are always switched out if they have this kind of
> event so that the correct per-thread state is maintained. Finally,
> the
> tools are updated to allow perf record to specify this combination
> and
> to correctly decode the sample data.
>
> In this configuration stream ids (such as may appear in the
> read_format
> field of a PERF_RECORD_SAMPLE) are no longer globally unique, rather
> the pair of (stream id, tid) uniquely identify each event. Tools that
> rely on this, for example to calculate a delta between samples, would
> need updating to take this into account. Previously valid event
> configurations (system-wide, no-inherit and so on) where each stream
> id
> is the identifier are unaffected.
>
>
> Changes since v4:
>  - Rebase on v6.9-rc1
>  - Removed the dependency on inherit_stat that was previously assumed
>    necessary as per feedback from Namhyung Kim.
>  - Fixed an incorrect use of zfree instead of free in the tools
> leading
>    to an abort on tool shutdown.
>  - Additional test coverage improvements added to perf test.
>  - Cleaned up the remaining bit of irrelevant change missed between
> v3
>    and v4.
>
> Changes since v3:
>  - Cleaned up perf test data changes incorrectly included into this
>    series from elsewhere.
>
> Changes since v2:
>  - Rebase on v6.8
>  - Respond to James Clarke's feedback; fixup some typos and move some
>    repeated checks into a helper macro.
>  - Cleaned up checkpatch lints.
>  - Updated perf test; fixed evsel handling so that existing tests
> pass
>    and added new tests to cover the new behaviour.
>
> Changes since v1:
>  - Rebase on v6.8-rc1
>  - Fixed value written into sample after child exists.
>  - Modified handling of switch-out so that context with these events
>    take the slow path, so that the per-event/per-thread PMU state is
>    correctly switched.
>  - Modified perf tools to support this mode of operation.
>
> Ben Gainey (4):
>   perf: Support PERF_SAMPLE_READ with inherit
>   tools/perf: Track where perf_sample_ids need per-thread periods
>   tools/perf: Correctly calculate sample period for inherited
>     SAMPLE_READ values
>   tools/perf: Allow inherit + PERF_SAMPLE_READ when opening events
>
>  include/linux/perf_event.h                    |  1 +
>  kernel/events/core.c                          | 82 ++++++++++++++---
> --
>  tools/lib/perf/evlist.c                       |  1 +
>  tools/lib/perf/evsel.c                        | 48 +++++++++++
>  tools/lib/perf/include/internal/evsel.h       | 54 +++++++++++-
>  tools/perf/tests/attr/README                  |  2 +
>  .../tests/attr/test-record-group-sampling     | 39 ---------
>  .../tests/attr/test-record-group-sampling1    | 50 +++++++++++
>  .../tests/attr/test-record-group-sampling2    | 60 ++++++++++++++
>  tools/perf/tests/attr/test-record-group2      |  9 +-
>  tools/perf/util/evsel.c                       | 19 ++++-
>  tools/perf/util/evsel.h                       |  1 +
>  tools/perf/util/session.c                     | 11 ++-
>  13 files changed, 306 insertions(+), 71 deletions(-)
>  delete mode 100644 tools/perf/tests/attr/test-record-group-sampling
>  create mode 100644 tools/perf/tests/attr/test-record-group-sampling1
>  create mode 100644 tools/perf/tests/attr/test-record-group-sampling2
>

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

      parent reply	other threads:[~2024-05-09  9:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15  8:14 [PATCH v5 0/4] perf: Support PERF_SAMPLE_READ with inherit Ben Gainey
2024-04-15  8:14 ` [PATCH v5 1/4] " Ben Gainey
2024-05-09 23:40   ` Namhyung Kim
2024-05-13 13:23     ` Ben Gainey
2024-04-15  8:14 ` [PATCH v5 2/4] tools/perf: Track where perf_sample_ids need per-thread periods Ben Gainey
2024-04-15  8:14 ` [PATCH v5 3/4] tools/perf: Correctly calculate sample period for inherited SAMPLE_READ values Ben Gainey
2024-04-15  8:14 ` [PATCH v5 4/4] tools/perf: Allow inherit + PERF_SAMPLE_READ when opening events Ben Gainey
2024-05-09  9:05 ` Ben Gainey [this message]

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=76bfb0dbee9347a43ef88d3712c30aa7b24fde9e.camel@arm.com \
    --to=ben.gainey@arm.com \
    --cc=James.Clark@arm.com \
    --cc=Mark.Rutland@arm.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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).