From patchwork Wed Sep 27 13:38:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13400825 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 AF54CE810D9 for ; Wed, 27 Sep 2023 13:39:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A090310E524; Wed, 27 Sep 2023 13:38:58 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id C0AD210E520; Wed, 27 Sep 2023 13:38:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695821934; x=1727357934; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XfhUSK9oPOsrUCWTOO8CEEobRY0kofBmGLtuhYVzvzk=; b=BnbzveEYmOUigJOT1VLKcHF3jDZy4hshnFMvg10alSFOlTry0b3Vol8P 5xEU5eCXDSRwJEji7YlP7/Tw/v9DYIwP19V5+mMoiCwXUXggYJjEVRttz 1xMQC9+vaRiJv2B22yERYu3AG5eBAHr1BMu4chJ9L5Vez5W4gA+zoNLPY x0yyhRbqC2SkCW5Hy3XORduGu9AnJSzHKz8b0MGhjEXIsLqUeNG6DRyRq UX0AanLa+mHo1T3Cc8R+6wWo9ctTYxj8yT0TETNV+YJfdnUVmnGG0aNIc RLRcAf/ReWE1c0bYsdp8pPQfNBVqpiEIodgR6ZQ7cYnqiuQ1M1ghplNrJ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10846"; a="412738601" X-IronPort-AV: E=Sophos;i="6.03,181,1694761200"; d="scan'208";a="412738601" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2023 06:38:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10846"; a="752597175" X-IronPort-AV: E=Sophos;i="6.03,181,1694761200"; d="scan'208";a="752597175" Received: from mscanex-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.204.17]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2023 06:38:49 -0700 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Wed, 27 Sep 2023 14:38:37 +0100 Message-Id: <20230927133843.247957-2-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927133843.247957-1-tvrtko.ursulin@linux.intel.com> References: <20230927133843.247957-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [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?= , steven.price@arm.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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); }