diff mbox

[v2] perf probe: Return errno when does not hit any event

Message ID 1489738592-61011-1-git-send-email-wangkefeng.wang@huawei.com
State Accepted
Commit 70946723eeb859466f026274b29c6196e39149c4
Headers show

Commit Message

Kefeng Wang March 17, 2017, 8:16 a.m. UTC
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 $?
"xxx" does not hit any event.
  Error: Failed to delete events.
254

And it is more appropriate to return -ENOENT instead of -EPERM.

Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>

Fixes: dddc7ee32fa1 ("perf probe: Fix an error when deleting probes successfully")
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

---

v1->v2:
- Using pr_wanring to show warning infos and drop inappropriate comment
  suggested by Masami Hiramatsu.

 tools/perf/builtin-probe.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
1.7.12.4

Comments

Masami Hiramatsu (Google) March 17, 2017, 11:23 p.m. UTC | #1
On Fri, 17 Mar 2017 16:16:32 +0800
Kefeng Wang <wangkefeng.wang@huawei.com> 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 $?

> "xxx" does not hit any event.

>   Error: Failed to delete events.

> 254

> 

> And it is more appropriate to return -ENOENT instead of -EPERM.


Looks good to me.

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>


Thanks!

> 

> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>

> Cc: Masami Hiramatsu <mhiramat@kernel.org>

> Cc: Jiri Olsa <jolsa@kernel.org>

> Cc: Peter Zijlstra <peterz@infradead.org>

> Cc: Wang Nan <wangnan0@huawei.com>

> 

> Fixes: dddc7ee32fa1 ("perf probe: Fix an error when deleting probes successfully")

> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

> ---

> 

> v1->v2:

> - Using pr_wanring to show warning infos and drop inappropriate comment

>   suggested by Masami Hiramatsu.

> 

>  tools/perf/builtin-probe.c | 6 +++---

>  1 file changed, 3 insertions(+), 3 deletions(-)

> 

> diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c

> index 1fcebc3..51cdc23 100644

> --- a/tools/perf/builtin-probe.c

> +++ b/tools/perf/builtin-probe.c

> @@ -442,9 +442,9 @@ 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;

> +		pr_warning("\"%s\" does not hit any event.\n", str);

> +	else

> +		ret = 0;

>  

>  error:

>  	if (kfd >= 0)

> -- 

> 1.7.12.4

> 



-- 
Masami Hiramatsu <mhiramat@kernel.org>
Arnaldo Carvalho de Melo March 21, 2017, 1:46 p.m. UTC | #2
Em Sat, Mar 18, 2017 at 08:23:02AM +0900, Masami Hiramatsu escreveu:
> On Fri, 17 Mar 2017 16:16:32 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote:

> > And it is more appropriate to return -ENOENT instead of -EPERM.

 
> Looks good to me.

 
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>


Thanks, applied.

- Arnaldo
diff mbox

Patch

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 1fcebc3..51cdc23 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -442,9 +442,9 @@  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;
+		pr_warning("\"%s\" does not hit any event.\n", str);
+	else
+		ret = 0;
 
 error:
 	if (kfd >= 0)