* [PATCH] perf kvm: fix sample_type manipulation
@ 2013-09-06 6:48 Adrian Hunter
2013-09-06 12:53 ` Arnaldo Carvalho de Melo
2013-09-06 17:39 ` David Ahern
0 siblings, 2 replies; 4+ messages in thread
From: Adrian Hunter @ 2013-09-06 6:48 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Peter Zijlstra, linux-kernel, David Ahern, Frederic Weisbecker,
Jiri Olsa, Mike Galbraith, Namhyung Kim, Paul Mackerras,
Stephane Eranian
Manipulating the sample_type of an evsel requires
the use of:
perf_evsel__set_sample_bit()
and perf_evsel__reset_sample_bit()
Manipulating the sample type of an evlist requires
the id position to be recalculated.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/builtin-kvm.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 47b3540..0b7c5a9 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1165,16 +1165,16 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm)
struct perf_event_attr *attr = &pos->attr;
/* make sure these *are* set */
- attr->sample_type |= PERF_SAMPLE_TID;
- attr->sample_type |= PERF_SAMPLE_TIME;
- attr->sample_type |= PERF_SAMPLE_CPU;
- attr->sample_type |= PERF_SAMPLE_RAW;
+ perf_evsel__set_sample_bit(pos, TID);
+ perf_evsel__set_sample_bit(pos, TIME);
+ perf_evsel__set_sample_bit(pos, CPU);
+ perf_evsel__set_sample_bit(pos, RAW);
/* make sure these are *not*; want as small a sample as possible */
- attr->sample_type &= ~PERF_SAMPLE_PERIOD;
- attr->sample_type &= ~PERF_SAMPLE_IP;
- attr->sample_type &= ~PERF_SAMPLE_CALLCHAIN;
- attr->sample_type &= ~PERF_SAMPLE_ADDR;
- attr->sample_type &= ~PERF_SAMPLE_READ;
+ perf_evsel__reset_sample_bit(pos, PERIOD);
+ perf_evsel__reset_sample_bit(pos, IP);
+ perf_evsel__reset_sample_bit(pos, CALLCHAIN);
+ perf_evsel__reset_sample_bit(pos, ADDR);
+ perf_evsel__reset_sample_bit(pos, READ);
attr->mmap = 0;
attr->comm = 0;
attr->task = 0;
@@ -1188,6 +1188,8 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm)
attr->disabled = 1;
}
+ perf_evlist__set_id_pos(evlist);
+
err = perf_evlist__open(evlist);
if (err < 0) {
printf("Couldn't create the events: %s\n", strerror(errno));
--
1.7.11.7
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] perf kvm: fix sample_type manipulation
2013-09-06 6:48 [PATCH] perf kvm: fix sample_type manipulation Adrian Hunter
@ 2013-09-06 12:53 ` Arnaldo Carvalho de Melo
2013-09-06 13:59 ` David Ahern
2013-09-06 17:39 ` David Ahern
1 sibling, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-09-06 12:53 UTC (permalink / raw)
To: Adrian Hunter
Cc: Peter Zijlstra, linux-kernel, David Ahern, Frederic Weisbecker,
Jiri Olsa, Mike Galbraith, Namhyung Kim, Paul Mackerras,
Stephane Eranian
Em Fri, Sep 06, 2013 at 09:48:54AM +0300, Adrian Hunter escreveu:
> Manipulating the sample_type of an evsel requires
> the use of:
> perf_evsel__set_sample_bit()
> and perf_evsel__reset_sample_bit()
Fine, but...
> Manipulating the sample type of an evlist requires
> the id position to be recalculated.
... can't we hide this detail? I.e. we could do it like we do with the
alloc_{mmap,poll}() evlist methods in perf_evlist__mmap(), checking if it was
already done, etc.
This we reduce the contact surface for tools using evlists and evsels.
I.e., this sequence:
+ perf_evlist__set_id_pos(evlist);
+
err = perf_evlist__open(evlist);
Could remain just:
err = perf_evlist__open(evlist);
I'm auditing the other calls to evlist now, to check if there are other cases.
Thanks for the patch!
- Arnaldo
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> tools/perf/builtin-kvm.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
> index 47b3540..0b7c5a9 100644
> --- a/tools/perf/builtin-kvm.c
> +++ b/tools/perf/builtin-kvm.c
> @@ -1165,16 +1165,16 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm)
> struct perf_event_attr *attr = &pos->attr;
>
> /* make sure these *are* set */
> - attr->sample_type |= PERF_SAMPLE_TID;
> - attr->sample_type |= PERF_SAMPLE_TIME;
> - attr->sample_type |= PERF_SAMPLE_CPU;
> - attr->sample_type |= PERF_SAMPLE_RAW;
> + perf_evsel__set_sample_bit(pos, TID);
> + perf_evsel__set_sample_bit(pos, TIME);
> + perf_evsel__set_sample_bit(pos, CPU);
> + perf_evsel__set_sample_bit(pos, RAW);
> /* make sure these are *not*; want as small a sample as possible */
> - attr->sample_type &= ~PERF_SAMPLE_PERIOD;
> - attr->sample_type &= ~PERF_SAMPLE_IP;
> - attr->sample_type &= ~PERF_SAMPLE_CALLCHAIN;
> - attr->sample_type &= ~PERF_SAMPLE_ADDR;
> - attr->sample_type &= ~PERF_SAMPLE_READ;
> + perf_evsel__reset_sample_bit(pos, PERIOD);
> + perf_evsel__reset_sample_bit(pos, IP);
> + perf_evsel__reset_sample_bit(pos, CALLCHAIN);
> + perf_evsel__reset_sample_bit(pos, ADDR);
> + perf_evsel__reset_sample_bit(pos, READ);
> attr->mmap = 0;
> attr->comm = 0;
> attr->task = 0;
> @@ -1188,6 +1188,8 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm)
> attr->disabled = 1;
> }
>
> + perf_evlist__set_id_pos(evlist);
> +
> err = perf_evlist__open(evlist);
> if (err < 0) {
> printf("Couldn't create the events: %s\n", strerror(errno));
> --
> 1.7.11.7
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] perf kvm: fix sample_type manipulation
2013-09-06 12:53 ` Arnaldo Carvalho de Melo
@ 2013-09-06 13:59 ` David Ahern
0 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2013-09-06 13:59 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Adrian Hunter, Peter Zijlstra, linux-kernel, Frederic Weisbecker,
Jiri Olsa, Mike Galbraith, Namhyung Kim, Paul Mackerras,
Stephane Eranian
On 9/6/13 6:53 AM, Arnaldo Carvalho de Melo wrote:
> Em Fri, Sep 06, 2013 at 09:48:54AM +0300, Adrian Hunter escreveu:
>> Manipulating the sample_type of an evsel requires
>> the use of:
>> perf_evsel__set_sample_bit()
>> and perf_evsel__reset_sample_bit()
>
> Fine, but...
hmmm... this is a relatively new API (7be5ebe8). The kvm-live command
and my scheduling daemon pre-date its introduction.
>
>> Manipulating the sample type of an evlist requires
>> the id position to be recalculated.
And this is hot of the presses ... 75562573.
>
> ... can't we hide this detail? I.e. we could do it like we do with the
> alloc_{mmap,poll}() evlist methods in perf_evlist__mmap(), checking if it was
> already done, etc.
>
> This we reduce the contact surface for tools using evlists and evsels.
>
> I.e., this sequence:
>
>
> + perf_evlist__set_id_pos(evlist);
> +
> err = perf_evlist__open(evlist);
>
> Could remain just:
>
> err = perf_evlist__open(evlist);
perf code has been around a while now and I know there are a number of
local analysis commands built around it. API changes like this --
required ones at that -- need to be simple and some error checking built
in where possible.
... and documentation for the API on what commands should be doing and
in what order.
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf kvm: fix sample_type manipulation
2013-09-06 6:48 [PATCH] perf kvm: fix sample_type manipulation Adrian Hunter
2013-09-06 12:53 ` Arnaldo Carvalho de Melo
@ 2013-09-06 17:39 ` David Ahern
1 sibling, 0 replies; 4+ messages in thread
From: David Ahern @ 2013-09-06 17:39 UTC (permalink / raw)
To: Adrian Hunter
Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, linux-kernel,
Frederic Weisbecker, Jiri Olsa, Mike Galbraith, Namhyung Kim,
Paul Mackerras, Stephane Eranian
On 9/6/13 12:48 AM, Adrian Hunter wrote:
> Manipulating the sample_type of an evsel requires
> the use of:
> perf_evsel__set_sample_bit()
> and perf_evsel__reset_sample_bit()
>
> Manipulating the sample type of an evlist requires
> the id position to be recalculated.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes the regression. Thanks for taking care of it
Tested-by-and-Acked-by: David Ahern <dsahern@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-09-06 17:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-06 6:48 [PATCH] perf kvm: fix sample_type manipulation Adrian Hunter
2013-09-06 12:53 ` Arnaldo Carvalho de Melo
2013-09-06 13:59 ` David Ahern
2013-09-06 17:39 ` David Ahern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox