Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: arselan.alvi@intel.com, stable@vger.kernel.org
Subject: [PATCH] drm/xe: Tie page count tracepoints to TTM accounting functions
Date: Tue,  6 Jan 2026 16:21:54 -0800	[thread overview]
Message-ID: <20260107002154.1934332-1-matthew.brost@intel.com> (raw)

Page accounting can change via the shrinker without calling
xe_ttm_tt_unpopulate(), but those paths already update accounting
through the xe_ttm_tt_account_*() helpers.

Move the page count tracepoints into xe_ttm_tt_account_add() and
xe_ttm_tt_account_subtract() so accounting updates are recorded
consistently, regardless of whether pages are populated, unpopulated,
or reclaimed via the shrinker.

This avoids missing page count updates and keeps global accounting
balanced across all TT lifecycle paths.

Cc: stable@vger.kernel.org
Fixes: ce3d39fae3d3 ("drm/xe/bo: add GPU memory trace points")
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_bo.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 8b6474cd3eaf..33afaee38f48 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -432,6 +432,9 @@ struct sg_table *xe_bo_sg(struct xe_bo *bo)
 	return xe_tt->sg;
 }
 
+static void update_global_total_pages(struct ttm_device *ttm_dev,
+				      long num_pages);
+
 /*
  * Account ttm pages against the device shrinker's shrinkable and
  * purgeable counts.
@@ -440,6 +443,7 @@ static void xe_ttm_tt_account_add(struct xe_device *xe, struct ttm_tt *tt)
 {
 	struct xe_ttm_tt *xe_tt = container_of(tt, struct xe_ttm_tt, ttm);
 
+	update_global_total_pages(&xe->ttm, tt->num_pages);
 	if (xe_tt->purgeable)
 		xe_shrinker_mod_pages(xe->mem.shrinker, 0, tt->num_pages);
 	else
@@ -450,6 +454,7 @@ static void xe_ttm_tt_account_subtract(struct xe_device *xe, struct ttm_tt *tt)
 {
 	struct xe_ttm_tt *xe_tt = container_of(tt, struct xe_ttm_tt, ttm);
 
+	update_global_total_pages(&xe->ttm, -(long)tt->num_pages);
 	if (xe_tt->purgeable)
 		xe_shrinker_mod_pages(xe->mem.shrinker, 0, -(long)tt->num_pages);
 	else
@@ -575,7 +580,6 @@ static int xe_ttm_tt_populate(struct ttm_device *ttm_dev, struct ttm_tt *tt,
 
 	xe_tt->purgeable = false;
 	xe_ttm_tt_account_add(ttm_to_xe_device(ttm_dev), tt);
-	update_global_total_pages(ttm_dev, tt->num_pages);
 
 	return 0;
 }
@@ -592,7 +596,6 @@ static void xe_ttm_tt_unpopulate(struct ttm_device *ttm_dev, struct ttm_tt *tt)
 
 	ttm_pool_free(&ttm_dev->pool, tt);
 	xe_ttm_tt_account_subtract(xe, tt);
-	update_global_total_pages(ttm_dev, -(long)tt->num_pages);
 }
 
 static void xe_ttm_tt_destroy(struct ttm_device *ttm_dev, struct ttm_tt *tt)
-- 
2.34.1


             reply	other threads:[~2026-01-07  0:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-07  0:21 Matthew Brost [this message]
2026-01-07  0:32 ` ✓ CI.KUnit: success for drm/xe: Tie page count tracepoints to TTM accounting functions Patchwork
2026-01-07  1:08 ` ✓ Xe.CI.BAT: " Patchwork
2026-01-07  3:16 ` [PATCH] " Alvi, Arselan
2026-01-07  3:32 ` Alvi, Arselan
2026-01-07  4:02 ` ✓ Xe.CI.Full: success for " Patchwork
2026-01-07 20:01 ` [PATCH] " Summers, Stuart
2026-01-07 20:35   ` Matthew Brost

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=20260107002154.1934332-1-matthew.brost@intel.com \
    --to=matthew.brost@intel.com \
    --cc=arselan.alvi@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=stable@vger.kernel.org \
    /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