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 47FB9E80AA6 for ; Wed, 27 Sep 2023 13:48:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 99C0310E52D; Wed, 27 Sep 2023 13:48:19 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id BF43910E52B; Wed, 27 Sep 2023 13:48:17 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 411E31FB; Wed, 27 Sep 2023 06:48:55 -0700 (PDT) Received: from [10.57.2.15] (unknown [10.57.2.15]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E1D953F59C; Wed, 27 Sep 2023 06:48:15 -0700 (PDT) Message-ID: <3344d3cf-2883-27d1-424e-d33b739dceb5@arm.com> Date: Wed, 27 Sep 2023 14:48:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 To: Tvrtko Ursulin , Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org References: <20230927133843.247957-1-tvrtko.ursulin@linux.intel.com> <20230927133843.247957-2-tvrtko.ursulin@linux.intel.com> Content-Language: en-GB From: Steven Price In-Reply-To: <20230927133843.247957-2-tvrtko.ursulin@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: [Intel-gfx] [PATCH 1/7] drm: Do not round to megabytes for greater than 1MiB sizes in fdinfo stats X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?Q?Adri=c3=a1n_Larumbe?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On 27/09/2023 14:38, Tvrtko Ursulin wrote: > From: Tvrtko Ursulin > > It is better not to lose precision and not revert to 1 MiB size > granularity for every size greater than 1 MiB. > > Sizes in KiB should not be so troublesome to read (and in fact machine > parsing is I expect the norm here), they align with other api like > /proc/meminfo, and they allow writing tests for the interface without > having to embed drm.ko implementation knowledge into them. (Like knowing > that minimum buffer size one can use for successful verification has to be > 1MiB aligned, and on top account for any pre-existing memory utilisation > outside of driver's control.) > > But probably even more importantly I think that it is just better to show > the accurate sizes and not arbitrary lose precision for a little bit of a > stretched use case of eyeballing fdinfo text directly. > > Signed-off-by: Tvrtko Ursulin > Cc: Rob Clark > Cc: Adrián Larumbe > Cc: steven.price@arm.com Reviewed-by: Steven Price > --- > drivers/gpu/drm/drm_file.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c > index e692770ef6d3..ecb5038009e7 100644 > --- a/drivers/gpu/drm/drm_file.c > +++ b/drivers/gpu/drm/drm_file.c > @@ -913,7 +913,7 @@ static void print_size(struct drm_printer *p, const char *stat, > unsigned u; > > for (u = 0; u < ARRAY_SIZE(units) - 1; u++) { > - if (sz < SZ_1K) > + if (sz == 0 || !IS_ALIGNED(sz, SZ_1K)) > break; > sz = div_u64(sz, SZ_1K); > }