From: Jiri Olsa <jolsa@redhat.com>
To: Mengting Zhang <zhangmengting@huawei.com>
Cc: namhyung@kernel.org, alexander.shishkin@linux.intel.com,
acme@kernel.org, Linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org, huawei.libin@huawei.com,
wangnan0@huawei.com
Subject: Re: [PATCH] perf parse events: Fix invalid precise_ip handling
Date: Fri, 10 Nov 2017 11:39:00 +0100 [thread overview]
Message-ID: <20171110103900.GA10233@krava> (raw)
In-Reply-To: <1510302517-33383-1-git-send-email-zhangmengting@huawei.com>
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
next prev parent reply other threads:[~2017-11-10 10:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 8:28 [PATCH] perf parse events: Fix invalid precise_ip handling Mengting Zhang
2017-11-10 10:39 ` Jiri Olsa [this message]
2017-11-15 1:00 ` zhangmengting
2017-11-20 7:33 ` Jiri Olsa
2017-11-21 8:30 ` zhangmengting
2017-11-21 15:23 ` Jiri Olsa
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=20171110103900.GA10233@krava \
--to=jolsa@redhat.com \
--cc=Linux-kernel@vger.kernel.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=huawei.libin@huawei.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=wangnan0@huawei.com \
--cc=zhangmengting@huawei.com \
/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).