Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1587912

Re: [PATCH v3 1/2] perf: probe: generalize probe event file open routine

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v3 1/2] perf: probe: generalize probe event file open routine
Date 2017-02-24 21:10 +0100
Message-ID <teulH-5iW-17@gated-at.bofh.it> (permalink)
References <tdXJ7-7Ko-11@gated-at.bofh.it> <tdZUC-Ex-15@gated-at.bofh.it> <tere9-2Ov-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Em Sat, Feb 25, 2017 at 01:46:01AM +0900, Masami Hiramatsu escreveu:
> On Thu, 23 Feb 2017 17:07:23 +0530
> "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:
> 
> > ...into a generic function for opening trace files.
> 
> Even if it repeats subject, please write complete description...
> 
> Patch itself is OK to me.

Did it and added your Acked-by as per your OK above.

- arnaldo
 
> Thanks,
> 
> > 
> > Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> > ---
> >  tools/perf/util/probe-file.c | 20 +++++++++++---------
> >  tools/perf/util/probe-file.h |  1 +
> >  2 files changed, 12 insertions(+), 9 deletions(-)
> > 
> > diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
> > index 436b64731f65..1a62daceb028 100644
> > --- a/tools/perf/util/probe-file.c
> > +++ b/tools/perf/util/probe-file.c
> > @@ -70,7 +70,7 @@ static void print_both_open_warning(int kerr, int uerr)
> >  	}
> >  }
> >  
> > -static int open_probe_events(const char *trace_file, bool readwrite)
> > +int open_trace_file(const char *trace_file, bool readwrite)
> >  {
> >  	char buf[PATH_MAX];
> >  	int ret;
> > @@ -92,12 +92,12 @@ static int open_probe_events(const char *trace_file, bool readwrite)
> >  
> >  static int open_kprobe_events(bool readwrite)
> >  {
> > -	return open_probe_events("kprobe_events", readwrite);
> > +	return open_trace_file("kprobe_events", readwrite);
> >  }
> >  
> >  static int open_uprobe_events(bool readwrite)
> >  {
> > -	return open_probe_events("uprobe_events", readwrite);
> > +	return open_trace_file("uprobe_events", readwrite);
> >  }
> >  
> >  int probe_file__open(int flag)
> > @@ -899,6 +899,7 @@ bool probe_type_is_available(enum probe_type type)
> >  	size_t len = 0;
> >  	bool target_line = false;
> >  	bool ret = probe_type_table[type].avail;
> > +	int fd;
> >  
> >  	if (type >= PROBE_TYPE_END)
> >  		return false;
> > @@ -906,14 +907,16 @@ bool probe_type_is_available(enum probe_type type)
> >  	if (ret || probe_type_table[type].checked)
> >  		return ret;
> >  
> > -	if (asprintf(&buf, "%s/README", tracing_path) < 0)
> > +	fd = open_trace_file("README", false);
> > +	if (fd < 0)
> >  		return ret;
> >  
> > -	fp = fopen(buf, "r");
> > -	if (!fp)
> > -		goto end;
> > +	fp = fdopen(fd, "r");
> > +	if (!fp) {
> > +		close(fd);
> > +		return ret;
> > +	}
> >  
> > -	zfree(&buf);
> >  	while (getline(&buf, &len, fp) > 0 && !ret) {
> >  		if (!target_line) {
> >  			target_line = !!strstr(buf, " type: ");
> > @@ -928,7 +931,6 @@ bool probe_type_is_available(enum probe_type type)
> >  	probe_type_table[type].avail = ret;
> >  
> >  	fclose(fp);
> > -end:
> >  	free(buf);
> >  
> >  	return ret;
> > diff --git a/tools/perf/util/probe-file.h b/tools/perf/util/probe-file.h
> > index eba44c3e9dca..a17a82eff8a0 100644
> > --- a/tools/perf/util/probe-file.h
> > +++ b/tools/perf/util/probe-file.h
> > @@ -35,6 +35,7 @@ enum probe_type {
> >  
> >  /* probe-file.c depends on libelf */
> >  #ifdef HAVE_LIBELF_SUPPORT
> > +int open_trace_file(const char *trace_file, bool readwrite);
> >  int probe_file__open(int flag);
> >  int probe_file__open_both(int *kfd, int *ufd, int flag);
> >  struct strlist *probe_file__get_namelist(int fd);
> > -- 
> > 2.11.1
> > 
> 
> 
> -- 
> Masami Hiramatsu <mhiramat@kernel.org>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 4/5] perf: kretprobes: offset from reloc_sym if kernel supports it "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-22 15:00 +0100
  Re: [PATCH v2 4/5] perf: kretprobes: offset from reloc_sym if  kernel supports it Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-23 10:20 +0100
    [PATCH v3 1/2] perf: probe: generalize probe event file open routine "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-23 12:40 +0100
      [PATCH v3 2/2] perf: kretprobes: offset from reloc_sym if kernel supports it "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-23 12:40 +0100
        Re: [PATCH v3 2/2] perf: kretprobes: offset from reloc_sym if  kernel supports it Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-24 18:30 +0100
      Re: [PATCH v3 1/2] perf: probe: generalize probe event file open  routine Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-24 17:50 +0100
        Re: [PATCH v3 1/2] perf: probe: generalize probe event file open  routine Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-24 21:10 +0100
    Re: [PATCH v2 4/5] perf: kretprobes: offset from reloc_sym if kernel  supports it "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-23 20:20 +0100
      Re: [PATCH v2 4/5] perf: kretprobes: offset from reloc_sym if  kernel supports it Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-24 18:40 +0100
        Re: [PATCH v2 4/5] perf: kretprobes: offset from reloc_sym if kernel  supports it Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-24 21:20 +0100
          Re: [PATCH v2 4/5] perf: kretprobes: offset from reloc_sym if  kernel supports it Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-25 01:00 +0100

csiph-web