aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/mmap.c
diff options
context:
space:
mode:
authorAlexey Budankov <alexey.budankov@linux.intel.com>2018-11-06 04:03:35 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-12-17 12:55:01 -0500
commit0b77383134f3dbb461189a9c4f3b46b20152045d (patch)
tree7feb64c63da57d61415e61308e6ff122586e550e /tools/perf/util/mmap.c
parent2a07d814747b386feec7d7150fe519feb2a2a5f2 (diff)
perf mmap: Map data buffer for preserving collected data
The map->data buffer is used to preserve map->base profiling data for writing to disk. AIO map->cblock is used to queue corresponding map->data buffer for asynchronous writing. Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com> Reviewed-by: Jiri Olsa <jolsa@redhat.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/5fcda10c-6c63-68df-383a-c6d9e5d1f918@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/mmap.c')
-rw-r--r--tools/perf/util/mmap.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index cdb95b3a1213..47cdc3ad6546 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -153,8 +153,55 @@ void __weak auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp __mayb
153{ 153{
154} 154}
155 155
156#ifdef HAVE_AIO_SUPPORT
157static int perf_mmap__aio_mmap(struct perf_mmap *map, struct mmap_params *mp)
158{
159 int delta_max;
160
161 if (mp->nr_cblocks) {
162 map->aio.data = malloc(perf_mmap__mmap_len(map));
163 if (!map->aio.data) {
164 pr_debug2("failed to allocate data buffer, error %m\n");
165 return -1;
166 }
167 /*
168 * Use cblock.aio_fildes value different from -1
169 * to denote started aio write operation on the
170 * cblock so it requires explicit record__aio_sync()
171 * call prior the cblock may be reused again.
172 */
173 map->aio.cblock.aio_fildes = -1;
174 /*
175 * Allocate cblock with max priority delta to
176 * have faster aio write system calls.
177 */
178 delta_max = sysconf(_SC_AIO_PRIO_DELTA_MAX);
179 map->aio.cblock.aio_reqprio = delta_max;
180 }
181
182 return 0;
183}
184
185static void perf_mmap__aio_munmap(struct perf_mmap *map)
186{
187 if (map->aio.data)
188 zfree(&map->aio.data);
189}
190#else
191static int perf_mmap__aio_mmap(struct perf_mmap *map __maybe_unused,
192 struct mmap_params *mp __maybe_unused)
193{
194 return 0;
195}
196
197static void perf_mmap__aio_munmap(struct perf_mmap *map __maybe_unused)
198{
199}
200#endif
201
156void perf_mmap__munmap(struct perf_mmap *map) 202void perf_mmap__munmap(struct perf_mmap *map)
157{ 203{
204 perf_mmap__aio_munmap(map);
158 if (map->base != NULL) { 205 if (map->base != NULL) {
159 munmap(map->base, perf_mmap__mmap_len(map)); 206 munmap(map->base, perf_mmap__mmap_len(map));
160 map->base = NULL; 207 map->base = NULL;
@@ -197,7 +244,7 @@ int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd, int c
197 &mp->auxtrace_mp, map->base, fd)) 244 &mp->auxtrace_mp, map->base, fd))
198 return -1; 245 return -1;
199 246
200 return 0; 247 return perf_mmap__aio_mmap(map, mp);
201} 248}
202 249
203static int overwrite_rb_find_range(void *buf, int mask, u64 *start, u64 *end) 250static int overwrite_rb_find_range(void *buf, int mask, u64 *start, u64 *end)