Lines Matching refs:top
76 static void perf_top__update_print_entries(struct perf_top *top) in perf_top__update_print_entries() argument
78 top->print_entries = top->winsize.ws_row - HEADER_LINE_NR; in perf_top__update_print_entries()
84 struct perf_top *top = arg; in perf_top__sig_winch() local
86 get_term_dimensions(&top->winsize); in perf_top__sig_winch()
87 perf_top__update_print_entries(top); in perf_top__sig_winch()
90 static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he) in perf_top__parse_source() argument
133 top->sym_filter_entry = he; in perf_top__parse_source()
173 static void perf_top__record_precise_ip(struct perf_top *top, in perf_top__record_precise_ip() argument
182 ((top->sym_filter_entry == NULL || in perf_top__record_precise_ip()
183 top->sym_filter_entry->ms.sym != he->ms.sym) && use_browser != 1)) in perf_top__record_precise_ip()
216 static void perf_top__show_details(struct perf_top *top) in perf_top__show_details() argument
218 struct hist_entry *he = top->sym_filter_entry; in perf_top__show_details()
234 printf("Showing %s for %s\n", perf_evsel__name(top->sym_evsel), symbol->name); in perf_top__show_details()
235 printf(" Events Pcnt (>=%d%%)\n", top->sym_pcnt_filter); in perf_top__show_details()
237 more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel, in perf_top__show_details()
238 0, top->sym_pcnt_filter, top->print_entries, 4); in perf_top__show_details()
240 if (top->evlist->enabled) { in perf_top__show_details()
241 if (top->zero) in perf_top__show_details()
242 symbol__annotate_zero_histogram(symbol, top->sym_evsel->idx); in perf_top__show_details()
244 symbol__annotate_decay_histogram(symbol, top->sym_evsel->idx); in perf_top__show_details()
252 static void perf_top__print_sym_table(struct perf_top *top) in perf_top__print_sym_table() argument
256 const int win_width = top->winsize.ws_col - 1; in perf_top__print_sym_table()
257 struct hists *hists = evsel__hists(top->sym_evsel); in perf_top__print_sym_table()
261 perf_top__header_snprintf(top, bf, sizeof(bf)); in perf_top__print_sym_table()
264 perf_top__reset_sample_counters(top); in perf_top__print_sym_table()
278 if (top->sym_filter_entry) { in perf_top__print_sym_table()
279 perf_top__show_details(top); in perf_top__print_sym_table()
283 if (top->evlist->enabled) { in perf_top__print_sym_table()
284 if (top->zero) { in perf_top__print_sym_table()
287 hists__decay_entries(hists, top->hide_user_symbols, in perf_top__print_sym_table()
288 top->hide_kernel_symbols); in perf_top__print_sym_table()
295 hists__output_recalc_col_len(hists, top->print_entries - printed); in perf_top__print_sym_table()
297 hists__fprintf(hists, false, top->print_entries - printed, win_width, in perf_top__print_sym_table()
298 top->min_percent, stdout); in perf_top__print_sym_table()
336 static void perf_top__prompt_symbol(struct perf_top *top, const char *msg) in perf_top__prompt_symbol() argument
339 struct hist_entry *syme = top->sym_filter_entry, *n, *found = NULL; in perf_top__prompt_symbol()
340 struct hists *hists = evsel__hists(top->sym_evsel); in perf_top__prompt_symbol()
347 top->sym_filter_entry = NULL; in perf_top__prompt_symbol()
372 perf_top__parse_source(top, found); in perf_top__prompt_symbol()
378 static void perf_top__print_mapped_keys(struct perf_top *top) in perf_top__print_mapped_keys() argument
382 if (top->sym_filter_entry) { in perf_top__print_mapped_keys()
383 struct symbol *sym = top->sym_filter_entry->ms.sym; in perf_top__print_mapped_keys()
388 fprintf(stdout, "\t[d] display refresh delay. \t(%d)\n", top->delay_secs); in perf_top__print_mapped_keys()
389 fprintf(stdout, "\t[e] display entries (lines). \t(%d)\n", top->print_entries); in perf_top__print_mapped_keys()
391 if (top->evlist->nr_entries > 1) in perf_top__print_mapped_keys()
392 …fprintf(stdout, "\t[E] active event counter. \t(%s)\n", perf_evsel__name(top->sym… in perf_top__print_mapped_keys()
394 fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", top->count_filter); in perf_top__print_mapped_keys()
396 fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", top->sym_pcnt_filter); in perf_top__print_mapped_keys()
402 top->hide_kernel_symbols ? "yes" : "no"); in perf_top__print_mapped_keys()
405 top->hide_user_symbols ? "yes" : "no"); in perf_top__print_mapped_keys()
406 fprintf(stdout, "\t[z] toggle sample zeroing. \t(%d)\n", top->zero ? 1 : 0); in perf_top__print_mapped_keys()
410 static int perf_top__key_mapped(struct perf_top *top, int c) in perf_top__key_mapped() argument
426 return top->evlist->nr_entries > 1 ? 1 : 0; in perf_top__key_mapped()
434 static bool perf_top__handle_keypress(struct perf_top *top, int c) in perf_top__handle_keypress() argument
438 if (!perf_top__key_mapped(top, c)) { in perf_top__handle_keypress()
442 perf_top__print_mapped_keys(top); in perf_top__handle_keypress()
452 if (!perf_top__key_mapped(top, c)) in perf_top__handle_keypress()
458 prompt_integer(&top->delay_secs, "Enter display delay"); in perf_top__handle_keypress()
459 if (top->delay_secs < 1) in perf_top__handle_keypress()
460 top->delay_secs = 1; in perf_top__handle_keypress()
463 prompt_integer(&top->print_entries, "Enter display entries (lines)"); in perf_top__handle_keypress()
464 if (top->print_entries == 0) { in perf_top__handle_keypress()
469 perf_top__sig_winch(SIGWINCH, NULL, top); in perf_top__handle_keypress()
476 if (top->evlist->nr_entries > 1) { in perf_top__handle_keypress()
482 evlist__for_each(top->evlist, top->sym_evsel) in perf_top__handle_keypress()
483 fprintf(stderr, "\n\t%d %s", top->sym_evsel->idx, perf_evsel__name(top->sym_evsel)); in perf_top__handle_keypress()
487 if (counter >= top->evlist->nr_entries) { in perf_top__handle_keypress()
488 top->sym_evsel = perf_evlist__first(top->evlist); in perf_top__handle_keypress()
489 fprintf(stderr, "Sorry, no such event, using %s.\n", perf_evsel__name(top->sym_evsel)); in perf_top__handle_keypress()
493 evlist__for_each(top->evlist, top->sym_evsel) in perf_top__handle_keypress()
494 if (top->sym_evsel->idx == counter) in perf_top__handle_keypress()
497 top->sym_evsel = perf_evlist__first(top->evlist); in perf_top__handle_keypress()
500 prompt_integer(&top->count_filter, "Enter display event count filter"); in perf_top__handle_keypress()
503 prompt_percent(&top->sym_pcnt_filter, in perf_top__handle_keypress()
507 top->hide_kernel_symbols = !top->hide_kernel_symbols; in perf_top__handle_keypress()
512 if (top->dump_symtab) in perf_top__handle_keypress()
513 perf_session__fprintf_dsos(top->session, stderr); in perf_top__handle_keypress()
517 perf_top__prompt_symbol(top, "Enter details symbol"); in perf_top__handle_keypress()
520 if (!top->sym_filter_entry) in perf_top__handle_keypress()
523 struct hist_entry *syme = top->sym_filter_entry; in perf_top__handle_keypress()
525 top->sym_filter_entry = NULL; in perf_top__handle_keypress()
530 top->hide_user_symbols = !top->hide_user_symbols; in perf_top__handle_keypress()
533 top->zero = !top->zero; in perf_top__handle_keypress()
570 struct perf_top *top = arg; in display_thread_tui() local
574 .arg = top, in display_thread_tui()
575 .refresh = top->delay_secs, in display_thread_tui()
578 perf_top__sort_new_samples(top); in display_thread_tui()
585 evlist__for_each(top->evlist, pos) { in display_thread_tui()
587 hists->uid_filter_str = top->record_opts.target.uid_str; in display_thread_tui()
590 perf_evlist__tui_browse_hists(top->evlist, help, &hbt, in display_thread_tui()
591 top->min_percent, in display_thread_tui()
592 &top->session->header.env); in display_thread_tui()
616 struct perf_top *top = arg; in display_thread() local
622 delay_msecs = top->delay_secs * 1000; in display_thread()
628 perf_top__print_sym_table(top); in display_thread()
644 if (perf_top__handle_keypress(top, c)) in display_thread()
686 struct perf_top *top = arg; in hist_iter__top_callback() local
696 perf_top__record_precise_ip(top, he, evsel->idx, ip); in hist_iter__top_callback()
700 !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY)); in hist_iter__top_callback()
710 struct perf_top *top = container_of(tool, struct perf_top, tool); in perf_event__process_sample() local
730 top->session->evlist->stats.nr_unprocessable_samples++); in perf_event__process_sample()
735 top->exact_samples++; in perf_event__process_sample()
740 if (!top->kptr_restrict_warned && in perf_event__process_sample()
751 top->kptr_restrict_warned = true; in perf_event__process_sample()
767 if (!top->kptr_restrict_warned && !top->vmlinux_warned && in perf_event__process_sample()
782 top->vmlinux_warned = true; in perf_event__process_sample()
801 err = hist_entry_iter__add(&iter, &al, top->max_stack, top); in perf_event__process_sample()
811 static void perf_top__mmap_read_idx(struct perf_top *top, int idx) in perf_top__mmap_read_idx() argument
815 struct perf_session *session = top->session; in perf_top__mmap_read_idx()
821 while ((event = perf_evlist__mmap_read(top->evlist, idx)) != NULL) { in perf_top__mmap_read_idx()
822 ret = perf_evlist__parse_sample(top->evlist, event, &sample); in perf_top__mmap_read_idx()
834 ++top->samples; in perf_top__mmap_read_idx()
838 ++top->us_samples; in perf_top__mmap_read_idx()
839 if (top->hide_user_symbols) in perf_top__mmap_read_idx()
844 ++top->kernel_samples; in perf_top__mmap_read_idx()
845 if (top->hide_kernel_symbols) in perf_top__mmap_read_idx()
850 ++top->guest_kernel_samples; in perf_top__mmap_read_idx()
855 ++top->guest_us_samples; in perf_top__mmap_read_idx()
870 perf_event__process_sample(&top->tool, event, evsel, in perf_top__mmap_read_idx()
878 perf_evlist__mmap_consume(top->evlist, idx); in perf_top__mmap_read_idx()
882 static void perf_top__mmap_read(struct perf_top *top) in perf_top__mmap_read() argument
886 for (i = 0; i < top->evlist->nr_mmaps; i++) in perf_top__mmap_read()
887 perf_top__mmap_read_idx(top, i); in perf_top__mmap_read()
890 static int perf_top__start_counters(struct perf_top *top) in perf_top__start_counters() argument
894 struct perf_evlist *evlist = top->evlist; in perf_top__start_counters()
895 struct record_opts *opts = &top->record_opts; in perf_top__start_counters()
901 if (perf_evsel__open(counter, top->evlist->cpus, in perf_top__start_counters()
902 top->evlist->threads) < 0) { in perf_top__start_counters()
928 static int perf_top__setup_sample_type(struct perf_top *top __maybe_unused) in perf_top__setup_sample_type()
945 static int __cmd_top(struct perf_top *top) in __cmd_top() argument
947 struct record_opts *opts = &top->record_opts; in __cmd_top()
951 top->session = perf_session__new(NULL, false, NULL); in __cmd_top()
952 if (top->session == NULL) in __cmd_top()
955 machines__set_symbol_filter(&top->session->machines, symbol_filter); in __cmd_top()
958 ret = perf_env__lookup_objdump(&top->session->header.env); in __cmd_top()
963 ret = perf_top__setup_sample_type(top); in __cmd_top()
967 if (perf_session__register_idle_thread(top->session) == NULL) in __cmd_top()
970 machine__synthesize_threads(&top->session->machines.host, &opts->target, in __cmd_top()
971 top->evlist->threads, false, opts->proc_map_timeout); in __cmd_top()
979 ret = perf_top__start_counters(top); in __cmd_top()
983 top->session->evlist = top->evlist; in __cmd_top()
984 perf_session__set_id_hdr_size(top->session); in __cmd_top()
995 perf_evlist__enable(top->evlist); in __cmd_top()
998 perf_evlist__poll(top->evlist, 100); in __cmd_top()
1000 perf_top__mmap_read(top); in __cmd_top()
1004 display_thread), top)) { in __cmd_top()
1009 if (top->realtime_prio) { in __cmd_top()
1012 param.sched_priority = top->realtime_prio; in __cmd_top()
1020 u64 hits = top->samples; in __cmd_top()
1022 perf_top__mmap_read(top); in __cmd_top()
1024 if (hits == top->samples) in __cmd_top()
1025 ret = perf_evlist__poll(top->evlist, 100); in __cmd_top()
1032 perf_session__delete(top->session); in __cmd_top()
1033 top->session = NULL; in __cmd_top()
1090 struct perf_top *top = opt->value; in parse_percent_limit() local
1092 top->min_percent = strtof(arg, NULL); in parse_percent_limit()
1102 struct perf_top top = { in cmd_top() local
1118 struct record_opts *opts = &top.record_opts; in cmd_top()
1121 OPT_CALLBACK('e', "event", &top.evlist, "event", in cmd_top()
1137 OPT_BOOLEAN('K', "hide_kernel_symbols", &top.hide_kernel_symbols, in cmd_top()
1142 OPT_INTEGER('r', "realtime", &top.realtime_prio, in cmd_top()
1144 OPT_INTEGER('d', "delay", &top.delay_secs, in cmd_top()
1146 OPT_BOOLEAN('D', "dump-symtab", &top.dump_symtab, in cmd_top()
1148 OPT_INTEGER('f', "count-filter", &top.count_filter, in cmd_top()
1154 OPT_STRING(0, "sym-annotate", &top.sym_filter, "symbol name", in cmd_top()
1156 OPT_BOOLEAN('z', "zero", &top.zero, "zero history across updates"), in cmd_top()
1158 OPT_INTEGER('E', "entries", &top.print_entries, in cmd_top()
1160 OPT_BOOLEAN('U', "hide_user_symbols", &top.hide_user_symbols, in cmd_top()
1162 OPT_BOOLEAN(0, "tui", &top.use_tui, "Use the TUI interface"), in cmd_top()
1163 OPT_BOOLEAN(0, "stdio", &top.use_stdio, "Use the stdio interface"), in cmd_top()
1173 OPT_CALLBACK_NOOPT('g', NULL, &top.record_opts, in cmd_top()
1176 OPT_CALLBACK(0, "call-graph", &top.record_opts, in cmd_top()
1181 OPT_INTEGER(0, "max-stack", &top.max_stack, in cmd_top()
1206 OPT_CALLBACK(0, "percent-limit", &top, "percent", in cmd_top()
1232 top.evlist = perf_evlist__new(); in cmd_top()
1233 if (top.evlist == NULL) in cmd_top()
1236 perf_config(perf_top_config, &top); in cmd_top()
1255 if (top.use_stdio) in cmd_top()
1257 else if (top.use_tui) in cmd_top()
1282 if (perf_evlist__create_maps(top.evlist, target) < 0) in cmd_top()
1285 if (!top.evlist->nr_entries && in cmd_top()
1286 perf_evlist__add_default(top.evlist) < 0) { in cmd_top()
1291 symbol_conf.nr_events = top.evlist->nr_entries; in cmd_top()
1293 if (top.delay_secs < 1) in cmd_top()
1294 top.delay_secs = 1; in cmd_top()
1301 top.sym_evsel = perf_evlist__first(top.evlist); in cmd_top()
1319 get_term_dimensions(&top.winsize); in cmd_top()
1320 if (top.print_entries == 0) { in cmd_top()
1325 perf_top__update_print_entries(&top); in cmd_top()
1329 status = __cmd_top(&top); in cmd_top()
1332 perf_evlist__delete(top.evlist); in cmd_top()