2 * Copyright (C) 2008 Eduard - Gabriel Munteanu
4 * This file is released under GPL version 2.
12 #include <kmemtrace.h>
15 unsigned long ev_num
= 1, target_ev
;
17 static int show(struct kmemtrace_event
*ev
, void *extra
)
19 struct kmemtrace_allocstats
*stats
= extra
;
21 if (ev_num
!= target_ev
) {
26 printf("Event %lu:\n", ev_num
);
27 printf("\tevent_id\t%d\n\tkind_id\t\t%d\n\tevent_size\t0x%x\n"
28 "\tcall_site\t%p\n\tptr\t\t%p\n\tseq_num\t%ld\n",
29 ev
->event_id
, ev
->type_id
, (unsigned int) ev
->event_size
,
30 (void *) ev
->call_site
, (void *) ev
->ptr
, (long) ev
->seq_num
);
32 if (ev
->event_id
== KMEMTRACE_EVENT_ALLOC
) {
33 if (ev
->event_size
!= sizeof(struct kmemtrace_event
) +
34 sizeof(struct kmemtrace_allocstats
)) {
35 printf("Size of alloc event is wrong!\n");
38 printf("\n\tbytes_req\t%lu\n\tbytes_alloc\t%lu\n"
39 "\tgfp_flags\t%d\n\tnuma_node\t%d\n",
40 (unsigned long) stats
->bytes_req
,
41 (unsigned long) stats
->bytes_alloc
,
42 (int) stats
->gfp_flags
, (int) stats
->numa_node
);
48 int main(int argc
, char **argv
)
54 panic("There must be two arguments!\n");
56 cpu
= strtoul(argv
[1], NULL
, 10);
57 set
= dataset_open("cpu%lu.out", cpu
);
59 panic("Could not open input file!\n");
61 target_ev
= strtoul(argv
[2], NULL
, 10);
63 if (!dataset_iter(set
, show
))
64 printf("Not found!\n");