From a063199626fa53361146130c0fd1cdfb2adf1320 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 29 Aug 2016 17:17:49 +0100 Subject: 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 --- lib/intel_os.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'lib/intel_os.c') 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); } -- cgit v1.2.3