Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libperf: Add perf_evlist__reset_id_hash()

Add the perf_evlist__reset_id_hash() function as an internal function so
that it can be called by perf to reset the hash table. This is
necessary for 'perf stat' to run the workload multiple times.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20210225035148.778569-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
e2a99c9a 034f7ee1

+11 -4
+9 -4
tools/lib/perf/evlist.c
··· 26 26 27 27 void perf_evlist__init(struct perf_evlist *evlist) 28 28 { 29 - int i; 30 - 31 - for (i = 0; i < PERF_EVLIST__HLIST_SIZE; ++i) 32 - INIT_HLIST_HEAD(&evlist->heads[i]); 33 29 INIT_LIST_HEAD(&evlist->entries); 34 30 evlist->nr_entries = 0; 35 31 fdarray__init(&evlist->pollfd, 64); 32 + perf_evlist__reset_id_hash(evlist); 36 33 } 37 34 38 35 static void __perf_evlist__propagate_maps(struct perf_evlist *evlist, ··· 232 235 sid->evsel = evsel; 233 236 hash = hash_64(sid->id, PERF_EVLIST__HLIST_BITS); 234 237 hlist_add_head(&sid->node, &evlist->heads[hash]); 238 + } 239 + 240 + void perf_evlist__reset_id_hash(struct perf_evlist *evlist) 241 + { 242 + int i; 243 + 244 + for (i = 0; i < PERF_EVLIST__HLIST_SIZE; ++i) 245 + INIT_HLIST_HEAD(&evlist->heads[i]); 235 246 } 236 247 237 248 void perf_evlist__id_add(struct perf_evlist *evlist,
+2
tools/lib/perf/include/internal/evlist.h
··· 124 124 struct perf_evsel *evsel, 125 125 int cpu, int thread, int fd); 126 126 127 + void perf_evlist__reset_id_hash(struct perf_evlist *evlist); 128 + 127 129 #endif /* __LIBPERF_INTERNAL_EVLIST_H */