aboutsummaryrefslogtreecommitdiffstats
path: root/lib/librte_eal/common/eal_common_memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/librte_eal/common/eal_common_memory.c')
-rw-r--r--lib/librte_eal/common/eal_common_memory.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 6155752e..996877ef 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -35,7 +35,9 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <unistd.h>
#include <inttypes.h>
+#include <sys/mman.h>
#include <sys/queue.h>
#include <rte_memory.h>
@@ -135,6 +137,16 @@ rte_eal_memdevice_init(void)
return 0;
}
+/* Lock page in physical memory and prevent from swapping. */
+int
+rte_mem_lock_page(const void *virt)
+{
+ unsigned long virtual = (unsigned long)virt;
+ int page_size = getpagesize();
+ unsigned long aligned = (virtual & ~(page_size - 1));
+ return mlock((void *)aligned, page_size);
+}
+
/* init memory subsystem */
int
rte_eal_memory_init(void)