On Wed, Dec 02, 2026 at 11:53:58PM +0000, [email protected] wrote: > Thank you for your contribution! Sashiko AI review found 1 potential > issue to consider: > - [Medium] drm/xe: no-op xe_bo_defrag_update() on CPU fault in > xe_bo_fault_migrate() > -- > > commit 22495e3a9f5a9f486e4a553586605bb281ab160e > Author: Matthew Brost <[email protected]> > > drm/xe: Track BOs backed at a sub-optimal page order > > This commit adds per-device tracking for buffer objects whose backing TT > pages were allocated below the pool's beneficial order so they can be > candidates for future defragmentation. > > > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c > > index ff5610ba4b740..98c0b32e95439 100644 > > --- a/drivers/gpu/drm/xe/xe_bo.c > > +++ b/drivers/gpu/drm/xe/xe_bo.c > [ ... ] > > +static bool xe_bo_needs_defrag(struct xe_bo *bo) > > +{ > > + struct ttm_buffer_object *ttm_bo = &bo->ttm; > > + struct ttm_tt *tt = ttm_bo->ttm; > > + > > + xe_bo_assert_held(bo); > > + > > + return xe_bo_defrag_supported(xe_bo_device(bo)) && > > + ttm_bo->type == ttm_bo_type_device && tt && > > + !xe_bo_madv_is_dontneed(bo) && > > + ttm_tt_is_populated(tt) && > > + ttm_tt_is_beneficial_order_failed(tt) && > > + ttm_bo->resource && ttm_bo->resource->mem_type == XE_PL_TT && > > + !xe_bo_is_pinned(bo); > > +} > [ ... ] > > @@ -2245,9 +2379,14 @@ static int xe_bo_fault_migrate(struct xe_bo *bo, > > struct ttm_operation_ctx *ctx, > > int err = 0; > > > > if (ttm_manager_type(tbo->bdev, tbo->resource->mem_type)->use_tt) { > > + bool populated = tbo->ttm && ttm_tt_is_populated(tbo->ttm); > > + > > err = xe_bo_wait_usage_kernel(bo, ctx); > > - if (!err) > > + if (!err) { > > err = ttm_bo_populate(&bo->ttm, ctx); > > + if (!err && !populated) > > + xe_bo_defrag_update(bo); > > + } > > } else if (should_migrate_to_smem(bo)) { > > [Severity: Medium] > Can xe_bo_defrag_update(bo) ever add a BO to xe->mem.defrag.list from > xe_bo_fault_migrate()? >
This is dead code and we actually don't have to call xe_bo_defrag_update here. The CPU is free to fault the buffer + populate when in SYSTEM but before GPU can use we move to TT which will call xe_bo_defrag_update in xe_bo_move. So I'm going to remove this code in the next rev. Matt > Any BO resident in XE_PL_TT is already populated before xe_bo_move() runs, > and all shrink, swapout and deferred-backing paths leave unpopulated BOs > in XE_PL_SYSTEM. When !populated is true here, tbo->resource->mem_type is > always XE_PL_SYSTEM, and ttm_bo_populate() populates tbo->ttm in place > without changing the resource's mem_type. Because xe_bo_needs_defrag() > requires ttm_bo->resource->mem_type == XE_PL_TT, BOs populated on a CPU > page fault at a sub-optimal order will never be added to the defrag list. > > -- > Sashiko AI review ยท > https://sashiko.dev/#/patchset/[email protected]?part=14
