perf cpu_map: Add data arg to cpu_map__build_map callback
authorJiri Olsa <jolsa@kernel.org>
Fri, 16 Oct 2015 10:41:15 +0000 (12:41 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 19 Oct 2015 21:04:01 +0000 (18:04 -0300)
Adding data arg to cpu_map__build_map callback, so we could pass data
along to the callback. It'll be needed in following patches to retrieve
topology info from perf.data.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Kan Liang <kan.liang@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1444992092-17897-41-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-stat.c
tools/perf/tests/topology.c
tools/perf/util/cpumap.c
tools/perf/util/cpumap.h
tools/perf/util/stat.c

index abeb15aebd12af779af66246838d7aa55168f951..91e793a76929dfe58a26211ad31ed24bb798851a 100644 (file)
@@ -944,6 +944,16 @@ static int stat__set_big_num(const struct option *opt __maybe_unused,
        return 0;
 }
 
+static int perf_stat__get_socket(struct cpu_map *map, int cpu)
+{
+       return cpu_map__get_socket(map, cpu, NULL);
+}
+
+static int perf_stat__get_core(struct cpu_map *map, int cpu)
+{
+       return cpu_map__get_core(map, cpu, NULL);
+}
+
 static int perf_stat_init_aggr_mode(void)
 {
        switch (stat_config.aggr_mode) {
@@ -952,14 +962,14 @@ static int perf_stat_init_aggr_mode(void)
                        perror("cannot build socket map");
                        return -1;
                }
-               aggr_get_id = cpu_map__get_socket;
+               aggr_get_id = perf_stat__get_socket;
                break;
        case AGGR_CORE:
                if (cpu_map__build_core_map(evsel_list->cpus, &aggr_map)) {
                        perror("cannot build core map");
                        return -1;
                }
-               aggr_get_id = cpu_map__get_core;
+               aggr_get_id = perf_stat__get_core;
                break;
        case AGGR_NONE:
        case AGGR_GLOBAL:
index c3aff53a976a57f30085252650cc2f2acd9f678d..f5bb096c3bd9704d2996468d0da490b4226b5c51 100644 (file)
@@ -73,10 +73,10 @@ static int check_cpu_topology(char *path, struct cpu_map *map)
 
        for (i = 0; i < map->nr; i++) {
                TEST_ASSERT_VAL("Core ID doesn't match",
-                       (session->header.env.cpu[map->map[i]].core_id == (cpu_map__get_core(map, i) & 0xffff)));
+                       (session->header.env.cpu[map->map[i]].core_id == (cpu_map__get_core(map, i, NULL) & 0xffff)));
 
                TEST_ASSERT_VAL("Socket ID doesn't match",
-                       (session->header.env.cpu[map->map[i]].socket_id == cpu_map__get_socket(map, i)));
+                       (session->header.env.cpu[map->map[i]].socket_id == cpu_map__get_socket(map, i, NULL)));
        }
 
        perf_session__delete(session);
index 70ec8d031f9d69d401e1487c63181d22d1439f50..b36845347f014768cea5679a4842008992441134 100644 (file)
@@ -241,7 +241,7 @@ int cpu_map__get_socket_id(int cpu)
        return ret ?: value;
 }
 
-int cpu_map__get_socket(struct cpu_map *map, int idx)
+int cpu_map__get_socket(struct cpu_map *map, int idx, void *data __maybe_unused)
 {
        int cpu;
 
@@ -259,7 +259,8 @@ static int cmp_ids(const void *a, const void *b)
 }
 
 int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res,
-                      int (*f)(struct cpu_map *map, int cpu))
+                      int (*f)(struct cpu_map *map, int cpu, void *data),
+                      void *data)
 {
        struct cpu_map *c;
        int nr = cpus->nr;
@@ -271,7 +272,7 @@ int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res,
                return -1;
 
        for (cpu = 0; cpu < nr; cpu++) {
-               s1 = f(cpus, cpu);
+               s1 = f(cpus, cpu, data);
                for (s2 = 0; s2 < c->nr; s2++) {
                        if (s1 == c->map[s2])
                                break;
@@ -295,7 +296,7 @@ int cpu_map__get_core_id(int cpu)
        return ret ?: value;
 }
 
-int cpu_map__get_core(struct cpu_map *map, int idx)
+int cpu_map__get_core(struct cpu_map *map, int idx, void *data)
 {
        int cpu, s;
 
@@ -306,7 +307,7 @@ int cpu_map__get_core(struct cpu_map *map, int idx)
 
        cpu = cpu_map__get_core_id(cpu);
 
-       s = cpu_map__get_socket(map, idx);
+       s = cpu_map__get_socket(map, idx, data);
        if (s == -1)
                return -1;
 
@@ -321,12 +322,12 @@ int cpu_map__get_core(struct cpu_map *map, int idx)
 
 int cpu_map__build_socket_map(struct cpu_map *cpus, struct cpu_map **sockp)
 {
-       return cpu_map__build_map(cpus, sockp, cpu_map__get_socket);
+       return cpu_map__build_map(cpus, sockp, cpu_map__get_socket, NULL);
 }
 
 int cpu_map__build_core_map(struct cpu_map *cpus, struct cpu_map **corep)
 {
-       return cpu_map__build_map(cpus, corep, cpu_map__get_core);
+       return cpu_map__build_map(cpus, corep, cpu_map__get_core, NULL);
 }
 
 /* setup simple routines to easily access node numbers given a cpu number */
index 6e36fc35eca6f08f66bbb91b63e31b50687b3399..f1bcd2cfa1642be1476124e4240c78a35ecb8a30 100644 (file)
@@ -19,9 +19,9 @@ struct cpu_map *cpu_map__dummy_new(void);
 struct cpu_map *cpu_map__read(FILE *file);
 size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp);
 int cpu_map__get_socket_id(int cpu);
-int cpu_map__get_socket(struct cpu_map *map, int idx);
+int cpu_map__get_socket(struct cpu_map *map, int idx, void *data);
 int cpu_map__get_core_id(int cpu);
-int cpu_map__get_core(struct cpu_map *map, int idx);
+int cpu_map__get_core(struct cpu_map *map, int idx, void *data);
 int cpu_map__build_socket_map(struct cpu_map *cpus, struct cpu_map **sockp);
 int cpu_map__build_core_map(struct cpu_map *cpus, struct cpu_map **corep);
 
@@ -88,5 +88,6 @@ static inline int cpu__get_node(int cpu)
 }
 
 int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res,
-                      int (*f)(struct cpu_map *map, int cpu));
+                      int (*f)(struct cpu_map *map, int cpu, void *data),
+                      void *data);
 #endif /* __PERF_CPUMAP_H */
index 837374181ec719afc8adadf5a4fb9d476d735d6f..2d9d8306dbd3f97f3d1f9734ace17b25d9ed583a 100644 (file)
@@ -230,7 +230,7 @@ static int check_per_pkg(struct perf_evsel *counter,
        if (!(vals->run && vals->ena))
                return 0;
 
-       s = cpu_map__get_socket(cpus, cpu);
+       s = cpu_map__get_socket(cpus, cpu, NULL);
        if (s < 0)
                return -1;
 
This page took 0.037061 seconds and 5 git commands to generate.