summaryrefslogtreecommitdiff
path: root/lib/intel_os.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2018-06-15 14:31:19 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2018-06-18 10:00:25 +0100
commit778497e7965dc8662c770a89ebbd741778feb71e (patch)
treebd0940818bbdc461bc4b42c98d214b56e6c02b18 /lib/intel_os.c
parent077c6f7c3786334c5e5c34888ab446fdb4347331 (diff)
lib: Purge os caches twice for good luck
If at first we don't succeed, try, try again. References: https://bugs.freedesktop.org/show_bug.cgi?id=105967 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Diffstat (limited to 'lib/intel_os.c')
-rw-r--r--lib/intel_os.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/intel_os.c b/lib/intel_os.c
index 0cd959ea..88a61f37 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -379,32 +379,34 @@ void intel_purge_vm_caches(int drm_fd)
{
int fd;
- igt_drop_caches_set(drm_fd, DROP_SHRINK_ALL | DROP_IDLE | DROP_FREED);
-
fd = open("/proc/sys/vm/drop_caches", O_WRONLY);
if (fd >= 0) {
- /* BIT(2): Be quiet. Cannot be combined with other operations,
+ /*
+ * BIT(2): Be quiet. Cannot be combined with other operations,
* the sysctl has a max value of 4.
*/
igt_ignore_warn(write(fd, "4\n", 2));
close(fd);
}
- /* Reset write position back to start. Do as a seperate write to keep
- * the stages segregated and avoid failure from the squelching stopping
- * the purge.
- */
- fd = open("/proc/sys/vm/drop_caches", O_WRONLY);
- if (fd < 0)
- return;
+ for (int loop = 0; loop < 2; loop++) {
+ igt_drop_caches_set(drm_fd,
+ DROP_SHRINK_ALL | DROP_IDLE | DROP_FREED);
- /* BIT(0): Drop page cache
- * BIT(1): Drop slab cache
- */
- igt_ignore_warn(write(fd, "3\n", 2));
- close(fd);
-}
+ fd = open("/proc/sys/vm/drop_caches", O_WRONLY);
+ if (fd < 0)
+ continue;
+ /*
+ * BIT(0): Drop page cache
+ * BIT(1): Drop slab cache
+ */
+ igt_ignore_warn(write(fd, "3\n", 2));
+ close(fd);
+ }
+
+ errno = 0;
+}
/*
* When testing a port to a new platform, create a standalone test binary