Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1716791 > unrolled thread

[PATCH] perf record: enable multiplexing scaling via -R

Started byStephane Eranian <eranian@google.com>
First post2017-08-21 21:20 +0200
Last post2017-08-22 09:30 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] perf record: enable multiplexing scaling via -R Stephane Eranian <eranian@google.com> - 2017-08-21 21:20 +0200
    Re: [PATCH] perf record: enable multiplexing scaling via -R Andi Kleen <andi@firstfloor.org> - 2017-08-22 01:10 +0200
      Re: [PATCH] perf record: enable multiplexing scaling via -R Stephane Eranian <eranian@google.com> - 2017-08-22 02:20 +0200
        Re: [PATCH] perf record: enable multiplexing scaling via -R Andi Kleen <andi@firstfloor.org> - 2017-08-22 03:30 +0200
          Re: [PATCH] perf record: enable multiplexing scaling via -R Jiri Olsa <jolsa@redhat.com> - 2017-08-22 09:10 +0200
            Re: [PATCH] perf record: enable multiplexing scaling via -R Stephane Eranian <eranian@google.com> - 2017-08-22 09:30 +0200

#1716791 — [PATCH] perf record: enable multiplexing scaling via -R

FromStephane Eranian <eranian@google.com>
Date2017-08-21 21:20 +0200
Subject[PATCH] perf record: enable multiplexing scaling via -R
Message-ID<uh0oV-8mG-13@gated-at.bofh.it>
This patch allows perf record to request that event
timing be recorded in each sample. The timing consists
of time_enabled and time_running. These two values are
used to compute the multiplexing correction, i.e.,
how long an event was actually measured by the hardware.

To activate, the user must use:
$ perf record -a -R ....

The patch works by forcing PERF_SAMPLE_READ in raw mode (-R),
i.e., reading of the event group in each sample.

The side effect is that both time_running and time_enable are
captured + an empty four byte RAW section. This way we leverage
an existing perf record mode and do not add yet another option.

With this patch, it is possible to evaluate the total number
of occurrences of each sampling event even when multiplexing is
active.

Signed-off-by: Stephane Eranian <eranian@google.com>
---
 tools/perf/Documentation/perf-record.txt | 2 ++
 tools/perf/util/evsel.c                  | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 9bdea047c5db..6a0bfd29bac9 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -270,6 +270,8 @@ OPTIONS
 -R::
 --raw-samples::
 Collect raw sample records from all opened counters (default for tracepoint counters).
+With this option, each sample includes at least: CPU, timestamp, time running/enabled
+(multiplexing scaling factor).
 
 -C::
 --cpu::
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 3735c9e0080d..3305c0b10161 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -852,6 +852,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
 	attr->sample_id_all = perf_missing_features.sample_id_all ? 0 : 1;
 	attr->inherit	    = !opts->no_inherit;
 	attr->write_backward = opts->overwrite ? 1 : 0;
+	attr->read_format   = PERF_FORMAT_TOTAL_TIME_ENABLED |
+			      PERF_FORMAT_TOTAL_TIME_RUNNING |
+			      PERF_FORMAT_ID;
 
 	perf_evsel__set_sample_bit(evsel, IP);
 	perf_evsel__set_sample_bit(evsel, TID);
@@ -945,6 +948,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
 		perf_evsel__set_sample_bit(evsel, TIME);
 		perf_evsel__set_sample_bit(evsel, RAW);
 		perf_evsel__set_sample_bit(evsel, CPU);
+		perf_evsel__set_sample_bit(evsel, ID);
+		perf_evsel__set_sample_bit(evsel, READ);
 	}
 
 	if (opts->sample_address)
-- 
2.7.4

[toc] | [next] | [standalone]


#1716932

FromAndi Kleen <andi@firstfloor.org>
Date2017-08-22 01:10 +0200
Message-ID<uh3Zv-2fV-9@gated-at.bofh.it>
In reply to#1716791
Stephane Eranian <eranian@google.com> writes:
>
> To activate, the user must use:
> $ perf record -a -R ....

I don't know why you're overloading the existing raw mode?

It has nothing to do with that.

-Andi

[toc] | [prev] | [next] | [standalone]


#1716946

FromStephane Eranian <eranian@google.com>
Date2017-08-22 02:20 +0200
Message-ID<uh55f-2TV-11@gated-at.bofh.it>
In reply to#1716932
On Mon, Aug 21, 2017 at 4:02 PM, Andi Kleen <andi@firstfloor.org> wrote:
>
> Stephane Eranian <eranian@google.com> writes:
> >
> > To activate, the user must use:
> > $ perf record -a -R ....
>
> I don't know why you're overloading the existing raw mode?
>
> It has nothing to do with that.
>
I explained this in the changelog. So that is does not change any of
the processing in perf report, i.e., no faced with data it does not
know how to handle.
Also trying to avoid adding yet another option.

>
> -Andi

[toc] | [prev] | [next] | [standalone]


#1716963

FromAndi Kleen <andi@firstfloor.org>
Date2017-08-22 03:30 +0200
Message-ID<uh6b0-3Bo-13@gated-at.bofh.it>
In reply to#1716946
On Mon, Aug 21, 2017 at 05:13:29PM -0700, Stephane Eranian wrote:
> On Mon, Aug 21, 2017 at 4:02 PM, Andi Kleen <andi@firstfloor.org> wrote:
> >
> > Stephane Eranian <eranian@google.com> writes:
> > >
> > > To activate, the user must use:
> > > $ perf record -a -R ....
> >
> > I don't know why you're overloading the existing raw mode?
> >
> > It has nothing to do with that.
> >
> I explained this in the changelog. So that is does not change any of
> the processing in perf report, i.e., no faced with data it does not
> know how to handle.
> Also trying to avoid adding yet another option.

But raw is needed for some of the non Intel PMUs. I believe it's 
the only way to use AMD IBS. You may as well break their usage.

You'll need a new option.

-Andi

[toc] | [prev] | [next] | [standalone]


#1717079

FromJiri Olsa <jolsa@redhat.com>
Date2017-08-22 09:10 +0200
Message-ID<uhbu1-7on-1@gated-at.bofh.it>
In reply to#1716963
On Mon, Aug 21, 2017 at 06:25:45PM -0700, Andi Kleen wrote:
> On Mon, Aug 21, 2017 at 05:13:29PM -0700, Stephane Eranian wrote:
> > On Mon, Aug 21, 2017 at 4:02 PM, Andi Kleen <andi@firstfloor.org> wrote:
> > >
> > > Stephane Eranian <eranian@google.com> writes:
> > > >
> > > > To activate, the user must use:
> > > > $ perf record -a -R ....
> > >
> > > I don't know why you're overloading the existing raw mode?
> > >
> > > It has nothing to do with that.
> > >
> > I explained this in the changelog. So that is does not change any of
> > the processing in perf report, i.e., no faced with data it does not
> > know how to handle.
> > Also trying to avoid adding yet another option.
> 
> But raw is needed for some of the non Intel PMUs. I believe it's 
> the only way to use AMD IBS. You may as well break their usage.
> 
> You'll need a new option.

I agree with Andi, I don't think we should mix those,
we should have a way to switch it on/off

jirka

[toc] | [prev] | [next] | [standalone]


#1717088

FromStephane Eranian <eranian@google.com>
Date2017-08-22 09:30 +0200
Message-ID<uhbNn-7yL-5@gated-at.bofh.it>
In reply to#1717079
On Tue, Aug 22, 2017 at 12:03 AM, Jiri Olsa <jolsa@redhat.com> wrote:
>
> On Mon, Aug 21, 2017 at 06:25:45PM -0700, Andi Kleen wrote:
> > On Mon, Aug 21, 2017 at 05:13:29PM -0700, Stephane Eranian wrote:
> > > On Mon, Aug 21, 2017 at 4:02 PM, Andi Kleen <andi@firstfloor.org> wrote:
> > > >
> > > > Stephane Eranian <eranian@google.com> writes:
> > > > >
> > > > > To activate, the user must use:
> > > > > $ perf record -a -R ....
> > > >
> > > > I don't know why you're overloading the existing raw mode?
> > > >
> > > > It has nothing to do with that.
> > > >
> > > I explained this in the changelog. So that is does not change any of
> > > the processing in perf report, i.e., no faced with data it does not
> > > know how to handle.
> > > Also trying to avoid adding yet another option.
> >
> > But raw is needed for some of the non Intel PMUs. I believe it's
> > the only way to use AMD IBS. You may as well break their usage.
> >
> > You'll need a new option.
>
> I agree with Andi, I don't think we should mix those,
> we should have a way to switch it on/off
>
Ok, then. I will add an option to turn this on. This is a useful mode
for many advanced users.

>
> jirka

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web