dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/i915/selftests: fixup igt_shrink_thp
@ 2021-07-28 15:50 Matthew Auld
  2021-07-29 10:53 ` [Intel-gfx] " Tvrtko Ursulin
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Auld @ 2021-07-28 15:50 UTC (permalink / raw)
  To: intel-gfx; +Cc: dri-devel, Tvrtko Ursulin

Since the object might still be active here, the shrink_all will simply
ignore it, which blows up in the test, since the pages will still be
there. Currently THP is disabled which should result in the test being
skipped, but if we ever re-enable THP we might start seeing the failure.
Fix this by forcing I915_SHRINK_ACTIVE.

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 5 ++++-
 1 file changed, 4 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 a094f3ce1a90..7a67e880b562 100644
--- a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
+++ b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
@@ -1575,7 +1575,10 @@ static int igt_shrink_thp(void *arg)
 	 * Now that the pages are *unpinned* shrink-all should invoke
 	 * shmem to truncate our pages.
 	 */
-	i915_gem_shrink_all(i915);
+	i915_gem_shrink(NULL, i915, -1UL, NULL,
+			I915_SHRINK_BOUND |
+			I915_SHRINK_UNBOUND |
+			I915_SHRINK_ACTIVE);
 	if (i915_gem_object_has_pages(obj)) {
 		pr_err("shrink-all didn't truncate the pages\n");
 		err = -EINVAL;
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Intel-gfx] [PATCH] drm/i915/selftests: fixup igt_shrink_thp
  2021-07-28 15:50 [PATCH] drm/i915/selftests: fixup igt_shrink_thp Matthew Auld
@ 2021-07-29 10:53 ` Tvrtko Ursulin
  2021-07-29 10:55   ` Matthew Auld
  0 siblings, 1 reply; 4+ messages in thread
From: Tvrtko Ursulin @ 2021-07-29 10:53 UTC (permalink / raw)
  To: Matthew Auld, intel-gfx; +Cc: dri-devel


Hi Matt,

On 28/07/2021 16:50, Matthew Auld wrote:
> Since the object might still be active here, the shrink_all will simply
> ignore it, which blows up in the test, since the pages will still be
> there. Currently THP is disabled which should result in the test being
> skipped, but if we ever re-enable THP we might start seeing the failure.
> Fix this by forcing I915_SHRINK_ACTIVE.
> 
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 5 ++++-
>   1 file changed, 4 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 a094f3ce1a90..7a67e880b562 100644
> --- a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
> +++ b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
> @@ -1575,7 +1575,10 @@ static int igt_shrink_thp(void *arg)
>   	 * Now that the pages are *unpinned* shrink-all should invoke
>   	 * shmem to truncate our pages.
>   	 */
> -	i915_gem_shrink_all(i915);
> +	i915_gem_shrink(NULL, i915, -1UL, NULL,
> +			I915_SHRINK_BOUND |
> +			I915_SHRINK_UNBOUND |
> +			I915_SHRINK_ACTIVE);
>   	if (i915_gem_object_has_pages(obj)) {
>   		pr_err("shrink-all didn't truncate the pages\n");
>   		err = -EINVAL;
> 

I did s/shrink-all/shrinking/ locally in the comment above, and in 
pr_err below the call to shrinker. Are you okay if I repost like that 
and with my r-b as part of my series?

Regards,

Tvrtko

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Intel-gfx] [PATCH] drm/i915/selftests: fixup igt_shrink_thp
  2021-07-29 10:53 ` [Intel-gfx] " Tvrtko Ursulin
@ 2021-07-29 10:55   ` Matthew Auld
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Auld @ 2021-07-29 10:55 UTC (permalink / raw)
  To: Tvrtko Ursulin, intel-gfx; +Cc: dri-devel

On 29/07/2021 11:53, Tvrtko Ursulin wrote:
> 
> Hi Matt,
> 
> On 28/07/2021 16:50, Matthew Auld wrote:
>> Since the object might still be active here, the shrink_all will simply
>> ignore it, which blows up in the test, since the pages will still be
>> there. Currently THP is disabled which should result in the test being
>> skipped, but if we ever re-enable THP we might start seeing the failure.
>> Fix this by forcing I915_SHRINK_ACTIVE.
>>
>> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
>> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> ---
>>   drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 5 ++++-
>>   1 file changed, 4 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 a094f3ce1a90..7a67e880b562 100644
>> --- a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
>> +++ b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
>> @@ -1575,7 +1575,10 @@ static int igt_shrink_thp(void *arg)
>>        * Now that the pages are *unpinned* shrink-all should invoke
>>        * shmem to truncate our pages.
>>        */
>> -    i915_gem_shrink_all(i915);
>> +    i915_gem_shrink(NULL, i915, -1UL, NULL,
>> +            I915_SHRINK_BOUND |
>> +            I915_SHRINK_UNBOUND |
>> +            I915_SHRINK_ACTIVE);
>>       if (i915_gem_object_has_pages(obj)) {
>>           pr_err("shrink-all didn't truncate the pages\n");
>>           err = -EINVAL;
>>
> 
> I did s/shrink-all/shrinking/ locally in the comment above, and in 
> pr_err below the call to shrinker. Are you okay if I repost like that 
> and with my r-b as part of my series?

Sure.

> 
> Regards,
> 
> Tvrtko

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] drm/i915/selftests: fixup igt_shrink_thp
@ 2021-09-06  9:17 Matthew Auld
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Auld @ 2021-09-06  9:17 UTC (permalink / raw)
  To: intel-gfx; +Cc: dri-devel, Tvrtko Ursulin, Thomas Hellström

Since the object might still be active here, the shrink_all will simply
ignore it, which blows up in the test, since the pages will still be
there. Currently THP is disabled which should result in the test being
skipped, but if we ever re-enable THP we might start seeing the failure.
Fix this by forcing I915_SHRINK_ACTIVE.

v2: Some machine in the shard runs doesn't seem to have any available
swap when running this test. Try to handle this.

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> #v1
---
 .../gpu/drm/i915/gem/selftests/huge_pages.c   | 31 ++++++++++++++-----
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
index a094f3ce1a90..46ea1997c114 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;
 
 	/*
@@ -1567,23 +1568,39 @@ static int igt_shrink_thp(void *arg)
 			break;
 	}
 	i915_gem_context_unlock_engines(ctx);
+	/*
+	 * Nuke everything *before* we unpin the pages so we can be reasonably
+	 * sure that when later checking get_nr_swap_pages() that some random
+	 * leftover object doesn't steal the remaining swap space.
+	 */
+	i915_gem_shrink(NULL, i915, -1UL, NULL,
+			I915_SHRINK_BOUND |
+			I915_SHRINK_UNBOUND |
+			I915_SHRINK_ACTIVE);
 	i915_vma_unpin(vma);
 	if (err)
 		goto out_put;
 
+
 	/*
-	 * Now that the pages are *unpinned* shrink-all should invoke
-	 * shmem to truncate our pages.
+	 * Now that the pages are *unpinned* shrinking should invoke
+	 * shmem to truncate our pages, if we have available swap.
 	 */
-	i915_gem_shrink_all(i915);
-	if (i915_gem_object_has_pages(obj)) {
-		pr_err("shrink-all didn't truncate the pages\n");
+	should_swap = get_nr_swap_pages() > 0;
+	i915_gem_shrink(NULL, i915, -1UL, NULL,
+			I915_SHRINK_BOUND |
+			I915_SHRINK_UNBOUND |
+			I915_SHRINK_ACTIVE);
+	if (should_swap == i915_gem_object_has_pages(obj)) {
+		pr_err("unexpected pages mismatch, should_swap=%s\n",
+		       yesno(should_swap));
 		err = -EINVAL;
 		goto out_put;
 	}
 
-	if (obj->mm.page_sizes.sg || obj->mm.page_sizes.phys) {
-		pr_err("residual page-size bits left\n");
+	if (should_swap == (obj->mm.page_sizes.sg || obj->mm.page_sizes.phys)) {
+		pr_err("unexpected residual page-size bits, should_swap=%s\n",
+		       yesno(should_swap));
 		err = -EINVAL;
 		goto out_put;
 	}
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-06  9:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-28 15:50 [PATCH] drm/i915/selftests: fixup igt_shrink_thp Matthew Auld
2021-07-29 10:53 ` [Intel-gfx] " Tvrtko Ursulin
2021-07-29 10:55   ` Matthew Auld
2021-09-06  9:17 Matthew Auld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).