From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755445AbdKJH5o (ORCPT ); Fri, 10 Nov 2017 02:57:44 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:10482 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750793AbdKJH5n (ORCPT ); Fri, 10 Nov 2017 02:57:43 -0500 Subject: Re: [PATCH] perf evsel: Fix incorrect precise_ip in default event name To: Namhyung Kim CC: , , , , , , , References: <1510292946-23686-1-git-send-email-zhangmengting@huawei.com> <20171110063053.GA1544@danjae.aot.lge.com> From: zhangmengting Message-ID: <520952d1-334b-d385-7e64-b8c963e01846@huawei.com> Date: Fri, 10 Nov 2017 15:56:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <20171110063053.GA1544@danjae.aot.lge.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.177.28.139] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090205.5A055BE5.01C4,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d4c654530162f96cdf68e4619cac7f11 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> --- >> 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 > > > . >