Skip to content

Commit e2a99c9

Browse files
namhyungacmel
authored andcommitted
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 <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 034f7ee commit e2a99c9

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

tools/lib/perf/evlist.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@
2626

2727
void perf_evlist__init(struct perf_evlist *evlist)
2828
{
29-
int i;
30-
31-
for (i = 0; i < PERF_EVLIST__HLIST_SIZE; ++i)
32-
INIT_HLIST_HEAD(&evlist->heads[i]);
3329
INIT_LIST_HEAD(&evlist->entries);
3430
evlist->nr_entries = 0;
3531
fdarray__init(&evlist->pollfd, 64);
32+
perf_evlist__reset_id_hash(evlist);
3633
}
3734

3835
static void __perf_evlist__propagate_maps(struct perf_evlist *evlist,
@@ -237,6 +234,14 @@ static void perf_evlist__id_hash(struct perf_evlist *evlist,
237234
hlist_add_head(&sid->node, &evlist->heads[hash]);
238235
}
239236

237+
void perf_evlist__reset_id_hash(struct perf_evlist *evlist)
238+
{
239+
int i;
240+
241+
for (i = 0; i < PERF_EVLIST__HLIST_SIZE; ++i)
242+
INIT_HLIST_HEAD(&evlist->heads[i]);
243+
}
244+
240245
void perf_evlist__id_add(struct perf_evlist *evlist,
241246
struct perf_evsel *evsel,
242247
int cpu, int thread, u64 id)

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

+2
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,6 @@ int perf_evlist__id_add_fd(struct perf_evlist *evlist,
124124
struct perf_evsel *evsel,
125125
int cpu, int thread, int fd);
126126

127+
void perf_evlist__reset_id_hash(struct perf_evlist *evlist);
128+
127129
#endif /* __LIBPERF_INTERNAL_EVLIST_H */

0 commit comments

Comments
 (0)