All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] lib: Purge os caches twice for good luck
Date: Fri, 15 Jun 2018 14:32:49 +0100	[thread overview]
Message-ID: <20180615133249.3505-1-chris@chris-wilson.co.uk> (raw)

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>
---
 lib/intel_os.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/lib/intel_os.c b/lib/intel_os.c
index 0cd959ea1..88a61f378 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
-- 
2.17.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2018-06-15 13:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15 13:32 Chris Wilson [this message]
2018-06-15 15:31 ` [igt-dev] ✓ Fi.CI.BAT: success for lib: Purge os caches twice for good luck Patchwork
2018-06-16  1:04 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-06-16 18:19 ` [igt-dev] ✓ Fi.CI.BAT: " Patchwork
2018-06-16 19:14 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-06-16 20:42 ` [igt-dev] ✓ Fi.CI.BAT: " Patchwork
2018-06-16 21:34 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-06-17 12:01 ` [igt-dev] ✓ Fi.CI.BAT: " Patchwork
2018-06-17 12:56 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-06-17 18:51 ` [igt-dev] ✓ Fi.CI.BAT: " Patchwork
2018-06-17 19:45 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-06-18  8:06 ` [igt-dev] [PATCH i-g-t] " Chris Wilson
2018-06-18  8:58 ` Joonas Lahtinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180615133249.3505-1-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.