OSDN Git Service

libperf: Add 'event_copy' to 'struct perf_mmap'
authorJiri Olsa <jolsa@kernel.org>
Sat, 27 Jul 2019 20:47:58 +0000 (22:47 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 25 Sep 2019 12:51:46 +0000 (09:51 -0300)
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>
tools/perf/lib/include/internal/mmap.h
tools/perf/util/mmap.c
tools/perf/util/mmap.h

index 47c09f3..10653b6 100644 (file)
@@ -2,10 +2,14 @@
 #ifndef __LIBPERF_INTERNAL_MMAP_H
 #define __LIBPERF_INTERNAL_MMAP_H
 
+#include <linux/compiler.h>
 #include <linux/refcount.h>
 #include <linux/types.h>
 #include <stdbool.h>
 
+/* perf sample has 16 bits size limit */
+#define PERF_SAMPLE_MAX_SIZE (1 << 16)
+
 /**
  * struct perf_mmap - perf's ring buffer mmap details
  *
@@ -21,6 +25,7 @@ struct perf_mmap {
        u64              start;
        u64              end;
        bool             overwrite;
+       char             event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8);
 };
 
 #endif /* __LIBPERF_INTERNAL_MMAP_H */
index a8850ce..4b8ec8d 100644 (file)
@@ -51,7 +51,7 @@ static union perf_event *perf_mmap__read(struct mmap *map,
                if ((*startp & map->core.mask) + size != ((*startp + size) & map->core.mask)) {
                        unsigned int offset = *startp;
                        unsigned int len = min(sizeof(*event), size), cpy;
-                       void *dst = map->event_copy;
+                       void *dst = map->core.event_copy;
 
                        do {
                                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,
                                len -= cpy;
                        } while (len);
 
-                       event = (union perf_event *)map->event_copy;
+                       event = (union perf_event *)map->core.event_copy;
                }
 
                *startp += size;
index d3e74c8..75c77fa 100644 (file)
@@ -23,7 +23,6 @@ struct aiocb;
 struct mmap {
        struct perf_mmap        core;
        struct auxtrace_mmap auxtrace_mmap;
-       char             event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8);
 #ifdef HAVE_AIO_SUPPORT
        struct {
                void             **data;