]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe: Add new SVM copy GT stats per size
authorFrancois Dugast <francois.dugast@intel.com>
Wed, 25 Mar 2026 16:01:52 +0000 (17:01 +0100)
committerMatthew Brost <matthew.brost@intel.com>
Thu, 26 Mar 2026 01:19:37 +0000 (18:19 -0700)
Breakdown the GT stats for copy to host and copy to device per size (4K,
64K 2M) to make it easier for user space to track memory migrations.
This is helpful to verify allocation alignment is correct when porting
applications to SVM.

Cc: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Francois Dugast <francois.dugast@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20260325160152.1057556-1-francois.dugast@intel.com
drivers/gpu/drm/xe/xe_gt_stats.c
drivers/gpu/drm/xe/xe_gt_stats_types.h
drivers/gpu/drm/xe/xe_svm.c

index 81cec441b44900348dcae3bb963c0296bdeda083..59b3b23a54c895aa2a25d610304e1406527a3716 100644 (file)
@@ -85,7 +85,13 @@ static const char *const stat_description[__XE_GT_STATS_NUM_IDS] = {
        DEF_STAT_STR(SVM_64K_CPU_COPY_US, "svm_64K_cpu_copy_us"),
        DEF_STAT_STR(SVM_2M_CPU_COPY_US, "svm_2M_cpu_copy_us"),
        DEF_STAT_STR(SVM_DEVICE_COPY_KB, "svm_device_copy_kb"),
+       DEF_STAT_STR(SVM_4K_DEVICE_COPY_KB, "svm_4K_device_copy_kb"),
+       DEF_STAT_STR(SVM_64K_DEVICE_COPY_KB, "svm_64K_device_copy_kb"),
+       DEF_STAT_STR(SVM_2M_DEVICE_COPY_KB, "svm_2M_device_copy_kb"),
        DEF_STAT_STR(SVM_CPU_COPY_KB, "svm_cpu_copy_kb"),
+       DEF_STAT_STR(SVM_4K_CPU_COPY_KB, "svm_4K_cpu_copy_kb"),
+       DEF_STAT_STR(SVM_64K_CPU_COPY_KB, "svm_64K_cpu_copy_kb"),
+       DEF_STAT_STR(SVM_2M_CPU_COPY_KB, "svm_2M_cpu_copy_kb"),
        DEF_STAT_STR(SVM_4K_GET_PAGES_US, "svm_4K_get_pages_us"),
        DEF_STAT_STR(SVM_64K_GET_PAGES_US, "svm_64K_get_pages_us"),
        DEF_STAT_STR(SVM_2M_GET_PAGES_US, "svm_2M_get_pages_us"),
index b6081c31247431aa736db18c809e8658175d9796..081c787ddcb6ee8309b3fc3afcf6bccda3da528f 100644 (file)
@@ -40,7 +40,13 @@ enum xe_gt_stats_id {
        XE_GT_STATS_ID_SVM_64K_CPU_COPY_US,
        XE_GT_STATS_ID_SVM_2M_CPU_COPY_US,
        XE_GT_STATS_ID_SVM_DEVICE_COPY_KB,
+       XE_GT_STATS_ID_SVM_4K_DEVICE_COPY_KB,
+       XE_GT_STATS_ID_SVM_64K_DEVICE_COPY_KB,
+       XE_GT_STATS_ID_SVM_2M_DEVICE_COPY_KB,
        XE_GT_STATS_ID_SVM_CPU_COPY_KB,
+       XE_GT_STATS_ID_SVM_4K_CPU_COPY_KB,
+       XE_GT_STATS_ID_SVM_64K_CPU_COPY_KB,
+       XE_GT_STATS_ID_SVM_2M_CPU_COPY_KB,
        XE_GT_STATS_ID_SVM_4K_GET_PAGES_US,
        XE_GT_STATS_ID_SVM_64K_GET_PAGES_US,
        XE_GT_STATS_ID_SVM_2M_GET_PAGES_US,
index a91c84487a674a8c02d1e933ef1f70f0acf2aeb2..0251098650af6a3787de6a7594e0d60984d5cbfe 100644 (file)
@@ -485,10 +485,33 @@ static void xe_svm_copy_kb_stats_incr(struct xe_gt *gt,
                                      const enum xe_svm_copy_dir dir,
                                      int kb)
 {
-       if (dir == XE_SVM_COPY_TO_VRAM)
+       if (dir == XE_SVM_COPY_TO_VRAM) {
+               switch (kb) {
+               case 4:
+                       xe_gt_stats_incr(gt, XE_GT_STATS_ID_SVM_4K_DEVICE_COPY_KB, kb);
+                       break;
+               case 64:
+                       xe_gt_stats_incr(gt, XE_GT_STATS_ID_SVM_64K_DEVICE_COPY_KB, kb);
+                       break;
+               case 2048:
+                       xe_gt_stats_incr(gt, XE_GT_STATS_ID_SVM_2M_DEVICE_COPY_KB, kb);
+                       break;
+               }
                xe_gt_stats_incr(gt, XE_GT_STATS_ID_SVM_DEVICE_COPY_KB, kb);
-       else
+       } else {
+               switch (kb) {
+               case 4:
+                       xe_gt_stats_incr(gt, XE_GT_STATS_ID_SVM_4K_CPU_COPY_KB, kb);
+                       break;
+               case 64:
+                       xe_gt_stats_incr(gt, XE_GT_STATS_ID_SVM_64K_CPU_COPY_KB, kb);
+                       break;
+               case 2048:
+                       xe_gt_stats_incr(gt, XE_GT_STATS_ID_SVM_2M_CPU_COPY_KB, kb);
+                       break;
+               }
                xe_gt_stats_incr(gt, XE_GT_STATS_ID_SVM_CPU_COPY_KB, kb);
+       }
 }
 
 static void xe_svm_copy_us_stats_incr(struct xe_gt *gt,