* [PATCH] perf evsel: Fix incorrect precise_ip in default event name
@ 2017-11-10 5:49 Mengting Zhang
2017-11-10 6:30 ` Namhyung Kim
0 siblings, 1 reply; 3+ messages in thread
From: Mengting Zhang @ 2017-11-10 5:49 UTC (permalink / raw)
To: jolsa, namhyung, alexander.shishkin
Cc: acme, Linux-kernel, linux-perf-users, huawei.libin, wangnan0,
zhangmengting
When no event is specified with -e option, perf will specify a
"cycles" event with the highest level of precision available in
perf_event_attr.precise_ip as the default event. But the evsel name
shows an incorrect precise ip, fix it.
For example, with a highest precision perf_event_attr.precise_ip = 2,
the evsel name "cycles:ppp" shows a wrong precision available.
Before:
$./perf record sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.014 MB perf.data (21 samples) ]
$./perf evlist -v
cycles:ppp: size: 112, { sample_period, sample_freq }: 4000,
sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1,
comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 2,
sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
After:
$./perf record sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.014 MB perf.data (16 samples) ]
$./perf evlist -v
cycles:pp: size: 112, { sample_period, sample_freq }: 4000,
sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1,
comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 2,
sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
Signed-off-by: Mengting Zhang <zhangmengting@huawei.com>
---
tools/perf/util/evsel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 0dccdb8..94cf11d 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -312,7 +312,7 @@ struct perf_evsel *perf_evsel__new_cycles(bool precise)
if (asprintf(&evsel->name, "cycles%s%s%.*s",
(attr.precise_ip || attr.exclude_kernel) ? ":" : "",
attr.exclude_kernel ? "u" : "",
- attr.precise_ip ? attr.precise_ip + 1 : 0, "ppp") < 0)
+ attr.precise_ip ? attr.precise_ip : 0, "ppp") < 0)
goto error_free;
out:
return evsel;
--
1.7.12.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf evsel: Fix incorrect precise_ip in default event name
2017-11-10 5:49 [PATCH] perf evsel: Fix incorrect precise_ip in default event name Mengting Zhang
@ 2017-11-10 6:30 ` Namhyung Kim
2017-11-10 7:56 ` zhangmengting
0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2017-11-10 6:30 UTC (permalink / raw)
To: Mengting Zhang
Cc: jolsa, alexander.shishkin, acme, Linux-kernel, linux-perf-users,
huawei.libin, wangnan0, kernel-team
Hello,
On Fri, Nov 10, 2017 at 01:49:06PM +0800, Mengting Zhang wrote:
> When no event is specified with -e option, perf will specify a
> "cycles" event with the highest level of precision available in
> perf_event_attr.precise_ip as the default event. But the evsel name
> shows an incorrect precise ip, fix it.
>
> For example, with a highest precision perf_event_attr.precise_ip = 2,
> the evsel name "cycles:ppp" shows a wrong precision available.
>
> Before:
> $./perf record sleep 1
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.014 MB perf.data (21 samples) ]
> $./perf evlist -v
> cycles:ppp: size: 112, { sample_period, sample_freq }: 4000,
> sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1,
> comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 2,
> sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
>
> After:
> $./perf record sleep 1
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.014 MB perf.data (16 samples) ]
> $./perf evlist -v
> cycles:pp: size: 112, { sample_period, sample_freq }: 4000,
> sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1,
> comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 2,
> sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
>
> Signed-off-by: Mengting Zhang <zhangmengting@huawei.com>
> ---
> tools/perf/util/evsel.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 0dccdb8..94cf11d 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -312,7 +312,7 @@ struct perf_evsel *perf_evsel__new_cycles(bool precise)
> if (asprintf(&evsel->name, "cycles%s%s%.*s",
> (attr.precise_ip || attr.exclude_kernel) ? ":" : "",
> attr.exclude_kernel ? "u" : "",
> - attr.precise_ip ? attr.precise_ip + 1 : 0, "ppp") < 0)
> + attr.precise_ip ? attr.precise_ip : 0, "ppp") < 0)
I think you don't need to check value of the precise_ip anymore.
The following should be ok:
attr.precise_ip, "ppp") < 0)
Thanks,
Namhyung
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf evsel: Fix incorrect precise_ip in default event name
2017-11-10 6:30 ` Namhyung Kim
@ 2017-11-10 7:56 ` zhangmengting
0 siblings, 0 replies; 3+ messages in thread
From: zhangmengting @ 2017-11-10 7:56 UTC (permalink / raw)
To: Namhyung Kim
Cc: jolsa, alexander.shishkin, acme, Linux-kernel, linux-perf-users,
huawei.libin, wangnan0, kernel-team
Hi Namhyung,
Yeah, you are right. I'll send a new patch later.
Thanks,
Mengting Zhang
On 2017/11/10 14:30, Namhyung Kim wrote:
> Hello,
>
> On Fri, Nov 10, 2017 at 01:49:06PM +0800, Mengting Zhang wrote:
>> When no event is specified with -e option, perf will specify a
>> "cycles" event with the highest level of precision available in
>> perf_event_attr.precise_ip as the default event. But the evsel name
>> shows an incorrect precise ip, fix it.
>>
>> For example, with a highest precision perf_event_attr.precise_ip = 2,
>> the evsel name "cycles:ppp" shows a wrong precision available.
>>
>> Before:
>> $./perf record sleep 1
>> [ perf record: Woken up 1 times to write data ]
>> [ perf record: Captured and wrote 0.014 MB perf.data (21 samples) ]
>> $./perf evlist -v
>> cycles:ppp: size: 112, { sample_period, sample_freq }: 4000,
>> sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1,
>> comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 2,
>> sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
>>
>> After:
>> $./perf record sleep 1
>> [ perf record: Woken up 1 times to write data ]
>> [ perf record: Captured and wrote 0.014 MB perf.data (16 samples) ]
>> $./perf evlist -v
>> cycles:pp: size: 112, { sample_period, sample_freq }: 4000,
>> sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1,
>> comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 2,
>> sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
>>
>> Signed-off-by: Mengting Zhang <zhangmengting@huawei.com>
>> ---
>> tools/perf/util/evsel.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
>> index 0dccdb8..94cf11d 100644
>> --- a/tools/perf/util/evsel.c
>> +++ b/tools/perf/util/evsel.c
>> @@ -312,7 +312,7 @@ struct perf_evsel *perf_evsel__new_cycles(bool precise)
>> if (asprintf(&evsel->name, "cycles%s%s%.*s",
>> (attr.precise_ip || attr.exclude_kernel) ? ":" : "",
>> attr.exclude_kernel ? "u" : "",
>> - attr.precise_ip ? attr.precise_ip + 1 : 0, "ppp") < 0)
>> + attr.precise_ip ? attr.precise_ip : 0, "ppp") < 0)
> I think you don't need to check value of the precise_ip anymore.
> The following should be ok:
>
> attr.precise_ip, "ppp") < 0)
>
> Thanks,
> Namhyung
>
>
> .
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-10 7:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-10 5:49 [PATCH] perf evsel: Fix incorrect precise_ip in default event name Mengting Zhang
2017-11-10 6:30 ` Namhyung Kim
2017-11-10 7:56 ` zhangmengting
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).