shm.c shm.h shm_types.h shm_internal.h \
ring_buffer_backend.c \
ring_buffer_frontend.c \
- api.h \
+ api.h mmap.h \
backend.h backend_internal.h backend_types.h \
frontend_api.h frontend.h frontend_internal.h frontend_types.h \
nohz.h vatomic.h rb-init.h
--- /dev/null
+#ifndef _LTTNG_MMAP_H
+#define _LTTNG_MMAP_H
+
+/*
+ * Copyright (c) 2019 - Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <sys/mman.h>
+
+#if defined(__linux__) && defined(MAP_POPULATE)
+# define LTTNG_MAP_POPULATE MAP_POPULATE
+#else
+# define LTTNG_MAP_POPULATE 0
+#endif /* __linux__ && MAP_POPULATE */
+
+#endif /* _LTTNG_MMAP_H */
#endif
#include <helper.h>
#include <ust-fd.h>
+#include "mmap.h"
/*
* Ensure we have the required amount of space available by writing 0
/* memory_map: mmap */
memory_map = mmap(NULL, memory_map_size, PROT_READ | PROT_WRITE,
- MAP_SHARED, shmfd, 0);
+ MAP_SHARED | LTTNG_MAP_POPULATE, shmfd, 0);
if (memory_map == MAP_FAILED) {
PERROR("mmap");
goto error_mmap;
/* memory_map: mmap */
memory_map = mmap(NULL, memory_map_size, PROT_READ | PROT_WRITE,
- MAP_SHARED, shm_fd, 0);
+ MAP_SHARED | LTTNG_MAP_POPULATE, shm_fd, 0);
if (memory_map == MAP_FAILED) {
PERROR("mmap");
goto error_mmap;