File: xe_gt_stats.c

package info (click to toggle)
linux 6.17.7-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,734,408 kB
  • sloc: ansic: 26,679,265; asm: 271,207; sh: 147,319; python: 75,916; makefile: 57,295; perl: 36,942; xml: 19,562; cpp: 5,899; yacc: 4,909; lex: 2,943; awk: 1,556; sed: 29; ruby: 25
file content (52 lines) | stat: -rw-r--r-- 1,184 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// 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, &gt->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(&gt->stats.counters[id]));

	return 0;
}