aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2011-02-18 19:42:21 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2011-02-18 19:42:21 -0500
commitf97d67b869c047d09d424ca29fd725688a4970de (patch)
treecc25ff79d51d81e6d3158fd14b5f475a401c93b4 /src
parentcff74703ad71f333491941d85baaa3f1835101fc (diff)
pre-page mapped files
Diffstat (limited to 'src')
-rw-r--r--src/mapping.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mapping.c b/src/mapping.c
index 45fde9a..e4ce96c 100644
--- a/src/mapping.c
+++ b/src/mapping.c
@@ -5,6 +5,8 @@
5#include <errno.h> 5#include <errno.h>
6#include <unistd.h> 6#include <unistd.h>
7 7
8#include <stdio.h>
9
8#include "mapping.h" 10#include "mapping.h"
9 11
10static int _map_file(const char* filename, void **addr, size_t *size, int writable) 12static int _map_file(const char* filename, void **addr, size_t *size, int writable)
@@ -26,6 +28,13 @@ static int _map_file(const char* filename, void **addr, size_t *size, int writab
26 fd, 0); 28 fd, 0);
27 if (*addr == MAP_FAILED) 29 if (*addr == MAP_FAILED)
28 error = -1; 30 error = -1;
31 else {
32 /* tell kernel to start getting the pages */
33 error = madvise(*addr, *size, MADV_SEQUENTIAL | MADV_WILLNEED);
34 if (error) {
35 perror("madvise");
36 }
37 }
29 close(fd); 38 close(fd);
30 } else 39 } else
31 error = fd; 40 error = fd;