From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org,
Ingo Molnar <mingo@kernel.org>, Jiri Olsa <jolsa@redhat.com>,
Namhyung Kim <namhyung@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Tzvetomir Stoyanov <tstoyanov@vmware.com>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH 1/2] perf: Iterate on tep event arrays directly
Date: Thu, 17 Oct 2019 18:24:31 -0300 [thread overview]
Message-ID: <20191017212431.GF3600@kernel.org> (raw)
In-Reply-To: <20191017210636.061448713@goodmis.org>
Em Thu, Oct 17, 2019 at 05:05:22PM -0400, Steven Rostedt escreveu:
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
>
> Instead of calling a useless (and broken) helper function to get the next
> event of a tep event array, just get the array directly and iterate over it.
>
> Note, the broken part was from trace_find_next_event() which after this will
> no longer be used, and can be removed.
>
> Link: http://lkml.kernel.org/r/20191017153733.630cd5eb@gandalf.local.home
I'll add a:
Fixes: bb3dd7e7c4d5 ("tools lib traceevent, perf tools: Move struct tep_handler definition in a local header file")
Cc: stable@vger.kernel.org : v4.20+
As this is when this problem starts causing the segfault when generating
python scripts from perf.data files with multiple tracepoint events, ok?
- Arnaldo
> Reported-by: Daniel Bristot de Oliveira <bristot@redhat.com>
> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
> tools/perf/util/scripting-engines/trace-event-perl.c | 8 ++++++--
> tools/perf/util/scripting-engines/trace-event-python.c | 9 +++++++--
> 2 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
> index 15961854ba67..741f040648b5 100644
> --- a/tools/perf/util/scripting-engines/trace-event-perl.c
> +++ b/tools/perf/util/scripting-engines/trace-event-perl.c
> @@ -539,10 +539,11 @@ static int perl_stop_script(void)
>
> static int perl_generate_script(struct tep_handle *pevent, const char *outfile)
> {
> + int i, not_first, count, nr_events;
> + struct tep_event **all_events;
> struct tep_event *event = NULL;
> struct tep_format_field *f;
> char fname[PATH_MAX];
> - int not_first, count;
> FILE *ofp;
>
> sprintf(fname, "%s.pl", outfile);
> @@ -603,8 +604,11 @@ sub print_backtrace\n\
> }\n\n\
> ");
>
> + nr_events = tep_get_events_count(pevent);
> + all_events = tep_list_events(pevent, TEP_EVENT_SORT_ID);
>
> - while ((event = trace_find_next_event(pevent, event))) {
> + for (i = 0; all_events && i < nr_events; i++) {
> + event = all_events[i];
> fprintf(ofp, "sub %s::%s\n{\n", event->system, event->name);
> fprintf(ofp, "\tmy (");
>
> diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
> index 5d341efc3237..93c03b39cd9c 100644
> --- a/tools/perf/util/scripting-engines/trace-event-python.c
> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> @@ -1687,10 +1687,11 @@ static int python_stop_script(void)
>
> static int python_generate_script(struct tep_handle *pevent, const char *outfile)
> {
> + int i, not_first, count, nr_events;
> + struct tep_event **all_events;
> struct tep_event *event = NULL;
> struct tep_format_field *f;
> char fname[PATH_MAX];
> - int not_first, count;
> FILE *ofp;
>
> sprintf(fname, "%s.py", outfile);
> @@ -1735,7 +1736,11 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile
> fprintf(ofp, "def trace_end():\n");
> fprintf(ofp, "\tprint(\"in trace_end\")\n\n");
>
> - while ((event = trace_find_next_event(pevent, event))) {
> + nr_events = tep_get_events_count(pevent);
> + all_events = tep_list_events(pevent, TEP_EVENT_SORT_ID);
> +
> + for (i = 0; all_events && i < nr_events; i++) {
> + event = all_events[i];
> fprintf(ofp, "def %s__%s(", event->system, event->name);
> fprintf(ofp, "event_name, ");
> fprintf(ofp, "context, ");
> --
> 2.23.0
>
--
- Arnaldo
next prev parent reply other threads:[~2019-10-17 21:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-17 21:05 [PATCH 0/2] perf: Remove trace_find_next_event() Steven Rostedt
2019-10-17 21:05 ` [PATCH 1/2] perf: Iterate on tep event arrays directly Steven Rostedt
2019-10-17 21:24 ` Arnaldo Carvalho de Melo [this message]
2019-10-17 21:28 ` Steven Rostedt
2019-10-17 21:29 ` Arnaldo Carvalho de Melo
2019-10-17 21:05 ` [PATCH 2/2] perf: Remove unused trace_find_next_event() Steven Rostedt
2019-10-21 23:18 ` [tip: perf/core] perf tools: " tip-bot2 for Steven Rostedt (VMware)
2019-11-06 18:14 ` [tip: perf/urgent] " tip-bot2 for Steven Rostedt (VMware)
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=20191017212431.GF3600@kernel.org \
--to=arnaldo.melo@gmail.com \
--cc=acme@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=bristot@redhat.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=rostedt@goodmis.org \
--cc=tstoyanov@vmware.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.