All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: "平松雅巳 / HIRAMATU,MASAMI" <masami.hiramatsu.pt@hitachi.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Wang Nan <wangnan0@huawei.com>, Kaixu Xia <xiakaixu@huawei.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Daniel Borkmann <daniel@iogearbox.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	He Kuang <hekuang@huawei.com>,
	"lizefan@huawei.com" <lizefan@huawei.com>,
	Jiri Olsa <jolsa@kernel.org>, David Ahern <dsahern@gmail.com>,
	Brendan Gregg <brendan.d.gregg@gmail.com>,
	"mingo@kernel.org" <mingo@kernel.org>,
	"ast@plumgrid.com" <ast@plumgrid.com>
Subject: Re: [PATCH perf/core ] perf-probe: Output the result of adding/deleting probe in buildin-probe
Date: Fri, 4 Sep 2015 02:25:33 +0900	[thread overview]
Message-ID: <20150903172533.GA4570@danjae.kornet> (raw)
In-Reply-To: <50399556C9727B4D88A595C8584AAB3752508593@GSjpTKYDCembx32.service.hitachi.net>

On Thu, Sep 03, 2015 at 12:18:28PM +0000, 平松雅巳 / HIRAMATU,MASAMI wrote:
> Hi Namhyung,
> 
> So, I hope this would be what you've suggested.
> 
> Thank you,

Hi Masami,

I think something different, but this can be ok.  Anyway, I'll send my
idea soon..

Thanks,
Namhyung


> 
> -- 
> Masami HIRAMATSU
> Linux Technology Research Center, System Productivity Research Dept.
> Center for Technology Innovation - Systems Engineering
> Hitachi, Ltd., Research & Development Group
> E-mail: masami.hiramatsu.pt@hitachi.com
> 
> 
> > -----Original Message-----
> > From: Masami Hiramatsu [mailto:masami.hiramatsu.pt@hitachi.com]
> > Sent: Thursday, September 03, 2015 9:11 PM
> > To: Namhyung Kim; Arnaldo Carvalho de Melo
> > Cc: Wang Nan; Kaixu Xia; Peter Zijlstra; Daniel Borkmann; linux-kernel@vger.kernel.org; He Kuang; lizefan@huawei.com;
> > Jiri Olsa; David Ahern; Brendan Gregg; mingo@kernel.org; ast@plumgrid.com
> > Subject: [PATCH perf/core ] perf-probe: Output the result of adding/deleting probe in buildin-probe
> > 
> > Output the normal result of adding/deleting probe in buildin-probe
> > instead of showing it by add/del_perf_probe_events.
> > All the result string is stored into "result" strbuf parameter.
> > If you want to ignore the result string, pass a NULL to the "result".
> > Note that all warning/debug strings are still in the
> > add/del_perf_probe_events.
> > 
> > Suggested-by: Namhyung Kim <namhyung@gmail.com>
> > Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> > ---
> >  tools/perf/builtin-probe.c    |    9 +++++++--
> >  tools/perf/util/probe-event.c |   33 ++++++++++++++++++++-------------
> >  tools/perf/util/probe-event.h |    6 ++++--
> >  tools/perf/util/probe-file.c  |    5 +++--
> >  tools/perf/util/probe-file.h  |    4 +++-
> >  5 files changed, 37 insertions(+), 20 deletions(-)
> > 
> > diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
> > index b81cec3..d11ad21 100644
> > --- a/tools/perf/builtin-probe.c
> > +++ b/tools/perf/builtin-probe.c
> > @@ -402,6 +402,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
> >  		    "Enable kernel symbol demangling"),
> >  	OPT_END()
> >  	};
> > +	struct strbuf buf = STRBUF_INIT;
> >  	int ret;
> > 
> >  	set_option_flag(options, 'a', "add", PARSE_OPT_EXCLUSIVE);
> > @@ -483,7 +484,9 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
> >  		return ret;
> >  #endif
> >  	case 'd':
> > -		ret = del_perf_probe_events(params.filter);
> > +		ret = del_perf_probe_events(params.filter, &buf);
> > +		/* Even if failed, we should show the result first */
> > +		pr_info("%s", buf.buf);
> >  		if (ret < 0) {
> >  			pr_err_with_code("  Error: Failed to delete events.", ret);
> >  			return ret;
> > @@ -496,7 +499,9 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
> >  			usage_with_options(probe_usage, options);
> >  		}
> > 
> > -		ret = add_perf_probe_events(params.events, params.nevents);
> > +		ret = add_perf_probe_events(params.events, params.nevents, &buf);
> > +		/* Even if failed, we should show the result first */
> > +		pr_info("%s", buf.buf);
> >  		if (ret < 0) {
> >  			pr_err_with_code("  Error: Failed to add events.", ret);
> >  			return ret;
> > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> > index eb5f18b..1a3ed7c 100644
> > --- a/tools/perf/util/probe-event.c
> > +++ b/tools/perf/util/probe-event.c
> > @@ -2395,7 +2395,8 @@ static int probe_trace_event__set_name(struct probe_trace_event *tev,
> > 
> >  static int __add_probe_trace_events(struct perf_probe_event *pev,
> >  				     struct probe_trace_event *tevs,
> > -				     int ntevs, bool allow_suffix)
> > +				     int ntevs, bool allow_suffix,
> > +				     struct strbuf *buf)
> >  {
> >  	int i, fd, ret;
> >  	struct probe_trace_event *tev = NULL;
> > @@ -2415,7 +2416,9 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
> >  	}
> > 
> >  	ret = 0;
> > -	pr_info("Added new event%s\n", (ntevs > 1) ? "s:" : ":");
> > +	if (buf)
> > +		strbuf_addf(buf, "Added new event%s\n",
> > +			    (ntevs > 1) ? "s:" : ":");
> >  	for (i = 0; i < ntevs; i++) {
> >  		tev = &tevs[i];
> >  		/* Skip if the symbol is out of .text or blacklisted */
> > @@ -2432,9 +2435,12 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
> >  		if (ret < 0)
> >  			break;
> > 
> > -		/* We use tev's name for showing new events */
> > -		show_perf_probe_event(tev->group, tev->event, pev,
> > -				      tev->point.module, false);
> > +		if (buf) {
> > +			/* We use tev's name for showing new events */
> > +			perf_probe_event__sprintf(tev->group, tev->event,
> > +						  pev, tev->point.module, buf);
> > +			strbuf_addch(buf, '\n');
> > +		}
> >  		/* Save the last valid name */
> >  		event = tev->event;
> >  		group = tev->group;
> > @@ -2451,10 +2457,10 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
> >  		warn_uprobe_event_compat(tev);
> > 
> >  	/* Note that it is possible to skip all events because of blacklist */
> > -	if (ret >= 0 && event) {
> > +	if (ret >= 0 && event && buf) {
> >  		/* Show how to use the event. */
> > -		pr_info("\nYou can now use it in all perf tools, such as:\n\n");
> > -		pr_info("\tperf record -e %s:%s -aR sleep 1\n\n", group, event);
> > +		strbuf_addf(buf, "\nYou can now use it in all perf tools, such as:\n\n");
> > +		strbuf_addf(buf, "\tperf record -e %s:%s -aR sleep 1\n\n", group, event);
> >  	}
> > 
> >  	strlist__delete(namelist);
> > @@ -2765,7 +2771,8 @@ struct __event_package {
> >  	int				ntevs;
> >  };
> > 
> > -int add_perf_probe_events(struct perf_probe_event *pevs, int npevs)
> > +int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
> > +			  struct strbuf *result)
> >  {
> >  	int i, j, ret;
> >  	struct __event_package *pkgs;
> > @@ -2802,7 +2809,7 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs)
> >  	for (i = 0; i < npevs; i++) {
> >  		ret = __add_probe_trace_events(pkgs[i].pev, pkgs[i].tevs,
> >  					       pkgs[i].ntevs,
> > -					       probe_conf.force_add);
> > +					       probe_conf.force_add, result);
> >  		if (ret < 0)
> >  			break;
> >  	}
> > @@ -2819,7 +2826,7 @@ end:
> >  	return ret;
> >  }
> > 
> > -int del_perf_probe_events(struct strfilter *filter)
> > +int del_perf_probe_events(struct strfilter *filter, struct strbuf *result)
> >  {
> >  	int ret, ret2, ufd = -1, kfd = -1;
> >  	char *str = strfilter__string(filter);
> > @@ -2834,11 +2841,11 @@ int del_perf_probe_events(struct strfilter *filter)
> >  	if (ret < 0)
> >  		goto out;
> > 
> > -	ret = probe_file__del_events(kfd, filter);
> > +	ret = probe_file__del_events(kfd, filter, result);
> >  	if (ret < 0 && ret != -ENOENT)
> >  		goto error;
> > 
> > -	ret2 = probe_file__del_events(ufd, filter);
> > +	ret2 = probe_file__del_events(ufd, filter, result);
> >  	if (ret2 < 0 && ret2 != -ENOENT) {
> >  		ret = ret2;
> >  		goto error;
> > diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
> > index 6e7ec68..9855dbf 100644
> > --- a/tools/perf/util/probe-event.h
> > +++ b/tools/perf/util/probe-event.h
> > @@ -137,8 +137,10 @@ extern void line_range__clear(struct line_range *lr);
> >  /* Initialize line range */
> >  extern int line_range__init(struct line_range *lr);
> > 
> > -extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs);
> > -extern int del_perf_probe_events(struct strfilter *filter);
> > +extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
> > +				 struct strbuf *result);
> > +extern int del_perf_probe_events(struct strfilter *filter,
> > +				 struct strbuf *result);
> >  extern int show_perf_probe_events(struct strfilter *filter);
> >  extern int show_line_range(struct line_range *lr, const char *module,
> >  			   bool user);
> > diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
> > index bbb2437..e22fa12 100644
> > --- a/tools/perf/util/probe-file.c
> > +++ b/tools/perf/util/probe-file.c
> > @@ -267,7 +267,6 @@ static int __del_trace_probe_event(int fd, struct str_node *ent)
> >  		goto error;
> >  	}
> > 
> > -	pr_info("Removed event: %s\n", ent->s);
> >  	return 0;
> >  error:
> >  	pr_warning("Failed to delete event: %s\n",
> > @@ -275,7 +274,7 @@ error:
> >  	return ret;
> >  }
> > 
> > -int probe_file__del_events(int fd, struct strfilter *filter)
> > +int probe_file__del_events(int fd, struct strfilter *filter, struct strbuf *buf)
> >  {
> >  	struct strlist *namelist;
> >  	struct str_node *ent;
> > @@ -293,6 +292,8 @@ int probe_file__del_events(int fd, struct strfilter *filter)
> >  			ret = __del_trace_probe_event(fd, ent);
> >  			if (ret < 0)
> >  				break;
> > +			if (buf)
> > +				strbuf_addf(buf, "Removed event: %s\n", ent->s);
> >  		}
> >  	}
> >  	strlist__delete(namelist);
> > diff --git a/tools/perf/util/probe-file.h b/tools/perf/util/probe-file.h
> > index ada94a2..ee89ef0 100644
> > --- a/tools/perf/util/probe-file.h
> > +++ b/tools/perf/util/probe-file.h
> > @@ -1,6 +1,7 @@
> >  #ifndef __PROBE_FILE_H
> >  #define __PROBE_FILE_H
> > 
> > +#include "strbuf.h"
> >  #include "strlist.h"
> >  #include "strfilter.h"
> >  #include "probe-event.h"
> > @@ -13,6 +14,7 @@ int probe_file__open_both(int *kfd, int *ufd, int flag);
> >  struct strlist *probe_file__get_namelist(int fd);
> >  struct strlist *probe_file__get_rawlist(int fd);
> >  int probe_file__add_event(int fd, struct probe_trace_event *tev);
> > -int probe_file__del_events(int fd, struct strfilter *filter);
> > +int probe_file__del_events(int fd, struct strfilter *filter,
> > +			   struct strbuf *buf);
> > 
> >  #endif
> > 
> 

  reply	other threads:[~2015-09-03 17:28 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-29  4:21 [GIT PULL 00/31] perf tools: filtering events using eBPF programs Wang Nan
2015-08-29  4:21 ` [PATCH 01/31] bpf tools: New API to get name from a BPF object Wang Nan
2015-08-29  4:21 ` [PATCH 02/31] perf tools: Don't set cmdline_group_boundary if no evsel is collected Wang Nan
2015-08-31 19:20   ` Arnaldo Carvalho de Melo
2015-09-01 10:37     ` Wangnan (F)
2015-09-01 10:38     ` Jiri Olsa
2015-09-01 12:44       ` Wangnan (F)
2015-09-02  2:53   ` [PATCH] perf tools: Don't set leader if parser doesn't collect an evsel Wang Nan
2015-09-02  3:01     ` Wangnan (F)
2015-09-02  5:57     ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-02  6:09       ` Wangnan (F)
     [not found]       ` <1441176553-116129-1-git-send-email-wangnan0@huawei.com>
2015-09-02  6:53         ` [PATCH] perf tools: Don't write to evsel if parser doesn't collect evsel Wangnan (F)
2015-09-02 10:31           ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-02 11:54           ` Jiri Olsa
2015-09-02 12:05             ` pi3orama
2015-09-02 12:46               ` Jiri Olsa
2015-09-02 13:55               ` Arnaldo Carvalho de Melo
2015-09-02 14:04                 ` pi3orama
2015-09-02 14:43                   ` Arnaldo Carvalho de Melo
2015-09-02 22:24                     ` pi3orama
2015-08-29  4:21 ` [PATCH 03/31] perf tools: Introduce dummy evsel Wang Nan
2015-08-31 19:38   ` Arnaldo Carvalho de Melo
2015-09-03  0:11   ` Namhyung Kim
2015-09-03  0:42     ` pi3orama
2015-09-06  5:55   ` [PATCH] perf tools: Allow BPF placeholder dummy events to collect --filter options Wang Nan
2015-09-06  5:56     ` [PATCH] perf tools: Sync setting of real bpf events with placeholder Wang Nan
2015-08-29  4:21 ` [PATCH 04/31] perf tools: Make perf depend on libbpf Wang Nan
2015-08-29  4:21 ` [PATCH 05/31] perf ebpf: Add the libbpf glue Wang Nan
2015-08-29  4:21 ` [PATCH 06/31] perf tools: Enable passing bpf object file to --event Wang Nan
2015-08-29  4:21 ` [PATCH 07/31] perf probe: Attach trace_probe_event with perf_probe_event Wang Nan
2015-09-02  4:32   ` Namhyung Kim
2015-09-02  5:40     ` Wangnan (F)
2015-08-29  4:21 ` [PATCH 08/31] perf record, bpf: Parse and probe eBPF programs probe points Wang Nan
2015-08-29  4:21 ` [PATCH 09/31] perf bpf: Collect 'struct perf_probe_event' for bpf_program Wang Nan
2015-08-29  4:21 ` [PATCH 10/31] perf record: Load all eBPF object into kernel Wang Nan
2015-08-29  4:21 ` [PATCH 11/31] perf tools: Add bpf_fd field to evsel and config it Wang Nan
2015-08-29  4:21 ` [PATCH 12/31] perf tools: Allow filter option to be applied to bof object Wang Nan
2015-08-29  4:21 ` [PATCH 13/31] perf tools: Attach eBPF program to perf event Wang Nan
2015-08-29  4:21 ` [PATCH 14/31] perf tools: Suppress probing messages when probing by BPF loading Wang Nan
2015-09-03  0:20   ` Namhyung Kim
2015-09-03  2:42     ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-03 12:10     ` [PATCH perf/core ] perf-probe: Output the result of adding/deleting probe in buildin-probe Masami Hiramatsu
2015-09-03 12:18       ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-03 17:25         ` Namhyung Kim [this message]
2015-09-03 20:28       ` Arnaldo Carvalho de Melo
2015-09-04  1:30         ` 平松雅巳 / HIRAMATU,MASAMI
2015-08-29  4:21 ` [PATCH 15/31] perf record: Add clang options for compiling BPF scripts Wang Nan
2015-08-29  4:21 ` [PATCH 16/31] perf tools: Infrastructure for compiling scriptlets when passing '.c' to --event Wang Nan
2015-08-29  4:21 ` [PATCH 17/31] perf tests: Enforce LLVM test for BPF test Wang Nan
2015-09-01  5:59   ` Wangnan (F)
2015-08-29  4:21 ` [PATCH 18/31] perf test: Add 'perf test BPF' Wang Nan
2015-09-02 12:45   ` Namhyung Kim
2015-09-05 12:21     ` Wang Nan
2015-08-29  4:21 ` [PATCH 19/31] bpf tools: Load a program with different instances using preprocessor Wang Nan
2015-08-29  4:21 ` [PATCH 20/31] perf probe: Reset args and nargs for probe_trace_event when failure Wang Nan
2015-08-29  4:21 ` [PATCH 21/31] perf tools: Move linux/filter.h to tools/include Wang Nan
2015-08-31 20:35   ` Arnaldo Carvalho de Melo
2015-09-01 19:39   ` Arnaldo Carvalho de Melo
2015-09-01 19:47     ` Arnaldo Carvalho de Melo
2015-09-01 21:08     ` pi3orama
2015-09-01 21:43       ` Arnaldo Carvalho de Melo
2015-09-08 14:31   ` [tip:perf/core] perf tools: Copy " tip-bot for He Kuang
2015-08-29  4:21 ` [PATCH 22/31] perf tools: Add BPF_PROLOGUE config options for further patches Wang Nan
2015-08-31 20:39   ` Arnaldo Carvalho de Melo
2015-09-01  6:59   ` Wang Nan
2015-09-01  6:59     ` [PATCH 23/31] perf tools: Introduce regs_query_register_offset() for x86 Wang Nan
2015-09-01 11:47       ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-01 13:52         ` Wangnan (F)
2015-09-01 14:50           ` Arnaldo Carvalho de Melo
2015-09-01 14:14         ` Arnaldo Carvalho de Melo
2015-09-01 15:54           ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-06  6:02             ` Wangnan (F)
2015-09-06  6:04               ` [PATCH] perf test: Enforce LLVM test, add kbuild test Wang Nan
2015-09-06  6:04                 ` [PATCH] perf test: Test BPF prologue Wang Nan
2015-09-02 14:08     ` [PATCH 22/31] perf tools: Add BPF_PROLOGUE config options for further patches Namhyung Kim
2015-08-29  4:21 ` [PATCH 23/31] perf tools: Introduce arch_get_reg_info() for x86 Wang Nan
2015-08-31 20:43   ` Arnaldo Carvalho de Melo
2015-09-01  2:39     ` Wangnan (F)
2015-08-29  4:21 ` [PATCH 24/31] perf tools: Add prologue for BPF programs for fetching arguments Wang Nan
2015-08-29  4:21 ` [PATCH 25/31] perf tools: Generate prologue for BPF programs Wang Nan
2015-08-29  4:22 ` [PATCH 26/31] perf tools: Use same BPF program if arguments are identical Wang Nan
2015-08-29  4:22 ` [PATCH 27/31] perf record: Support custom vmlinux path Wang Nan
2015-09-01 20:19   ` Arnaldo Carvalho de Melo
2015-09-01 20:21     ` Arnaldo Carvalho de Melo
2015-09-01 21:00       ` pi3orama
2015-09-01 21:33         ` Arnaldo Carvalho de Melo
2015-08-29  4:22 ` [PATCH 28/31] perf probe: Init symbol as kprobe Wang Nan
2015-09-01 20:11   ` Arnaldo Carvalho de Melo
2015-09-02  1:22     ` Wangnan (F)
2015-09-02  1:38     ` 平松雅巳 / HIRAMATU,MASAMI
2015-08-29  4:22 ` [PATCH 29/31] perf tools: Support attach BPF program on uprobe events Wang Nan
2015-08-29  4:22 ` [PATCH 30/31] perf tools: Fix cross compiling error Wang Nan
2015-08-29  4:22 ` [PATCH 31/31] tools lib traceevent: Support function __get_dynamic_array_len Wang Nan
2015-09-08 14:31   ` [tip:perf/core] " tip-bot for He Kuang

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=20150903172533.GA4570@danjae.kornet \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=ast@plumgrid.com \
    --cc=brendan.d.gregg@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=dsahern@gmail.com \
    --cc=hekuang@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@kernel.org \
    --cc=wangnan0@huawei.com \
    --cc=xiakaixu@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.