AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yunxiang Li <Yunxiang.Li@amd.com>
To: <amd-gfx@lists.freedesktop.org>, <christian.koenig@amd.com>,
	<tvrtko.ursulin@igalia.com>
Cc: <Alexander.Deucher@amd.com>, Yunxiang Li <Yunxiang.Li@amd.com>,
	<dri-devel@lists.freedesktop.org>
Subject: [PATCH v7 1/4] drm: add drm_memory_stats_is_zero
Date: Sun, 10 Nov 2024 10:41:49 -0500	[thread overview]
Message-ID: <20241110154152.592-2-Yunxiang.Li@amd.com> (raw)
In-Reply-To: <20241110154152.592-1-Yunxiang.Li@amd.com>

Add a helper to check if the memory stats is zero, this will be used to
check for memory accounting errors.

Signed-off-by: Yunxiang Li <Yunxiang.Li@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
CC: dri-devel@lists.freedesktop.org
---
 drivers/gpu/drm/drm_file.c | 10 ++++++++++
 include/drm/drm_file.h     |  1 +
 2 files changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 714e42b051080..e285fcc28c59c 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -859,6 +859,16 @@ static void print_size(struct drm_printer *p, const char *stat,
 	drm_printf(p, "drm-%s-%s:\t%llu%s\n", stat, region, sz, units[u]);
 }
 
+int drm_memory_stats_is_zero(const struct drm_memory_stats *stats)
+{
+	return (stats->shared == 0 &&
+		stats->private == 0 &&
+		stats->resident == 0 &&
+		stats->purgeable == 0 &&
+		stats->active == 0);
+}
+EXPORT_SYMBOL(drm_memory_stats_is_zero);
+
 /**
  * drm_print_memory_stats - A helper to print memory stats
  * @p: The printer to print output to
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index ab230d3af138d..7f91e35d027d9 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -477,6 +477,7 @@ struct drm_memory_stats {
 
 enum drm_gem_object_status;
 
+int drm_memory_stats_is_zero(const struct drm_memory_stats *stats);
 void drm_print_memory_stats(struct drm_printer *p,
 			    const struct drm_memory_stats *stats,
 			    enum drm_gem_object_status supported_status,
-- 
2.34.1


  reply	other threads:[~2024-11-10 15:42 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-10 15:41 [PATCH v7 0/4] rework bo mem stats tracking Yunxiang Li
2024-11-10 15:41 ` Yunxiang Li [this message]
2024-11-10 15:41 ` [PATCH v7 2/4] drm: make drm-active- stats optional Yunxiang Li
2024-11-11  9:14   ` Jani Nikula
2024-11-11 14:28     ` [PATCH v8 " Yunxiang Li
2024-11-11 10:29   ` [PATCH v7 " Tvrtko Ursulin
2024-11-18 15:17     ` Li, Yunxiang (Teddy)
2024-11-18 15:42       ` Tvrtko Ursulin
2024-11-10 15:41 ` [PATCH v7 3/4] drm/amdgpu: remove unused function parameter Yunxiang Li
2024-11-10 15:41 ` [PATCH v7 4/4] drm/amdgpu: track bo memory stats at runtime Yunxiang Li
2024-11-12 10:54   ` Christian König
2024-11-12 18:16     ` Li, Yunxiang (Teddy)
2024-11-13  8:49       ` Christian König
2024-11-13 10:25         ` Tvrtko Ursulin
2024-11-13 11:38           ` Christian König
2024-11-13 13:53             ` Li, Yunxiang (Teddy)
2024-11-13 14:22               ` Christian König
2024-11-13 17:01                 ` Li, Yunxiang (Teddy)
2024-11-13 17:30                   ` Tvrtko Ursulin
2024-11-14  9:06                     ` Matthew Auld
2024-11-14 15:52                     ` Li, Yunxiang (Teddy)
2024-11-13 14:09         ` Li, Yunxiang (Teddy)
2024-11-13 14:19           ` Christian König

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=20241110154152.592-2-Yunxiang.Li@amd.com \
    --to=yunxiang.li@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tvrtko.ursulin@igalia.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