]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - tools/perf/builtin-top.c
perf tools: Rename perf_evlist__mmap() to evlist__mmap()
[linux.git] / tools / perf / builtin-top.c
index 5970723cd55a4ef8156727175e3e126d8c2e8d12..771b3ff47dc3b64062a53e38e94bbfd0676810dd 100644 (file)
@@ -24,6 +24,7 @@
 #include "util/bpf-event.h"
 #include "util/config.h"
 #include "util/color.h"
+#include "util/dso.h"
 #include "util/evlist.h"
 #include "util/evsel.h"
 #include "util/event.h"
 #include "util/map.h"
 #include "util/session.h"
 #include "util/symbol.h"
-#include "util/thread.h"
-#include "util/thread_map.h"
+#include "util/synthetic-events.h"
 #include "util/top.h"
+#include "util/util.h"
 #include <linux/rbtree.h>
 #include <subcmd/parse-options.h>
 #include "util/parse-events.h"
+#include "util/callchain.h"
 #include "util/cpumap.h"
 #include "util/sort.h"
 #include "util/string2.h"
@@ -44,6 +46,7 @@
 #include "util/intlist.h"
 #include "util/parse-branch-options.h"
 #include "arch/common.h"
+#include "ui/ui.h"
 
 #include "util/debug.h"
 #include "util/ordered-events.h"
@@ -74,6 +77,7 @@
 #include <linux/stringify.h>
 #include <linux/time64.h>
 #include <linux/types.h>
+#include <linux/err.h>
 
 #include <linux/ctype.h>
 
@@ -264,13 +268,29 @@ static void perf_top__show_details(struct perf_top *top)
        pthread_mutex_unlock(&notes->lock);
 }
 
-static void evlist__resort_hists(struct evlist *evlist)
+static void perf_top__resort_hists(struct perf_top *t)
 {
+       struct evlist *evlist = t->evlist;
        struct evsel *pos;
 
        evlist__for_each_entry(evlist, pos) {
                struct hists *hists = evsel__hists(pos);
 
+               /*
+                * unlink existing entries so that they can be linked
+                * in a correct order in hists__match() below.
+                */
+               hists__unlink(hists);
+
+               if (evlist->enabled) {
+                       if (t->zero) {
+                               hists__delete_entries(hists);
+                       } else {
+                               hists__decay_entries(hists, t->hide_user_symbols,
+                                                    t->hide_kernel_symbols);
+                       }
+               }
+
                hists__collapse_resort(hists, NULL);
 
                /* Non-group events are considered as leader */
@@ -319,16 +339,7 @@ static void perf_top__print_sym_table(struct perf_top *top)
                return;
        }
 
-       if (top->evlist->enabled) {
-               if (top->zero) {
-                       hists__delete_entries(hists);
-               } else {
-                       hists__decay_entries(hists, top->hide_user_symbols,
-                                            top->hide_kernel_symbols);
-               }
-       }
-
-       evlist__resort_hists(top->evlist);
+       perf_top__resort_hists(top);
 
        hists__output_recalc_col_len(hists, top->print_entries - printed);
        putchar('\n');
@@ -576,24 +587,11 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
 static void perf_top__sort_new_samples(void *arg)
 {
        struct perf_top *t = arg;
-       struct evsel *evsel = t->sym_evsel;
-       struct hists *hists;
 
        if (t->evlist->selected != NULL)
                t->sym_evsel = t->evlist->selected;
 
-       hists = evsel__hists(evsel);
-
-       if (t->evlist->enabled) {
-               if (t->zero) {
-                       hists__delete_entries(hists);
-               } else {
-                       hists__decay_entries(hists, t->hide_user_symbols,
-                                            t->hide_kernel_symbols);
-               }
-       }
-
-       evlist__resort_hists(t->evlist);
+       perf_top__resort_hists(t);
 
        if (t->lost || t->drop)
                pr_warning("Too slow to read ring buffer (change period (-c/-F) or limit CPUs (-C)\n");
@@ -770,7 +768,7 @@ static void perf_event__process_sample(struct perf_tool *tool,
                if (!perf_evlist__exclude_kernel(top->session->evlist)) {
                        ui__warning(
 "Kernel address maps (/proc/{kallsyms,modules}) are restricted.\n\n"
-"Check /proc/sys/kernel/kptr_restrict.\n\n"
+"Check /proc/sys/kernel/kptr_restrict and /proc/sys/kernel/perf_event_paranoid.\n\n"
 "Kernel%s samples will not be resolved.\n",
                          al.map && map__has_symbols(al.map) ?
                          " modules" : "");
@@ -865,7 +863,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
 {
        struct record_opts *opts = &top->record_opts;
        struct evlist *evlist = top->evlist;
-       struct perf_mmap *md;
+       struct mmap *md;
        union perf_event *event;
 
        md = opts->overwrite ? &evlist->overwrite_mmap[idx] : &evlist->mmap[idx];
@@ -1044,7 +1042,7 @@ static int perf_top__start_counters(struct perf_top *top)
                }
        }
 
-       if (perf_evlist__mmap(evlist, opts->mmap_pages) < 0) {
+       if (evlist__mmap(evlist, opts->mmap_pages) < 0) {
                ui__error("Failed to mmap with %d (%s)\n",
                            errno, str_error_r(errno, msg, sizeof(msg)));
                goto out_err;
@@ -1675,8 +1673,8 @@ int cmd_top(int argc, const char **argv)
        }
 
        top.session = perf_session__new(NULL, false, NULL);
-       if (top.session == NULL) {
-               status = -1;
+       if (IS_ERR(top.session)) {
+               status = PTR_ERR(top.session);
                goto out_delete_evlist;
        }