[lxc-devel] [lxc/master] parse: prefault config file with MAP_POPULATE

brauner on Github lxc-bot at linuxcontainers.org
Tue Oct 2 14:43:09 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 519 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181002/05c70c79/attachment.bin>
-------------- next part --------------
From 2291ea4a1a40f67d76a108e96cee83cb65038f9a Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 2 Oct 2018 16:40:13 +0200
Subject: [PATCH] parse: prefault config file with MAP_POPULATE

When we call lxc_file_for_each_line_mmap() we will always parse the
whole config file. Prefault it in case it is really long to optimize
performance.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/parse.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/lxc/parse.c b/src/lxc/parse.c
index fcc174a77..1c0cc9f49 100644
--- a/src/lxc/parse.c
+++ b/src/lxc/parse.c
@@ -88,7 +88,8 @@ int lxc_file_for_each_line_mmap(const char *file, lxc_file_cb callback,
 		return 0;
 	}
 
-	buf = lxc_strmmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+	buf = lxc_strmmap(NULL, st.st_size, PROT_READ | PROT_WRITE,
+			  MAP_PRIVATE | MAP_POPULATE, fd, 0);
 	if (buf == MAP_FAILED) {
 		close(fd);
 		return -1;


More information about the lxc-devel mailing list