From: Kenneth Crudup <kenny@panix.com>
To: Matthew Brost <matthew.brost@intel.com>,
intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: Christian Koenig <christian.koenig@amd.com>,
Huang Rui <ray.huang@amd.com>,
Matthew Auld <matthew.auld@intel.com>,
David Airlie <airlied@gmail.com>
Subject: Re: [PATCH] drm/ttm: Fix GPU MM stats during pool shrinking
Date: Fri, 1 May 2026 15:57:19 -0700 [thread overview]
Message-ID: <cc2ef040-23c2-4dab-a57f-e2df374deef9@panix.com> (raw)
In-Reply-To: <20260501223003.2648450-1-matthew.brost@intel.com>
On 5/1/26 15:30, Matthew Brost wrote:
> TTM pool shrinking frees pages by calling __free_pages() directly,
> which bypasses updates to NR_GPU_ACTIVE and leaves GPU MM accounting
> out of sync.
>
> Introduce a helper, __free_pages_gpu_account(), and use it for all page
> frees in ttm_pool.c so GPU MM statistics are updated consistently.
>
> Reported-by: Kenneth Crudup <kenny@panix.com>
> Fixes: ae80122f3896 ("drm/ttm: use gpu mm stats to track gpu memory allocations. (v4)")
> Cc: Christian Koenig <christian.koenig@amd.com>
> Cc: Huang Rui <ray.huang@amd.com>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: David Airlie <airlied@gmail.com>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/ttm/ttm_pool.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
Tested-By: Kenneth R. Crudup <kenny@panix.com>
> diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
> index 26a3689e5fd9..95bbd9328072 100644
> --- a/drivers/gpu/drm/ttm/ttm_pool.c
> +++ b/drivers/gpu/drm/ttm/ttm_pool.c
> @@ -206,6 +206,14 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
> return NULL;
> }
>
> +static void __free_pages_gpu_account(struct page *p, unsigned int order,
> + bool reclaim)
> +{
> + mod_lruvec_page_state(p, reclaim ? NR_GPU_RECLAIM : NR_GPU_ACTIVE,
> + -(1 << order));
> + __free_pages(p, order);
> +}
> +
> /* Reset the caching and pages of size 1 << order */
> static void ttm_pool_free_page(struct ttm_pool *pool, enum ttm_caching caching,
> unsigned int order, struct page *p, bool reclaim)
> @@ -223,9 +231,7 @@ static void ttm_pool_free_page(struct ttm_pool *pool, enum ttm_caching caching,
> #endif
>
> if (!pool || !ttm_pool_uses_dma_alloc(pool)) {
> - mod_lruvec_page_state(p, reclaim ? NR_GPU_RECLAIM : NR_GPU_ACTIVE,
> - -(1 << order));
> - __free_pages(p, order);
> + __free_pages_gpu_account(p, order, reclaim);
> return;
> }
>
> @@ -606,7 +612,7 @@ static int ttm_pool_restore_commit(struct ttm_pool_tt_restore *restore,
> */
> ttm_pool_split_for_swap(restore->pool, p);
> copy_highpage(restore->alloced_page + i, p);
> - __free_pages(p, 0);
> + __free_pages_gpu_account(p, 0, false);
> }
>
> restore->restored_pages++;
> @@ -1068,7 +1074,7 @@ long ttm_pool_backup(struct ttm_pool *pool, struct ttm_tt *tt,
> if (flags->purge) {
> shrunken += num_pages;
> page->private = 0;
> - __free_pages(page, order);
> + __free_pages_gpu_account(page, order, false);
> memset(tt->pages + i, 0,
> num_pages * sizeof(*tt->pages));
> }
--
Kenneth R. Crudup / Sr. SW Engineer, Scott County Consulting, Orange
County CA
next prev parent reply other threads:[~2026-05-04 12:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 22:30 [PATCH] drm/ttm: Fix GPU MM stats during pool shrinking Matthew Brost
2026-05-01 22:36 ` ✗ CI.checkpatch: warning for " Patchwork
2026-05-01 22:37 ` ✓ CI.KUnit: success " Patchwork
2026-05-01 22:57 ` Kenneth Crudup [this message]
2026-05-01 23:28 ` ✓ Xe.CI.BAT: " Patchwork
2026-05-02 0:05 ` [PATCH] " Kenneth Crudup
2026-05-02 4:12 ` Matthew Brost
2026-05-02 4:13 ` Matthew Brost
2026-05-02 0:48 ` ✗ Xe.CI.FULL: failure for " Patchwork
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=cc2ef040-23c2-4dab-a57f-e2df374deef9@panix.com \
--to=kenny@panix.com \
--cc=airlied@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=ray.huang@amd.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