diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-07-21 16:15:24 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-07-21 16:32:42 +0100 |
commit | 70e6ed92abbca575f03f5a28402ef1eb9a6b97b8 (patch) | |
tree | 66a6e11d77e56269aa1822c411a4f7c5e4d1d034 | |
parent | 784b77257b023b5debb05dceb397b4ba6092ae21 (diff) |
linux: Flush page/buffer cache before querying available memory
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | lib/intel_os.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/intel_os.c b/lib/intel_os.c index 2a29cc02..0d4f43da 100644 --- a/lib/intel_os.c +++ b/lib/intel_os.c @@ -98,7 +98,14 @@ intel_get_avail_ram_mb(void) #ifdef HAVE_STRUCT_SYSINFO_TOTALRAM /* Linux */ struct sysinfo sysinf; - int ret; + int fd, ret; + + fd = open("/proc/sys/vm/drop_caches", O_RDWR); + if (fd != -1) { + ret = write(fd, "3", 2); + close(fd); + (void)ret; + } ret = sysinfo(&sysinf); assert(ret == 0); |