aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2019-07-27 16:47:58 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-09-25 08:51:46 -0400
commit4443e6d7704ee85412e5cb0a0181d7ceee7e984f (patch)
treea7a3e5465a9b60e08737a6193e79adf7b6b5c08f /tools
parent8df7a869818ec278969d34e4792985f12b24f23d (diff)
libperf: Add 'event_copy' to 'struct perf_mmap'
Move 'event_copy' from tools/perf's mmap to libperf's perf_mmap struct. Committer notes: Add linux/compiler.h as we need it for '__aligned'. 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-18-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/lib/include/internal/mmap.h5
-rw-r--r--tools/perf/util/mmap.c4
-rw-r--r--tools/perf/util/mmap.h1
3 files changed, 7 insertions, 3 deletions
diff --git a/tools/perf/lib/include/internal/mmap.h b/tools/perf/lib/include/internal/mmap.h
index 47c09f375fb6..10653b6e864e 100644
--- a/tools/perf/lib/include/internal/mmap.h
+++ b/tools/perf/lib/include/internal/mmap.h
@@ -2,10 +2,14 @@
2#ifndef __LIBPERF_INTERNAL_MMAP_H 2#ifndef __LIBPERF_INTERNAL_MMAP_H
3#define __LIBPERF_INTERNAL_MMAP_H 3#define __LIBPERF_INTERNAL_MMAP_H
4 4
5#include <linux/compiler.h>
5#include <linux/refcount.h> 6#include <linux/refcount.h>
6#include <linux/types.h> 7#include <linux/types.h>
7#include <stdbool.h> 8#include <stdbool.h>
8 9
10/* perf sample has 16 bits size limit */
11#define PERF_SAMPLE_MAX_SIZE (1 << 16)
12
9/** 13/**
10 * struct perf_mmap - perf's ring buffer mmap details 14 * struct perf_mmap - perf's ring buffer mmap details
11 * 15 *
@@ -21,6 +25,7 @@ struct perf_mmap {
21 u64 start; 25 u64 start;
22 u64 end; 26 u64 end;
23 bool overwrite; 27 bool overwrite;
28 char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8);
24}; 29};
25 30
26#endif /* __LIBPERF_INTERNAL_MMAP_H */ 31#endif /* __LIBPERF_INTERNAL_MMAP_H */
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index a8850ce2c2ff..4b8ec8dd79c5 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -51,7 +51,7 @@ static union perf_event *perf_mmap__read(struct mmap *map,
51 if ((*startp & map->core.mask) + size != ((*startp + size) & map->core.mask)) { 51 if ((*startp & map->core.mask) + size != ((*startp + size) & map->core.mask)) {
52 unsigned int offset = *startp; 52 unsigned int offset = *startp;
53 unsigned int len = min(sizeof(*event), size), cpy; 53 unsigned int len = min(sizeof(*event), size), cpy;
54 void *dst = map->event_copy; 54 void *dst = map->core.event_copy;
55 55
56 do { 56 do {
57 cpy = min(map->core.mask + 1 - (offset & map->core.mask), len); 57 cpy = min(map->core.mask + 1 - (offset & map->core.mask), len);
@@ -61,7 +61,7 @@ static union perf_event *perf_mmap__read(struct mmap *map,
61 len -= cpy; 61 len -= cpy;
62 } while (len); 62 } while (len);
63 63
64 event = (union perf_event *)map->event_copy; 64 event = (union perf_event *)map->core.event_copy;
65 } 65 }
66 66
67 *startp += size; 67 *startp += size;
diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h
index d3e74c8da51a..75c77fa57121 100644
--- a/tools/perf/util/mmap.h
+++ b/tools/perf/util/mmap.h
@@ -23,7 +23,6 @@ struct aiocb;
23struct mmap { 23struct mmap {
24 struct perf_mmap core; 24 struct perf_mmap core;
25 struct auxtrace_mmap auxtrace_mmap; 25 struct auxtrace_mmap auxtrace_mmap;
26 char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8);
27#ifdef HAVE_AIO_SUPPORT 26#ifdef HAVE_AIO_SUPPORT
28 struct { 27 struct {
29 void **data; 28 void **data;