diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-07 09:56:43 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-07 22:44:20 -0400 |
commit | 22ad798c37cb554afae79a72c1d420ecb4d27b86 (patch) | |
tree | a9d3660433ab8daa6b99955218e8c73e52d67fde /tools/perf/builtin-kmem.c | |
parent | fcf65bf149afa91b875ffde4455967cb63ee0be9 (diff) |
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>
Diffstat (limited to 'tools/perf/builtin-kmem.c')
-rw-r--r-- | tools/perf/builtin-kmem.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index ffb93f424953..fc6607b383f2 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
@@ -192,16 +192,15 @@ static void insert_caller_stat(unsigned long call_site, | |||
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | static void process_alloc_event(void *data, | 195 | static void perf_evsel__process_alloc_event(struct perf_evsel *evsel, |
196 | struct event_format *event, | 196 | struct perf_sample *sample, |
197 | int cpu, | 197 | int node) |
198 | u64 timestamp __used, | ||
199 | struct thread *thread __used, | ||
200 | int node) | ||
201 | { | 198 | { |
199 | struct event_format *event = evsel->tp_format; | ||
200 | void *data = sample->raw_data; | ||
202 | unsigned long call_site; | 201 | unsigned long call_site; |
203 | unsigned long ptr; | 202 | unsigned long ptr; |
204 | int bytes_req; | 203 | int bytes_req, cpu = sample->cpu; |
205 | int bytes_alloc; | 204 | int bytes_alloc; |
206 | int node1, node2; | 205 | int node1, node2; |
207 | 206 | ||
@@ -253,22 +252,18 @@ static struct alloc_stat *search_alloc_stat(unsigned long ptr, | |||
253 | return NULL; | 252 | return NULL; |
254 | } | 253 | } |
255 | 254 | ||
256 | static void process_free_event(void *data, | 255 | static void perf_evsel__process_free_event(struct perf_evsel *evsel, |
257 | struct event_format *event, | 256 | struct perf_sample *sample) |
258 | int cpu, | ||
259 | u64 timestamp __used, | ||
260 | struct thread *thread __used) | ||
261 | { | 257 | { |
262 | unsigned long ptr; | 258 | unsigned long ptr = raw_field_value(evsel->tp_format, "ptr", |
259 | sample->raw_data); | ||
263 | struct alloc_stat *s_alloc, *s_caller; | 260 | struct alloc_stat *s_alloc, *s_caller; |
264 | 261 | ||
265 | ptr = raw_field_value(event, "ptr", data); | ||
266 | |||
267 | s_alloc = search_alloc_stat(ptr, 0, &root_alloc_stat, ptr_cmp); | 262 | s_alloc = search_alloc_stat(ptr, 0, &root_alloc_stat, ptr_cmp); |
268 | if (!s_alloc) | 263 | if (!s_alloc) |
269 | return; | 264 | return; |
270 | 265 | ||
271 | if (cpu != s_alloc->alloc_cpu) { | 266 | if ((short)sample->cpu != s_alloc->alloc_cpu) { |
272 | s_alloc->pingpong++; | 267 | s_alloc->pingpong++; |
273 | 268 | ||
274 | s_caller = search_alloc_stat(0, s_alloc->call_site, | 269 | s_caller = search_alloc_stat(0, s_alloc->call_site, |
@@ -279,26 +274,26 @@ static void process_free_event(void *data, | |||
279 | s_alloc->alloc_cpu = -1; | 274 | s_alloc->alloc_cpu = -1; |
280 | } | 275 | } |
281 | 276 | ||
282 | static void process_raw_event(struct perf_evsel *evsel, void *data, | 277 | static void perf_evsel__process_kmem_event(struct perf_evsel *evsel, |
283 | int cpu, u64 timestamp, struct thread *thread) | 278 | struct perf_sample *sample) |
284 | { | 279 | { |
285 | struct event_format *event = evsel->tp_format; | 280 | struct event_format *event = evsel->tp_format; |
286 | 281 | ||
287 | if (!strcmp(event->name, "kmalloc") || | 282 | if (!strcmp(event->name, "kmalloc") || |
288 | !strcmp(event->name, "kmem_cache_alloc")) { | 283 | !strcmp(event->name, "kmem_cache_alloc")) { |
289 | process_alloc_event(data, event, cpu, timestamp, thread, 0); | 284 | perf_evsel__process_alloc_event(evsel, sample, 0); |
290 | return; | 285 | return; |
291 | } | 286 | } |
292 | 287 | ||
293 | if (!strcmp(event->name, "kmalloc_node") || | 288 | if (!strcmp(event->name, "kmalloc_node") || |
294 | !strcmp(event->name, "kmem_cache_alloc_node")) { | 289 | !strcmp(event->name, "kmem_cache_alloc_node")) { |
295 | process_alloc_event(data, event, cpu, timestamp, thread, 1); | 290 | perf_evsel__process_alloc_event(evsel, sample, 1); |
296 | return; | 291 | return; |
297 | } | 292 | } |
298 | 293 | ||
299 | if (!strcmp(event->name, "kfree") || | 294 | if (!strcmp(event->name, "kfree") || |
300 | !strcmp(event->name, "kmem_cache_free")) { | 295 | !strcmp(event->name, "kmem_cache_free")) { |
301 | process_free_event(data, event, cpu, timestamp, thread); | 296 | perf_evsel__process_free_event(evsel, sample); |
302 | return; | 297 | return; |
303 | } | 298 | } |
304 | } | 299 | } |
@@ -319,9 +314,7 @@ static int process_sample_event(struct perf_tool *tool __used, | |||
319 | 314 | ||
320 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); | 315 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); |
321 | 316 | ||
322 | process_raw_event(evsel, sample->raw_data, sample->cpu, | 317 | perf_evsel__process_kmem_event(evsel, sample); |
323 | sample->time, thread); | ||
324 | |||
325 | return 0; | 318 | return 0; |
326 | } | 319 | } |
327 | 320 | ||