]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe: Add page reclamation related stats
authorBrian Nguyen <brian3.nguyen@intel.com>
Wed, 7 Jan 2026 01:04:52 +0000 (09:04 +0800)
committerMatthew Brost <matthew.brost@intel.com>
Thu, 8 Jan 2026 22:33:34 +0000 (14:33 -0800)
Add page reclaim list (PRL) related stats to GT stats to assist in
debugging and tuning of page reclaim related actions. Include counters
of page sizes added to PRL and if PRL action is issued.

v2:
 - Add PRL_ABORTED_COUNT stats and corresponding changes. (Matthew B)

Signed-off-by: Brian Nguyen <brian3.nguyen@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20260107010447.4125005-10-brian3.nguyen@intel.com
drivers/gpu/drm/xe/xe_gt_stats.c
drivers/gpu/drm/xe/xe_gt_stats_types.h
drivers/gpu/drm/xe/xe_guc_tlb_inval.c
drivers/gpu/drm/xe/xe_page_reclaim.c
drivers/gpu/drm/xe/xe_page_reclaim.h
drivers/gpu/drm/xe/xe_pt.c

index fb2904bd0abd4d974ad148e8620c9f7aa8f4f930..8294bcd403106d55ff6e4472b4cdfda417175ce0 100644 (file)
@@ -76,6 +76,11 @@ static const char *const stat_description[__XE_GT_STATS_NUM_IDS] = {
                     "hw_engine_group_suspend_lr_queue_us"),
        DEF_STAT_STR(HW_ENGINE_GROUP_WAIT_DMA_QUEUE_US,
                     "hw_engine_group_wait_dma_queue_us"),
+       DEF_STAT_STR(PRL_4K_ENTRY_COUNT, "prl_4k_entry_count"),
+       DEF_STAT_STR(PRL_64K_ENTRY_COUNT, "prl_64k_entry_count"),
+       DEF_STAT_STR(PRL_2M_ENTRY_COUNT, "prl_2m_entry_count"),
+       DEF_STAT_STR(PRL_ISSUED_COUNT, "prl_issued_count"),
+       DEF_STAT_STR(PRL_ABORTED_COUNT, "prl_aborted_count"),
 };
 
 /**
index b92d013091d5e9542a7f74853a9bcc48816cbddd..b8accdbc54eb3d962a6216e38cb1fc61bbe0a784 100644 (file)
@@ -49,6 +49,11 @@ enum xe_gt_stats_id {
        XE_GT_STATS_ID_HW_ENGINE_GROUP_WAIT_DMA_QUEUE_COUNT,
        XE_GT_STATS_ID_HW_ENGINE_GROUP_SUSPEND_LR_QUEUE_US,
        XE_GT_STATS_ID_HW_ENGINE_GROUP_WAIT_DMA_QUEUE_US,
+       XE_GT_STATS_ID_PRL_4K_ENTRY_COUNT,
+       XE_GT_STATS_ID_PRL_64K_ENTRY_COUNT,
+       XE_GT_STATS_ID_PRL_2M_ENTRY_COUNT,
+       XE_GT_STATS_ID_PRL_ISSUED_COUNT,
+       XE_GT_STATS_ID_PRL_ABORTED_COUNT,
        /* must be the last entry */
        __XE_GT_STATS_NUM_IDS,
 };
index 6532a88d51e23acc57c02751ebff17c484d61d8f..774467befbb9fb1e903d54d9afca9bf79aa967f8 100644 (file)
@@ -97,6 +97,7 @@ static int send_tlb_inval_ggtt(struct xe_tlb_inval *tlb_inval, u32 seqno)
 static int send_page_reclaim(struct xe_guc *guc, u32 seqno,
                             u64 gpu_addr)
 {
+       struct xe_gt *gt = guc_to_gt(guc);
        u32 action[] = {
                XE_GUC_ACTION_PAGE_RECLAMATION,
                seqno,
@@ -104,6 +105,8 @@ static int send_page_reclaim(struct xe_guc *guc, u32 seqno,
                upper_32_bits(gpu_addr),
        };
 
+       xe_gt_stats_incr(gt, XE_GT_STATS_ID_PRL_ISSUED_COUNT, 1);
+
        return xe_guc_ct_send(&guc->ct, action, ARRAY_SIZE(action),
                              G2H_LEN_DW_PAGE_RECLAMATION, 1);
 }
index 94d4608ebd7492d67bc8e59eaf7b756c2405cbb5..a8f35919a9da2f1d3af53a5889c6ab3f4fc3c822 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "regs/xe_gt_regs.h"
 #include "xe_assert.h"
+#include "xe_gt_stats.h"
 #include "xe_macros.h"
 #include "xe_mmio.h"
 #include "xe_pat.h"
index 12f861f357d8439283c3d1c0a41ef43948d25e40..3dd103e37bebb41b5a3b466007cc2f30c7a830a0 100644 (file)
@@ -91,6 +91,7 @@ void xe_page_reclaim_list_invalidate(struct xe_page_reclaim_list *prl);
                struct xe_page_reclaim_list *__prl = (prl);                             \
                                                                                        \
                xe_page_reclaim_list_invalidate(__prl);                                 \
+               xe_gt_stats_incr(__gt, XE_GT_STATS_ID_PRL_ABORTED_COUNT, 1);            \
                vm_dbg(&gt_to_xe(__gt)->drm, "PRL aborted: " fmt, ##__VA_ARGS__);       \
        } while (0)
 
index a53944957be444c0374628b86d3ecc3b70fc00fd..6703a70492275426a833b529e47be390253fcf2a 100644 (file)
@@ -11,6 +11,7 @@
 #include "xe_drm_client.h"
 #include "xe_exec_queue.h"
 #include "xe_gt.h"
+#include "xe_gt_stats.h"
 #include "xe_migrate.h"
 #include "xe_page_reclaim.h"
 #include "xe_pt_types.h"
@@ -1587,6 +1588,7 @@ static int generate_reclaim_entry(struct xe_tile *tile,
                                  struct xe_page_reclaim_list *prl,
                                  u64 pte, struct xe_pt *xe_child)
 {
+       struct xe_gt *gt = tile->primary_gt;
        struct xe_guc_page_reclaim_entry *reclaim_entries = prl->entries;
        u64 phys_addr = pte & XE_PTE_ADDR_MASK;
        u64 phys_page = phys_addr >> XE_PTE_SHIFT;
@@ -1607,12 +1609,15 @@ static int generate_reclaim_entry(struct xe_tile *tile,
         * Only 4K, 64K (level 0), and 2M pages are supported by hardware for page reclaim
         */
        if (xe_child->level == 0 && !(pte & XE_PTE_PS64)) {
+               xe_gt_stats_incr(gt, XE_GT_STATS_ID_PRL_4K_ENTRY_COUNT, 1);
                reclamation_size = COMPUTE_RECLAIM_ADDRESS_MASK(SZ_4K);  /* reclamation_size = 0 */
                xe_tile_assert(tile, phys_addr % SZ_4K == 0);
        } else if (xe_child->level == 0) {
+               xe_gt_stats_incr(gt, XE_GT_STATS_ID_PRL_64K_ENTRY_COUNT, 1);
                reclamation_size = COMPUTE_RECLAIM_ADDRESS_MASK(SZ_64K); /* reclamation_size = 4 */
                xe_tile_assert(tile, phys_addr % SZ_64K == 0);
        } else if (xe_child->level == 1 && pte & XE_PDE_PS_2M) {
+               xe_gt_stats_incr(gt, XE_GT_STATS_ID_PRL_2M_ENTRY_COUNT, 1);
                reclamation_size = COMPUTE_RECLAIM_ADDRESS_MASK(SZ_2M);  /* reclamation_size = 9 */
                xe_tile_assert(tile, phys_addr % SZ_2M == 0);
        } else {