Skip to content

Commit 6484d2f

Browse files
olsajiriacmel
authored andcommitted
libperf: Add nr_entries to struct perf_evlist
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>
1 parent 52e22fb commit 6484d2f

20 files changed

Lines changed: 83 additions & 80 deletions

File tree

‎tools/perf/arch/s390/util/auxtrace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct auxtrace_record *auxtrace_record__init(struct evlist *evlist,
9090
int diagnose = 0;
9191

9292
*err = 0;
93-
if (evlist->nr_entries == 0)
93+
if (evlist->core.nr_entries == 0)
9494
return NULL;
9595

9696
evlist__for_each_entry(evlist, pos) {

‎tools/perf/builtin-record.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
13751375
* because we synthesize event name through the pipe
13761376
* and need the id for that.
13771377
*/
1378-
if (data->is_pipe && rec->evlist->nr_entries == 1)
1378+
if (data->is_pipe && rec->evlist->core.nr_entries == 1)
13791379
rec->opts.sample_id = true;
13801380

13811381
if (record__open(rec) != 0) {
@@ -2386,7 +2386,7 @@ int cmd_record(int argc, const char **argv)
23862386
if (record.opts.overwrite)
23872387
record.opts.tail_synthesize = true;
23882388

2389-
if (rec->evlist->nr_entries == 0 &&
2389+
if (rec->evlist->core.nr_entries == 0 &&
23902390
__perf_evlist__add_default(rec->evlist, !record.opts.no_samples) < 0) {
23912391
pr_err("Not enough memory for event selector list\n");
23922392
goto out;

‎tools/perf/builtin-stat.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ static int add_default_attributes(void)
13661366
free(str);
13671367
}
13681368

1369-
if (!evsel_list->nr_entries) {
1369+
if (!evsel_list->core.nr_entries) {
13701370
if (target__has_cpu(&target))
13711371
default_attrs0[0].config = PERF_COUNT_SW_CPU_CLOCK;
13721372

@@ -1683,7 +1683,7 @@ static void setup_system_wide(int forks)
16831683
return;
16841684
}
16851685

1686-
if (evsel_list->nr_entries)
1686+
if (evsel_list->core.nr_entries)
16871687
target.system_wide = true;
16881688
}
16891689
}

‎tools/perf/builtin-top.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)
129129
notes = symbol__annotation(sym);
130130
pthread_mutex_lock(&notes->lock);
131131

132-
if (!symbol__hists(sym, top->evlist->nr_entries)) {
132+
if (!symbol__hists(sym, top->evlist->core.nr_entries)) {
133133
pthread_mutex_unlock(&notes->lock);
134134
pr_err("Not enough memory for annotating '%s' symbol!\n",
135135
sym->name);
@@ -404,7 +404,7 @@ static void perf_top__print_mapped_keys(struct perf_top *top)
404404
fprintf(stdout, "\t[d] display refresh delay. \t(%d)\n", top->delay_secs);
405405
fprintf(stdout, "\t[e] display entries (lines). \t(%d)\n", top->print_entries);
406406

407-
if (top->evlist->nr_entries > 1)
407+
if (top->evlist->core.nr_entries > 1)
408408
fprintf(stdout, "\t[E] active event counter. \t(%s)\n", perf_evsel__name(top->sym_evsel));
409409

410410
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)
439439
case 'S':
440440
return 1;
441441
case 'E':
442-
return top->evlist->nr_entries > 1 ? 1 : 0;
442+
return top->evlist->core.nr_entries > 1 ? 1 : 0;
443443
default:
444444
break;
445445
}
@@ -485,7 +485,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
485485
}
486486
break;
487487
case 'E':
488-
if (top->evlist->nr_entries > 1) {
488+
if (top->evlist->core.nr_entries > 1) {
489489
/* Select 0 as the default event: */
490490
int counter = 0;
491491

@@ -496,7 +496,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
496496

497497
prompt_integer(&counter, "Enter details event counter");
498498

499-
if (counter >= top->evlist->nr_entries) {
499+
if (counter >= top->evlist->core.nr_entries) {
500500
top->sym_evsel = perf_evlist__first(top->evlist);
501501
fprintf(stderr, "Sorry, no such event, using %s.\n", perf_evsel__name(top->sym_evsel));
502502
sleep(1);
@@ -1536,7 +1536,7 @@ int cmd_top(int argc, const char **argv)
15361536
if (argc)
15371537
usage_with_options(top_usage, options);
15381538

1539-
if (!top.evlist->nr_entries &&
1539+
if (!top.evlist->core.nr_entries &&
15401540
perf_evlist__add_default(top.evlist) < 0) {
15411541
pr_err("Not enough memory for event selector list\n");
15421542
goto out_delete_evlist;

‎tools/perf/builtin-trace.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4270,7 +4270,7 @@ int cmd_trace(int argc, const char **argv)
42704270
symbol_conf.use_callchain = true;
42714271
}
42724272

4273-
if (trace.evlist->nr_entries > 0) {
4273+
if (trace.evlist->core.nr_entries > 0) {
42744274
evlist__set_evsel_handler(trace.evlist, trace__event_handler);
42754275
if (evlist__set_syscall_tp_fields(trace.evlist)) {
42764276
perror("failed to set syscalls:* tracepoint fields");
@@ -4368,7 +4368,7 @@ int cmd_trace(int argc, const char **argv)
43684368
trace.summary = trace.summary_only;
43694369

43704370
if (!trace.trace_syscalls && !trace.trace_pgfaults &&
4371-
trace.evlist->nr_entries == 0 /* Was --events used? */) {
4371+
trace.evlist->core.nr_entries == 0 /* Was --events used? */) {
43724372
trace.trace_syscalls = true;
43734373
}
43744374

‎tools/perf/lib/evlist.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
void perf_evlist__init(struct perf_evlist *evlist)
88
{
99
INIT_LIST_HEAD(&evlist->entries);
10+
evlist->nr_entries = 0;
1011
}
1112

1213
void perf_evlist__add(struct perf_evlist *evlist,
1314
struct perf_evsel *evsel)
1415
{
1516
list_add_tail(&evsel->node, &evlist->entries);
17+
evlist->nr_entries += 1;
1618
}
1719

1820
void perf_evlist__remove(struct perf_evlist *evlist,
1921
struct perf_evsel *evsel)
2022
{
2123
list_del_init(&evsel->node);
24+
evlist->nr_entries -= 1;
2225
}

‎tools/perf/lib/include/internal/evlist.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
struct perf_evlist {
66
struct list_head entries;
7+
int nr_entries;
78
};
89

910
#endif /* __LIBPERF_INTERNAL_EVLIST_H */

0 commit comments

Comments
 (0)