Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	intel-xe@lists.freedesktop.org
Cc: Nathan Chancellor <nathan@kernel.org>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/xe/tests: Fix the shrinker test compiler warnings.
Date: Fri, 4 Oct 2024 15:25:25 +0100	[thread overview]
Message-ID: <6b335b0f-d67e-43e0-928d-c44208043fa0@intel.com> (raw)
In-Reply-To: <20241004141121.186177-1-thomas.hellstrom@linux.intel.com>

On 04/10/2024 15:11, Thomas Hellström wrote:
> The xe_bo_shrink_kunit test has an uninitialized value and illegal
> integer size conversions on 32-bit. Fix.
> 
> v2:
> - Use div64_u64 to ensure the u64 division compiles everywhere. (Matt Auld)
> 
> Reported-by: Nathan Chancellor <nathan@kernel.org>
> Closes: https://lore.kernel.org/20240913195649.GA61514@thelio-3990X/
> Fixes: 5a90b60db5e6 ("drm/xe: Add a xe_bo subtest for shrinking / swapping")
> Cc: dri-devel@lists.freedesktop.org
> Cc: Matthew Auld <matthew.auld@intel.com>
> Reviewed-by: Matthew Auld <matthew.auld@intel.com> #v1
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>

Could probably use div_u64().

Anyway,
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

> ---
>   drivers/gpu/drm/xe/tests/xe_bo.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/tests/xe_bo.c b/drivers/gpu/drm/xe/tests/xe_bo.c
> index 7d3fd720478b..cd811aa2b227 100644
> --- a/drivers/gpu/drm/xe/tests/xe_bo.c
> +++ b/drivers/gpu/drm/xe/tests/xe_bo.c
> @@ -7,6 +7,7 @@
>   #include <kunit/visibility.h>
>   
>   #include <linux/iosys-map.h>
> +#include <linux/math64.h>
>   #include <linux/random.h>
>   #include <linux/swap.h>
>   
> @@ -440,7 +441,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;
> @@ -469,7 +470,7 @@ static int shrink_test_run_device(struct xe_device *xe)
>   	ram_and_swap = ram + get_nr_swap_pages() * PAGE_SIZE;
>   	if (to_alloc > ram_and_swap)
>   		purgeable = to_alloc - ram_and_swap;
> -	purgeable += purgeable / 5;
> +	purgeable += div64_u64(purgeable, 5);
>   
>   	kunit_info(test, "Free ram is %lu bytes. Will allocate twice of that.\n",
>   		   (unsigned long)ram);

  reply	other threads:[~2024-10-04 14:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-04 14:11 [PATCH v2] drm/xe/tests: Fix the shrinker test compiler warnings Thomas Hellström
2024-10-04 14:25 ` Matthew Auld [this message]
2024-10-07 12:29 ` ✓ CI.Patch_applied: success for drm/xe/tests: Fix the shrinker test compiler warnings. (rev2) Patchwork
2024-10-07 12:29 ` ✓ CI.checkpatch: " Patchwork
2024-10-07 12:30 ` ✓ CI.KUnit: " Patchwork
2024-10-07 12:42 ` ✓ CI.Build: " Patchwork
2024-10-07 12:44 ` ✓ CI.Hooks: " Patchwork
2024-10-07 12:45 ` ✓ CI.checksparse: " Patchwork
2024-10-07 13:10 ` ✓ CI.BAT: " Patchwork
2024-10-08  6:20 ` ✗ CI.FULL: failure " Patchwork

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=6b335b0f-d67e-43e0-928d-c44208043fa0@intel.com \
    --to=matthew.auld@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=nathan@kernel.org \
    --cc=thomas.hellstrom@linux.intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox