libperf: Add nr_entries to struct perf_evlist
authorJiri Olsa <jolsa@kernel.org>
Sun, 21 Jul 2019 11:24:28 +0000 (13:24 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 29 Jul 2019 21:34:45 +0000 (18:34 -0300)
Move nr_entries count from 'struct perf' to into perf_evlist struct.

Committer notes:

Fix tools/perf/arch/s390/util/auxtrace.c case. And also the comment in
tools/perf/util/annotate.h.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190721112506.12306-42-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
20 files changed:
tools/perf/arch/s390/util/auxtrace.c
tools/perf/builtin-record.c
tools/perf/builtin-stat.c
tools/perf/builtin-top.c
tools/perf/builtin-trace.c
tools/perf/lib/evlist.c
tools/perf/lib/include/internal/evlist.h
tools/perf/tests/parse-events.c
tools/perf/ui/browsers/annotate.c
tools/perf/ui/browsers/hists.c
tools/perf/util/annotate.c
tools/perf/util/annotate.h
tools/perf/util/evlist.c
tools/perf/util/evlist.h
tools/perf/util/header.c
tools/perf/util/parse-events.c
tools/perf/util/python.c
tools/perf/util/record.c
tools/perf/util/sort.c
tools/perf/util/top.c

index 833f60fa9c5a091ee76899b28e3caf61f0ceadaa..480ada281bdba611ad4048dbc263f252e2b23c6e 100644 (file)
@@ -90,7 +90,7 @@ struct auxtrace_record *auxtrace_record__init(struct evlist *evlist,
        int diagnose = 0;
 
        *err = 0;
-       if (evlist->nr_entries == 0)
+       if (evlist->core.nr_entries == 0)
                return NULL;
 
        evlist__for_each_entry(evlist, pos) {
index 17bb0a536da311707571b6c0040984c5c1922df7..778e46417f6b0d73d5620f7260a9f6fffbff256a 100644 (file)
@@ -1375,7 +1375,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
         * because we synthesize event name through the pipe
         * and need the id for that.
         */
-       if (data->is_pipe && rec->evlist->nr_entries == 1)
+       if (data->is_pipe && rec->evlist->core.nr_entries == 1)
                rec->opts.sample_id = true;
 
        if (record__open(rec) != 0) {
@@ -2386,7 +2386,7 @@ int cmd_record(int argc, const char **argv)
        if (record.opts.overwrite)
                record.opts.tail_synthesize = true;
 
-       if (rec->evlist->nr_entries == 0 &&
+       if (rec->evlist->core.nr_entries == 0 &&
            __perf_evlist__add_default(rec->evlist, !record.opts.no_samples) < 0) {
                pr_err("Not enough memory for event selector list\n");
                goto out;
index 39bd73d0e06e60896c03a0959b9ccc14fd33ec32..3ba184f2e64fac00531ee6dd3b3a84e17f8fb0bf 100644 (file)
@@ -1366,7 +1366,7 @@ static int add_default_attributes(void)
                free(str);
        }
 
-       if (!evsel_list->nr_entries) {
+       if (!evsel_list->core.nr_entries) {
                if (target__has_cpu(&target))
                        default_attrs0[0].config = PERF_COUNT_SW_CPU_CLOCK;
 
@@ -1683,7 +1683,7 @@ static void setup_system_wide(int forks)
                                return;
                }
 
-               if (evsel_list->nr_entries)
+               if (evsel_list->core.nr_entries)
                        target.system_wide = true;
        }
 }
index b103f1ba01cb0789152ff66c6d481ef1976f2d1e..3291eff13e28f78343311456e47da13ba99b0100 100644 (file)
@@ -129,7 +129,7 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)
        notes = symbol__annotation(sym);
        pthread_mutex_lock(&notes->lock);
 
-       if (!symbol__hists(sym, top->evlist->nr_entries)) {
+       if (!symbol__hists(sym, top->evlist->core.nr_entries)) {
                pthread_mutex_unlock(&notes->lock);
                pr_err("Not enough memory for annotating '%s' symbol!\n",
                       sym->name);
@@ -404,7 +404,7 @@ static void perf_top__print_mapped_keys(struct perf_top *top)
        fprintf(stdout, "\t[d]     display refresh delay.             \t(%d)\n", top->delay_secs);
        fprintf(stdout, "\t[e]     display entries (lines).           \t(%d)\n", top->print_entries);
 
-       if (top->evlist->nr_entries > 1)
+       if (top->evlist->core.nr_entries > 1)
                fprintf(stdout, "\t[E]     active event counter.              \t(%s)\n", perf_evsel__name(top->sym_evsel));
 
        fprintf(stdout, "\t[f]     profile display filter (count).    \t(%d)\n", top->count_filter);
@@ -439,7 +439,7 @@ static int perf_top__key_mapped(struct perf_top *top, int c)
                case 'S':
                        return 1;
                case 'E':
-                       return top->evlist->nr_entries > 1 ? 1 : 0;
+                       return top->evlist->core.nr_entries > 1 ? 1 : 0;
                default:
                        break;
        }
@@ -485,7 +485,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
                        }
                        break;
                case 'E':
-                       if (top->evlist->nr_entries > 1) {
+                       if (top->evlist->core.nr_entries > 1) {
                                /* Select 0 as the default event: */
                                int counter = 0;
 
@@ -496,7 +496,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
 
                                prompt_integer(&counter, "Enter details event counter");
 
-                               if (counter >= top->evlist->nr_entries) {
+                               if (counter >= top->evlist->core.nr_entries) {
                                        top->sym_evsel = perf_evlist__first(top->evlist);
                                        fprintf(stderr, "Sorry, no such event, using %s.\n", perf_evsel__name(top->sym_evsel));
                                        sleep(1);
@@ -1536,7 +1536,7 @@ int cmd_top(int argc, const char **argv)
        if (argc)
                usage_with_options(top_usage, options);
 
-       if (!top.evlist->nr_entries &&
+       if (!top.evlist->core.nr_entries &&
            perf_evlist__add_default(top.evlist) < 0) {
                pr_err("Not enough memory for event selector list\n");
                goto out_delete_evlist;
index bcd033e91de47e87d3ebda68528c1b1d2f149472..06fcd8b1f160d50a78bc55f9ab4a2315f012424b 100644 (file)
@@ -4270,7 +4270,7 @@ int cmd_trace(int argc, const char **argv)
                symbol_conf.use_callchain = true;
        }
 
-       if (trace.evlist->nr_entries > 0) {
+       if (trace.evlist->core.nr_entries > 0) {
                evlist__set_evsel_handler(trace.evlist, trace__event_handler);
                if (evlist__set_syscall_tp_fields(trace.evlist)) {
                        perror("failed to set syscalls:* tracepoint fields");
@@ -4368,7 +4368,7 @@ init_augmented_syscall_tp:
                trace.summary = trace.summary_only;
 
        if (!trace.trace_syscalls && !trace.trace_pgfaults &&
-           trace.evlist->nr_entries == 0 /* Was --events used? */) {
+           trace.evlist->core.nr_entries == 0 /* Was --events used? */) {
                trace.trace_syscalls = true;
        }
 
index 023fe4b4413113379171c943d8f3848b8cf9f41c..1b27fd2de9b99ceebbd4e9655eff13ad5e2059f4 100644 (file)
@@ -7,16 +7,19 @@
 void perf_evlist__init(struct perf_evlist *evlist)
 {
        INIT_LIST_HEAD(&evlist->entries);
+       evlist->nr_entries = 0;
 }
 
 void perf_evlist__add(struct perf_evlist *evlist,
                      struct perf_evsel *evsel)
 {
        list_add_tail(&evsel->node, &evlist->entries);
+       evlist->nr_entries += 1;
 }
 
 void perf_evlist__remove(struct perf_evlist *evlist,
                         struct perf_evsel *evsel)
 {
        list_del_init(&evsel->node);
+       evlist->nr_entries -= 1;
 }
index 7fbfe57166523e92562ecf273e0341bcb391dd43..a12c712a91975a60ea8f314cdf739b3c0d19279f 100644 (file)
@@ -4,6 +4,7 @@
 
 struct perf_evlist {
        struct list_head        entries;
+       int                     nr_entries;
 };
 
 #endif /* __LIBPERF_INTERNAL_EVLIST_H */
index 2365dd655c880fc74f8ef04f60c60da2bf9d4062..878140501edf1cb60a1454f5f58d8bf8e5fc75a1 100644 (file)
@@ -48,7 +48,7 @@ static int test__checkevent_tracepoint(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
        TEST_ASSERT_VAL("wrong sample_type",
@@ -61,7 +61,7 @@ static int test__checkevent_tracepoint_multi(struct evlist *evlist)
 {
        struct evsel *evsel;
 
-       TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1);
+       TEST_ASSERT_VAL("wrong number of entries", evlist->core.nr_entries > 1);
        TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups);
 
        evlist__for_each_entry(evlist, evsel) {
@@ -79,7 +79,7 @@ static int test__checkevent_raw(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config", 0x1a == evsel->attr.config);
        return 0;
@@ -89,7 +89,7 @@ static int test__checkevent_numeric(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
        return 0;
@@ -99,7 +99,7 @@ static int test__checkevent_symbolic_name(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
@@ -110,7 +110,7 @@ static int test__checkevent_symbolic_name_config(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
@@ -131,7 +131,7 @@ static int test__checkevent_symbolic_alias(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config);
@@ -142,7 +142,7 @@ static int test__checkevent_genhw(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel->attr.config);
        return 0;
@@ -152,7 +152,7 @@ static int test__checkevent_breakpoint(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
        TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
@@ -166,7 +166,7 @@ static int test__checkevent_breakpoint_x(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
        TEST_ASSERT_VAL("wrong bp_type",
@@ -179,7 +179,7 @@ static int test__checkevent_breakpoint_r(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type",
                        PERF_TYPE_BREAKPOINT == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
@@ -194,7 +194,7 @@ static int test__checkevent_breakpoint_w(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type",
                        PERF_TYPE_BREAKPOINT == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
@@ -209,7 +209,7 @@ static int test__checkevent_breakpoint_rw(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type",
                        PERF_TYPE_BREAKPOINT == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
@@ -237,7 +237,7 @@ test__checkevent_tracepoint_multi_modifier(struct evlist *evlist)
 {
        struct evsel *evsel;
 
-       TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1);
+       TEST_ASSERT_VAL("wrong number of entries", evlist->core.nr_entries > 1);
 
        evlist__for_each_entry(evlist, evsel) {
                TEST_ASSERT_VAL("wrong exclude_user",
@@ -437,7 +437,7 @@ static int test__checkevent_pmu(struct evlist *evlist)
 
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config",    10 == evsel->attr.config);
        TEST_ASSERT_VAL("wrong config1",    1 == evsel->attr.config1);
@@ -455,7 +455,7 @@ static int test__checkevent_list(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
 
        /* r1 */
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
@@ -495,14 +495,14 @@ static int test__checkevent_pmu_name(struct evlist *evlist)
        struct evsel *evsel = perf_evlist__first(evlist);
 
        /* cpu/config=1,name=krava/u */
-       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config",  1 == evsel->attr.config);
        TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel), "krava"));
 
        /* cpu/config=2/u" */
        evsel = perf_evsel__next(evsel);
-       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config",  2 == evsel->attr.config);
        TEST_ASSERT_VAL("wrong name",
@@ -516,7 +516,7 @@ static int test__checkevent_pmu_partial_time_callgraph(struct evlist *evlist)
        struct evsel *evsel = perf_evlist__first(evlist);
 
        /* cpu/config=1,call-graph=fp,time,period=100000/ */
-       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config",  1 == evsel->attr.config);
        /*
@@ -548,7 +548,7 @@ static int test__checkevent_pmu_events(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
        TEST_ASSERT_VAL("wrong exclude_user",
                        !evsel->attr.exclude_user);
@@ -567,7 +567,7 @@ static int test__checkevent_pmu_events_mix(struct evlist *evlist)
        struct evsel *evsel = perf_evlist__first(evlist);
 
        /* pmu-event:u */
-       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong exclude_user",
                        !evsel->attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel",
@@ -578,7 +578,7 @@ static int test__checkevent_pmu_events_mix(struct evlist *evlist)
 
        /* cpu/pmu-event/u*/
        evsel = perf_evsel__next(evsel);
-       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
        TEST_ASSERT_VAL("wrong exclude_user",
                        !evsel->attr.exclude_user);
@@ -638,7 +638,7 @@ static int test__group1(struct evlist *evlist)
 {
        struct evsel *evsel, *leader;
 
-       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* instructions:k */
@@ -680,7 +680,7 @@ static int test__group2(struct evlist *evlist)
 {
        struct evsel *evsel, *leader;
 
-       TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* faults + :ku modifier */
@@ -735,7 +735,7 @@ static int test__group3(struct evlist *evlist __maybe_unused)
 {
        struct evsel *evsel, *leader;
 
-       TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
 
        /* group1 syscalls:sys_enter_openat:H */
@@ -827,7 +827,7 @@ static int test__group4(struct evlist *evlist __maybe_unused)
 {
        struct evsel *evsel, *leader;
 
-       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* cycles:u + p */
@@ -871,7 +871,7 @@ static int test__group5(struct evlist *evlist __maybe_unused)
 {
        struct evsel *evsel, *leader;
 
-       TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
 
        /* cycles + G */
@@ -957,7 +957,7 @@ static int test__group_gh1(struct evlist *evlist)
 {
        struct evsel *evsel, *leader;
 
-       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* cycles + :H group modifier */
@@ -997,7 +997,7 @@ static int test__group_gh2(struct evlist *evlist)
 {
        struct evsel *evsel, *leader;
 
-       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* cycles + :G group modifier */
@@ -1037,7 +1037,7 @@ static int test__group_gh3(struct evlist *evlist)
 {
        struct evsel *evsel, *leader;
 
-       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* cycles:G + :u group modifier */
@@ -1077,7 +1077,7 @@ static int test__group_gh4(struct evlist *evlist)
 {
        struct evsel *evsel, *leader;
 
-       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* cycles:G + :uG group modifier */
@@ -1117,7 +1117,7 @@ static int test__leader_sample1(struct evlist *evlist)
 {
        struct evsel *evsel, *leader;
 
-       TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
 
        /* cycles - sampling group leader */
        evsel = leader = perf_evlist__first(evlist);
@@ -1170,7 +1170,7 @@ static int test__leader_sample2(struct evlist *evlist __maybe_unused)
 {
        struct evsel *evsel, *leader;
 
-       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
 
        /* instructions - sampling group leader */
        evsel = leader = perf_evlist__first(evlist);
@@ -1222,7 +1222,7 @@ static int test__pinned_group(struct evlist *evlist)
 {
        struct evsel *evsel, *leader;
 
-       TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
 
        /* cycles - group leader */
        evsel = leader = perf_evlist__first(evlist);
@@ -1253,7 +1253,7 @@ static int test__checkevent_breakpoint_len(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
        TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
@@ -1268,7 +1268,7 @@ static int test__checkevent_breakpoint_len_w(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
        TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W ==
@@ -1296,7 +1296,7 @@ static int test__checkevent_precise_max_modifier(struct evlist *evlist)
 {
        struct evsel *evsel = perf_evlist__first(evlist);
 
-       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_SW_TASK_CLOCK == evsel->attr.config);
@@ -1425,7 +1425,7 @@ static int count_tracepoints(void)
 static int test__all_tracepoints(struct evlist *evlist)
 {
        TEST_ASSERT_VAL("wrong events count",
-                       count_tracepoints() == evlist->nr_entries);
+                       count_tracepoints() == evlist->core.nr_entries);
 
        return test__checkevent_tracepoint_multi(evlist);
 }
index 64cc650c45434d9f0ac802a0026da240491021c0..e633eb42550da91523f9be7fa118012efeb7f84e 100644 (file)
@@ -422,7 +422,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
        notes = symbol__annotation(dl->ops.target.sym);
        pthread_mutex_lock(&notes->lock);
 
-       if (!symbol__hists(dl->ops.target.sym, evsel->evlist->nr_entries)) {
+       if (!symbol__hists(dl->ops.target.sym, evsel->evlist->core.nr_entries)) {
                pthread_mutex_unlock(&notes->lock);
                ui__warning("Not enough memory for annotating '%s' symbol!\n",
                            dl->ops.target.sym->name);
index ed5406ff9fe4dabf9e57c39944a1545c25a7d297..b195b1ba625bb8db764a5aa9f4f9f1de4180c423 100644 (file)
@@ -3404,7 +3404,7 @@ int perf_evlist__tui_browse_hists(struct evlist *evlist, const char *help,
                                  bool warn_lost_event,
                                  struct annotation_options *annotation_opts)
 {
-       int nr_entries = evlist->nr_entries;
+       int nr_entries = evlist->core.nr_entries;
 
 single_entry:
        if (nr_entries == 1) {
index 6ea5d678a81c9dc0b644aaae90ee2e8ad408abb1..d46f2ae2c695c695d113044f44a5efcc7453e1a2 100644 (file)
@@ -936,7 +936,7 @@ static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
 
        if (sym == NULL)
                return 0;
-       src = symbol__hists(sym, evsel->evlist->nr_entries);
+       src = symbol__hists(sym, evsel->evlist->core.nr_entries);
        return (src) ?  __symbol__inc_addr_samples(sym, map, src, evsel->idx,
                                                   addr, sample) : 0;
 }
index 7c42f320efa284be1faeda87b27da8579fa6453c..d94be9140e314d6e66ef083498e0395f772cdd3f 100644 (file)
@@ -245,7 +245,7 @@ struct cyc_hist {
 /** struct annotated_source - symbols with hits have this attached as in sannotation
  *
  * @histograms: Array of addr hit histograms per event being monitored
- * nr_histograms: This may not be the same as evsel->evlist->nr_entries if
+ * nr_histograms: This may not be the same as evsel->evlist->core.nr_entries if
  *               we have more than a group in a evlist, where we will want
  *               to see each group separately, that is why symbol__annotate2()
  *               sets src->nr_histograms to evsel->nr_members.
index 9b0108c23010211bb1f2f0d01c49bc07df4a40bf..ce9f52215d601b16e0843ecd0a4dd69c5d72a2b0 100644 (file)
@@ -125,7 +125,7 @@ static void perf_evlist__purge(struct evlist *evlist)
                evsel__delete(pos);
        }
 
-       evlist->nr_entries = 0;
+       evlist->core.nr_entries = 0;
 }
 
 void perf_evlist__exit(struct evlist *evlist)
@@ -180,12 +180,13 @@ static void perf_evlist__propagate_maps(struct evlist *evlist)
 
 void evlist__add(struct evlist *evlist, struct evsel *entry)
 {
-       perf_evlist__add(&evlist->core, &entry->core);
        entry->evlist = evlist;
-       entry->idx = evlist->nr_entries;
+       entry->idx = evlist->core.nr_entries;
        entry->tracking = !entry->idx;
 
-       if (!evlist->nr_entries++)
+       perf_evlist__add(&evlist->core, &entry->core);
+
+       if (evlist->core.nr_entries == 1)
                perf_evlist__set_id_pos(evlist);
 
        __perf_evlist__propagate_maps(evlist, entry);
@@ -195,7 +196,6 @@ void evlist__remove(struct evlist *evlist, struct evsel *evsel)
 {
        evsel->evlist = NULL;
        perf_evlist__remove(&evlist->core, &evsel->core);
-       evlist->nr_entries -= 1;
 }
 
 void perf_evlist__splice_list_tail(struct evlist *evlist,
@@ -225,8 +225,8 @@ void __perf_evlist__set_leader(struct list_head *list)
 
 void perf_evlist__set_leader(struct evlist *evlist)
 {
-       if (evlist->nr_entries) {
-               evlist->nr_groups = evlist->nr_entries > 1 ? 1 : 0;
+       if (evlist->core.nr_entries) {
+               evlist->nr_groups = evlist->core.nr_entries > 1 ? 1 : 0;
                __perf_evlist__set_leader(&evlist->core.entries);
        }
 }
@@ -249,7 +249,7 @@ int perf_evlist__add_dummy(struct evlist *evlist)
                .config = PERF_COUNT_SW_DUMMY,
                .size   = sizeof(attr), /* to capture ABI version */
        };
-       struct evsel *evsel = perf_evsel__new_idx(&attr, evlist->nr_entries);
+       struct evsel *evsel = perf_evsel__new_idx(&attr, evlist->core.nr_entries);
 
        if (evsel == NULL)
                return -ENOMEM;
@@ -266,7 +266,7 @@ static int evlist__add_attrs(struct evlist *evlist,
        size_t i;
 
        for (i = 0; i < nr_attrs; i++) {
-               evsel = perf_evsel__new_idx(attrs + i, evlist->nr_entries + i);
+               evsel = perf_evsel__new_idx(attrs + i, evlist->core.nr_entries + i);
                if (evsel == NULL)
                        goto out_delete_partial_list;
                list_add_tail(&evsel->core.node, &head);
@@ -581,7 +581,7 @@ struct evsel *perf_evlist__id2evsel(struct evlist *evlist, u64 id)
 {
        struct perf_sample_id *sid;
 
-       if (evlist->nr_entries == 1 || !id)
+       if (evlist->core.nr_entries == 1 || !id)
                return perf_evlist__first(evlist);
 
        sid = perf_evlist__id2sid(evlist, id);
@@ -639,7 +639,7 @@ struct evsel *perf_evlist__event2evsel(struct evlist *evlist,
        int hash;
        u64 id;
 
-       if (evlist->nr_entries == 1)
+       if (evlist->core.nr_entries == 1)
                return first;
 
        if (!first->attr.sample_id_all &&
@@ -1222,7 +1222,7 @@ bool perf_evlist__valid_sample_type(struct evlist *evlist)
 {
        struct evsel *pos;
 
-       if (evlist->nr_entries == 1)
+       if (evlist->core.nr_entries == 1)
                return true;
 
        if (evlist->id_pos < 0 || evlist->is_pos < 0)
@@ -1849,7 +1849,7 @@ int perf_evlist__add_sb_event(struct evlist **evlist,
                attr->sample_id_all = 1;
        }
 
-       evsel = perf_evsel__new_idx(attr, (*evlist)->nr_entries);
+       evsel = perf_evsel__new_idx(attr, (*evlist)->core.nr_entries);
        if (!evsel)
                goto out_err;
 
index 7117378a08e31e1f785c3d26b852f828c3942fb3..17dd83021a7963939340a4b30ac152d416336725 100644 (file)
@@ -28,7 +28,6 @@ struct record_opts;
 struct evlist {
        struct perf_evlist core;
        struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
-       int              nr_entries;
        int              nr_groups;
        int              nr_mmaps;
        bool             enabled;
index 70ab6b8c715b5f6cd5d554b18d6617cee3a34f0d..141de44251004f5895da7592c587529573227ab6 100644 (file)
@@ -476,7 +476,7 @@ static int write_event_desc(struct feat_fd *ff,
        u32 nre, nri, sz;
        int ret;
 
-       nre = evlist->nr_entries;
+       nre = evlist->core.nr_entries;
 
        /*
         * write number of events
@@ -3100,7 +3100,7 @@ int perf_session__write_header(struct perf_session *session,
                .attr_size = sizeof(f_attr),
                .attrs = {
                        .offset = attr_offset,
-                       .size   = evlist->nr_entries * sizeof(f_attr),
+                       .size   = evlist->core.nr_entries * sizeof(f_attr),
                },
                .data = {
                        .offset = header->data_offset,
index a0b7d68d2f8e5e67f9640fcd1dbbebe0e6baf583..10efc33c56a13970b9d6de9989ad31c5da63bc59 100644 (file)
@@ -1909,7 +1909,7 @@ int parse_events(struct evlist *evlist, const char *str,
 {
        struct parse_events_state parse_state = {
                .list   = LIST_HEAD_INIT(parse_state.list),
-               .idx    = evlist->nr_entries,
+               .idx    = evlist->core.nr_entries,
                .error  = err,
                .evlist = evlist,
        };
@@ -2040,7 +2040,7 @@ foreach_evsel_in_last_glob(struct evlist *evlist,
         *
         * So no need to WARN here, let *func do this.
         */
-       if (evlist->nr_entries > 0)
+       if (evlist->core.nr_entries > 0)
                last = perf_evlist__last(evlist);
 
        do {
index 19d2feee91d57b4ff059b8c06962322d9f10b382..cf0a18d49018f17da52b00d27474477c7f567adf 100644 (file)
@@ -973,10 +973,10 @@ static PyObject *pyrf_evlist__add(struct pyrf_evlist *pevlist,
 
        Py_INCREF(pevsel);
        evsel = &((struct pyrf_evsel *)pevsel)->evsel;
-       evsel->idx = evlist->nr_entries;
+       evsel->idx = evlist->core.nr_entries;
        evlist__add(evlist, evsel);
 
-       return Py_BuildValue("i", evlist->nr_entries);
+       return Py_BuildValue("i", evlist->core.nr_entries);
 }
 
 static struct perf_mmap *get_md(struct evlist *evlist, int cpu)
@@ -1112,7 +1112,7 @@ static Py_ssize_t pyrf_evlist__length(PyObject *obj)
 {
        struct pyrf_evlist *pevlist = (void *)obj;
 
-       return pevlist->evlist.nr_entries;
+       return pevlist->evlist.core.nr_entries;
 }
 
 static PyObject *pyrf_evlist__item(PyObject *obj, Py_ssize_t i)
@@ -1120,7 +1120,7 @@ static PyObject *pyrf_evlist__item(PyObject *obj, Py_ssize_t i)
        struct pyrf_evlist *pevlist = (void *)obj;
        struct evsel *pos;
 
-       if (i >= pevlist->evlist.nr_entries)
+       if (i >= pevlist->evlist.core.nr_entries)
                return NULL;
 
        evlist__for_each_entry(&pevlist->evlist, pos) {
index fecccfd71aa1ae6d7287486a78e1d897ea1f336f..3d3d732498e1f0682fb9615917d358b37227c751 100644 (file)
@@ -166,7 +166,7 @@ void perf_evlist__config(struct evlist *evlist, struct record_opts *opts,
                 */
                use_sample_identifier = perf_can_sample_identifier();
                sample_id = true;
-       } else if (evlist->nr_entries > 1) {
+       } else if (evlist->core.nr_entries > 1) {
                struct evsel *first = perf_evlist__first(evlist);
 
                evlist__for_each_entry(evlist, evsel) {
index d8e4392d6e18262360dd31064a55a8035aad3af0..fa3cc2112b823dda23b74e39a7b33073bebceef9 100644 (file)
@@ -2323,7 +2323,7 @@ static struct evsel *find_evsel(struct evlist *evlist, char *event_name)
        if (event_name[0] == '%') {
                int nr = strtol(event_name+1, NULL, 0);
 
-               if (nr > evlist->nr_entries)
+               if (nr > evlist->core.nr_entries)
                        return NULL;
 
                evsel = perf_evlist__first(evlist);
index 9f098db76e3c130dc52a43d226a6aa56d9e259a0..3bbbdac2c5501a4fd624306f2e2908941fdff6c4 100644 (file)
@@ -70,7 +70,7 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size)
                               esamples_percent);
        }
 
-       if (top->evlist->nr_entries == 1) {
+       if (top->evlist->core.nr_entries == 1) {
                struct evsel *first = perf_evlist__first(top->evlist);
                ret += SNPRINTF(bf + ret, size - ret, "%" PRIu64 "%s ",
                                (uint64_t)first->attr.sample_period,