blob: fe70a2c92a8e8a8bd467128d792da0e533e4d686 [file] [log] [blame]
Ingo Molnare0143ba2009-03-23 21:29:59 +01001/*
2 * kerneltop.c: show top kernel functions - performance counters showcase
3
4 Build with:
5
6 cc -O6 -Wall `pkg-config --cflags --libs glib-2.0` -o kerneltop kerneltop.c
7
8 Sample output:
9
10------------------------------------------------------------------------------
11 KernelTop: 2669 irqs/sec [NMI, cache-misses/cache-refs], (all, cpu: 2)
12------------------------------------------------------------------------------
13
14 weight RIP kernel function
15 ______ ________________ _______________
16
17 35.20 - ffffffff804ce74b : skb_copy_and_csum_dev
18 33.00 - ffffffff804cb740 : sock_alloc_send_skb
19 31.26 - ffffffff804ce808 : skb_push
20 22.43 - ffffffff80510004 : tcp_established_options
21 19.00 - ffffffff8027d250 : find_get_page
22 15.76 - ffffffff804e4fc9 : eth_type_trans
23 15.20 - ffffffff804d8baa : dst_release
24 14.86 - ffffffff804cf5d8 : skb_release_head_state
25 14.00 - ffffffff802217d5 : read_hpet
26 12.00 - ffffffff804ffb7f : __ip_local_out
27 11.97 - ffffffff804fc0c8 : ip_local_deliver_finish
28 8.54 - ffffffff805001a3 : ip_queue_xmit
29
30 Started by Ingo Molnar <mingo@redhat.com>
31
32 Improvements and fixes by:
33
34 Arjan van de Ven <arjan@linux.intel.com>
35 Yanmin Zhang <yanmin.zhang@intel.com>
36 Mike Galbraith <efault@gmx.de>
37
38 Released under the GPL v2. (and only v2, not any later version)
39
40 */
41#define _GNU_SOURCE
42#include <sys/types.h>
43#include <sys/stat.h>
44#include <sys/time.h>
45#include <unistd.h>
46#include <stdint.h>
47#include <stdlib.h>
48#include <string.h>
49#include <getopt.h>
50#include <assert.h>
51#include <fcntl.h>
52#include <stdio.h>
53#include <errno.h>
54#include <ctype.h>
55#include <time.h>
56
57#include <glib.h>
58
59#include <sys/syscall.h>
60#include <sys/ioctl.h>
61#include <sys/poll.h>
62#include <sys/prctl.h>
63#include <sys/wait.h>
64#include <sys/uio.h>
65
66#include <linux/unistd.h>
67
Wu Fengguangcea92ce2009-03-20 10:08:02 +080068#include "perfcounters.h"
Ingo Molnare0143ba2009-03-23 21:29:59 +010069
70const char *event_types [] = {
71 "CPU cycles",
72 "instructions",
73 "cache-refs",
74 "cache-misses",
75 "branches",
76 "branch-misses",
77 "bus cycles"
78};
79
80const unsigned int default_count[] = {
81 1000000,
82 1000000,
83 10000,
84 10000,
85 1000000,
86 10000,
87};
88
Ingo Molnare0143ba2009-03-23 21:29:59 +010089static int nr_counters = -1;
90
91static __u64 count_filter = 100;
92
Ingo Molnare0143ba2009-03-23 21:29:59 +010093static int event_count[MAX_COUNTERS];
94static unsigned long event_id[MAX_COUNTERS];
95static int event_raw[MAX_COUNTERS];
96
97static int tid = -1;
98static int profile_cpu = -1;
99static int nr_cpus = 0;
100static int nmi = 1;
101static int group = 0;
102
103static char *vmlinux;
104
105static char *sym_filter;
106static unsigned long filter_start;
107static unsigned long filter_end;
108
109static int delay_secs = 2;
110static int zero;
111static int dump_symtab;
112
113struct source_line {
114 uint64_t EIP;
115 unsigned long count;
116 char *line;
117};
118
119static GList *lines;
120
121static void display_help(void)
122{
123 printf(
124 "Usage: kerneltop [<options>]\n\n"
125 "KernelTop Options (up to %d event types can be specified at once):\n\n",
126 MAX_COUNTERS);
127 printf(
128 " -e EID --event_id=EID # event type ID [default: 0]\n"
129 " 0: CPU cycles\n"
130 " 1: instructions\n"
131 " 2: cache accesses\n"
132 " 3: cache misses\n"
133 " 4: branch instructions\n"
134 " 5: branch prediction misses\n"
135 " 6: bus cycles\n\n"
136 " rNNN: raw PMU events (eventsel+umask)\n\n"
137 " -c CNT --count=CNT # event period to sample\n\n"
138 " -C CPU --cpu=CPU # CPU (-1 for all) [default: -1]\n"
139 " -p PID --pid=PID # PID of sampled task (-1 for all) [default: -1]\n\n"
140 " -d delay --delay=<seconds> # sampling/display delay [default: 2]\n"
141 " -f CNT --filter=CNT # min-event-count filter [default: 100]\n\n"
142 " -s symbol --symbol=<symbol> # function to be showed annotated one-shot\n"
143 " -x path --vmlinux=<path> # the vmlinux binary, required for -s use:\n"
144 " -z --zero # zero counts after display\n"
145 " -D --dump_symtab # dump symbol table to stderr on startup\n"
146 "\n");
147
148 exit(0);
149}
150
151static void process_options(int argc, char *argv[])
152{
153 int error = 0, counter;
154
155 for (;;) {
156 int option_index = 0;
157 /** Options for getopt */
158 static struct option long_options[] = {
159 {"count", required_argument, NULL, 'c'},
160 {"cpu", required_argument, NULL, 'C'},
161 {"delay", required_argument, NULL, 'd'},
162 {"dump_symtab", no_argument, NULL, 'D'},
163 {"event_id", required_argument, NULL, 'e'},
164 {"filter", required_argument, NULL, 'f'},
165 {"group", required_argument, NULL, 'g'},
166 {"help", no_argument, NULL, 'h'},
167 {"nmi", required_argument, NULL, 'n'},
168 {"pid", required_argument, NULL, 'p'},
169 {"vmlinux", required_argument, NULL, 'x'},
170 {"symbol", required_argument, NULL, 's'},
171 {"zero", no_argument, NULL, 'z'},
172 {NULL, 0, NULL, 0 }
173 };
174 int c = getopt_long(argc, argv, "c:C:d:De:f:g:hn:p:s:x:z",
175 long_options, &option_index);
176 if (c == -1)
177 break;
178
179 switch (c) {
180 case 'c':
181 if (nr_counters == -1)
182 nr_counters = 0;
183 event_count[nr_counters] = atoi(optarg); break;
184 case 'C':
185 /* CPU and PID are mutually exclusive */
186 if (tid != -1) {
187 printf("WARNING: CPU switch overriding PID\n");
188 sleep(1);
189 tid = -1;
190 }
191 profile_cpu = atoi(optarg); break;
192 case 'd': delay_secs = atoi(optarg); break;
193 case 'D': dump_symtab = 1; break;
194
195 case 'e':
196 nr_counters++;
197 if (nr_counters == MAX_COUNTERS) {
198 error = 1;
199 break;
200 }
201 if (*optarg == 'r') {
202 event_raw[nr_counters] = 1;
203 ++optarg;
204 }
205 event_id[nr_counters] = strtol(optarg, NULL, 16);
206 break;
207
208 case 'f': count_filter = atoi(optarg); break;
209 case 'g': group = atoi(optarg); break;
210 case 'h': display_help(); break;
211 case 'n': nmi = atoi(optarg); break;
212 case 'p':
213 /* CPU and PID are mutually exclusive */
214 if (profile_cpu != -1) {
215 printf("WARNING: PID switch overriding CPU\n");
216 sleep(1);
217 profile_cpu = -1;
218 }
219 tid = atoi(optarg); break;
220 case 's': sym_filter = strdup(optarg); break;
221 case 'x': vmlinux = strdup(optarg); break;
222 case 'z': zero = 1; break;
223 default: error = 1; break;
224 }
225 }
226 if (error)
227 display_help();
228
229 nr_counters++;
230 if (nr_counters < 1)
231 nr_counters = 1;
232
233 for (counter = 0; counter < nr_counters; counter++) {
234 if (event_count[counter])
235 continue;
236
237 if (event_id[counter] < PERF_HW_EVENTS_MAX)
238 event_count[counter] = default_count[event_id[counter]];
239 else
240 event_count[counter] = 100000;
241 }
242}
243
244static uint64_t min_ip;
245static uint64_t max_ip = -1ll;
246
247struct sym_entry {
248 unsigned long long addr;
249 char *sym;
250 unsigned long count[MAX_COUNTERS];
251 int skip;
252 GList *source;
253};
254
255#define MAX_SYMS 100000
256
257static int sym_table_count;
258
259struct sym_entry *sym_filter_entry;
260
261static struct sym_entry sym_table[MAX_SYMS];
262
263static void show_details(struct sym_entry *sym);
264
265/*
266 * Ordering weight: count-1 * count-1 * ... / count-n
267 */
268static double sym_weight(const struct sym_entry *sym)
269{
270 double weight;
271 int counter;
272
273 weight = sym->count[0];
274
275 for (counter = 1; counter < nr_counters-1; counter++)
276 weight *= sym->count[counter];
277
278 weight /= (sym->count[counter] + 1);
279
280 return weight;
281}
282
283static int compare(const void *__sym1, const void *__sym2)
284{
285 const struct sym_entry *sym1 = __sym1, *sym2 = __sym2;
286
287 return sym_weight(sym1) < sym_weight(sym2);
288}
289
290static time_t last_refresh;
291static long events;
292static long userspace_events;
293static const char CONSOLE_CLEAR[] = "";
294
295static struct sym_entry tmp[MAX_SYMS];
296
297static void print_sym_table(void)
298{
299 int i, printed;
300 int counter;
301 float events_per_sec = events/delay_secs;
302 float kevents_per_sec = (events-userspace_events)/delay_secs;
303
304 memcpy(tmp, sym_table, sizeof(sym_table[0])*sym_table_count);
305 qsort(tmp, sym_table_count, sizeof(tmp[0]), compare);
306
307 write(1, CONSOLE_CLEAR, strlen(CONSOLE_CLEAR));
308
309 printf(
310"------------------------------------------------------------------------------\n");
311 printf( " KernelTop:%8.0f irqs/sec kernel:%3.1f%% [%s, ",
312 events_per_sec,
313 100.0 - (100.0*((events_per_sec-kevents_per_sec)/events_per_sec)),
314 nmi ? "NMI" : "IRQ");
315
316 if (nr_counters == 1)
317 printf("%d ", event_count[0]);
318
319 for (counter = 0; counter < nr_counters; counter++) {
320 if (counter)
321 printf("/");
322
323 if (event_id[counter] < PERF_HW_EVENTS_MAX)
324 printf( "%s", event_types[event_id[counter]]);
325 else
326 printf( "raw:%04lx", event_id[counter]);
327 }
328
329 printf( "], ");
330
331 if (tid != -1)
332 printf(" (tid: %d", tid);
333 else
334 printf(" (all");
335
336 if (profile_cpu != -1)
337 printf(", cpu: %d)\n", profile_cpu);
338 else {
339 if (tid != -1)
340 printf(")\n");
341 else
342 printf(", %d CPUs)\n", nr_cpus);
343 }
344
345 printf("------------------------------------------------------------------------------\n\n");
346
347 if (nr_counters == 1)
348 printf(" events");
349 else
350 printf(" weight events");
351
352 printf(" RIP kernel function\n"
353 " ______ ______ ________________ _______________\n\n"
354 );
355
356 printed = 0;
357 for (i = 0; i < sym_table_count; i++) {
358 int count;
359
360 if (nr_counters == 1) {
361 if (printed <= 18 &&
362 tmp[i].count[0] >= count_filter) {
363 printf("%19.2f - %016llx : %s\n",
364 sym_weight(tmp + i), tmp[i].addr, tmp[i].sym);
365 printed++;
366 }
367 } else {
368 if (printed <= 18 &&
369 tmp[i].count[0] >= count_filter) {
370 printf("%8.1f %10ld - %016llx : %s\n",
371 sym_weight(tmp + i),
372 tmp[i].count[0],
373 tmp[i].addr, tmp[i].sym);
374 printed++;
375 }
376 }
377 /*
378 * Add decay to the counts:
379 */
380 for (count = 0; count < nr_counters; count++)
381 sym_table[i].count[count] = zero ? 0 : sym_table[i].count[count] * 7 / 8;
382 }
383
384 if (sym_filter_entry)
385 show_details(sym_filter_entry);
386
387 last_refresh = time(NULL);
388
389 {
390 struct pollfd stdin_poll = { .fd = 0, .events = POLLIN };
391
392 if (poll(&stdin_poll, 1, 0) == 1) {
393 printf("key pressed - exiting.\n");
394 exit(0);
395 }
396 }
397}
398
399static int read_symbol(FILE *in, struct sym_entry *s)
400{
401 static int filter_match = 0;
402 char *sym, stype;
403 char str[500];
404 int rc, pos;
405
406 rc = fscanf(in, "%llx %c %499s", &s->addr, &stype, str);
407 if (rc == EOF)
408 return -1;
409
410 assert(rc == 3);
411
412 /* skip until end of line: */
413 pos = strlen(str);
414 do {
415 rc = fgetc(in);
416 if (rc == '\n' || rc == EOF || pos >= 499)
417 break;
418 str[pos] = rc;
419 pos++;
420 } while (1);
421 str[pos] = 0;
422
423 sym = str;
424
425 /* Filter out known duplicates and non-text symbols. */
426 if (!strcmp(sym, "_text"))
427 return 1;
428 if (!min_ip && !strcmp(sym, "_stext"))
429 return 1;
430 if (!strcmp(sym, "_etext") || !strcmp(sym, "_sinittext"))
431 return 1;
432 if (stype != 'T' && stype != 't')
433 return 1;
434 if (!strncmp("init_module", sym, 11) || !strncmp("cleanup_module", sym, 14))
435 return 1;
436 if (strstr(sym, "_text_start") || strstr(sym, "_text_end"))
437 return 1;
438
439 s->sym = malloc(strlen(str));
440 assert(s->sym);
441
442 strcpy((char *)s->sym, str);
443 s->skip = 0;
444
445 /* Tag events to be skipped. */
446 if (!strcmp("default_idle", s->sym) || !strcmp("cpu_idle", s->sym))
447 s->skip = 1;
448 if (!strcmp("enter_idle", s->sym) || !strcmp("exit_idle", s->sym))
449 s->skip = 1;
450
451 if (filter_match == 1) {
452 filter_end = s->addr;
453 filter_match = -1;
454 if (filter_end - filter_start > 10000) {
455 printf("hm, too large filter symbol <%s> - skipping.\n",
456 sym_filter);
457 printf("symbol filter start: %016lx\n", filter_start);
458 printf(" end: %016lx\n", filter_end);
459 filter_end = filter_start = 0;
460 sym_filter = NULL;
461 sleep(1);
462 }
463 }
464 if (filter_match == 0 && sym_filter && !strcmp(s->sym, sym_filter)) {
465 filter_match = 1;
466 filter_start = s->addr;
467 }
468
469 return 0;
470}
471
472int compare_addr(const void *__sym1, const void *__sym2)
473{
474 const struct sym_entry *sym1 = __sym1, *sym2 = __sym2;
475
476 return sym1->addr > sym2->addr;
477}
478
479static void sort_symbol_table(void)
480{
481 int i, dups;
482
483 do {
484 qsort(sym_table, sym_table_count, sizeof(sym_table[0]), compare_addr);
485 for (i = 0, dups = 0; i < sym_table_count; i++) {
486 if (sym_table[i].addr == sym_table[i+1].addr) {
487 sym_table[i+1].addr = -1ll;
488 dups++;
489 }
490 }
491 sym_table_count -= dups;
492 } while(dups);
493}
494
495static void parse_symbols(void)
496{
497 struct sym_entry *last;
498
499 FILE *kallsyms = fopen("/proc/kallsyms", "r");
500
501 if (!kallsyms) {
502 printf("Could not open /proc/kallsyms - no CONFIG_KALLSYMS_ALL=y?\n");
503 exit(-1);
504 }
505
506 while (!feof(kallsyms)) {
507 if (read_symbol(kallsyms, &sym_table[sym_table_count]) == 0) {
508 sym_table_count++;
509 assert(sym_table_count <= MAX_SYMS);
510 }
511 }
512
513 sort_symbol_table();
514 min_ip = sym_table[0].addr;
515 max_ip = sym_table[sym_table_count-1].addr;
516 last = sym_table + sym_table_count++;
517
518 last->addr = -1ll;
519 last->sym = "<end>";
520
521 if (filter_end) {
522 int count;
523 for (count=0; count < sym_table_count; count ++) {
524 if (!strcmp(sym_table[count].sym, sym_filter)) {
525 sym_filter_entry = &sym_table[count];
526 break;
527 }
528 }
529 }
530 if (dump_symtab) {
531 int i;
532
533 for (i = 0; i < sym_table_count; i++)
534 fprintf(stderr, "%llx %s\n",
535 sym_table[i].addr, sym_table[i].sym);
536 }
537}
538
539
540static void parse_vmlinux(char *filename)
541{
542 FILE *file;
543 char command[PATH_MAX*2];
544 if (!filename)
545 return;
546
547 sprintf(command, "objdump --start-address=0x%016lx --stop-address=0x%016lx -dS %s", filter_start, filter_end, filename);
548
549 file = popen(command, "r");
550 if (!file)
551 return;
552
553 while (!feof(file)) {
554 struct source_line *src;
555 size_t dummy = 0;
556 char *c;
557
558 src = malloc(sizeof(struct source_line));
559 assert(src != NULL);
560 memset(src, 0, sizeof(struct source_line));
561
562 if (getline(&src->line, &dummy, file) < 0)
563 break;
564 if (!src->line)
565 break;
566
567 c = strchr(src->line, '\n');
568 if (c)
569 *c = 0;
570
571 lines = g_list_prepend(lines, src);
572
573 if (strlen(src->line)>8 && src->line[8] == ':')
574 src->EIP = strtoull(src->line, NULL, 16);
575 if (strlen(src->line)>8 && src->line[16] == ':')
576 src->EIP = strtoull(src->line, NULL, 16);
577 }
578 pclose(file);
579 lines = g_list_reverse(lines);
580}
581
582static void record_precise_ip(uint64_t ip)
583{
584 struct source_line *line;
585 GList *item;
586
587 item = g_list_first(lines);
588 while (item) {
589 line = item->data;
590 if (line->EIP == ip)
591 line->count++;
592 if (line->EIP > ip)
593 break;
594 item = g_list_next(item);
595 }
596}
597
598static void lookup_sym_in_vmlinux(struct sym_entry *sym)
599{
600 struct source_line *line;
601 GList *item;
602 char pattern[PATH_MAX];
603 sprintf(pattern, "<%s>:", sym->sym);
604
605 item = g_list_first(lines);
606 while (item) {
607 line = item->data;
608 if (strstr(line->line, pattern)) {
609 sym->source = item;
610 break;
611 }
612 item = g_list_next(item);
613 }
614}
615
616void show_lines(GList *item_queue, int item_queue_count)
617{
618 int i;
619 struct source_line *line;
620
621 for (i = 0; i < item_queue_count; i++) {
622 line = item_queue->data;
623 printf("%8li\t%s\n", line->count, line->line);
624 item_queue = g_list_next(item_queue);
625 }
626}
627
628#define TRACE_COUNT 3
629
630static void show_details(struct sym_entry *sym)
631{
632 struct source_line *line;
633 GList *item;
634 int displayed = 0;
635 GList *item_queue = NULL;
636 int item_queue_count = 0;
637
638 if (!sym->source)
639 lookup_sym_in_vmlinux(sym);
640 if (!sym->source)
641 return;
642
643 printf("Showing details for %s\n", sym->sym);
644
645 item = sym->source;
646 while (item) {
647 line = item->data;
648 if (displayed && strstr(line->line, ">:"))
649 break;
650
651 if (!item_queue_count)
652 item_queue = item;
653 item_queue_count ++;
654
655 if (line->count >= count_filter) {
656 show_lines(item_queue, item_queue_count);
657 item_queue_count = 0;
658 item_queue = NULL;
659 } else if (item_queue_count > TRACE_COUNT) {
660 item_queue = g_list_next(item_queue);
661 item_queue_count --;
662 }
663
664 line->count = 0;
665 displayed++;
666 if (displayed > 300)
667 break;
668 item = g_list_next(item);
669 }
670}
671
672/*
673 * Binary search in the histogram table and record the hit:
674 */
675static void record_ip(uint64_t ip, int counter)
676{
677 int left_idx, middle_idx, right_idx, idx;
678 unsigned long left, middle, right;
679
680 record_precise_ip(ip);
681
682 left_idx = 0;
683 right_idx = sym_table_count-1;
684 assert(ip <= max_ip && ip >= min_ip);
685
686 while (left_idx + 1 < right_idx) {
687 middle_idx = (left_idx + right_idx) / 2;
688
689 left = sym_table[ left_idx].addr;
690 middle = sym_table[middle_idx].addr;
691 right = sym_table[ right_idx].addr;
692
693 if (!(left <= middle && middle <= right)) {
694 printf("%016lx...\n%016lx...\n%016lx\n", left, middle, right);
695 printf("%d %d %d\n", left_idx, middle_idx, right_idx);
696 }
697 assert(left <= middle && middle <= right);
698 if (!(left <= ip && ip <= right)) {
699 printf(" left: %016lx\n", left);
700 printf(" ip: %016lx\n", ip);
701 printf("right: %016lx\n", right);
702 }
703 assert(left <= ip && ip <= right);
704 /*
705 * [ left .... target .... middle .... right ]
706 * => right := middle
707 */
708 if (ip < middle) {
709 right_idx = middle_idx;
710 continue;
711 }
712 /*
713 * [ left .... middle ... target ... right ]
714 * => left := middle
715 */
716 left_idx = middle_idx;
717 }
718
719 idx = left_idx;
720
721 if (!sym_table[idx].skip)
722 sym_table[idx].count[counter]++;
723 else events--;
724}
725
726static void process_event(uint64_t ip, int counter)
727{
728 events++;
729
730 if (ip < min_ip || ip > max_ip) {
731 userspace_events++;
732 return;
733 }
734
735 record_ip(ip, counter);
736}
737
738int main(int argc, char *argv[])
739{
740 struct pollfd event_array[MAX_NR_CPUS][MAX_COUNTERS];
741 struct perf_counter_hw_event hw_event;
742 int fd[MAX_NR_CPUS][MAX_COUNTERS];
743 int i, counter, group_fd;
744 unsigned int cpu;
745 uint64_t ip;
746 ssize_t res;
747 int ret;
748
749 process_options(argc, argv);
750
751 nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
752 if (tid != -1 || profile_cpu != -1)
753 nr_cpus = 1;
754
755 assert(nr_cpus <= MAX_NR_CPUS);
756
757 for (i = 0; i < nr_cpus; i++) {
758 group_fd = -1;
759 for (counter = 0; counter < nr_counters; counter++) {
760
761 cpu = profile_cpu;
762 if (tid == -1 && profile_cpu == -1)
763 cpu = i;
764
765 memset(&hw_event, 0, sizeof(hw_event));
766 hw_event.type = event_id[counter];
767 hw_event.raw = event_raw[counter];
768 hw_event.irq_period = event_count[counter];
769 hw_event.record_type = PERF_RECORD_IRQ;
770 hw_event.nmi = nmi;
771
772 fd[i][counter] = sys_perf_counter_open(&hw_event, tid, cpu, group_fd, 0);
773 fcntl(fd[i][counter], F_SETFL, O_NONBLOCK);
774 if (fd[i][counter] < 0) {
775 printf("kerneltop error: syscall returned with %d (%s)\n",
776 fd[i][counter], strerror(-fd[i][counter]));
777 if (fd[i][counter] == -1)
778 printf("Are you root?\n");
779 exit(-1);
780 }
781 assert(fd[i][counter] >= 0);
782
783 /*
784 * First counter acts as the group leader:
785 */
786 if (group && group_fd == -1)
787 group_fd = fd[i][counter];
788
789 event_array[i][counter].fd = fd[i][counter];
790 event_array[i][counter].events = POLLIN;
791 }
792 }
793
794 parse_symbols();
795 if (vmlinux && sym_filter_entry)
796 parse_vmlinux(vmlinux);
797
798 printf("KernelTop refresh period: %d seconds\n", delay_secs);
799 last_refresh = time(NULL);
800
801 while (1) {
802 int hits = events;
803
804 for (i = 0; i < nr_cpus; i++) {
805 for (counter = 0; counter < nr_counters; counter++) {
806 res = read(fd[i][counter], (char *) &ip, sizeof(ip));
807 if (res > 0) {
808 assert(res == sizeof(ip));
809
810 process_event(ip, counter);
811 }
812 }
813 }
814
815 if (time(NULL) >= last_refresh + delay_secs) {
816 print_sym_table();
817 events = userspace_events = 0;
818 }
819
820 if (hits == events)
821 ret = poll(event_array[0], nr_cpus, 1000);
822 hits = events;
823 }
824
825 return 0;
826}