perf top: Collapse and resort all evsels in a group

And link them, i.e. find the hist entries in the non-leader events and
link them to the ones in the leader.

This should be the same thing already done for the 'perf report' case,
but now we do it periodically.

With this in place we get percentages in from the second overhead column
on, not just on the first (the leader).

Try it using:

  perf top --stdio -e '{cycles,instructions}'

You should see something like:

   PerfTop:   20776 irqs/sec  kernel:68.7%  exact:  0.0% lost: 0/0 drop: 0/0 [cycles],  (all, 8 CPUs)
  ---------------------------------------------------------------------------------------------------

     4.44%   0.44%  [kernel]                 [k] do_syscall_64
     2.27%   0.17%  [kernel]                 [k] entry_SYSCALL_64
     1.73%   0.27%  [kernel]                 [k] syscall_return_via_sysret
     1.60%   0.91%  [kernel]                 [k] _raw_spin_lock_irqsave
     1.45%   3.53%  libglib-2.0.so.0.6000.4  [.] g_string_insert_unichar
     1.39%   0.21%  [kernel]                 [k] copy_user_enhanced_fast_string
     1.26%   1.15%  [kernel]                 [k] psi_task_change
     1.16%   0.14%  libpixman-1.so.0.38.0    [.] 0x000000000006f403
     1.00%   0.32%  [kernel]                 [k] __sched_text_start
     0.97%   2.11%  [kernel]                 [k] n_tty_write
     0.96%   0.04%  [kernel]                 [k] queued_spin_lock_slowpath
     0.93%   0.88%  [kernel]                 [k] menu_select
     0.87%   0.14%  [kernel]                 [k] try_to_wake_up
     0.77%   0.10%  libpixman-1.so.0.38.0    [.] 0x000000000006f40b
     0.73%   0.09%  libpixman-1.so.0.38.0    [.] 0x000000000006f413
     0.69%   0.48%  libc-2.29.so             [.] __memmove_avx_unaligned_erms
     0.68%   0.29%  [kernel]                 [k] _raw_spin_lock_irq
     0.61%   0.04%  libpixman-1.so.0.38.0    [.] 0x000000000006f423
     0.60%   0.37%  [kernel]                 [k] native_sched_clock
     0.57%   0.23%  [kernel]                 [k] do_idle
     0.57%   0.23%  [kernel]                 [k] __fget
     0.56%   0.30%  [kernel]                 [k] __switch_to_asm
     0.56%   0.00%  libc-2.29.so             [.] __memset_avx2_erms
     0.52%   0.32%  [kernel]                 [k] _raw_spin_lock
     0.49%   0.24%  [kernel]                 [k] n_tty_poll
     0.49%   0.54%  libglib-2.0.so.0.6000.4  [.] g_mutex_lock
     0.48%   0.62%  [kernel]                 [k] _raw_spin_unlock_irqrestore
     0.47%   0.27%  [kernel]                 [k] __switch_to
     0.47%   0.25%  [kernel]                 [k] pick_next_task_fair
     0.45%   0.17%  [kernel]                 [k] filldir64
     0.40%   0.16%  [kernel]                 [k] update_rq_clock
     0.39%   0.19%  [kernel]                 [k] enqueue_task_fair
  #

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-uw8cjeifxvjpkjp6x2iil0ar@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 5f8b4d5d
...@@ -264,6 +264,30 @@ static void perf_top__show_details(struct perf_top *top) ...@@ -264,6 +264,30 @@ static void perf_top__show_details(struct perf_top *top)
pthread_mutex_unlock(&notes->lock); pthread_mutex_unlock(&notes->lock);
} }
static void evlist__resort_hists(struct evlist *evlist)
{
struct evsel *pos;
evlist__for_each_entry(evlist, pos) {
struct hists *hists = evsel__hists(pos);
hists__collapse_resort(hists, NULL);
/* Non-group events are considered as leader */
if (symbol_conf.event_group &&
!perf_evsel__is_group_leader(pos)) {
struct hists *leader_hists = evsel__hists(pos->leader);
hists__match(leader_hists, hists);
hists__link(leader_hists, hists);
}
}
evlist__for_each_entry(evlist, pos) {
perf_evsel__output_resort(pos, NULL);
}
}
static void perf_top__print_sym_table(struct perf_top *top) static void perf_top__print_sym_table(struct perf_top *top)
{ {
char bf[160]; char bf[160];
...@@ -304,8 +328,7 @@ static void perf_top__print_sym_table(struct perf_top *top) ...@@ -304,8 +328,7 @@ static void perf_top__print_sym_table(struct perf_top *top)
} }
} }
hists__collapse_resort(hists, NULL); evlist__resort_hists(top->evlist);
perf_evsel__output_resort(evsel, NULL);
hists__output_recalc_col_len(hists, top->print_entries - printed); hists__output_recalc_col_len(hists, top->print_entries - printed);
putchar('\n'); putchar('\n');
...@@ -570,8 +593,7 @@ static void perf_top__sort_new_samples(void *arg) ...@@ -570,8 +593,7 @@ static void perf_top__sort_new_samples(void *arg)
} }
} }
hists__collapse_resort(hists, NULL); evlist__resort_hists(t->evlist);
perf_evsel__output_resort(evsel, NULL);
if (t->lost || t->drop) if (t->lost || t->drop)
pr_warning("Too slow to read ring buffer (change period (-c/-F) or limit CPUs (-C)\n"); pr_warning("Too slow to read ring buffer (change period (-c/-F) or limit CPUs (-C)\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment