Skip to content

Commit 18f2806

Browse files
committed
use MAP_POPULATE on Linux if -ql
1 parent af86e27 commit 18f2806

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

vmtouch.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ void vmtouch_file(char *path) {
504504
int i;
505505
int res;
506506
int open_flags;
507+
int mmap_flags = MAP_SHARED;
507508

508509
retry_open:
509510

@@ -572,7 +573,13 @@ void vmtouch_file(char *path) {
572573
len_of_range = len_of_file - offset;
573574
}
574575

575-
mem = mmap(NULL, len_of_range, PROT_READ, MAP_SHARED, fd, offset);
576+
#ifdef __linux__
577+
if (o_lock && o_quiet) {
578+
mmap_flags |= MAP_POPULATE;
579+
}
580+
#endif
581+
582+
mem = mmap(NULL, len_of_range, PROT_READ, mmap_flags, fd, offset);
576583

577584
if (mem == MAP_FAILED) {
578585
warning("unable to mmap file %s (%s), skipping", path, strerror(errno));
@@ -597,7 +604,11 @@ void vmtouch_file(char *path) {
597604
#else
598605
fatal("cache eviction not (yet?) supported on this platform");
599606
#endif
607+
#ifdef __linux__
608+
} else if (!(o_lock && o_quiet)) {
609+
#else
600610
} else {
611+
#endif
601612
double last_chart_print_time=0.0, temp_time;
602613
char *mincore_array = malloc(pages_in_range);
603614
if (mincore_array == NULL) fatal("Failed to allocate memory for mincore array (%s)", strerror(errno));

0 commit comments

Comments
 (0)