perf kmem: Use evsel->tp_format and perf_sample
To reduce the number of parameters passed to the various event handling functions. Cc: Andrey Wagin <avagin@gmail.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-p936ngz06yo5h797ggsm7xru@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
fcf65bf149
commit
22ad798c37
|
@ -192,16 +192,15 @@ static void insert_caller_stat(unsigned long call_site,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_alloc_event(void *data,
|
static void perf_evsel__process_alloc_event(struct perf_evsel *evsel,
|
||||||
struct event_format *event,
|
struct perf_sample *sample,
|
||||||
int cpu,
|
int node)
|
||||||
u64 timestamp __used,
|
|
||||||
struct thread *thread __used,
|
|
||||||
int node)
|
|
||||||
{
|
{
|
||||||
|
struct event_format *event = evsel->tp_format;
|
||||||
|
void *data = sample->raw_data;
|
||||||
unsigned long call_site;
|
unsigned long call_site;
|
||||||
unsigned long ptr;
|
unsigned long ptr;
|
||||||
int bytes_req;
|
int bytes_req, cpu = sample->cpu;
|
||||||
int bytes_alloc;
|
int bytes_alloc;
|
||||||
int node1, node2;
|
int node1, node2;
|
||||||
|
|
||||||
|
@ -253,22 +252,18 @@ static struct alloc_stat *search_alloc_stat(unsigned long ptr,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_free_event(void *data,
|
static void perf_evsel__process_free_event(struct perf_evsel *evsel,
|
||||||
struct event_format *event,
|
struct perf_sample *sample)
|
||||||
int cpu,
|
|
||||||
u64 timestamp __used,
|
|
||||||
struct thread *thread __used)
|
|
||||||
{
|
{
|
||||||
unsigned long ptr;
|
unsigned long ptr = raw_field_value(evsel->tp_format, "ptr",
|
||||||
|
sample->raw_data);
|
||||||
struct alloc_stat *s_alloc, *s_caller;
|
struct alloc_stat *s_alloc, *s_caller;
|
||||||
|
|
||||||
ptr = raw_field_value(event, "ptr", data);
|
|
||||||
|
|
||||||
s_alloc = search_alloc_stat(ptr, 0, &root_alloc_stat, ptr_cmp);
|
s_alloc = search_alloc_stat(ptr, 0, &root_alloc_stat, ptr_cmp);
|
||||||
if (!s_alloc)
|
if (!s_alloc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cpu != s_alloc->alloc_cpu) {
|
if ((short)sample->cpu != s_alloc->alloc_cpu) {
|
||||||
s_alloc->pingpong++;
|
s_alloc->pingpong++;
|
||||||
|
|
||||||
s_caller = search_alloc_stat(0, s_alloc->call_site,
|
s_caller = search_alloc_stat(0, s_alloc->call_site,
|
||||||
|
@ -279,26 +274,26 @@ static void process_free_event(void *data,
|
||||||
s_alloc->alloc_cpu = -1;
|
s_alloc->alloc_cpu = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_raw_event(struct perf_evsel *evsel, void *data,
|
static void perf_evsel__process_kmem_event(struct perf_evsel *evsel,
|
||||||
int cpu, u64 timestamp, struct thread *thread)
|
struct perf_sample *sample)
|
||||||
{
|
{
|
||||||
struct event_format *event = evsel->tp_format;
|
struct event_format *event = evsel->tp_format;
|
||||||
|
|
||||||
if (!strcmp(event->name, "kmalloc") ||
|
if (!strcmp(event->name, "kmalloc") ||
|
||||||
!strcmp(event->name, "kmem_cache_alloc")) {
|
!strcmp(event->name, "kmem_cache_alloc")) {
|
||||||
process_alloc_event(data, event, cpu, timestamp, thread, 0);
|
perf_evsel__process_alloc_event(evsel, sample, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(event->name, "kmalloc_node") ||
|
if (!strcmp(event->name, "kmalloc_node") ||
|
||||||
!strcmp(event->name, "kmem_cache_alloc_node")) {
|
!strcmp(event->name, "kmem_cache_alloc_node")) {
|
||||||
process_alloc_event(data, event, cpu, timestamp, thread, 1);
|
perf_evsel__process_alloc_event(evsel, sample, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(event->name, "kfree") ||
|
if (!strcmp(event->name, "kfree") ||
|
||||||
!strcmp(event->name, "kmem_cache_free")) {
|
!strcmp(event->name, "kmem_cache_free")) {
|
||||||
process_free_event(data, event, cpu, timestamp, thread);
|
perf_evsel__process_free_event(evsel, sample);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,9 +314,7 @@ static int process_sample_event(struct perf_tool *tool __used,
|
||||||
|
|
||||||
dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
|
dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
|
||||||
|
|
||||||
process_raw_event(evsel, sample->raw_data, sample->cpu,
|
perf_evsel__process_kmem_event(evsel, sample);
|
||||||
sample->time, thread);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue