All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Adrián Larumbe" <adrian.larumbe@collabora.com>
To: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch,
	robdclark@gmail.com, quic_abhinavk@quicinc.com,
	dmitry.baryshkov@linaro.org, sean@poorly.run,
	marijn.suijten@somainline.org, robh@kernel.org,
	steven.price@arm.com
Cc: adrian.larumbe@collabora.com, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	freedreno@lists.freedesktop.org, healych@amazon.com,
	kernel@collabora.com
Subject: [PATCH v5 6/6] drm/drm-file: Show finer-grained BO sizes in drm_show_memory_stats
Date: Thu, 14 Sep 2023 23:38:44 +0100	[thread overview]
Message-ID: <20230914223928.2374933-7-adrian.larumbe@collabora.com> (raw)
In-Reply-To: <20230914223928.2374933-1-adrian.larumbe@collabora.com>

The current implementation will try to pick the highest available size
display unit as soon as the BO size exceeds that of the previous
multiplier. That can lead to loss of precision in contexts of low memory
usage.

The new selection criteria try to preserve precision, whilst also
increasing the display unit selection threshold to render more accurate
values.

Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
---
 drivers/gpu/drm/drm_file.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 762965e3d503..34cfa128ffe5 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -872,6 +872,8 @@ void drm_send_event(struct drm_device *dev, struct drm_pending_event *e)
 }
 EXPORT_SYMBOL(drm_send_event);
 
+#define UPPER_UNIT_THRESHOLD 100
+
 static void print_size(struct drm_printer *p, const char *stat,
 		       const char *region, u64 sz)
 {
@@ -879,7 +881,8 @@ 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 & (SZ_1K - 1)) &&
+		    sz < UPPER_UNIT_THRESHOLD * SZ_1K)
 			break;
 		sz = div_u64(sz, SZ_1K);
 	}
-- 
2.42.0


WARNING: multiple messages have this Message-ID (diff)
From: "Adrián Larumbe" <adrian.larumbe@collabora.com>
To: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch,
	robdclark@gmail.com, quic_abhinavk@quicinc.com,
	dmitry.baryshkov@linaro.org, sean@poorly.run,
	marijn.suijten@somainline.org, robh@kernel.org,
	steven.price@arm.com
Cc: linux-arm-msm@vger.kernel.org, adrian.larumbe@collabora.com,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	healych@amazon.com, kernel@collabora.com,
	freedreno@lists.freedesktop.org
Subject: [PATCH v5 6/6] drm/drm-file: Show finer-grained BO sizes in drm_show_memory_stats
Date: Thu, 14 Sep 2023 23:38:44 +0100	[thread overview]
Message-ID: <20230914223928.2374933-7-adrian.larumbe@collabora.com> (raw)
In-Reply-To: <20230914223928.2374933-1-adrian.larumbe@collabora.com>

The current implementation will try to pick the highest available size
display unit as soon as the BO size exceeds that of the previous
multiplier. That can lead to loss of precision in contexts of low memory
usage.

The new selection criteria try to preserve precision, whilst also
increasing the display unit selection threshold to render more accurate
values.

Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
---
 drivers/gpu/drm/drm_file.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 762965e3d503..34cfa128ffe5 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -872,6 +872,8 @@ void drm_send_event(struct drm_device *dev, struct drm_pending_event *e)
 }
 EXPORT_SYMBOL(drm_send_event);
 
+#define UPPER_UNIT_THRESHOLD 100
+
 static void print_size(struct drm_printer *p, const char *stat,
 		       const char *region, u64 sz)
 {
@@ -879,7 +881,8 @@ 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 & (SZ_1K - 1)) &&
+		    sz < UPPER_UNIT_THRESHOLD * SZ_1K)
 			break;
 		sz = div_u64(sz, SZ_1K);
 	}
-- 
2.42.0


  parent reply	other threads:[~2023-09-14 22:39 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14 22:38 [PATCH v5 0/6] Add fdinfo support to Panfrost Adrián Larumbe
2023-09-14 22:38 ` Adrián Larumbe
2023-09-14 22:38 ` [PATCH v5 1/6] drm/panfrost: Add cycle count GPU register definitions Adrián Larumbe
2023-09-14 22:38   ` Adrián Larumbe
2023-09-14 22:38 ` [PATCH v5 2/6] drm/panfrost: Add fdinfo support GPU load metrics Adrián Larumbe
2023-09-14 22:38   ` Adrián Larumbe
2023-09-18  9:50   ` Steven Price
2023-09-18  9:50     ` Steven Price
2023-09-14 22:38 ` [PATCH v5 3/6] drm/panfrost: Add fdinfo support for memory stats Adrián Larumbe
2023-09-14 22:38   ` Adrián Larumbe
2023-09-18  9:54   ` Steven Price
2023-09-18  9:54     ` Steven Price
2023-09-14 22:38 ` [PATCH v5 4/6] drm/drm_file: Add DRM obj's RSS reporting function for fdinfo Adrián Larumbe
2023-09-14 22:38   ` Adrián Larumbe
2023-09-18  9:54   ` Steven Price
2023-09-18  9:54     ` Steven Price
2023-09-14 22:38 ` [PATCH v5 5/6] drm/panfrost: Implement generic DRM object RSS reporting function Adrián Larumbe
2023-09-14 22:38   ` Adrián Larumbe
2023-09-18 10:01   ` Steven Price
2023-09-18 10:01     ` Steven Price
2023-09-18 10:32     ` Boris Brezillon
2023-09-18 10:32       ` Boris Brezillon
2023-09-18 12:59       ` Steven Price
2023-09-18 12:59         ` Steven Price
2023-09-14 22:38 ` Adrián Larumbe [this message]
2023-09-14 22:38   ` [PATCH v5 6/6] drm/drm-file: Show finer-grained BO sizes in drm_show_memory_stats Adrián Larumbe
2023-09-15  8:55   ` Boris Brezillon
2023-09-15  8:55     ` Boris Brezillon
2023-09-18 10:03   ` Steven Price
2023-09-18 10:03     ` Steven Price

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=20230914223928.2374933-7-adrian.larumbe@collabora.com \
    --to=adrian.larumbe@collabora.com \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=healych@amazon.com \
    --cc=kernel@collabora.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=marijn.suijten@somainline.org \
    --cc=mripard@kernel.org \
    --cc=quic_abhinavk@quicinc.com \
    --cc=robdclark@gmail.com \
    --cc=robh@kernel.org \
    --cc=sean@poorly.run \
    --cc=steven.price@arm.com \
    --cc=tzimmermann@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.