From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752088AbdCPMIY (ORCPT ); Thu, 16 Mar 2017 08:08:24 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:3896 "EHLO dggrg02-dlp.huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751353AbdCPMIW (ORCPT ); Thu, 16 Mar 2017 08:08:22 -0400 Subject: Re: [PATCH] perf probe: Return errno when does not hit any event To: Masami Hiramatsu , Arnaldo Carvalho de Melo References: <1488792891-57629-1-git-send-email-wangkefeng.wang@huawei.com> <326abd0a-1dd5-0cf0-245a-78c3b7802515@huawei.com> <20170314133056.GE3089@kernel.org> <20170316183903.559f13536a3e94198ad972be@kernel.org> CC: , Peter Zijlstra , Jiri Olsa , Namhyung Kim , Wang Nan , From: Kefeng Wang Message-ID: <9b267cb2-02cc-0259-0b28-1e9e79164899@huawei.com> Date: Thu, 16 Mar 2017 20:07:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20170316183903.559f13536a3e94198ad972be@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.19.180] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090205.58CA8008.0164,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: 75973d5b7319549396452c0b1f8c2710 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/3/16 17:39, Masami Hiramatsu wrote: > On Tue, 14 Mar 2017 10:30:56 -0300 > Arnaldo Carvalho de Melo wrote: > >> Em Tue, Mar 14, 2017 at 09:19:47PM +0800, Kefeng Wang escreveu: >>> Hi all, any comments, thanks. >> >> For 'perf probe' make sure Masami is in the CC list, adding him, Masami? > > Thanks Arnaldo, > > Hi Kefeng, I've made the error ignored by design, since user might pass > the wildcard pattern to perf probe -d just for making sure. > > You can check the pattern hits any event by using perf-probe --list PATTERN. > Would you have any use case to check the result? There are some perf test cases from our inner tester, they will check the returned value for each execution, and they think return errno is better to cater for users when delete inexistent events, as it was before. And the patch only returns error when does not hit any event. If such behavior, error ignored is more reasonableo< I will push them to modify the test cases. Thanks, Kefeng > > Thank you, > >> >> - Arnaldo >> >>> On 2017/3/7 15:33, Kefeng Wang wrote: >>>> + Arnaldo Carvalho de Melo >>>> >>>> On 2017/3/6 17:34, Kefeng Wang wrote: >>>>> On old perf, when using perf probe -d to delete an inexistent event, >>>>> it return errno, eg, >>>>> >>>>> -bash-4.3# perf probe -d xxx || echo $? >>>>> Info: Event "*:xxx" does not exist. >>>>> Error: Failed to delete events. >>>>> 255 >>>>> >>>>> But now perf_del_probe_events() will always set ret = 0, different >>>>> from previous del_perf_probe_events(). After this, it return errno >>>>> again, eg, >>>>> >>>>> -bash-4.3# ./perf probe -d xxx || echo $? >>>>> Error: Failed to delete events. >>>>> 254 >>>>> >>>>> And it is more appropriate to return -ENOENT instead of -EPERM. >>>>> >>>>> Signed-off-by: Kefeng Wang >>>>> --- >>>>> tools/perf/builtin-probe.c | 3 ++- >>>>> 1 file changed, 2 insertions(+), 1 deletion(-) >>>>> >>>>> diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c >>>>> index 1fcebc3..c46b41c 100644 >>>>> --- a/tools/perf/builtin-probe.c >>>>> +++ b/tools/perf/builtin-probe.c >>>>> @@ -444,7 +444,8 @@ static int perf_del_probe_events(struct strfilter *filter) >>>>> if (ret == -ENOENT && ret2 == -ENOENT) >>>>> pr_debug("\"%s\" does not hit any event.\n", str); >>>>> /* Note that this is silently ignored */ >>>>> - ret = 0; >>>>> + else >>>>> + ret = 0; >>>>> >>>>> error: >>>>> if (kfd >= 0) >>>>> >>>> >>>> >>>> . >>>> > >