[PATCH 26/73] libperf: Move heads from struct evlist to struct perf_evlist
From: Jiri Olsa
Date: Fri Sep 13 2019 - 09:25:12 EST
Move heads hash from struct evlist to struct perf_evlist.
Link: http://lkml.kernel.org/n/tip-4y1fuw43ave7y32ypc9epthv@xxxxxxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/lib/evlist.c | 4 ++++
tools/perf/lib/include/internal/evlist.h | 4 ++++
tools/perf/util/evlist.c | 10 +++-------
tools/perf/util/evlist.h | 4 ----
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c
index f4dc9a208332..2bdd9d2c79d9 100644
--- a/tools/perf/lib/evlist.c
+++ b/tools/perf/lib/evlist.c
@@ -11,6 +11,10 @@
void perf_evlist__init(struct perf_evlist *evlist)
{
+ int i;
+
+ for (i = 0; i < PERF_EVLIST__HLIST_SIZE; ++i)
+ INIT_HLIST_HEAD(&evlist->heads[i]);
INIT_LIST_HEAD(&evlist->entries);
evlist->nr_entries = 0;
}
diff --git a/tools/perf/lib/include/internal/evlist.h b/tools/perf/lib/include/internal/evlist.h
index 8a4eb66fbf3a..c5a06890fd6a 100644
--- a/tools/perf/lib/include/internal/evlist.h
+++ b/tools/perf/lib/include/internal/evlist.h
@@ -5,6 +5,9 @@
#include <linux/list.h>
#include <api/fd/array.h>
+#define PERF_EVLIST__HLIST_BITS 8
+#define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)
+
struct perf_cpu_map;
struct perf_thread_map;
@@ -17,6 +20,7 @@ struct perf_evlist {
int nr_mmaps;
size_t mmap_len;
struct fdarray pollfd;
+ struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
};
/**
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 9dcecb5e05a0..2f883db7c8e7 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -54,10 +54,6 @@ int sigqueue(pid_t pid, int sig, const union sigval value);
void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,
struct perf_thread_map *threads)
{
- int i;
-
- for (i = 0; i < PERF_EVLIST__HLIST_SIZE; ++i)
- INIT_HLIST_HEAD(&evlist->heads[i]);
perf_evlist__init(&evlist->core);
perf_evlist__set_maps(&evlist->core, cpus, threads);
fdarray__init(&evlist->core.pollfd, 64);
@@ -474,7 +470,7 @@ static void perf_evlist__id_hash(struct evlist *evlist,
sid->id = id;
sid->evsel = evsel;
hash = hash_64(sid->id, PERF_EVLIST__HLIST_BITS);
- hlist_add_head(&sid->node, &evlist->heads[hash]);
+ hlist_add_head(&sid->node, &evlist->core.heads[hash]);
}
void perf_evlist__id_add(struct evlist *evlist, struct evsel *evsel,
@@ -548,7 +544,7 @@ struct perf_sample_id *perf_evlist__id2sid(struct evlist *evlist, u64 id)
int hash;
hash = hash_64(id, PERF_EVLIST__HLIST_BITS);
- head = &evlist->heads[hash];
+ head = &evlist->core.heads[hash];
hlist_for_each_entry(sid, head, node)
if (sid->id == id)
@@ -634,7 +630,7 @@ struct evsel *perf_evlist__event2evsel(struct evlist *evlist,
return first;
hash = hash_64(id, PERF_EVLIST__HLIST_BITS);
- head = &evlist->heads[hash];
+ head = &evlist->core.heads[hash];
hlist_for_each_entry(sid, head, node) {
if (sid->id == id)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index b8f03452196f..7306a0677171 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -20,12 +20,8 @@ struct thread_map;
struct perf_cpu_map;
struct record_opts;
-#define PERF_EVLIST__HLIST_BITS 8
-#define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)
-
struct evlist {
struct perf_evlist core;
- struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
int nr_groups;
bool enabled;
int id_pos;
--
2.21.0