[PATCH 02/11] should_swap

Matthew Auld matthew.auld at intel.com
Fri Sep 3 12:04:08 UTC 2021


---
 drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
index acc435f14ac9..76fee5167e89 100644
--- a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
+++ b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
@@ -1519,6 +1519,7 @@ static int igt_shrink_thp(void *arg)
 	struct i915_vma *vma;
 	unsigned int flags = PIN_USER;
 	unsigned int n;
+	bool should_swap;
 	int err = 0;
 
 	/*
@@ -1571,6 +1572,12 @@ static int igt_shrink_thp(void *arg)
 	if (err)
 		goto out_put;
 
+	should_swap = false;
+	if (get_nr_swap_pages() > 0) {
+		pr_err("found swap space\n");
+		should_swap = true;
+	}
+
 	/*
 	 * Now that the pages are *unpinned* shrinking should invoke
 	 * shmem to truncate our pages.
@@ -1579,7 +1586,7 @@ static int igt_shrink_thp(void *arg)
 			I915_SHRINK_BOUND |
 			I915_SHRINK_UNBOUND |
 			I915_SHRINK_ACTIVE);
-	if (i915_gem_object_has_pages(obj)) {
+	if (should_swap && i915_gem_object_has_pages(obj)) {
 		pr_err("shrinking didn't truncate the pages\n");
 		err = -EINVAL;
 		goto out_put;
-- 
2.26.3



More information about the Intel-gfx-trybot mailing list