Skip to content

Commit 485c053

Browse files
committed
Merge tag 'perf-urgent-for-mingo-5.4-20191105' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf fixes from Arnaldo Carvalho de Melo: perf report/top: Jiri Olsa: - Fix time sorting for big numbers, i.e.: perf report -s time -F time,overhead --stdio was failing because the sort comparision routine was returning 'int' while that particular -s key was int64_t, fix it. perf scripting engines: Steven Rostedt (VMware): - Iterate on tep event arrays directly, fixing a bug when generating python/perl source code from a perf.data file with more than one tracepoint event. Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
2 parents 652521d + 722ddfd commit 485c053

File tree

5 files changed

+14
-38
lines changed

5 files changed

+14
-38
lines changed

tools/perf/util/hist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ int hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
16251625
return 0;
16261626
}
16271627

1628-
static int hist_entry__sort(struct hist_entry *a, struct hist_entry *b)
1628+
static int64_t hist_entry__sort(struct hist_entry *a, struct hist_entry *b)
16291629
{
16301630
struct hists *hists = a->hists;
16311631
struct perf_hpp_fmt *fmt;

tools/perf/util/scripting-engines/trace-event-perl.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,11 @@ static int perl_stop_script(void)
539539

540540
static int perl_generate_script(struct tep_handle *pevent, const char *outfile)
541541
{
542+
int i, not_first, count, nr_events;
543+
struct tep_event **all_events;
542544
struct tep_event *event = NULL;
543545
struct tep_format_field *f;
544546
char fname[PATH_MAX];
545-
int not_first, count;
546547
FILE *ofp;
547548

548549
sprintf(fname, "%s.pl", outfile);
@@ -603,8 +604,11 @@ sub print_backtrace\n\
603604
}\n\n\
604605
");
605606

607+
nr_events = tep_get_events_count(pevent);
608+
all_events = tep_list_events(pevent, TEP_EVENT_SORT_ID);
606609

607-
while ((event = trace_find_next_event(pevent, event))) {
610+
for (i = 0; all_events && i < nr_events; i++) {
611+
event = all_events[i];
608612
fprintf(ofp, "sub %s::%s\n{\n", event->system, event->name);
609613
fprintf(ofp, "\tmy (");
610614

tools/perf/util/scripting-engines/trace-event-python.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,10 +1687,11 @@ static int python_stop_script(void)
16871687

16881688
static int python_generate_script(struct tep_handle *pevent, const char *outfile)
16891689
{
1690+
int i, not_first, count, nr_events;
1691+
struct tep_event **all_events;
16901692
struct tep_event *event = NULL;
16911693
struct tep_format_field *f;
16921694
char fname[PATH_MAX];
1693-
int not_first, count;
16941695
FILE *ofp;
16951696

16961697
sprintf(fname, "%s.py", outfile);
@@ -1735,7 +1736,11 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile
17351736
fprintf(ofp, "def trace_end():\n");
17361737
fprintf(ofp, "\tprint(\"in trace_end\")\n\n");
17371738

1738-
while ((event = trace_find_next_event(pevent, event))) {
1739+
nr_events = tep_get_events_count(pevent);
1740+
all_events = tep_list_events(pevent, TEP_EVENT_SORT_ID);
1741+
1742+
for (i = 0; all_events && i < nr_events; i++) {
1743+
event = all_events[i];
17391744
fprintf(ofp, "def %s__%s(", event->system, event->name);
17401745
fprintf(ofp, "event_name, ");
17411746
fprintf(ofp, "context, ");

tools/perf/util/trace-event-parse.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -173,37 +173,6 @@ int parse_event_file(struct tep_handle *pevent,
173173
return tep_parse_event(pevent, buf, size, sys);
174174
}
175175

176-
struct tep_event *trace_find_next_event(struct tep_handle *pevent,
177-
struct tep_event *event)
178-
{
179-
static int idx;
180-
int events_count;
181-
struct tep_event *all_events;
182-
183-
all_events = tep_get_first_event(pevent);
184-
events_count = tep_get_events_count(pevent);
185-
if (!pevent || !all_events || events_count < 1)
186-
return NULL;
187-
188-
if (!event) {
189-
idx = 0;
190-
return all_events;
191-
}
192-
193-
if (idx < events_count && event == (all_events + idx)) {
194-
idx++;
195-
if (idx == events_count)
196-
return NULL;
197-
return (all_events + idx);
198-
}
199-
200-
for (idx = 1; idx < events_count; idx++) {
201-
if (event == (all_events + (idx - 1)))
202-
return (all_events + idx);
203-
}
204-
return NULL;
205-
}
206-
207176
struct flag {
208177
const char *name;
209178
unsigned long long value;

tools/perf/util/trace-event.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int siz
4747

4848
ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe);
4949

50-
struct tep_event *trace_find_next_event(struct tep_handle *pevent,
51-
struct tep_event *event);
5250
unsigned long long read_size(struct tep_event *event, void *ptr, int size);
5351
unsigned long long eval_flag(const char *flag);
5452

0 commit comments

Comments
 (0)