blob: 6d359c9f75ddd73847d54258b622f2746b37c83b [file] [log] [blame]
Ingo Molnarbf9e1872009-06-02 23:37:05 +02001/*
2 * builtin-report.c
3 *
4 * Builtin report command: Analyze the perf.data input file,
5 * look up and read DSOs and symbol information and display
6 * a histogram of results, along various sorting keys.
7 */
Ingo Molnar16f762a2009-05-27 09:10:38 +02008#include "builtin.h"
Ingo Molnar53cb8bc2009-05-26 09:17:18 +02009
Ingo Molnarbf9e1872009-06-02 23:37:05 +020010#include "util/util.h"
11
Arnaldo Carvalho de Melo35a50c82009-05-18 16:24:49 -030012#include "util/list.h"
Ingo Molnara930d2c2009-05-27 09:50:13 +020013#include "util/cache.h"
Arnaldo Carvalho de Melo35a50c82009-05-18 16:24:49 -030014#include "util/rbtree.h"
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030015#include "util/symbol.h"
Arnaldo Carvalho de Meloa0055ae2009-06-01 17:50:19 -030016#include "util/string.h"
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030017
Ingo Molnar53cb8bc2009-05-26 09:17:18 +020018#include "perf.h"
19
20#include "util/parse-options.h"
21#include "util/parse-events.h"
22
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030023#define SHOW_KERNEL 1
24#define SHOW_USER 2
25#define SHOW_HV 4
26
Ingo Molnar23ac9cb2009-05-27 09:33:18 +020027static char const *input_name = "perf.data";
Peter Zijlstra450aaa22009-05-27 20:20:23 +020028static char *vmlinux = NULL;
Peter Zijlstraf70e87d2009-06-02 14:13:24 +020029static char *sort_order = "comm,dso";
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030030static int input;
31static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
32
Ingo Molnar97b07b62009-05-26 18:48:58 +020033static int dump_trace = 0;
Ingo Molnar35029732009-06-03 09:38:58 +020034#define dprintf(x...) do { if (dump_trace) printf(x); } while (0)
35
Ingo Molnar16f762a2009-05-27 09:10:38 +020036static int verbose;
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -030037static int full_paths;
Ingo Molnar97b07b62009-05-26 18:48:58 +020038
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030039static unsigned long page_size;
40static unsigned long mmap_window = 32;
41
Ingo Molnar53cb8bc2009-05-26 09:17:18 +020042const char *perf_event_names[] = {
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030043 [PERF_EVENT_MMAP] = " PERF_EVENT_MMAP",
44 [PERF_EVENT_MUNMAP] = " PERF_EVENT_MUNMAP",
45 [PERF_EVENT_COMM] = " PERF_EVENT_COMM",
46};
47
48struct ip_event {
49 struct perf_event_header header;
50 __u64 ip;
51 __u32 pid, tid;
52};
53struct mmap_event {
54 struct perf_event_header header;
55 __u32 pid, tid;
56 __u64 start;
57 __u64 len;
58 __u64 pgoff;
59 char filename[PATH_MAX];
60};
61struct comm_event {
62 struct perf_event_header header;
63 __u32 pid,tid;
64 char comm[16];
65};
66
67typedef union event_union {
68 struct perf_event_header header;
69 struct ip_event ip;
70 struct mmap_event mmap;
71 struct comm_event comm;
72} event_t;
73
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030074static LIST_HEAD(dsos);
75static struct dso *kernel_dso;
76
77static void dsos__add(struct dso *dso)
78{
79 list_add_tail(&dso->node, &dsos);
80}
81
82static struct dso *dsos__find(const char *name)
83{
84 struct dso *pos;
85
86 list_for_each_entry(pos, &dsos, node)
87 if (strcmp(pos->name, name) == 0)
88 return pos;
89 return NULL;
90}
91
92static struct dso *dsos__findnew(const char *name)
93{
94 struct dso *dso = dsos__find(name);
Peter Zijlstrab7a16ea2009-05-27 13:35:35 +020095 int nr;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030096
Ingo Molnar4593bba2009-06-02 15:34:25 +020097 if (dso)
98 return dso;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030099
Ingo Molnar4593bba2009-06-02 15:34:25 +0200100 dso = dso__new(name, 0);
101 if (!dso)
102 goto out_delete_dso;
Peter Zijlstrab7a16ea2009-05-27 13:35:35 +0200103
Ingo Molnar4593bba2009-06-02 15:34:25 +0200104 nr = dso__load(dso, NULL);
105 if (nr < 0) {
106 fprintf(stderr, "Failed to open: %s\n", name);
107 goto out_delete_dso;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300108 }
Ingo Molnar4593bba2009-06-02 15:34:25 +0200109 if (!nr && verbose) {
110 fprintf(stderr,
111 "No symbols found in: %s, maybe install a debug package?\n",
112 name);
113 }
114
115 dsos__add(dso);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300116
117 return dso;
118
119out_delete_dso:
120 dso__delete(dso);
121 return NULL;
122}
123
Ingo Molnar16f762a2009-05-27 09:10:38 +0200124static void dsos__fprintf(FILE *fp)
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300125{
126 struct dso *pos;
127
128 list_for_each_entry(pos, &dsos, node)
129 dso__fprintf(pos, fp);
130}
131
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200132static int load_kernel(void)
133{
Arnaldo Carvalho de Meloa827c872009-05-28 14:55:19 -0300134 int err;
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200135
Arnaldo Carvalho de Melo0085c952009-05-28 14:55:13 -0300136 kernel_dso = dso__new("[kernel]", 0);
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200137 if (!kernel_dso)
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300138 return -1;
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200139
Arnaldo Carvalho de Melo69ee69f2009-05-28 14:55:26 -0300140 err = dso__load_kernel(kernel_dso, vmlinux, NULL);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300141 if (err) {
142 dso__delete(kernel_dso);
143 kernel_dso = NULL;
144 } else
145 dsos__add(kernel_dso);
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200146
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300147 return err;
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200148}
149
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -0300150static int strcommon(const char *pathname, const char *cwd, int cwdlen)
151{
152 int n = 0;
153
154 while (pathname[n] == cwd[n] && n < cwdlen)
155 ++n;
156
157 return n;
158}
159
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300160struct map {
161 struct list_head node;
162 uint64_t start;
163 uint64_t end;
164 uint64_t pgoff;
165 struct dso *dso;
166};
167
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -0300168static struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen)
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300169{
170 struct map *self = malloc(sizeof(*self));
171
172 if (self != NULL) {
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -0300173 const char *filename = event->filename;
174 char newfilename[PATH_MAX];
175
176 if (cwd) {
177 int n = strcommon(filename, cwd, cwdlen);
178 if (n == cwdlen) {
179 snprintf(newfilename, sizeof(newfilename),
180 ".%s", filename + n);
181 filename = newfilename;
182 }
183 }
184
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300185 self->start = event->start;
186 self->end = event->start + event->len;
187 self->pgoff = event->pgoff;
188
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -0300189 self->dso = dsos__findnew(filename);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300190 if (self->dso == NULL)
191 goto out_delete;
192 }
193 return self;
194out_delete:
195 free(self);
196 return NULL;
197}
198
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300199struct thread;
200
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300201struct thread {
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300202 struct rb_node rb_node;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300203 struct list_head maps;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300204 pid_t pid;
205 char *comm;
206};
207
208static struct thread *thread__new(pid_t pid)
209{
210 struct thread *self = malloc(sizeof(*self));
211
212 if (self != NULL) {
213 self->pid = pid;
Peter Zijlstra82292892009-06-03 12:37:36 +0200214 self->comm = malloc(32);
Ingo Molnar0a520c62009-06-02 23:24:45 +0200215 if (self->comm)
Peter Zijlstra82292892009-06-03 12:37:36 +0200216 snprintf(self->comm, 32, ":%d", self->pid);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300217 INIT_LIST_HEAD(&self->maps);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300218 }
219
220 return self;
221}
222
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300223static int thread__set_comm(struct thread *self, const char *comm)
224{
Peter Zijlstra82292892009-06-03 12:37:36 +0200225 if (self->comm)
226 free(self->comm);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300227 self->comm = strdup(comm);
228 return self->comm ? 0 : -ENOMEM;
229}
230
Ingo Molnar16f762a2009-05-27 09:10:38 +0200231static struct rb_root threads;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300232
233static struct thread *threads__findnew(pid_t pid)
234{
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300235 struct rb_node **p = &threads.rb_node;
236 struct rb_node *parent = NULL;
237 struct thread *th;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300238
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300239 while (*p != NULL) {
240 parent = *p;
241 th = rb_entry(parent, struct thread, rb_node);
242
243 if (th->pid == pid)
244 return th;
245
246 if (pid < th->pid)
247 p = &(*p)->rb_left;
248 else
249 p = &(*p)->rb_right;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300250 }
251
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300252 th = thread__new(pid);
253 if (th != NULL) {
254 rb_link_node(&th->rb_node, parent, p);
255 rb_insert_color(&th->rb_node, &threads);
256 }
257 return th;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300258}
259
260static void thread__insert_map(struct thread *self, struct map *map)
261{
262 list_add_tail(&map->node, &self->maps);
263}
264
265static struct map *thread__find_map(struct thread *self, uint64_t ip)
266{
Ingo Molnar16f762a2009-05-27 09:10:38 +0200267 struct map *pos;
268
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300269 if (self == NULL)
270 return NULL;
271
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300272 list_for_each_entry(pos, &self->maps, node)
273 if (ip >= pos->start && ip <= pos->end)
274 return pos;
275
276 return NULL;
277}
278
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200279/*
280 * histogram, sorted on item, collects counts
281 */
282
283static struct rb_root hist;
284
285struct hist_entry {
286 struct rb_node rb_node;
287
288 struct thread *thread;
289 struct map *map;
290 struct dso *dso;
291 struct symbol *sym;
292 uint64_t ip;
293 char level;
294
295 uint32_t count;
296};
297
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200298/*
299 * configurable sorting bits
300 */
301
302struct sort_entry {
303 struct list_head list;
304
Peter Zijlstraca8cdee2009-05-28 11:08:33 +0200305 char *header;
306
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200307 int64_t (*cmp)(struct hist_entry *, struct hist_entry *);
Peter Zijlstra82292892009-06-03 12:37:36 +0200308 int64_t (*collapse)(struct hist_entry *, struct hist_entry *);
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200309 size_t (*print)(FILE *fp, struct hist_entry *);
310};
311
Peter Zijlstra82292892009-06-03 12:37:36 +0200312/* --sort pid */
313
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200314static int64_t
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200315sort__thread_cmp(struct hist_entry *left, struct hist_entry *right)
316{
317 return right->thread->pid - left->thread->pid;
318}
319
320static size_t
321sort__thread_print(FILE *fp, struct hist_entry *self)
322{
Ingo Molnarcf25c632009-06-02 22:12:14 +0200323 return fprintf(fp, " %16s:%5d", self->thread->comm ?: "", self->thread->pid);
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200324}
325
326static struct sort_entry sort_thread = {
Ingo Molnarcf25c632009-06-02 22:12:14 +0200327 .header = " Command: Pid ",
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200328 .cmp = sort__thread_cmp,
329 .print = sort__thread_print,
330};
331
Peter Zijlstra82292892009-06-03 12:37:36 +0200332/* --sort comm */
333
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200334static int64_t
Peter Zijlstra992444b2009-05-27 20:20:27 +0200335sort__comm_cmp(struct hist_entry *left, struct hist_entry *right)
336{
Peter Zijlstra82292892009-06-03 12:37:36 +0200337 return right->thread->pid - left->thread->pid;
338}
339
340static int64_t
341sort__comm_collapse(struct hist_entry *left, struct hist_entry *right)
342{
Peter Zijlstra992444b2009-05-27 20:20:27 +0200343 char *comm_l = left->thread->comm;
344 char *comm_r = right->thread->comm;
345
346 if (!comm_l || !comm_r) {
347 if (!comm_l && !comm_r)
348 return 0;
349 else if (!comm_l)
350 return -1;
351 else
352 return 1;
353 }
354
355 return strcmp(comm_l, comm_r);
356}
357
358static size_t
359sort__comm_print(FILE *fp, struct hist_entry *self)
360{
Ingo Molnar0a520c62009-06-02 23:24:45 +0200361 return fprintf(fp, " %16s", self->thread->comm);
Peter Zijlstra992444b2009-05-27 20:20:27 +0200362}
363
364static struct sort_entry sort_comm = {
Peter Zijlstra82292892009-06-03 12:37:36 +0200365 .header = " Command",
366 .cmp = sort__comm_cmp,
367 .collapse = sort__comm_collapse,
368 .print = sort__comm_print,
Peter Zijlstra992444b2009-05-27 20:20:27 +0200369};
370
Peter Zijlstra82292892009-06-03 12:37:36 +0200371/* --sort dso */
372
Peter Zijlstra992444b2009-05-27 20:20:27 +0200373static int64_t
Peter Zijlstra55e5ec42009-05-27 20:20:28 +0200374sort__dso_cmp(struct hist_entry *left, struct hist_entry *right)
375{
376 struct dso *dso_l = left->dso;
377 struct dso *dso_r = right->dso;
378
379 if (!dso_l || !dso_r) {
380 if (!dso_l && !dso_r)
381 return 0;
382 else if (!dso_l)
383 return -1;
384 else
385 return 1;
386 }
387
388 return strcmp(dso_l->name, dso_r->name);
389}
390
391static size_t
392sort__dso_print(FILE *fp, struct hist_entry *self)
393{
Ingo Molnar0a520c62009-06-02 23:24:45 +0200394 if (self->dso)
395 return fprintf(fp, " %-25s", self->dso->name);
396
397 return fprintf(fp, " %016llx", (__u64)self->ip);
Peter Zijlstra55e5ec42009-05-27 20:20:28 +0200398}
399
400static struct sort_entry sort_dso = {
Ingo Molnarcf25c632009-06-02 22:12:14 +0200401 .header = " Shared Object ",
Peter Zijlstra55e5ec42009-05-27 20:20:28 +0200402 .cmp = sort__dso_cmp,
403 .print = sort__dso_print,
404};
405
Peter Zijlstra82292892009-06-03 12:37:36 +0200406/* --sort symbol */
407
Peter Zijlstra55e5ec42009-05-27 20:20:28 +0200408static int64_t
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200409sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300410{
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200411 uint64_t ip_l, ip_r;
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200412
413 if (left->sym == right->sym)
414 return 0;
415
416 ip_l = left->sym ? left->sym->start : left->ip;
417 ip_r = right->sym ? right->sym->start : right->ip;
418
419 return (int64_t)(ip_r - ip_l);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300420}
421
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200422static size_t
423sort__sym_print(FILE *fp, struct hist_entry *self)
424{
425 size_t ret = 0;
426
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200427 if (verbose)
Ingo Molnar0a520c62009-06-02 23:24:45 +0200428 ret += fprintf(fp, " %#018llx", (__u64)self->ip);
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200429
Ingo Molnar0a520c62009-06-02 23:24:45 +0200430 if (self->dso)
431 ret += fprintf(fp, " %s: ", self->dso->name);
432 else
433 ret += fprintf(fp, " %#016llx: ", (__u64)self->ip);
434
435 if (self->sym)
436 ret += fprintf(fp, "%s", self->sym->name);
437 else
438 ret += fprintf(fp, "%#016llx", (__u64)self->ip);
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200439
440 return ret;
441}
442
443static struct sort_entry sort_sym = {
Ingo Molnar4593bba2009-06-02 15:34:25 +0200444 .header = " Shared Object: Symbol",
Peter Zijlstraca8cdee2009-05-28 11:08:33 +0200445 .cmp = sort__sym_cmp,
446 .print = sort__sym_print,
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200447};
448
Peter Zijlstra82292892009-06-03 12:37:36 +0200449static int sort__need_collapse = 0;
450
Peter Zijlstra37f440c2009-05-27 20:20:26 +0200451struct sort_dimension {
452 char *name;
453 struct sort_entry *entry;
454 int taken;
455};
456
457static struct sort_dimension sort_dimensions[] = {
458 { .name = "pid", .entry = &sort_thread, },
Peter Zijlstra992444b2009-05-27 20:20:27 +0200459 { .name = "comm", .entry = &sort_comm, },
Peter Zijlstra55e5ec42009-05-27 20:20:28 +0200460 { .name = "dso", .entry = &sort_dso, },
Peter Zijlstra37f440c2009-05-27 20:20:26 +0200461 { .name = "symbol", .entry = &sort_sym, },
462};
463
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200464static LIST_HEAD(hist_entry__sort_list);
465
Peter Zijlstra37f440c2009-05-27 20:20:26 +0200466static int sort_dimension__add(char *tok)
467{
468 int i;
469
470 for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) {
471 struct sort_dimension *sd = &sort_dimensions[i];
472
473 if (sd->taken)
474 continue;
475
Ingo Molnar5352f352009-06-03 10:07:39 +0200476 if (strncasecmp(tok, sd->name, strlen(tok)))
Peter Zijlstra37f440c2009-05-27 20:20:26 +0200477 continue;
478
Peter Zijlstra82292892009-06-03 12:37:36 +0200479 if (sd->entry->collapse)
480 sort__need_collapse = 1;
481
Peter Zijlstra37f440c2009-05-27 20:20:26 +0200482 list_add_tail(&sd->entry->list, &hist_entry__sort_list);
483 sd->taken = 1;
Ingo Molnar5352f352009-06-03 10:07:39 +0200484
Peter Zijlstra37f440c2009-05-27 20:20:26 +0200485 return 0;
486 }
487
488 return -ESRCH;
489}
490
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200491static int64_t
492hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
493{
494 struct sort_entry *se;
495 int64_t cmp = 0;
496
497 list_for_each_entry(se, &hist_entry__sort_list, list) {
498 cmp = se->cmp(left, right);
499 if (cmp)
500 break;
501 }
502
503 return cmp;
504}
505
Peter Zijlstra82292892009-06-03 12:37:36 +0200506static int64_t
507hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
508{
509 struct sort_entry *se;
510 int64_t cmp = 0;
511
512 list_for_each_entry(se, &hist_entry__sort_list, list) {
513 int64_t (*f)(struct hist_entry *, struct hist_entry *);
514
515 f = se->collapse ?: se->cmp;
516
517 cmp = f(left, right);
518 if (cmp)
519 break;
520 }
521
522 return cmp;
523}
524
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200525static size_t
526hist_entry__fprintf(FILE *fp, struct hist_entry *self, uint64_t total_samples)
527{
528 struct sort_entry *se;
529 size_t ret;
530
531 if (total_samples) {
Ingo Molnar2d655372009-05-27 21:36:22 +0200532 ret = fprintf(fp, " %5.2f%%",
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200533 (self->count * 100.0) / total_samples);
534 } else
535 ret = fprintf(fp, "%12d ", self->count);
536
537 list_for_each_entry(se, &hist_entry__sort_list, list)
538 ret += se->print(fp, self);
539
540 ret += fprintf(fp, "\n");
541
542 return ret;
543}
544
545/*
546 * collect histogram counts
547 */
548
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200549static int
550hist_entry__add(struct thread *thread, struct map *map, struct dso *dso,
551 struct symbol *sym, uint64_t ip, char level)
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300552{
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200553 struct rb_node **p = &hist.rb_node;
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300554 struct rb_node *parent = NULL;
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200555 struct hist_entry *he;
556 struct hist_entry entry = {
557 .thread = thread,
558 .map = map,
559 .dso = dso,
560 .sym = sym,
561 .ip = ip,
562 .level = level,
563 .count = 1,
564 };
565 int cmp;
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300566
567 while (*p != NULL) {
568 parent = *p;
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200569 he = rb_entry(parent, struct hist_entry, rb_node);
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300570
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200571 cmp = hist_entry__cmp(&entry, he);
572
573 if (!cmp) {
574 he->count++;
575 return 0;
576 }
577
578 if (cmp < 0)
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300579 p = &(*p)->rb_left;
580 else
581 p = &(*p)->rb_right;
582 }
583
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200584 he = malloc(sizeof(*he));
585 if (!he)
586 return -ENOMEM;
587 *he = entry;
588 rb_link_node(&he->rb_node, parent, p);
589 rb_insert_color(&he->rb_node, &hist);
590
591 return 0;
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300592}
593
Peter Zijlstra82292892009-06-03 12:37:36 +0200594static void hist_entry__free(struct hist_entry *he)
595{
596 free(he);
597}
598
599/*
600 * collapse the histogram
601 */
602
603static struct rb_root collapse_hists;
604
605static void collapse__insert_entry(struct hist_entry *he)
606{
607 struct rb_node **p = &collapse_hists.rb_node;
608 struct rb_node *parent = NULL;
609 struct hist_entry *iter;
610 int64_t cmp;
611
612 while (*p != NULL) {
613 parent = *p;
614 iter = rb_entry(parent, struct hist_entry, rb_node);
615
616 cmp = hist_entry__collapse(iter, he);
617
618 if (!cmp) {
619 iter->count += he->count;
620 hist_entry__free(he);
621 return;
622 }
623
624 if (cmp < 0)
625 p = &(*p)->rb_left;
626 else
627 p = &(*p)->rb_right;
628 }
629
630 rb_link_node(&he->rb_node, parent, p);
631 rb_insert_color(&he->rb_node, &collapse_hists);
632}
633
634static void collapse__resort(void)
635{
636 struct rb_node *next;
637 struct hist_entry *n;
638
639 if (!sort__need_collapse)
640 return;
641
642 next = rb_first(&hist);
643 while (next) {
644 n = rb_entry(next, struct hist_entry, rb_node);
645 next = rb_next(&n->rb_node);
646
647 rb_erase(&n->rb_node, &hist);
648 collapse__insert_entry(n);
649 }
650}
651
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200652/*
653 * reverse the map, sort on count.
654 */
655
656static struct rb_root output_hists;
657
658static void output__insert_entry(struct hist_entry *he)
659{
660 struct rb_node **p = &output_hists.rb_node;
661 struct rb_node *parent = NULL;
662 struct hist_entry *iter;
663
664 while (*p != NULL) {
665 parent = *p;
666 iter = rb_entry(parent, struct hist_entry, rb_node);
667
668 if (he->count > iter->count)
669 p = &(*p)->rb_left;
670 else
671 p = &(*p)->rb_right;
672 }
673
674 rb_link_node(&he->rb_node, parent, p);
675 rb_insert_color(&he->rb_node, &output_hists);
676}
677
678static void output__resort(void)
679{
Peter Zijlstra82292892009-06-03 12:37:36 +0200680 struct rb_node *next;
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200681 struct hist_entry *n;
682
Peter Zijlstra82292892009-06-03 12:37:36 +0200683 if (sort__need_collapse)
684 next = rb_first(&collapse_hists);
685 else
686 next = rb_first(&hist);
687
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200688 while (next) {
689 n = rb_entry(next, struct hist_entry, rb_node);
690 next = rb_next(&n->rb_node);
691
692 rb_erase(&n->rb_node, &hist);
693 output__insert_entry(n);
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300694 }
695}
696
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200697static size_t output__fprintf(FILE *fp, uint64_t total_samples)
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300698{
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200699 struct hist_entry *pos;
Ingo Molnar2d655372009-05-27 21:36:22 +0200700 struct sort_entry *se;
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300701 struct rb_node *nd;
702 size_t ret = 0;
703
Peter Zijlstraca8cdee2009-05-28 11:08:33 +0200704 fprintf(fp, "#\n");
705
706 fprintf(fp, "# Overhead");
707 list_for_each_entry(se, &hist_entry__sort_list, list)
708 fprintf(fp, " %s", se->header);
709 fprintf(fp, "\n");
710
711 fprintf(fp, "# ........");
Ingo Molnar2d655372009-05-27 21:36:22 +0200712 list_for_each_entry(se, &hist_entry__sort_list, list) {
Peter Zijlstraca8cdee2009-05-28 11:08:33 +0200713 int i;
714
Ingo Molnar4593bba2009-06-02 15:34:25 +0200715 fprintf(fp, " ");
716 for (i = 0; i < strlen(se->header)-1; i++)
Peter Zijlstraca8cdee2009-05-28 11:08:33 +0200717 fprintf(fp, ".");
Ingo Molnar2d655372009-05-27 21:36:22 +0200718 }
Peter Zijlstraca8cdee2009-05-28 11:08:33 +0200719 fprintf(fp, "\n");
720
721 fprintf(fp, "#\n");
Ingo Molnar2d655372009-05-27 21:36:22 +0200722
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200723 for (nd = rb_first(&output_hists); nd; nd = rb_next(nd)) {
724 pos = rb_entry(nd, struct hist_entry, rb_node);
725 ret += hist_entry__fprintf(fp, pos, total_samples);
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300726 }
727
728 return ret;
729}
730
Peter Zijlstra436224a2009-06-02 21:02:36 +0200731static void register_idle_thread(void)
732{
733 struct thread *thread = threads__findnew(0);
734
735 if (thread == NULL ||
736 thread__set_comm(thread, "[idle]")) {
737 fprintf(stderr, "problem inserting idle task.\n");
738 exit(-1);
739 }
740}
741
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200742
Ingo Molnar53cb8bc2009-05-26 09:17:18 +0200743static int __cmd_report(void)
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300744{
745 unsigned long offset = 0;
746 unsigned long head = 0;
747 struct stat stat;
748 char *buf;
749 event_t *event;
750 int ret, rc = EXIT_FAILURE;
Peter Zijlstra6142f9e2009-05-26 20:51:47 +0200751 uint32_t size;
Ingo Molnarf49515b2009-05-26 19:03:36 +0200752 unsigned long total = 0, total_mmap = 0, total_comm = 0, total_unknown = 0;
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -0300753 char cwd[PATH_MAX], *cwdp = cwd;
754 int cwdlen;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300755
Peter Zijlstra436224a2009-06-02 21:02:36 +0200756 register_idle_thread();
757
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300758 input = open(input_name, O_RDONLY);
759 if (input < 0) {
760 perror("failed to open file");
761 exit(-1);
762 }
763
764 ret = fstat(input, &stat);
765 if (ret < 0) {
766 perror("failed to stat file");
767 exit(-1);
768 }
769
770 if (!stat.st_size) {
771 fprintf(stderr, "zero-sized file, nothing to do!\n");
772 exit(0);
773 }
774
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200775 if (load_kernel() < 0) {
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300776 perror("failed to load kernel symbols");
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300777 return EXIT_FAILURE;
778 }
779
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -0300780 if (!full_paths) {
781 if (getcwd(cwd, sizeof(cwd)) == NULL) {
782 perror("failed to get the current directory");
783 return EXIT_FAILURE;
784 }
785 cwdlen = strlen(cwd);
Mike Galbraith10a28252009-06-02 11:04:44 +0200786 } else {
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -0300787 cwdp = NULL;
Mike Galbraith10a28252009-06-02 11:04:44 +0200788 cwdlen = 0;
789 }
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300790remap:
791 buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ,
792 MAP_SHARED, input, offset);
793 if (buf == MAP_FAILED) {
794 perror("failed to mmap file");
795 exit(-1);
796 }
797
798more:
799 event = (event_t *)(buf + head);
800
Peter Zijlstra6142f9e2009-05-26 20:51:47 +0200801 size = event->header.size;
802 if (!size)
803 size = 8;
804
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300805 if (head + event->header.size >= page_size * mmap_window) {
806 unsigned long shift = page_size * (head / page_size);
807 int ret;
808
809 ret = munmap(buf, page_size * mmap_window);
810 assert(ret == 0);
811
812 offset += shift;
813 head -= shift;
814 goto remap;
815 }
816
Peter Zijlstra6142f9e2009-05-26 20:51:47 +0200817 size = event->header.size;
818 if (!size)
819 goto broken_event;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300820
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300821 if (event->header.misc & PERF_EVENT_MISC_OVERFLOW) {
822 char level;
823 int show = 0;
824 struct dso *dso = NULL;
825 struct thread *thread = threads__findnew(event->ip.pid);
Peter Zijlstraf17e04a2009-05-26 15:30:22 +0200826 uint64_t ip = event->ip.ip;
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200827 struct map *map = NULL;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300828
Ingo Molnar35029732009-06-03 09:38:58 +0200829 dprintf("%p [%p]: PERF_EVENT (IP, %d): %d: %p\n",
830 (void *)(offset + head),
831 (void *)(long)(event->header.size),
832 event->header.misc,
833 event->ip.pid,
834 (void *)(long)ip);
Ingo Molnar97b07b62009-05-26 18:48:58 +0200835
Ingo Molnared966aa2009-06-03 10:39:26 +0200836 dprintf(" ... thread: %s:%d\n", thread->comm, thread->pid);
837
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300838 if (thread == NULL) {
Ingo Molnar55717312009-05-27 22:13:17 +0200839 fprintf(stderr, "problem processing %d event, skipping it.\n",
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300840 event->header.type);
Ingo Molnar55717312009-05-27 22:13:17 +0200841 goto broken_event;
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300842 }
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300843
844 if (event->header.misc & PERF_EVENT_MISC_KERNEL) {
845 show = SHOW_KERNEL;
846 level = 'k';
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200847
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300848 dso = kernel_dso;
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200849
Ingo Molnared966aa2009-06-03 10:39:26 +0200850 dprintf(" ...... dso: %s\n", dso->name);
851
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300852 } else if (event->header.misc & PERF_EVENT_MISC_USER) {
Ingo Molnar16f762a2009-05-27 09:10:38 +0200853
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300854 show = SHOW_USER;
855 level = '.';
Ingo Molnar16f762a2009-05-27 09:10:38 +0200856
857 map = thread__find_map(thread, ip);
Peter Zijlstraf17e04a2009-05-26 15:30:22 +0200858 if (map != NULL) {
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300859 dso = map->dso;
Peter Zijlstraf17e04a2009-05-26 15:30:22 +0200860 ip -= map->start + map->pgoff;
Ingo Molnared966aa2009-06-03 10:39:26 +0200861 } else {
862 /*
863 * If this is outside of all known maps,
864 * and is a negative address, try to look it
865 * up in the kernel dso, as it might be a
866 * vsyscall (which executes in user-mode):
867 */
868 if ((long long)ip < 0)
869 dso = kernel_dso;
Peter Zijlstraf17e04a2009-05-26 15:30:22 +0200870 }
Ingo Molnared966aa2009-06-03 10:39:26 +0200871 dprintf(" ...... dso: %s\n", dso ? dso->name : "<not found>");
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200872
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300873 } else {
874 show = SHOW_HV;
875 level = 'H';
Ingo Molnared966aa2009-06-03 10:39:26 +0200876 dprintf(" ...... dso: [hypervisor]\n");
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300877 }
878
879 if (show & show_mask) {
Peter Zijlstraf17e04a2009-05-26 15:30:22 +0200880 struct symbol *sym = dso__find_symbol(dso, ip);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300881
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200882 if (hist_entry__add(thread, map, dso, sym, ip, level)) {
883 fprintf(stderr,
Ingo Molnar55717312009-05-27 22:13:17 +0200884 "problem incrementing symbol count, skipping event\n");
885 goto broken_event;
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300886 }
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300887 }
888 total++;
889 } else switch (event->header.type) {
890 case PERF_EVENT_MMAP: {
891 struct thread *thread = threads__findnew(event->mmap.pid);
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -0300892 struct map *map = map__new(&event->mmap, cwdp, cwdlen);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300893
Ingo Molnar35029732009-06-03 09:38:58 +0200894 dprintf("%p [%p]: PERF_EVENT_MMAP: [%p(%p) @ %p]: %s\n",
895 (void *)(offset + head),
896 (void *)(long)(event->header.size),
897 (void *)(long)event->mmap.start,
898 (void *)(long)event->mmap.len,
899 (void *)(long)event->mmap.pgoff,
900 event->mmap.filename);
901
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300902 if (thread == NULL || map == NULL) {
Ingo Molnar0a520c62009-06-02 23:24:45 +0200903 if (verbose)
904 fprintf(stderr, "problem processing PERF_EVENT_MMAP, skipping event.\n");
Ingo Molnar55717312009-05-27 22:13:17 +0200905 goto broken_event;
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300906 }
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300907 thread__insert_map(thread, map);
Ingo Molnar97b07b62009-05-26 18:48:58 +0200908 total_mmap++;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300909 break;
910 }
911 case PERF_EVENT_COMM: {
912 struct thread *thread = threads__findnew(event->comm.pid);
913
Ingo Molnar35029732009-06-03 09:38:58 +0200914 dprintf("%p [%p]: PERF_EVENT_COMM: %s:%d\n",
915 (void *)(offset + head),
916 (void *)(long)(event->header.size),
917 event->comm.comm, event->comm.pid);
918
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300919 if (thread == NULL ||
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300920 thread__set_comm(thread, event->comm.comm)) {
Ingo Molnar55717312009-05-27 22:13:17 +0200921 fprintf(stderr, "problem processing PERF_EVENT_COMM, skipping event.\n");
922 goto broken_event;
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300923 }
Ingo Molnar97b07b62009-05-26 18:48:58 +0200924 total_comm++;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300925 break;
926 }
Ingo Molnar97b07b62009-05-26 18:48:58 +0200927 default: {
Peter Zijlstra6142f9e2009-05-26 20:51:47 +0200928broken_event:
Ingo Molnar35029732009-06-03 09:38:58 +0200929 dprintf("%p [%p]: skipping unknown header type: %d\n",
930 (void *)(offset + head),
931 (void *)(long)(event->header.size),
932 event->header.type);
Peter Zijlstrab7a16ea2009-05-27 13:35:35 +0200933
Ingo Molnar3e706112009-05-26 18:53:17 +0200934 total_unknown++;
Peter Zijlstra6142f9e2009-05-26 20:51:47 +0200935
936 /*
937 * assume we lost track of the stream, check alignment, and
938 * increment a single u64 in the hope to catch on again 'soon'.
939 */
940
941 if (unlikely(head & 7))
942 head &= ~7ULL;
943
944 size = 8;
Ingo Molnar97b07b62009-05-26 18:48:58 +0200945 }
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300946 }
947
Peter Zijlstra6142f9e2009-05-26 20:51:47 +0200948 head += size;
Ingo Molnarf49515b2009-05-26 19:03:36 +0200949
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300950 if (offset + head < stat.st_size)
951 goto more;
952
953 rc = EXIT_SUCCESS;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300954 close(input);
Ingo Molnar97b07b62009-05-26 18:48:58 +0200955
Ingo Molnar35029732009-06-03 09:38:58 +0200956 dprintf(" IP events: %10ld\n", total);
957 dprintf(" mmap events: %10ld\n", total_mmap);
958 dprintf(" comm events: %10ld\n", total_comm);
959 dprintf(" unknown events: %10ld\n", total_unknown);
Ingo Molnar97b07b62009-05-26 18:48:58 +0200960
Ingo Molnar35029732009-06-03 09:38:58 +0200961 if (dump_trace)
Ingo Molnar97b07b62009-05-26 18:48:58 +0200962 return 0;
Ingo Molnar97b07b62009-05-26 18:48:58 +0200963
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200964 if (verbose >= 2)
Ingo Molnar16f762a2009-05-27 09:10:38 +0200965 dsos__fprintf(stdout);
Ingo Molnar16f762a2009-05-27 09:10:38 +0200966
Peter Zijlstra82292892009-06-03 12:37:36 +0200967 collapse__resort();
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200968 output__resort();
969 output__fprintf(stdout, total);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300970
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300971 return rc;
972}
973
Ingo Molnar53cb8bc2009-05-26 09:17:18 +0200974static const char * const report_usage[] = {
975 "perf report [<options>] <command>",
976 NULL
977};
978
979static const struct option options[] = {
980 OPT_STRING('i', "input", &input_name, "file",
981 "input file name"),
Arnaldo Carvalho de Melo815e7772009-05-26 19:46:14 -0300982 OPT_BOOLEAN('v', "verbose", &verbose,
983 "be more verbose (show symbol address, etc)"),
Ingo Molnar97b07b62009-05-26 18:48:58 +0200984 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
985 "dump raw trace in ASCII"),
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200986 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
Ingo Molnar63299f02009-05-28 10:52:00 +0200987 OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
988 "sort by key(s): pid, comm, dso, symbol. Default: pid,symbol"),
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -0300989 OPT_BOOLEAN('P', "full-paths", &full_paths,
990 "Don't shorten the pathnames taking into account the cwd"),
Ingo Molnar53cb8bc2009-05-26 09:17:18 +0200991 OPT_END()
992};
993
Ingo Molnar5352f352009-06-03 10:07:39 +0200994static void setup_sorting(void)
995{
996 char *tmp, *tok, *str = strdup(sort_order);
997
998 for (tok = strtok_r(str, ", ", &tmp);
999 tok; tok = strtok_r(NULL, ", ", &tmp)) {
1000 if (sort_dimension__add(tok) < 0) {
1001 error("Unknown --sort key: `%s'", tok);
1002 usage_with_options(report_usage, options);
1003 }
1004 }
1005
1006 free(str);
1007}
1008
Ingo Molnar53cb8bc2009-05-26 09:17:18 +02001009int cmd_report(int argc, const char **argv, const char *prefix)
1010{
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -03001011 symbol__init();
Ingo Molnar53cb8bc2009-05-26 09:17:18 +02001012
1013 page_size = getpagesize();
1014
1015 parse_options(argc, argv, options, report_usage, 0);
1016
Peter Zijlstra1aa16732009-05-27 20:20:25 +02001017 setup_sorting();
1018
Ingo Molnara930d2c2009-05-27 09:50:13 +02001019 setup_pager();
1020
Ingo Molnar53cb8bc2009-05-26 09:17:18 +02001021 return __cmd_report();
1022}