Skip to content

Commit 5b38083

Browse files
committed
drm/xe: Add stats for vma page faults
Add new entries in stats for vma page faults. If CONFIG_DEBUG_FS is enabled, the count and number of bytes can be viewed per GT in the stat debugfs file. This helps when testing, to confirm page faults have been triggered as expected. It also helps when looking at the performance impact of page faults. Data is simply collected when entering the page fault handler so there is no indication whether it completed successfully, with or without retries, etc. Example output: cat /sys/kernel/debug/dri/0/gt0/stats tlb_inval_count: 129 vma_pagefault_count: 12 vma_pagefault_bytes: 98304 v2: Rebase Reviewed-by: Jonathan Cavitt <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Francois Dugast <[email protected]>
1 parent 01aebfa commit 5b38083

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

drivers/gpu/drm/xe/xe_gt_pagefault.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "abi/guc_actions_abi.h"
1515
#include "xe_bo.h"
1616
#include "xe_gt.h"
17+
#include "xe_gt_stats.h"
1718
#include "xe_gt_tlb_invalidation.h"
1819
#include "xe_guc.h"
1920
#include "xe_guc_ct.h"
@@ -124,16 +125,20 @@ static int xe_pf_begin(struct drm_exec *exec, struct xe_vma *vma,
124125
return 0;
125126
}
126127

127-
static int handle_vma_pagefault(struct xe_tile *tile, struct pagefault *pf,
128+
static int handle_vma_pagefault(struct xe_gt *gt, struct pagefault *pf,
128129
struct xe_vma *vma)
129130
{
130131
struct xe_vm *vm = xe_vma_vm(vma);
132+
struct xe_tile *tile = gt_to_tile(gt);
131133
struct drm_exec exec;
132134
struct dma_fence *fence;
133135
ktime_t end = 0;
134136
int err;
135137
bool atomic;
136138

139+
xe_gt_stats_incr(gt, XE_GT_STATS_ID_VMA_PAGEFAULT_COUNT, 1);
140+
xe_gt_stats_incr(gt, XE_GT_STATS_ID_VMA_PAGEFAULT_BYTES, xe_vma_size(vma));
141+
137142
trace_xe_vma_pagefault(vma);
138143
atomic = access_is_atomic(pf->access_type);
139144

@@ -202,7 +207,6 @@ static struct xe_vm *asid_to_vm(struct xe_device *xe, u32 asid)
202207
static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf)
203208
{
204209
struct xe_device *xe = gt_to_xe(gt);
205-
struct xe_tile *tile = gt_to_tile(gt);
206210
struct xe_vm *vm;
207211
struct xe_vma *vma = NULL;
208212
int err;
@@ -231,7 +235,7 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf)
231235
goto unlock_vm;
232236
}
233237

234-
err = handle_vma_pagefault(tile, pf, vma);
238+
err = handle_vma_pagefault(gt, pf, vma);
235239

236240
unlock_vm:
237241
if (!err)

drivers/gpu/drm/xe/xe_gt_stats.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ void xe_gt_stats_incr(struct xe_gt *gt, const enum xe_gt_stats_id id, int incr)
2828

2929
static const char *const stat_description[__XE_GT_STATS_NUM_IDS] = {
3030
"tlb_inval_count",
31+
"vma_pagefault_count",
32+
"vma_pagefault_bytes",
3133
};
3234

3335
/**

drivers/gpu/drm/xe/xe_gt_stats_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
enum xe_gt_stats_id {
1010
XE_GT_STATS_ID_TLB_INVAL,
11+
XE_GT_STATS_ID_VMA_PAGEFAULT_COUNT,
12+
XE_GT_STATS_ID_VMA_PAGEFAULT_BYTES,
1113
/* must be the last entry */
1214
__XE_GT_STATS_NUM_IDS,
1315
};

0 commit comments

Comments
 (0)