]> git.proxmox.com Git - mirror_lxc.git/commitdiff
parse: prefault config file with MAP_POPULATE
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Oct 2018 14:40:13 +0000 (16:40 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Oct 2018 14:40:13 +0000 (16:40 +0200)
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@ubuntu.com>
src/lxc/parse.c

index fcc174a7710ea7f6894a02696cc45978772b614b..1c0cc9f49127552b4368f1b14a393ee6bdfd1a35 100644 (file)
@@ -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;