diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-08-29 17:17:49 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-08-29 17:20:22 +0100 |
commit | a063199626fa53361146130c0fd1cdfb2adf1320 (patch) | |
tree | 1e9eeba79337ff6b274cc8eda184213ae21a50dc /lib/intel_os.c | |
parent | 572a770f997cae6c3bcb76577e6eac61baa0afa3 (diff) |
lib: Avoid using 2 writes to /proc/sys/vm/drop_caches
As the second write is ignored (leading to lack of memory freeing and
spuriously failing tests), just do everything from the one write.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/intel_os.c')
-rw-r--r-- | lib/intel_os.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/intel_os.c b/lib/intel_os.c index 812199c1..b9f970df 100644 --- a/lib/intel_os.c +++ b/lib/intel_os.c @@ -291,21 +291,19 @@ void intel_require_memory(uint64_t count, uint64_t size, unsigned mode) igt_skip_on_simulation(); } -void -intel_purge_vm_caches(void) +void intel_purge_vm_caches(void) { - static int once; int fd; - fd = open("/proc/sys/vm/drop_caches", O_RDWR); + fd = open("/proc/sys/vm/drop_caches", O_WRONLY); if (fd < 0) return; - if (!once) { - igt_assert_eq(write(fd, "4\n", 2), 2); /* Be quiet! */ - once = 1; - } - igt_assert_eq(write(fd, "3\n", 2), 2); /* Drop page/slab caches */ + /* BIT(0): Drop page cache + * BIT(1): Drop slab cache + * BIT(2): Be quiet in future + */ + igt_ignore_warn(write(fd, "7\n", 2)); close(fd); } |