Commit cdae2d1e authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf script perl: Removing event cache as it's no longer needed

We don't need to maintain cache of 'struct event_format' objects.
Currently the 'struct perf_evsel' holds this reference already.

Adding events_defined bitmap to keep track of defined events, which is
much cheaper than array of pointers.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Acked-by: default avatarNamhyung Kim <namhyung@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1414363445-22370-2-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 416c419c
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <linux/bitmap.h>
#include "../util.h" #include "../util.h"
#include <EXTERN.h> #include <EXTERN.h>
...@@ -57,7 +58,7 @@ INTERP my_perl; ...@@ -57,7 +58,7 @@ INTERP my_perl;
#define FTRACE_MAX_EVENT \ #define FTRACE_MAX_EVENT \
((1 << (sizeof(unsigned short) * 8)) - 1) ((1 << (sizeof(unsigned short) * 8)) - 1)
struct event_format *events[FTRACE_MAX_EVENT]; static DECLARE_BITMAP(events_defined, FTRACE_MAX_EVENT);
extern struct scripting_context *scripting_context; extern struct scripting_context *scripting_context;
...@@ -238,35 +239,15 @@ static void define_event_symbols(struct event_format *event, ...@@ -238,35 +239,15 @@ static void define_event_symbols(struct event_format *event,
define_event_symbols(event, ev_name, args->next); define_event_symbols(event, ev_name, args->next);
} }
static inline struct event_format *find_cache_event(struct perf_evsel *evsel)
{
static char ev_name[256];
struct event_format *event;
int type = evsel->attr.config;
if (events[type])
return events[type];
events[type] = event = evsel->tp_format;
if (!event)
return NULL;
sprintf(ev_name, "%s::%s", event->system, event->name);
define_event_symbols(event, ev_name, event->print_fmt.args);
return event;
}
static void perl_process_tracepoint(struct perf_sample *sample, static void perl_process_tracepoint(struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct thread *thread) struct thread *thread)
{ {
struct event_format *event = evsel->tp_format;
struct format_field *field; struct format_field *field;
static char handler[256]; static char handler[256];
unsigned long long val; unsigned long long val;
unsigned long s, ns; unsigned long s, ns;
struct event_format *event;
int pid; int pid;
int cpu = sample->cpu; int cpu = sample->cpu;
void *data = sample->raw_data; void *data = sample->raw_data;
...@@ -278,7 +259,6 @@ static void perl_process_tracepoint(struct perf_sample *sample, ...@@ -278,7 +259,6 @@ static void perl_process_tracepoint(struct perf_sample *sample,
if (evsel->attr.type != PERF_TYPE_TRACEPOINT) if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
return; return;
event = find_cache_event(evsel);
if (!event) if (!event)
die("ug! no event found for type %" PRIu64, (u64)evsel->attr.config); die("ug! no event found for type %" PRIu64, (u64)evsel->attr.config);
...@@ -286,6 +266,9 @@ static void perl_process_tracepoint(struct perf_sample *sample, ...@@ -286,6 +266,9 @@ static void perl_process_tracepoint(struct perf_sample *sample,
sprintf(handler, "%s::%s", event->system, event->name); sprintf(handler, "%s::%s", event->system, event->name);
if (!test_and_set_bit(event->id, events_defined))
define_event_symbols(event, handler, event->print_fmt.args);
s = nsecs / NSECS_PER_SEC; s = nsecs / NSECS_PER_SEC;
ns = nsecs - s * NSECS_PER_SEC; ns = nsecs - s * NSECS_PER_SEC;
......
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