]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
perf cpu_map: Add cpu_map__empty_new function
authorJiri Olsa <jolsa@kernel.org>
Sun, 25 Oct 2015 14:51:17 +0000 (15:51 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 27 Oct 2015 18:05:36 +0000 (15:05 -0300)
Adding cpu_map__empty_new interface to create empty cpumap with given
size. The cpumap entries are initialized with -1.

It'll be used for caching cpu_map in following patches.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1445784728-21732-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/cpumap.c
tools/perf/util/cpumap.h

index aa6b490aa47192820d793adf263d9f90028a1b33..10af1e7524fbd24de791c38fa23c7d730d54a193 100644 (file)
@@ -203,6 +203,23 @@ struct cpu_map *cpu_map__dummy_new(void)
        return cpus;
 }
 
+struct cpu_map *cpu_map__empty_new(int nr)
+{
+       struct cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int) * nr);
+
+       if (cpus != NULL) {
+               int i;
+
+               cpus->nr = nr;
+               for (i = 0; i < nr; i++)
+                       cpus->map[i] = -1;
+
+               atomic_set(&cpus->refcnt, 1);
+       }
+
+       return cpus;
+}
+
 static void cpu_map__delete(struct cpu_map *map)
 {
        if (map) {
index f1bcd2cfa1642be1476124e4240c78a35ecb8a30..85f7772457fa091655d62212067f2edddf6e55ae 100644 (file)
@@ -15,6 +15,7 @@ struct cpu_map {
 };
 
 struct cpu_map *cpu_map__new(const char *cpu_list);
+struct cpu_map *cpu_map__empty_new(int nr);
 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);