mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-08-28 12:42:46 +00:00

Add a new entry in stats to for svm page faults. If CONFIG_DEBUG_FS is enabled, the count can be viewed with per GT stat debugfs file. This is similar to what is already in place for vma page faults. Example output: cat /sys/kernel/debug/dri/0/gt0/stats svm_pagefault_count: 6 tlb_inval_count: 78 vma_pagefault_count: 0 vma_pagefault_kb: 0 v2: Fix build with CONFIG_DRM_GPUSVM disabled v3: Update argument in kernel doc Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250312092749.164232-1-francois.dugast@intel.com Signed-off-by: Francois Dugast <francois.dugast@intel.com>
53 lines
1.2 KiB
C
53 lines
1.2 KiB
C
// SPDX-License-Identifier: MIT
|
|
/*
|
|
* Copyright © 2024 Intel Corporation
|
|
*/
|
|
|
|
#include <linux/atomic.h>
|
|
|
|
#include <drm/drm_print.h>
|
|
|
|
#include "xe_gt.h"
|
|
#include "xe_gt_stats.h"
|
|
|
|
/**
|
|
* xe_gt_stats_incr - Increments the specified stats counter
|
|
* @gt: GT structure
|
|
* @id: xe_gt_stats_id type id that needs to be incremented
|
|
* @incr: value to be incremented with
|
|
*
|
|
* Increments the specified stats counter.
|
|
*/
|
|
void xe_gt_stats_incr(struct xe_gt *gt, const enum xe_gt_stats_id id, int incr)
|
|
{
|
|
if (id >= __XE_GT_STATS_NUM_IDS)
|
|
return;
|
|
|
|
atomic64_add(incr, >->stats.counters[id]);
|
|
}
|
|
|
|
static const char *const stat_description[__XE_GT_STATS_NUM_IDS] = {
|
|
"svm_pagefault_count",
|
|
"tlb_inval_count",
|
|
"vma_pagefault_count",
|
|
"vma_pagefault_kb",
|
|
};
|
|
|
|
/**
|
|
* xe_gt_stats_print_info - Print the GT stats
|
|
* @gt: GT structure
|
|
* @p: drm_printer where it will be printed out.
|
|
*
|
|
* This prints out all the available GT stats.
|
|
*/
|
|
int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p)
|
|
{
|
|
enum xe_gt_stats_id id;
|
|
|
|
for (id = 0; id < __XE_GT_STATS_NUM_IDS; ++id)
|
|
drm_printf(p, "%s: %lld\n", stat_description[id],
|
|
atomic64_read(>->stats.counters[id]));
|
|
|
|
return 0;
|
|
}
|