diff options
author | Jiri Olsa <jolsa@kernel.org> | 2019-07-21 07:24:44 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-07-29 17:34:45 -0400 |
commit | 4b247fa7314ce48282f3da400a9ffb7f3fd3f863 (patch) | |
tree | 24382bbdf28160daa8e2278e709d7432e78b50c9 | |
parent | 453fa03090a64c0e0a561f10dfd5e8747796949c (diff) |
libperf: Adopt xyarray class from perf
Move the xyarray class from perf to libperf, because it's going to be
used in both.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190721112506.12306-58-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-top.c | 1 | ||||
-rw-r--r-- | tools/perf/lib/Build | 1 | ||||
-rw-r--r-- | tools/perf/lib/include/internal/xyarray.h (renamed from tools/perf/util/xyarray.h) | 6 | ||||
-rw-r--r-- | tools/perf/lib/xyarray.c | 33 | ||||
-rw-r--r-- | tools/perf/util/Build | 1 | ||||
-rw-r--r-- | tools/perf/util/counts.h | 2 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 2 | ||||
-rw-r--r-- | tools/perf/util/python-ext-sources | 1 | ||||
-rw-r--r-- | tools/perf/util/stat.h | 1 |
9 files changed, 39 insertions, 9 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index c69ddc67c672..1a4615a5f6c9 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <subcmd/parse-options.h> | 38 | #include <subcmd/parse-options.h> |
39 | #include "util/parse-events.h" | 39 | #include "util/parse-events.h" |
40 | #include "util/cpumap.h" | 40 | #include "util/cpumap.h" |
41 | #include "util/xyarray.h" | ||
42 | #include "util/sort.h" | 41 | #include "util/sort.h" |
43 | #include "util/string2.h" | 42 | #include "util/string2.h" |
44 | #include "util/term.h" | 43 | #include "util/term.h" |
diff --git a/tools/perf/lib/Build b/tools/perf/lib/Build index faf64db13e37..4f78ec0b4e10 100644 --- a/tools/perf/lib/Build +++ b/tools/perf/lib/Build | |||
@@ -4,6 +4,7 @@ libperf-y += threadmap.o | |||
4 | libperf-y += evsel.o | 4 | libperf-y += evsel.o |
5 | libperf-y += evlist.o | 5 | libperf-y += evlist.o |
6 | libperf-y += zalloc.o | 6 | libperf-y += zalloc.o |
7 | libperf-y += xyarray.o | ||
7 | 8 | ||
8 | $(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE | 9 | $(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE |
9 | $(call rule_mkdir) | 10 | $(call rule_mkdir) |
diff --git a/tools/perf/util/xyarray.h b/tools/perf/lib/include/internal/xyarray.h index 7ffe562e7ae7..3bf70e4d474c 100644 --- a/tools/perf/util/xyarray.h +++ b/tools/perf/lib/include/internal/xyarray.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef _PERF_XYARRAY_H_ | 2 | #ifndef __LIBPERF_INTERNAL_XYARRAY_H |
3 | #define _PERF_XYARRAY_H_ 1 | 3 | #define __LIBPERF_INTERNAL_XYARRAY_H |
4 | 4 | ||
5 | #include <sys/types.h> | 5 | #include <sys/types.h> |
6 | 6 | ||
@@ -32,4 +32,4 @@ static inline int xyarray__max_x(struct xyarray *xy) | |||
32 | return xy->max_x; | 32 | return xy->max_x; |
33 | } | 33 | } |
34 | 34 | ||
35 | #endif /* _PERF_XYARRAY_H_ */ | 35 | #endif /* __LIBPERF_INTERNAL_XYARRAY_H */ |
diff --git a/tools/perf/lib/xyarray.c b/tools/perf/lib/xyarray.c new file mode 100644 index 000000000000..dcd901d154bb --- /dev/null +++ b/tools/perf/lib/xyarray.c | |||
@@ -0,0 +1,33 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
2 | #include <internal/xyarray.h> | ||
3 | #include <linux/zalloc.h> | ||
4 | #include <stdlib.h> | ||
5 | #include <string.h> | ||
6 | |||
7 | struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size) | ||
8 | { | ||
9 | size_t row_size = ylen * entry_size; | ||
10 | struct xyarray *xy = zalloc(sizeof(*xy) + xlen * row_size); | ||
11 | |||
12 | if (xy != NULL) { | ||
13 | xy->entry_size = entry_size; | ||
14 | xy->row_size = row_size; | ||
15 | xy->entries = xlen * ylen; | ||
16 | xy->max_x = xlen; | ||
17 | xy->max_y = ylen; | ||
18 | } | ||
19 | |||
20 | return xy; | ||
21 | } | ||
22 | |||
23 | void xyarray__reset(struct xyarray *xy) | ||
24 | { | ||
25 | size_t n = xy->entries * xy->entry_size; | ||
26 | |||
27 | memset(xy->contents, 0, n); | ||
28 | } | ||
29 | |||
30 | void xyarray__delete(struct xyarray *xy) | ||
31 | { | ||
32 | free(xy); | ||
33 | } | ||
diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 08f670d21615..7abf05131889 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build | |||
@@ -69,7 +69,6 @@ perf-y += svghelper.o | |||
69 | perf-y += sort.o | 69 | perf-y += sort.o |
70 | perf-y += hist.o | 70 | perf-y += hist.o |
71 | perf-y += util.o | 71 | perf-y += util.o |
72 | perf-y += xyarray.o | ||
73 | perf-y += cpumap.o | 72 | perf-y += cpumap.o |
74 | perf-y += cputopo.o | 73 | perf-y += cputopo.o |
75 | perf-y += cgroup.o | 74 | perf-y += cgroup.o |
diff --git a/tools/perf/util/counts.h b/tools/perf/util/counts.h index 0f0cb2d8f70d..bbfac9ecf642 100644 --- a/tools/perf/util/counts.h +++ b/tools/perf/util/counts.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #ifndef __PERF_COUNTS_H | 2 | #ifndef __PERF_COUNTS_H |
3 | #define __PERF_COUNTS_H | 3 | #define __PERF_COUNTS_H |
4 | 4 | ||
5 | #include "xyarray.h" | 5 | #include <internal/xyarray.h> |
6 | 6 | ||
7 | struct perf_counts_values { | 7 | struct perf_counts_values { |
8 | union { | 8 | union { |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 57b5523b480c..1f9f66fe43f4 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -8,7 +8,7 @@ | |||
8 | #include <linux/perf_event.h> | 8 | #include <linux/perf_event.h> |
9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
10 | #include <internal/evsel.h> | 10 | #include <internal/evsel.h> |
11 | #include "xyarray.h" | 11 | #include <internal/xyarray.h> |
12 | #include "symbol_conf.h" | 12 | #include "symbol_conf.h" |
13 | #include "cpumap.h" | 13 | #include "cpumap.h" |
14 | #include "counts.h" | 14 | #include "counts.h" |
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources index 2237bac9fadb..235bd9803390 100644 --- a/tools/perf/util/python-ext-sources +++ b/tools/perf/util/python-ext-sources | |||
@@ -20,7 +20,6 @@ util/namespaces.c | |||
20 | ../lib/vsprintf.c | 20 | ../lib/vsprintf.c |
21 | util/thread_map.c | 21 | util/thread_map.c |
22 | util/util.c | 22 | util/util.c |
23 | util/xyarray.c | ||
24 | util/cgroup.c | 23 | util/cgroup.c |
25 | util/parse-branch-options.c | 24 | util/parse-branch-options.c |
26 | util/rblist.c | 25 | util/rblist.c |
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 95b4de7a9d51..bcb376e1b3a7 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <sys/time.h> | 8 | #include <sys/time.h> |
9 | #include <sys/resource.h> | 9 | #include <sys/resource.h> |
10 | #include <sys/wait.h> | 10 | #include <sys/wait.h> |
11 | #include "xyarray.h" | ||
12 | #include "rblist.h" | 11 | #include "rblist.h" |
13 | #include "perf.h" | 12 | #include "perf.h" |
14 | #include "event.h" | 13 | #include "event.h" |