From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7229DCF8842 for ; Fri, 4 Oct 2024 14:25:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3D97C10EA1E; Fri, 4 Oct 2024 14:25:30 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="J5i78QYB"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id D7DE510E046; Fri, 4 Oct 2024 14:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728051929; x=1759587929; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=oTHAQ15P9F9p+yse5XCZutqxQhRigAzsZoXWYihcX8c=; b=J5i78QYB4gKv3HkmHog6lhFB7a+MvkCy+6cVRQUfLgkirMlVd6FcKzSU M8fdUgFlHJpCHCqQ9RBKGP1KuVM1JcIvbtdNHPHvWRtE6aVeil/5GPIAY HDDWbzsIBRm3Znti5c4RUbeRqGbwCWYafu3cdFOGZVPu+EsGjluppGLt+ HlLe1LK+S8a4koZ/qJu4zkzjish73zTObOjqtGjcdSlhbGZKtFDwyhjqD jN8GjGvC2N3u3sWkg9LvqspC6wfWY5y2ZIY70AhkYJBrBcsY2pIdfvQqU Prc9BcJdaipIjMzoFNOJN49Qs7Wt5VV/dOaQn8i4R4MvTYNJk/b0BCuhS w==; X-CSE-ConnectionGUID: qoATD8viTr2NUysEhHRZSQ== X-CSE-MsgGUID: ccDsxGdrSgq7ki5W2K2a+w== X-IronPort-AV: E=McAfee;i="6700,10204,11215"; a="27422675" X-IronPort-AV: E=Sophos;i="6.11,177,1725346800"; d="scan'208";a="27422675" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2024 07:25:28 -0700 X-CSE-ConnectionGUID: o/xYaLb1TMOeCeNbwI1JrA== X-CSE-MsgGUID: hMQ7S8K7TKOLIQJfttz/3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,177,1725346800"; d="scan'208";a="74304731" Received: from oandoniu-mobl3.ger.corp.intel.com (HELO [10.245.245.57]) ([10.245.245.57]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2024 07:25:27 -0700 Message-ID: <6b335b0f-d67e-43e0-928d-c44208043fa0@intel.com> Date: Fri, 4 Oct 2024 15:25:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] drm/xe/tests: Fix the shrinker test compiler warnings. To: =?UTF-8?Q?Thomas_Hellstr=C3=B6m?= , intel-xe@lists.freedesktop.org Cc: Nathan Chancellor , dri-devel@lists.freedesktop.org References: <20241004141121.186177-1-thomas.hellstrom@linux.intel.com> Content-Language: en-GB From: Matthew Auld In-Reply-To: <20241004141121.186177-1-thomas.hellstrom@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" 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 > 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 > Reviewed-by: Matthew Auld #v1 > Signed-off-by: Thomas Hellström Could probably use div_u64(). Anyway, Reviewed-by: Matthew Auld > --- > 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 > > #include > +#include > #include > #include > > @@ -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);