From: Matthew Brost <matthew.brost@intel.com>
To: Brian Nguyen <brian3.nguyen@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <tejas.upadhyay@intel.com>,
<shuicheng.lin@intel.com>, <stuart.summers@intel.com>
Subject: Re: [PATCH v2 07/11] drm/xe: Suballocate BO for page reclaim
Date: Wed, 3 Dec 2025 15:06:59 -0800 [thread overview]
Message-ID: <aTDCkxzgOUUO3Y4t@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20251126230201.3782788-20-brian3.nguyen@intel.com>
On Thu, Nov 27, 2025 at 07:02:08AM +0800, Brian Nguyen wrote:
> Page reclamation feature needs the PRL to be suballocated into a
> GGTT-mapped BO. On allocation failure, fallback to default tlb
> invalidation with full PPC flush.
>
> PRL's BO allocation is managed in separate pool to ensure 4K alignment
> for proper GGTT address.
>
> With BO, pass into TLB invalidation backend and modify fence to
> accomadate accordingly.
>
> v2:
> - Removed page reclaim related variables from TLB fence. (Matthew B)
> - Allocate PRL bo size to num_entries. (Matthew B)
> - Move PRL bo allocation to tlb_inval run_job. (Matthew B)
>
> Signed-off-by: Brian Nguyen <brian3.nguyen@intel.com>
> Suggested-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/xe_device_types.h | 7 +++++
> drivers/gpu/drm/xe/xe_page_reclaim.c | 39 +++++++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_page_reclaim.h | 6 +++++
> drivers/gpu/drm/xe/xe_tile.c | 5 ++++
> drivers/gpu/drm/xe/xe_tlb_inval_job.c | 9 +++++++
> 5 files changed, 66 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
> index 3836c5ed1c72..155ea0800f1b 100644
> --- a/drivers/gpu/drm/xe/xe_device_types.h
> +++ b/drivers/gpu/drm/xe/xe_device_types.h
> @@ -184,6 +184,13 @@ struct xe_tile {
> * Media GT shares a pool with its primary GT.
> */
> struct xe_sa_manager *kernel_bb_pool;
> +
> + /**
> + * @mem.reclaim_pool: Pool for PRLs allocated.
> + *
> + * Only main GT has page reclaim list allocations.
> + */
> + struct xe_sa_manager *reclaim_pool;
> } mem;
>
> /** @sriov: tile level virtualization data */
> diff --git a/drivers/gpu/drm/xe/xe_page_reclaim.c b/drivers/gpu/drm/xe/xe_page_reclaim.c
> index 63facea28213..740563277872 100644
> --- a/drivers/gpu/drm/xe/xe_page_reclaim.c
> +++ b/drivers/gpu/drm/xe/xe_page_reclaim.c
> @@ -13,6 +13,45 @@
> #include "regs/xe_gt_regs.h"
> #include "xe_assert.h"
> #include "xe_macros.h"
> +#include "xe_sa.h"
> +#include "xe_tlb_inval_types.h"
> +
> +/**
> + * xe_page_reclaim_create_prl_bo() - Back a PRL with a suballocated GGTT BO
> + * @tlb_inval: TLB invalidation frontend associated with the request
> + * @prl: page reclaim list data that bo will copy from
> + * @ifence: tlb invalidation fence that page reclaim action is paired to
> + *
> + * Suballocates a 4K BO out of the tile reclaim pool, copies the PRL CPU
> + * copy into the BO and queues the buffer for release when @fence signals.
> + *
> + * Return: struct drm_suballoc pointer on success or ERR_PTR on failure.
> + */
> +struct drm_suballoc *xe_page_reclaim_create_prl_bo(struct xe_tlb_inval *tlb_inval,
> + struct xe_page_reclaim_list *prl,
> + struct xe_tlb_inval_fence *fence)
> +{
> + struct xe_gt *gt = container_of(tlb_inval, struct xe_gt, tlb_inval);
> + struct xe_tile *tile = gt_to_tile(gt);
> + /* (+1) for NULL page_reclaim_entry to indicate end of list */
> + int prl_size = min(prl->num_entries + 1, XE_PAGE_RECLAIM_MAX_ENTRIES) *
> + sizeof(struct xe_guc_page_reclaim_entry);
> + struct drm_suballoc *prl_sa;
> +
> + /* Maximum size of PRL is 1 4K-page */
> + prl_sa = __xe_sa_bo_new(tile->mem.reclaim_pool,
> + prl_size, GFP_ATOMIC);
> + if (IS_ERR(prl_sa))
> + return prl_sa;
> +
> + memcpy(xe_sa_bo_cpu_addr(prl_sa), prl->entries,
> + prl_size);
> + xe_sa_bo_flush_write(prl_sa);
> + /* Queue up sa_bo_free on tlb invalidation fence signal */
> + xe_sa_bo_free(prl_sa, &fence->base);
> +
> + return prl_sa;
> +}
>
> /**
> * xe_page_reclaim_list_invalidate() - Mark a PRL as invalid
> diff --git a/drivers/gpu/drm/xe/xe_page_reclaim.h b/drivers/gpu/drm/xe/xe_page_reclaim.h
> index 5ccff46d1b4e..4ecea05b1f2e 100644
> --- a/drivers/gpu/drm/xe/xe_page_reclaim.h
> +++ b/drivers/gpu/drm/xe/xe_page_reclaim.h
> @@ -16,6 +16,9 @@
> #define XE_PAGE_RECLAIM_MAX_ENTRIES 512
> #define XE_PAGE_RECLAIM_LIST_MAX_SIZE SZ_4K
>
> +struct xe_tlb_inval;
> +struct xe_tlb_inval_fence;
> +
> struct xe_guc_page_reclaim_entry {
> u32 dw0;
> /* valid reclaim entry bit */
> @@ -42,6 +45,9 @@ struct xe_page_reclaim_list {
> #define XE_PAGE_RECLAIM_INVALID_LIST -1
> };
>
> +struct drm_suballoc *xe_page_reclaim_create_prl_bo(struct xe_tlb_inval *tlb_inval,
> + struct xe_page_reclaim_list *prl,
> + struct xe_tlb_inval_fence *fence);
> void xe_page_reclaim_list_invalidate(struct xe_page_reclaim_list *prl);
> void xe_page_reclaim_list_init(struct xe_page_reclaim_list *prl);
> int xe_page_reclaim_list_alloc_entries(struct xe_page_reclaim_list *prl);
> diff --git a/drivers/gpu/drm/xe/xe_tile.c b/drivers/gpu/drm/xe/xe_tile.c
> index 4f4f9a5c43af..63c060c2ea5c 100644
> --- a/drivers/gpu/drm/xe/xe_tile.c
> +++ b/drivers/gpu/drm/xe/xe_tile.c
> @@ -209,6 +209,11 @@ int xe_tile_init(struct xe_tile *tile)
> if (IS_ERR(tile->mem.kernel_bb_pool))
> return PTR_ERR(tile->mem.kernel_bb_pool);
>
> + /* Optimistically anticipate at most 256 TLB fences with PRL */
> + tile->mem.reclaim_pool = xe_sa_bo_manager_init(tile, SZ_1M, XE_PAGE_RECLAIM_LIST_MAX_SIZE);
> + if (IS_ERR(tile->mem.reclaim_pool))
> + return PTR_ERR(tile->mem.reclaim_pool);
> +
> return 0;
> }
> void xe_tile_migrate_wait(struct xe_tile *tile)
> diff --git a/drivers/gpu/drm/xe/xe_tlb_inval_job.c b/drivers/gpu/drm/xe/xe_tlb_inval_job.c
> index 1ae0dec2cf31..dbd3171fff12 100644
> --- a/drivers/gpu/drm/xe/xe_tlb_inval_job.c
> +++ b/drivers/gpu/drm/xe/xe_tlb_inval_job.c
> @@ -24,6 +24,8 @@ struct xe_tlb_inval_job {
> struct xe_exec_queue *q;
> /** @vm: VM which TLB invalidation is being issued for */
> struct xe_vm *vm;
> + /** @prl: Embedded copy of page reclaim list */
> + struct xe_page_reclaim_list prl;
> /** @refcount: ref count of this job */
> struct kref refcount;
> /**
> @@ -47,6 +49,13 @@ static struct dma_fence *xe_tlb_inval_job_run(struct xe_dep_job *dep_job)
> container_of(dep_job, typeof(*job), dep);
> struct xe_tlb_inval_fence *ifence =
> container_of(job->fence, typeof(*ifence), base);
> + struct drm_suballoc *prl_sa = NULL;
> +
> + if (job->prl.entries) {
> + prl_sa = xe_page_reclaim_create_prl_bo(job->tlb_inval, &job->prl, ifence);
> + if (IS_ERR(prl_sa))
> + prl_sa = NULL; /* Indicate fall back PPC flush with NULL */
> + }
>
> xe_tlb_inval_range(job->tlb_inval, ifence, job->start,
> job->end, job->vm->usm.asid);
> --
> 2.52.0
>
next prev parent reply other threads:[~2025-12-03 23:07 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 23:02 [PATCH v2 00/11] Page Reclamation Support for Xe3p Platforms Brian Nguyen
2025-11-26 23:02 ` [PATCH v2 01/11] [DO, NOT, REVIEW] drm/xe: Do not forward invalid TLB invalidation seqnos to upper layers Brian Nguyen
2025-11-26 23:02 ` [PATCH v2 02/11] drm/xe: Reset tlb fence timeout on invalid seqno received Brian Nguyen
2025-12-02 22:24 ` Matthew Brost
2025-11-26 23:02 ` [PATCH v2 03/11] drm/xe/xe_tlb_inval: Modify fence interface to support PPC flush Brian Nguyen
2025-12-02 22:18 ` Matthew Brost
2025-11-26 23:02 ` [PATCH v2 04/11] drm/xe: Add page reclamation info to device info Brian Nguyen
2025-11-26 23:02 ` [PATCH v2 05/11] drm/xe/guc: Add page reclamation interface to GuC Brian Nguyen
2025-12-02 22:21 ` Matthew Brost
2025-12-03 0:17 ` Lin, Shuicheng
2025-11-26 23:02 ` [PATCH v2 06/11] drm/xe: Create page reclaim list on unbind Brian Nguyen
2025-12-01 21:45 ` Nguyen, Brian3
2025-12-03 22:56 ` Matthew Brost
2025-12-04 0:19 ` Nguyen, Brian3
2025-11-26 23:02 ` [PATCH v2 07/11] drm/xe: Suballocate BO for page reclaim Brian Nguyen
2025-12-03 23:06 ` Matthew Brost [this message]
2025-11-26 23:02 ` [PATCH v2 08/11] drm/xe: Prep page reclaim in tlb inval job Brian Nguyen
2025-12-03 23:13 ` Matthew Brost
2025-12-04 0:22 ` Nguyen, Brian3
2025-12-04 1:20 ` Matthew Brost
2025-12-04 5:42 ` Nguyen, Brian3
2025-12-04 18:05 ` Matthew Brost
2025-12-04 20:02 ` Nguyen, Brian3
2025-12-09 5:57 ` Upadhyay, Tejas
2025-12-09 6:14 ` Nguyen, Brian3
2025-11-26 23:02 ` [PATCH v2 09/11] drm/xe: Append page reclamation action to tlb inval Brian Nguyen
2025-12-03 23:15 ` Matthew Brost
2025-11-26 23:02 ` [PATCH v2 10/11] drm/xe: Optimize flushing of L2$ by skipping unnecessary page reclaim Brian Nguyen
2025-12-09 14:23 ` Upadhyay, Tejas
2025-11-26 23:02 ` [PATCH v2 11/11] drm/xe: Add debugfs support for page reclamation Brian Nguyen
2025-12-02 22:28 ` Matthew Brost
2025-12-02 22:51 ` Nguyen, Brian3
2025-12-02 22:59 ` Matthew Brost
2025-12-05 18:02 ` Lin, Shuicheng
2025-11-26 23:52 ` ✗ CI.checkpatch: warning for Page Reclamation Support for Xe3p Platforms (rev2) Patchwork
2025-11-26 23:54 ` ✓ CI.KUnit: success " Patchwork
2025-11-27 0:54 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-11-27 1:42 ` ✗ 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=aTDCkxzgOUUO3Y4t@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=brian3.nguyen@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=shuicheng.lin@intel.com \
--cc=stuart.summers@intel.com \
--cc=tejas.upadhyay@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox