Commit b584a176 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf tooling fixes from Thomas Gleixner:

 - Fix the time sorting algorithm which was broken due to truncation of
   big numbers

 - Fix the python script generator fail caused by a broken tracepoint
   array iterator

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf tools: Fix time sorting
  perf tools: Remove unused trace_find_next_event()
  perf scripting engines: Iterate on tep event arrays directly
parents ffba65ea 485c0535
...@@ -1625,7 +1625,7 @@ int hists__collapse_resort(struct hists *hists, struct ui_progress *prog) ...@@ -1625,7 +1625,7 @@ int hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
return 0; return 0;
} }
static int hist_entry__sort(struct hist_entry *a, struct hist_entry *b) static int64_t hist_entry__sort(struct hist_entry *a, struct hist_entry *b)
{ {
struct hists *hists = a->hists; struct hists *hists = a->hists;
struct perf_hpp_fmt *fmt; struct perf_hpp_fmt *fmt;
......
...@@ -539,10 +539,11 @@ static int perl_stop_script(void) ...@@ -539,10 +539,11 @@ static int perl_stop_script(void)
static int perl_generate_script(struct tep_handle *pevent, const char *outfile) 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_event *event = NULL;
struct tep_format_field *f; struct tep_format_field *f;
char fname[PATH_MAX]; char fname[PATH_MAX];
int not_first, count;
FILE *ofp; FILE *ofp;
sprintf(fname, "%s.pl", outfile); sprintf(fname, "%s.pl", outfile);
...@@ -603,8 +604,11 @@ sub print_backtrace\n\ ...@@ -603,8 +604,11 @@ sub print_backtrace\n\
}\n\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, "sub %s::%s\n{\n", event->system, event->name);
fprintf(ofp, "\tmy ("); fprintf(ofp, "\tmy (");
......
...@@ -1687,10 +1687,11 @@ static int python_stop_script(void) ...@@ -1687,10 +1687,11 @@ static int python_stop_script(void)
static int python_generate_script(struct tep_handle *pevent, const char *outfile) 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_event *event = NULL;
struct tep_format_field *f; struct tep_format_field *f;
char fname[PATH_MAX]; char fname[PATH_MAX];
int not_first, count;
FILE *ofp; FILE *ofp;
sprintf(fname, "%s.py", outfile); sprintf(fname, "%s.py", outfile);
...@@ -1735,7 +1736,11 @@ static int python_generate_script(struct tep_handle *pevent, const char *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, "def trace_end():\n");
fprintf(ofp, "\tprint(\"in trace_end\")\n\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, "def %s__%s(", event->system, event->name);
fprintf(ofp, "event_name, "); fprintf(ofp, "event_name, ");
fprintf(ofp, "context, "); fprintf(ofp, "context, ");
......
...@@ -173,37 +173,6 @@ int parse_event_file(struct tep_handle *pevent, ...@@ -173,37 +173,6 @@ int parse_event_file(struct tep_handle *pevent,
return tep_parse_event(pevent, buf, size, sys); return tep_parse_event(pevent, buf, size, sys);
} }
struct tep_event *trace_find_next_event(struct tep_handle *pevent,
struct tep_event *event)
{
static int idx;
int events_count;
struct tep_event *all_events;
all_events = tep_get_first_event(pevent);
events_count = tep_get_events_count(pevent);
if (!pevent || !all_events || events_count < 1)
return NULL;
if (!event) {
idx = 0;
return all_events;
}
if (idx < events_count && event == (all_events + idx)) {
idx++;
if (idx == events_count)
return NULL;
return (all_events + idx);
}
for (idx = 1; idx < events_count; idx++) {
if (event == (all_events + (idx - 1)))
return (all_events + idx);
}
return NULL;
}
struct flag { struct flag {
const char *name; const char *name;
unsigned long long value; unsigned long long value;
......
...@@ -47,8 +47,6 @@ void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int siz ...@@ -47,8 +47,6 @@ void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int siz
ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe); ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe);
struct tep_event *trace_find_next_event(struct tep_handle *pevent,
struct tep_event *event);
unsigned long long read_size(struct tep_event *event, void *ptr, int size); unsigned long long read_size(struct tep_event *event, void *ptr, int size);
unsigned long long eval_flag(const char *flag); unsigned long long eval_flag(const char *flag);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment