From: Matthew Brost <matthew.brost@intel.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>, <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 3/3] drm/ttm, drm/xe: Drop the ttm_tt on null moves to VRAM
Date: Tue, 24 Nov 2026 11:48:02 -0800 [thread overview]
Message-ID: <awXp8nbFKlXWG3vJ@gsse-cloud1.jf.intel.com> (raw)
In-Reply-To: <4cfd3d47d3029380cc4757ecdebb844658f93940.camel@linux.intel.com>
On Tue, Nov 24, 2026 at 08:20:00PM +0100, Thomas Hellström wrote:
> On Fri, 2026-11-13 at 07:30 -0800, Matthew Brost wrote:
> > On Sat, Nov 07, 2026 at 05:26:52PM +0000, Matthew Auld wrote:
> > > From: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > >
> > > A BO created with DRM_XE_GEM_CREATE_FLAG_DEFER_BACKING starts in
> > > system
> > > placement with an unpopulated ttm_tt. Its initial move to VRAM has
> > > no
> > > source data and uses ttm_bo_move_null(), which unlike
> > > ttm_bo_move_accel_cleanup() leaves bo->ttm attached. If the VRAM BO
> > > is
> > > later exported, ttm_bo_setup_export() populates that stale ttm_tt,
> > > pinning unused, unshrinkable host pages equal to the BO size and
> > > potentially exhausting host RAM.
> > >
> > > Add ttm_bo_move_null_drop_tt() to destroy the ttm_tt when moving to
> > > a
> > > manager that doesn't use one, and use it in xe_bo_move().
> > >
> > > Fixes: 91494dee1091 ("xe: populate buffers before exporting them.")
> > > Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > > Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> > > ---
> > > drivers/gpu/drm/ttm/ttm_bo_util.c | 20 ++++++++++++++++++++
> > > drivers/gpu/drm/xe/xe_bo.c | 6 +++---
> > > include/drm/ttm/ttm_bo.h | 2 ++
> > > 3 files changed, 25 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c
> > > b/drivers/gpu/drm/ttm/ttm_bo_util.c
> > > index f9458a4d5a09..0ab52be3a5f7 100644
> > > --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> > > +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> > > @@ -756,6 +756,26 @@ void ttm_bo_move_sync_cleanup(struct
> > > ttm_buffer_object *bo,
> > > }
> > > EXPORT_SYMBOL(ttm_bo_move_sync_cleanup);
> > >
> > > +/**
> > > + * ttm_bo_move_null_drop_tt - assign memory without moving data,
> > > dropping the TT
> > > + * @bo: The buffer object.
> > > + * @new_mem: The memory to be assigned.
> > > + *
> > > + * Like ttm_bo_move_null(), but if the memory manager of @new_mem
> > > doesn't use
> > > + * a struct ttm_tt, also destroy @bo's ttm_tt, mimicking what
> > > + * ttm_bo_move_accel_cleanup() does. The caller must hold the bo's
> > > + * reservation, and the ttm_tt must not hold data that needs to be
> > > preserved.
> > > + */
> > > +void ttm_bo_move_null_drop_tt(struct ttm_buffer_object *bo,
> > > + struct ttm_resource *new_mem)
> > > +{
> > > + if (!ttm_manager_type(bo->bdev, new_mem->mem_type)-
> > > >use_tt)
> > > + ttm_bo_tt_destroy(bo);
> >
> > This is certainly right, as I have seen TT leak.
> >
> > I do have question - should this just be built in ttm_bo_move_null?
> >
> > IOW...
>
> The problem happened only when moving a "lacks_source" bo to VRAM, and
> I was a little afraid of other drivers regressing when moving to
> stable.
>
> But this should be safe, really. I've sent a new patch.
>
I agree this should always be safe.
> "drm/ttm: Destroy the ttm_tt in ttm_bo_move_null() when it's no longer
> needed."
Let me look.
Matt
>
> /Thomas
>
>
> >
> > mbrost@gsse-cloud1:xe$ grep -n ttm_bo_move_null *.c
> > xe_bo.c:892: ttm_bo_move_null(ttm_bo, new_res);
> > xe_bo.c:1110: ttm_bo_move_null(ttm_bo, new_mem);
> > xe_bo.c:1137: ttm_bo_move_null(ttm_bo, new_mem);
> > xe_bo.c:1146: ttm_bo_move_null(ttm_bo, new_mem);
> > xe_bo.c:1163: ttm_bo_move_null(ttm_bo, new_mem);
> > xe_bo.c:1173: ttm_bo_move_null(ttm_bo, new_mem);
> > xe_bo.c:1195: ttm_bo_move_null(ttm_bo, new_mem);
> > xe_bo.c:1272: ttm_bo_move_null(ttm_bo, new_mem);
> > xe_bo.c:1283: ttm_bo_move_null(ttm_bo, new_mem);
> > xe_bo.c:1340: ttm_bo_move_null(bo, new_resource);
> >
> > Why are some call sites in Xe in which use ttm_bo_move_null_drop_tt
> > vs
> > ttm_bo_move_null?
> >
> > Matt
> >
> > > +
> > > + ttm_bo_move_null(bo, new_mem);
> > > +}
> > > +EXPORT_SYMBOL(ttm_bo_move_null_drop_tt);
> > > +
> > > /**
> > > * ttm_bo_pipeline_gutting - purge the contents of a bo
> > > * @bo: The buffer object
> > > diff --git a/drivers/gpu/drm/xe/xe_bo.c
> > > b/drivers/gpu/drm/xe/xe_bo.c
> > > index 0181f73ef66d..6628db44951f 100644
> > > --- a/drivers/gpu/drm/xe/xe_bo.c
> > > +++ b/drivers/gpu/drm/xe/xe_bo.c
> > > @@ -1178,7 +1178,7 @@ static int xe_bo_move(struct
> > > ttm_buffer_object *ttm_bo, bool evict,
> > > }
> > >
> > > if ((move_lacks_source && !needs_clear)) {
> > > - ttm_bo_move_null(ttm_bo, new_mem);
> > > + ttm_bo_move_null_drop_tt(ttm_bo, new_mem);
> > > goto out;
> > > }
> > >
> > > @@ -1313,7 +1313,7 @@ static int xe_bo_move(struct
> > > ttm_buffer_object *ttm_bo, bool evict,
> > > new_mem);
> > > if (ret) {
> > > dma_fence_wait(fence, false);
> > > - ttm_bo_move_null(ttm_bo, new_mem);
> > > + ttm_bo_move_null_drop_tt(ttm_bo, new_mem);
> > > ret = 0;
> > > }
> > > } else {
> > > @@ -1324,7 +1324,7 @@ static int xe_bo_move(struct
> > > ttm_buffer_object *ttm_bo, bool evict,
> > > */
> > > dma_resv_add_fence(ttm_bo->base.resv, fence,
> > > DMA_RESV_USAGE_KERNEL);
> > > - ttm_bo_move_null(ttm_bo, new_mem);
> > > + ttm_bo_move_null_drop_tt(ttm_bo, new_mem);
> > > }
> > >
> > > /*
> > > diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h
> > > index 32791c4db2a9..123ef68bd849 100644
> > > --- a/include/drm/ttm/ttm_bo.h
> > > +++ b/include/drm/ttm/ttm_bo.h
> > > @@ -480,6 +480,8 @@ int ttm_bo_move_accel_cleanup(struct
> > > ttm_buffer_object *bo,
> > > struct ttm_resource *new_mem);
> > > void ttm_bo_move_sync_cleanup(struct ttm_buffer_object *bo,
> > > struct ttm_resource *new_mem);
> > > +void ttm_bo_move_null_drop_tt(struct ttm_buffer_object *bo,
> > > + struct ttm_resource *new_mem);
> > > int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo);
> > > pgprot_t ttm_io_prot(struct ttm_buffer_object *bo, struct
> > > ttm_resource *res,
> > > pgprot_t tmp);
> > >
> > > --
> > > 2.56.0
next prev parent reply other threads:[~2026-11-24 19:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 17:26 [PATCH 0/3] Spurious OOM with P2P dma-buf imports on multi-GPU systems Matthew Auld
2026-11-07 17:26 ` [PATCH 1/3] drm/xe: don't allocate fake mmap offsets for imported dma-bufs Matthew Auld
2026-11-07 17:43 ` sashiko-bot
2026-11-07 17:26 ` [PATCH 2/3] drm/xe: Exclude imported dma-buf BOs from the TT budget Matthew Auld
2026-11-07 17:36 ` sashiko-bot
2026-11-07 17:26 ` [PATCH 3/3] drm/ttm, drm/xe: Drop the ttm_tt on null moves to VRAM Matthew Auld
2026-11-13 15:30 ` Matthew Brost
2026-11-24 19:20 ` Thomas Hellström
2026-11-24 19:48 ` Matthew Brost [this message]
2026-11-07 17:36 ` ✓ CI.KUnit: success for Spurious OOM with P2P dma-buf imports on multi-GPU systems Patchwork
2026-11-07 18:10 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-08 8:22 ` ✓ Xe.CI.FULL: " 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=awXp8nbFKlXWG3vJ@gsse-cloud1.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=thomas.hellstrom@linux.intel.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 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.