libperf: Move 'heads' from 'struct evlist' to 'struct perf_evlist'
authorJiri Olsa <jolsa@kernel.org>
Mon, 2 Sep 2019 20:20:12 +0000 (22:20 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 25 Sep 2019 12:51:48 +0000 (09:51 -0300)
Move 'heads' hash table from 'struct evlist' to 'struct perf_evlist'.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lore.kernel.org/lkml/20190913132355.21634-27-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/lib/evlist.c
tools/perf/lib/include/internal/evlist.h
tools/perf/util/evlist.c
tools/perf/util/evlist.h

index f4dc9a20833261938c0cb7b33971afc2e5d8054c..2bdd9d2c79d938fdbf9feec881de17a1dae2260a 100644 (file)
 
 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;
 }
index 8a4eb66fbf3aa7de4e0262e58eae4042067d04dc..c5a06890fd6a9c6605bc0bdd00fd61d7b333c551 100644 (file)
@@ -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];
 };
 
 /**
index 5e43fb9da359fcf35160c9628ee9e4aad38c7e11..c6af7c622612f2152b3f678bc71c1d3135bed791 100644 (file)
@@ -55,10 +55,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);
@@ -475,7 +471,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,
@@ -549,7 +545,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)
@@ -635,7 +631,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)
index 4fcdf93eb19c5b768f4bdedd455118541c8d8a17..ad9c0ba57a919c311f24b7c44163a3370e3b64e4 100644 (file)
@@ -48,12 +48,8 @@ enum bkw_mmap_state {
        BKW_MMAP_EMPTY,
 };
 
-#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;