Skip to contentSkip to conversation

drm/xe/tests: Fix the shrinker test compiler warnings.

PATCH Superseded Thomas Hellström 2 participants 3 messages Oct 4, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Thomas Hellström

author maintainer
#0 lore raw

PATCH 1/1 drm/xe/tests: Fix the shrinker test compiler warnings.

The xe_bo_shrink_kunit test has an uninitialized value and illegal integer size conversions on 32-bit. Fix.

Fixes 5a90b60db5e6 ("drm/xe: Add a xe_bo subtest for shrinking / swapping")
Cc Matthew Auld <[email protected]>
---
 drivers/gpu/drm/xe/tests/xe_bo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/tests/xe_bo.c +1 -1
index 7d3fd720478b..1562c08aaf34 100644
@@ -440,7 +440,7 @@ static int shrink_test_run_device(struct xe_device *xe)
 	LIST_HEAD(bos);
 	struct xe_bo_link *link, *next;
 	struct sysinfo si;
-	size_t ram, ram_and_swap, purgeable, alloced, to_alloc, limit;
+	u64 ram, ram_and_swap, purgeable = 0, alloced, to_alloc, limit;
 	unsigned int interrupted = 0, successful = 0, count = 0;
 	struct rnd_state prng;
 	u64 rand_seed;
Signature · 1 line
2.46.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Thomas Hellström

The xe_bo_shrink_kunit test has an uninitialized value and illegal integer size conversions on 32-bit. Fix.

Fixes 5a90b60db5e6 ("drm/xe: Add a xe_bo subtest for shrinking / swapping")
Cc Matthew Auld <[email protected]>
---
  drivers/gpu/drm/xe/tests/xe_bo.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/tests/xe_bo.c +0 -0
index 7d3fd720478b..1562c08aaf34 100644

drivers/gpu/drm/xe/tests/xe_bo.c static int shrink_test_run_device(struct xe_device *xe) · line 443

Quoted 5 lines
drivers/gpu/drm/xe/tests/xe_bo.c +1 -1
@@ -440,7 +440,7 @@ static int shrink_test_run_device(struct xe_device *xe)
  	LIST_HEAD(bos);
  	struct xe_bo_link *link, *next;
  	struct sysinfo si;
-	size_t ram, ram_and_swap, purgeable, alloced, to_alloc, limit;
+	u64 ram, ram_and_swap, purgeable = 0, alloced, to_alloc, limit;

Maybe just double check that this doesn't now introduce 64b division errors on 32b arch.

Assuming it doesn't,

Quoted 3 lines
drivers/gpu/drm/xe/tests/xe_bo.c +0 -0
  	unsigned int interrupted = 0, successful = 0, count = 0;
  	struct rnd_state prng;
  	u64 rand_seed;
author maintainer
#2 lore raw
Quoted 33 lines · Matthew Auld
Quoted 20 lines · Thomas Hellström

The xe_bo_shrink_kunit test has an uninitialized value and illegal integer size conversions on 32-bit. Fix.

Closes:
https://lore.kernel.org/20240913195649.GA61514@thelio-3990X/

Fixes 5a90b60db5e6 ("drm/xe: Add a xe_bo subtest for shrinking /

swapping")

---
  drivers/gpu/drm/xe/tests/xe_bo.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/tests/xe_bo.c +0 -0
index 7d3fd720478b..1562c08aaf34 100644

drivers/gpu/drm/xe/tests/xe_bo.c static int shrink_test_run_device(struct · line 446

Quoted 8 lines
drivers/gpu/drm/xe/tests/xe_bo.c +1 -1
@@ -440,7 +440,7 @@ static int shrink_test_run_device(struct
 xe_device *xe)
   	LIST_HEAD(bos);
   	struct xe_bo_link *link, *next;
   	struct sysinfo si;
-	size_t ram, ram_and_swap, purgeable, alloced, to_alloc,
 limit;
+	u64 ram, ram_and_swap, purgeable = 0, alloced, to_alloc,
 limit;

Maybe just double check that this doesn't now introduce 64b division errors on 32b arch.

Quoted 2 lines

Assuming it doesn't,

Good point. While it compiles without missing symbol on gcc ARCH=i386 it may well complain on other compilers / archs. I'll respin to use div64_u64

/Thomas

Quoted 4 lines
Quoted 4 lines

   unsigned int interrupted = 0, successful = 0, count = 0; struct rnd_state prng;
   u64 rand_seed;