lkml.org 
[lkml]   [2017]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf parse events: Fix invalid precise_ip handling
On Fri, Nov 10, 2017 at 04:28:37PM +0800, Mengting Zhang wrote:

SNIP

> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 39b1596..25225f4 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -1369,6 +1369,32 @@ struct event_modifier {
> int pinned;
> };
>
> +static int perf_get_max_precise_ip(void)
> +{
> + int max_precise_ip = 0;
> + struct perf_event_attr attr = {
> + .type = PERF_TYPE_HARDWARE,
> + .config = PERF_COUNT_HW_CPU_CYCLES,
> + };
> +
> + event_attr_init(&attr);
> +
> + attr.precise_ip = 3;
> + attr.sample_period = 1;
> +
> + while (attr.precise_ip != 0) {
> + int fd = sys_perf_event_open(&attr, 0, -1, -1, 0);
> + if (fd != -1){
> + close(fd);
> + break;
> + }
> + --attr.precise_ip;
> + }
> + max_precise_ip = attr.precise_ip;
> +
> + return max_precise_ip;
> +}

we already have a function for that, please check perf_event_attr__set_max_precise_ip

also I think the precise level is not generic for all the events,
so you should check it for specific perf_event_attr later, when
the attr is ready, not in modifier parsing

thanks,
jirka

\
 
 \ /
  Last update: 2017-11-10 11:40    [W:0.048 / U:6.504 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site