drm/xe/gt: Add APIs for printing stats over debugfs
Subsystems (2)
PATCH 1/2 drm/xe/gt: Add APIs for printing stats over debugfs
Add skeleton APIs for recording and printing various stats over debugfs. This currently only added counter types stats which is backed by atomic_t and wrapped with CONFIG_DRM_XE_STATS so this can be disabled on production system.
--- drivers/gpu/drm/xe/Kconfig.debug | 11 +++++++++++ drivers/gpu/drm/xe/Makefile | 2 ++ drivers/gpu/drm/xe/xe_gt_debugfs.c | 4 ++++ drivers/gpu/drm/xe/xe_gt_stats.c | 30 +++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_stats.h | 31 ++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_types.h | 7 +++++++ 6 files changed, 85 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_gt_stats.c create mode 100644 drivers/gpu/drm/xe/xe_gt_stats.h
drivers/gpu/drm/xe/Kconfig.debug +11 -0
@@ -94,3 +94,14 @@ config DRM_XE_USERPTR_INVAL_INJECT Recomended for driver developers only. If in doubt, say "N". + +config DRM_XE_STATS + bool "Enable XE statistics" + default n + help + Choose this option to enable support for collecting and + displaying XE statistics as debugfs. + + Recommended for driver developers only. + + If in doubt, say "N".
drivers/gpu/drm/xe/Makefile +2 -0
@@ -143,6 +143,8 @@ xe-$(CONFIG_PCI_IOV) += \ xe_pci_sriov.o \ xe_sriov_pf.o +xe-$(CONFIG_DRM_XE_STATS) += xe_gt_stats.o + # include helpers for tests even when XE is built-in ifdef CONFIG_DRM_XE_KUNIT_TEST xe-y += tests/xe_kunit_helpers.o
drivers/gpu/drm/xe/xe_gt_debugfs.c +4 -0
@@ -17,6 +17,7 @@#include "xe_gt_mcr.h" #include "xe_gt_sriov_pf_debugfs.h" #include "xe_gt_sriov_vf_debugfs.h" +#include "xe_gt_stats.h" #include "xe_gt_topology.h" #include "xe_hw_engine.h" #include "xe_lrc.h"
@@ -286,6 +287,9 @@ static const struct drm_info_list debugfs_list[] = { {"default_lrc_bcs", .show = xe_gt_debugfs_simple_show, .data = bcs_default_lrc}, {"default_lrc_vcs", .show = xe_gt_debugfs_simple_show, .data = vcs_default_lrc}, {"default_lrc_vecs", .show = xe_gt_debugfs_simple_show, .data = vecs_default_lrc}, +#if IS_ENABLED(CONFIG_DRM_XE_STATS) + {"stats", .show = xe_gt_debugfs_simple_show, .data = xe_gt_stats_print_info}, +#endif };void xe_gt_debugfs_register (struct xe_gt *gt)
drivers/gpu/drm/xe/xe_gt_stats.c new file +30 -0
@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2024 Intel Corporation +*/ + +#include <linux/atomic.h> + +#include "xe_gt.h" +#include "xe_gt_stats.h" + +#ifdef CONFIG_DRM_XE_STATS +void xe_gt_stats_incr (struct xe_gt *gt,enum xe_gt_counter_stats id,int incr) +{ +atomic_add (incr, >->stats.counters[id]); +} + +static const char *const stat_description[] = { +}; + +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p) +{ +enum xe_gt_counter_stats id; + +for (id =0 ; id <XE_GT_COUNTER_STATS_NUM ; ++id) +drm_printf (p,"%s: %d\n" , stat_description[id], +atomic_read (>->stats.counters[id])); + +return 0 ; +} +#endif
drivers/gpu/drm/xe/xe_gt_stats.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2024 Intel Corporation +*/ + +#ifndef _XE_GT_STATS_H_ +#define _XE_GT_STATS_H_ + +#include <drm/drm_print.h> + +struct xe_gt ; +//struct drm_printer; + +enum xe_gt_counter_stats { +XE_GT_COUNTER_STATS_NUM , +}; + +#ifdef CONFIG_DRM_XE_STATS +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p); +void xe_gt_stats_incr (struct xe_gt *gt,enum xe_gt_counter_stats stat,int incr); +#else +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p) +{ +} + +void xe_gt_stats_incr (struct xe_gt *gt,enum xe_gt_counter_stats stat,int incr) +{ +} + +#endif /* CONFIG_DRM_XE_STATS */ +#endif /* _XE_GT_STATS_H_ */
drivers/gpu/drm/xe/xe_gt_types.h +7 -0
@@ -10,6 +10,7 @@#include "xe_gt_idle_types.h" #include "xe_gt_sriov_pf_types.h" #include "xe_gt_sriov_vf_types.h" +#include "xe_gt_stats.h" #include "xe_hw_engine_types.h" #include "xe_hw_fence_types.h" #include "xe_oa.h"
@@ -133,6 +134,12 @@ struct xe_gt { u8 has_indirect_ring_state:1; } info; +#if IS_ENABLED (CONFIG_DRM_XE_STATS ) +struct { +atomic_t counters[XE_GT_COUNTER_STATS_NUM ]; + } stats; +#endif +/** * @mmio: mmio info for GT. All GTs within a tile share the same * register space, but have their own copy of GSI registers at a
Signature · 1 line
2.42.0
PATCH 2/2 drm/xe: Add stats for tlb invalidation count
Add stats for tlb invalidadtion count which can be viewed with per GT stat debugfs file.
Example output:
cat /sys/kernel/debug/dri/0/gt0/statstlb_inval_count: 22
--- drivers/gpu/drm/xe/xe_gt_stats.c | 1 + drivers/gpu/drm/xe/xe_gt_stats.h | 1 + drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c | 2 ++ 3 files changed, 4 insertions(+)
drivers/gpu/drm/xe/xe_gt_stats.c +1 -0
@@ -15,6 +15,7 @@ void xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_stats id, int incr) }static const char *const stat_description[] = { +"tlb_inval_count" , };int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p)
drivers/gpu/drm/xe/xe_gt_stats.h +1 -0
@@ -12,6 +12,7 @@ struct xe_gt;//struct drm_printer; enum xe_gt_counter_stats { +XE_GT_COUNTER_TLB_INVAL ,XE_GT_COUNTER_STATS_NUM , };
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c +2 -0
@@ -16,6 +16,7 @@#include "xe_pm.h" #include "xe_sriov.h" #include "xe_trace.h" +#include "xe_gt_stats.h" #include "regs/xe_guc_regs.h" #define FENCE_STACK_BIT DMA_FENCE_FLAG_USER_BITS
@@ -213,6 +214,7 @@ static int send_tlb_invalidation(struct xe_guc *guc, gt->tlb_invalidation.seqno =1 ; }mutex_unlock (&guc->ct.lock); +xe_gt_stats_incr (gt,XE_GT_COUNTER_TLB_INVAL ,1 );return ret; }
Signature · 1 line
2.42.0
RE: [PATCH 2/2] drm/xe: Add stats for tlb invalidation count
Quoted 59 lines
-----Original Message-----
From: Intel-xe <[email protected]> On Behalf Of Nirmoy Das
Sent: Wednesday, August 7, 2024 1:15 AM
To: [email protected]
Cc: Das, Nirmoy <[email protected]>; Brost, Matthew <[email protected]>; Wajdeczko, Michal <[email protected]>
Subject: [PATCH 2/2] drm/xe: Add stats for tlb invalidation countAdd stats for tlb invalidadtion count which can be viewed with per GT stat debugfs file.
Example output:
cat/sys/kernel/debug/dri/0/gt0/statstlb_inval_count: 22Cc Matthew Brost <[email protected]>Cc Michal Wajdeczko <[email protected]>Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/xe/xe_gt_stats.c | 1 + drivers/gpu/drm/xe/xe_gt_stats.h | 1 + drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c | 2 ++ 3 files changed, 4 insertions(+)drivers/gpu/drm/xe/xe_gt_stats.c +1
-0@@ -15,6 +15,7 @@ void xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_stats id, int incr) }static const char *const stat_description[] = { +"tlb_inval_count" , }; int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p) diff --git
a/drivers/gpu/drm/xe/xe_gt_stats.hb/drivers/gpu/drm/xe/xe_gt_stats.hindexe83155ab1fdb..11b8ed17f9d9100644drivers/gpu/drm/xe/xe_gt_stats.h +1
-0@@ -12,6 +12,7 @@ struct xe_gt;//struct drm_printer; enum xe_gt_counter_stats { +XE_GT_COUNTER_TLB_INVAL ,XE_GT_COUNTER_STATS_NUM , };drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c +0
-0
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c line 19
Quoted 4 lines
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c +1
-0@@ -16,6 +16,7 @@#include "xe_pm.h" #include "xe_sriov.h" #include "xe_trace.h" +#include "xe_gt_stats.h"
nit: include alphabetical order
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c static int send_tlb_invalidation(struct xe_guc *guc, · line 217
Quoted 8 lines
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c +1
-0#include "regs/xe_guc_regs.h" #define FENCE_STACK_BIT DMA_FENCE_FLAG_USER_BITS@@ -213,6 +214,7 @@ static int send_tlb_invalidation(struct xe_guc *guc, gt->tlb_invalidation.seqno =1 ; }mutex_unlock (&guc->ct.lock); +xe_gt_stats_incr (gt,XE_GT_COUNTER_TLB_INVAL ,1 );
Apart from above nit, LGTM :
Quoted 5 lines
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c +0
-1return ret; } --2.42.0
Re: [PATCH 2/2] drm/xe: Add stats for tlb invalidation count
Quoted 66 lines · Tejas
Quoted 58 lines
-----Original Message-----
From: Intel-xe <[email protected]> On Behalf Of Nirmoy Das
Sent: Wednesday, August 7, 2024 1:15 AM
To: [email protected]
Cc: Das, Nirmoy <[email protected]>; Brost, Matthew <[email protected]>; Wajdeczko, Michal <[email protected]>
Subject: [PATCH 2/2] drm/xe: Add stats for tlb invalidation countAdd stats for tlb invalidadtion count which can be viewed with per GT stat debugfs file.
Example output:
cat/sys/kernel/debug/dri/0/gt0/statstlb_inval_count: 22Cc Matthew Brost <[email protected]>Cc Michal Wajdeczko <[email protected]>Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/xe/xe_gt_stats.c | 1 + drivers/gpu/drm/xe/xe_gt_stats.h | 1 + drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c | 2 ++ 3 files changed, 4 insertions(+)drivers/gpu/drm/xe/xe_gt_stats.c +1
-0@@ -15,6 +15,7 @@ void xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_stats id, int incr) }static const char *const stat_description[] = { +"tlb_inval_count" , }; int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p) diff --git
a/drivers/gpu/drm/xe/xe_gt_stats.hb/drivers/gpu/drm/xe/xe_gt_stats.hindexe83155ab1fdb..11b8ed17f9d9100644drivers/gpu/drm/xe/xe_gt_stats.h +1
-0@@ -12,6 +12,7 @@ struct xe_gt;//struct drm_printer; enum xe_gt_counter_stats { +XE_GT_COUNTER_TLB_INVAL ,XE_GT_COUNTER_STATS_NUM , };drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c +0
-0drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c line 19
Quoted 4 lines
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c +1
-0@@ -16,6 +16,7 @@#include "xe_pm.h" #include "xe_sriov.h" #include "xe_trace.h" +#include "xe_gt_stats.h" nit: include alphabetical order
Quoted 2 lines
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c +0
-0#include "regs/xe_guc_regs.h"
Quoted 8 lines
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c static int send_tlb_invalidation(struct xe_guc *guc, · line 217
Quoted 6 lines
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c +1
-0#define FENCE_STACK_BIT DMA_FENCE_FLAG_USER_BITS@@ -213,6 +214,7 @@ static int send_tlb_invalidation(struct xe_guc *guc, gt->tlb_invalidation.seqno =1 ; }mutex_unlock (&guc->ct.lock); +xe_gt_stats_incr (gt,XE_GT_COUNTER_TLB_INVAL ,1 );Apart from above nit, LGTM :
Reviewed-by Tejas Upadhyay <[email protected]>
Thanks, will fix the ordering in the next version.
Nirmoy
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c +0
-1return ret; } --2.42.0
Looks like send this bit prematurely:
Quoted 117 lines · Nirmoy Das
Add skeleton APIs for recording and printing various stats over debugfs. This currently only added counter types stats which is backed by
atomic_tand wrapped withCONFIG_DRM_XE_STATSso this can be disabled on production system.Cc Matthew Brost <[email protected]>Cc Michal Wajdeczko <[email protected]>Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/xe/Kconfig.debug | 11 +++++++++++ drivers/gpu/drm/xe/Makefile | 2 ++ drivers/gpu/drm/xe/xe_gt_debugfs.c | 4 ++++ drivers/gpu/drm/xe/xe_gt_stats.c | 30 +++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_stats.h | 31 ++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_types.h | 7 +++++++ 6 files changed, 85 insertions(+)create mode 100644
drivers/gpu/drm/xe/xe_gt_stats.ccreate mode 100644drivers/gpu/drm/xe/xe_gt_stats.hdrivers/gpu/drm/xe/Kconfig.debug +11
-0@@ -94,3 +94,14 @@ config DRM_XE_USERPTR_INVAL_INJECT Recomended for driver developers only. If in doubt, say "N". + +config DRM_XE_STATS + bool "Enable XE statistics" + default n + help + Choose this option to enable support for collecting and + displaying XE statistics as debugfs. + + Recommended for driver developers only. + + If in doubt, say "N".drivers/gpu/drm/xe/Makefile +2
-0@@ -143,6 +143,8 @@ xe-$(CONFIG_PCI_IOV) += \ xe_pci_sriov.o \ xe_sriov_pf.o +xe-$(CONFIG_DRM_XE_STATS) += xe_gt_stats.o + # include helpers for tests even when XE is built-in ifdef CONFIG_DRM_XE_KUNIT_TEST xe-y += tests/xe_kunit_helpers.odrivers/gpu/drm/xe/xe_gt_debugfs.c +4
-0@@ -17,6 +17,7 @@#include "xe_gt_mcr.h" #include "xe_gt_sriov_pf_debugfs.h" #include "xe_gt_sriov_vf_debugfs.h" +#include "xe_gt_stats.h" #include "xe_gt_topology.h" #include "xe_hw_engine.h" #include "xe_lrc.h" @@ -286,6 +287,9 @@ static const struct drm_info_list debugfs_list[] = { {"default_lrc_bcs", .show = xe_gt_debugfs_simple_show, .data = bcs_default_lrc}, {"default_lrc_vcs", .show = xe_gt_debugfs_simple_show, .data = vcs_default_lrc}, {"default_lrc_vecs", .show = xe_gt_debugfs_simple_show, .data = vecs_default_lrc}, +#if IS_ENABLED(CONFIG_DRM_XE_STATS) + {"stats", .show = xe_gt_debugfs_simple_show, .data = xe_gt_stats_print_info}, +#endif };void xe_gt_debugfs_register (struct xe_gt *gt)drivers/gpu/drm/xe/xe_gt_stats.c new file +30
-0@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2024 Intel Corporation +*/ + +#include <linux/atomic.h> + +#include "xe_gt.h" +#include "xe_gt_stats.h" + +#ifdef CONFIG_DRM_XE_STATS +void xe_gt_stats_incr (struct xe_gt *gt,enum xe_gt_counter_stats id,int incr) +{ +atomic_add (incr, >->stats.counters[id]); +} + +static const char *const stat_description[] = { +}; + +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p) +{ +enum xe_gt_counter_stats id; + +for (id =0 ; id <XE_GT_COUNTER_STATS_NUM ; ++id) +drm_printf (p,"%s: %d\n" , stat_description[id], +atomic_read (>->stats.counters[id])); + +return 0 ; +} +#endif drivers/gpu/drm/xe/xe_gt_stats.h new file +2
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: MIT */ +/*
drivers/gpu/drm/xe/xe_gt_stats.h line 12
Quoted 10 lines
drivers/gpu/drm/xe/xe_gt_stats.h new file +10
-0+* Copyright © 2024 Intel Corporation +*/ + +#ifndef _XE_GT_STATS_H_ +#define _XE_GT_STATS_H_ + +#include <drm/drm_print.h> + +struct xe_gt ; +//struct drm_printer;
Forgot to remove this.
Quoted 32 lines
drivers/gpu/drm/xe/xe_gt_stats.h new file +19
-0+ +enum xe_gt_counter_stats { +XE_GT_COUNTER_STATS_NUM , +}; + +#ifdef CONFIG_DRM_XE_STATS +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p); +void xe_gt_stats_incr (struct xe_gt *gt,enum xe_gt_counter_stats stat,int incr); +#else +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p) +{ +} + +void xe_gt_stats_incr (struct xe_gt *gt,enum xe_gt_counter_stats stat,int incr) +{ +} + +#endif /* CONFIG_DRM_XE_STATS */ +#endif /* _XE_GT_STATS_H_ */ drivers/gpu/drm/xe/xe_gt_types.h +1
-0@@ -10,6 +10,7 @@#include "xe_gt_idle_types.h" #include "xe_gt_sriov_pf_types.h" #include "xe_gt_sriov_vf_types.h" +#include "xe_gt_stats.h" #include "xe_hw_engine_types.h" #include "xe_hw_fence_types.h" #include "xe_oa.h"
drivers/gpu/drm/xe/xe_gt_types.h struct xe_gt { · line 141
Quoted 8 lines
drivers/gpu/drm/xe/xe_gt_types.h +5
-0@@ -133,6 +134,12 @@ struct xe_gt { u8 has_indirect_ring_state:1; } info; +#if IS_ENABLED (CONFIG_DRM_XE_STATS ) +struct { +atomic_t counters[XE_GT_COUNTER_STATS_NUM ]; + } stats; +#endif
I forgot to add doc here. I will wait for reviews and resend with docs.
Regards,
Nirmoy
Quoted 4 lines
drivers/gpu/drm/xe/xe_gt_types.h +1
-0+/** * @mmio: mmio info for GT. All GTs within a tile share the same * register space, but have their own copy of GSI registers at a
Quoted 89 lines · Nirmoy Das
Looks like send this bit prematurely:
Quoted 86 lines · Nirmoy Das
Add skeleton APIs for recording and printing various stats over debugfs. This currently only added counter types stats which is backed by
atomic_tand wrapped withCONFIG_DRM_XE_STATSso this can be disabled on production system.Cc Matthew Brost <[email protected]>Cc Michal Wajdeczko <[email protected]>Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/xe/Kconfig.debug | 11 +++++++++++ drivers/gpu/drm/xe/Makefile | 2 ++drivers/gpu/drm/xe/xe_gt_debugfs.c| 4 ++++drivers/gpu/drm/xe/xe_gt_stats.c | 30 +++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_stats.h | 31 ++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_types.h | 7 +++++++ 6 files changed, 85 insertions(+)create mode 100644
drivers/gpu/drm/xe/xe_gt_stats.ccreate mode 100644drivers/gpu/drm/xe/xe_gt_stats.hdrivers/gpu/drm/xe/Kconfig.debug +0
-0@@ -94,3 +94,14 @@ config DRM_XE_USERPTR_INVAL_INJECTRecomended for driver developers only.
If in doubt, say "N".drivers/gpu/drm/xe/Kconfig.debug +11
-0+ +config DRM_XE_STATS + bool "Enable XE statistics" + default n + help + Choose this option to enable support for collecting and + displaying XE statistics as debugfs. + + Recommended for driver developers only. + + If in doubt, say "N".drivers/gpu/drm/xe/Makefile +0
-0@@ -143,6 +143,8 @@ xe-$(CONFIG_PCI_IOV) += \ xe_pci_sriov.o \xe_sriov_pf.o
+xe-$(CONFIG_DRM_XE_STATS) += xe_gt_stats.o
+# include helpers for tests even when XE is built-in ifdef CONFIG_DRM_XE_KUNIT_TEST xe-y += tests/xe_kunit_helpers.odrivers/gpu/drm/xe/xe_gt_debugfs.c +1
-0@@ -17,6 +17,7 @@ #include "xe_gt_mcr.h" #include "xe_gt_sriov_pf_debugfs.h" #include "xe_gt_sriov_vf_debugfs.h" +#include "xe_gt_stats.h" #include "xe_gt_topology.h" #include "xe_hw_engine.h" #include "xe_lrc.h"@@ -286,6 +287,9 @@ static const struct drm_info_list debugfs_list[] = {{"
default_lrc_bcs", .show =xe_gt_debugfs_simple_show, .data =bcs_default_lrc},
{"default_lrc_vcs", .show =xe_gt_debugfs_simple_show, .data =vcs_default_lrc},
{"default_lrc_vecs", .show =xe_gt_debugfs_simple_show, .data =vecs_default_lrc},
+#ifIS_ENABLED(CONFIG_DRM_XE_STATS)
+ {"stats", .show =xe_gt_debugfs_simple_show, .data =xe_gt_stats_print_info},
+#endif
};
voidxe_gt_debugfs_register(struct xe_gt *gt)drivers/gpu/drm/xe/xe_gt_stats.c new file +3
-0@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2024 Intel Corporation
Quoted 8 lines
drivers/gpu/drm/xe/xe_gt_stats.c line 11
Quoted 8 lines
drivers/gpu/drm/xe/xe_gt_stats.c new file +8
-0+*/ + +#include <linux/atomic.h> + +#include "xe_gt.h" +#include "xe_gt_stats.h" + +#ifdef CONFIG_DRM_XE_STATS
doc is also missing here
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/xe/xe_gt_stats.c new file +1
-0+void xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_stats id,int incr)
+{
what if id = STATS_NUM ?
Quoted 6 lines
drivers/gpu/drm/xe/xe_gt_stats.c line 19
Quoted 6 lines
+
atomic_add(incr, >->stats.counters[id]);drivers/gpu/drm/xe/xe_gt_stats.c new file +5
-0+} + +static const char *const stat_description[] = { +}; +
and here
Quoted 24 lines
Quoted 24 lines
drivers/gpu/drm/xe/xe_gt_stats.c new file +11
-0+int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p) +{ + enum xe_gt_counter_stats id; + + for (id = 0; id < XE_GT_COUNTER_STATS_NUM; ++id) + drm_printf(p, "%s: %d\n", stat_description[id], + atomic_read(>->stats.counters[id])); + + return 0; +} +#endif drivers/gpu/drm/xe/xe_gt_stats.h new file +6
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2024 Intel Corporation +*/ + +#ifndef _XE_GT_STATS_H_
Quoted 8 lines
drivers/gpu/drm/xe/xe_gt_stats.h line 12
Quoted 6 lines
drivers/gpu/drm/xe/xe_gt_stats.h new file +6
-0+#define _XE_GT_STATS_H_ + +#include <drm/drm_print.h> + +struct xe_gt ; +//struct drm_printer; Forgot to remove this.
actually this forward decl should stay (instead of the full #include above)
Quoted 4 lines
drivers/gpu/drm/xe/xe_gt_stats.h line 14
Quoted 4 lines
drivers/gpu/drm/xe/xe_gt_stats.h new file +2
-0+ +enum xe_gt_counter_stats {
nit: this file is "xe_gt_stats" so type name should follow it:
enum xe_gt_stats_id {same with enumerator names:
XE_GT_STATS_ID_TLB_INVAL,
Quoted 1 line
drivers/gpu/drm/xe/xe_gt_stats.h line 15
Quoted 1 line
drivers/gpu/drm/xe/xe_gt_stats.h new file +1
-0+ XE_GT_COUNTER_STATS_NUM,
hmm, if you really want to count stat ids using this last enumerator then make sure that functions that accepts such enum will not accept this NUM as index and maybe name it slightly differently than regular IDs:
__XE_GT_STATS_NUM_IDS,
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/xe/xe_gt_stats.h new file +5
-0+}; + +#ifdef CONFIG_DRM_XE_STATS +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p); +void xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_statsstat, int incr);
drivers/gpu/drm/xe/xe_gt_stats.h new file +4
-0+#else +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p) +{ +}
Quoted 8 lines
drivers/gpu/drm/xe/xe_gt_stats.h line 31
Quoted 8 lines
drivers/gpu/drm/xe/xe_gt_stats.h new file +2
-0+ +void xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_statsstat, int incr)
drivers/gpu/drm/xe/xe_gt_stats.h new file +5
-0+{ +} + +#endif /* CONFIG_DRM_XE_STATS */ +#endif /* _XE_GT_STATS_H_ */
IIRC we don't use comments on closing guards
Quoted 33 lines
Quoted 14 lines
drivers/gpu/drm/xe/xe_gt_types.h +1
-0@@ -10,6 +10,7 @@ #include "xe_gt_idle_types.h" #include "xe_gt_sriov_pf_types.h" #include "xe_gt_sriov_vf_types.h" +#include "xe_gt_stats.h" #include "xe_hw_engine_types.h" #include "xe_hw_fence_types.h" #include "xe_oa.h"drivers/gpu/drm/xe/xe_gt_types.h struct xe_gt { · line 140
Quoted 7 lines
drivers/gpu/drm/xe/xe_gt_types.h +4
-0@@ -133,6 +134,12 @@ struct xe_gt { u8 has_indirect_ring_state:1; } info; +#if IS_ENABLED(CONFIG_DRM_XE_STATS) + struct { + atomic_t counters[XE_GT_COUNTER_STATS_NUM]; + } stats; +#endif I forgot to add doc here. I will wait for reviews and resend with docs.
Regards,
Nirmoy
Quoted 4 lines
drivers/gpu/drm/xe/xe_gt_types.h +1
-0+ /*** @mmio: mmio info for GT. All GTs within a tile share the same * register space, but have their own copy of GSI registers at a
Quoted 92 lines · Michal Wajdeczko
Quoted 90 lines · Nirmoy Das
Looks like send this bit prematurely:
Quoted 87 lines · Nirmoy Das
Add skeleton APIs for recording and printing various stats over debugfs. This currently only added counter types stats which is backed by
atomic_tand wrapped withCONFIG_DRM_XE_STATSso this can be disabled on production system.Cc Matthew Brost <[email protected]>Cc Michal Wajdeczko <[email protected]>Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/xe/Kconfig.debug | 11 +++++++++++ drivers/gpu/drm/xe/Makefile | 2 ++ drivers/gpu/drm/xe/xe_gt_debugfs.c | 4 ++++ drivers/gpu/drm/xe/xe_gt_stats.c | 30 +++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_stats.h | 31 ++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_types.h | 7 +++++++ 6 files changed, 85 insertions(+)create mode 100644
drivers/gpu/drm/xe/xe_gt_stats.ccreate mode 100644drivers/gpu/drm/xe/xe_gt_stats.hdrivers/gpu/drm/xe/Kconfig.debug +11
-0@@ -94,3 +94,14 @@ config DRM_XE_USERPTR_INVAL_INJECT Recomended for driver developers only. If in doubt, say "N". + +config DRM_XE_STATS + bool "Enable XE statistics" + default n + help + Choose this option to enable support for collecting and + displaying XE statistics as debugfs. + + Recommended for driver developers only. + + If in doubt, say "N".drivers/gpu/drm/xe/Makefile +1
-0@@ -143,6 +143,8 @@ xe-$(CONFIG_PCI_IOV) += \ xe_pci_sriov.o \ xe_sriov_pf.o +xe-$(CONFIG_DRM_XE_STATS) += xe_gt_stats.o + # include helpers for tests even when XE is built-in ifdef CONFIG_DRM_XE_KUNIT_TEST xe-y += tests/xe_kunit_helpers.odrivers/gpu/drm/xe/xe_gt_debugfs.c +3
-0@@ -17,6 +17,7 @@ #include "xe_gt_mcr.h" #include "xe_gt_sriov_pf_debugfs.h" #include "xe_gt_sriov_vf_debugfs.h" +#include "xe_gt_stats.h" #include "xe_gt_topology.h" #include "xe_hw_engine.h" #include "xe_lrc.h"@@ -286,6 +287,9 @@ static const struct drm_info_list debugfs_list[] = { {"default_lrc_bcs", .show = xe_gt_debugfs_simple_show, .data = bcs_default_lrc}, {"default_lrc_vcs", .show = xe_gt_debugfs_simple_show, .data = vcs_default_lrc}, {"default_lrc_vecs", .show = xe_gt_debugfs_simple_show, .data = vecs_default_lrc}, +#if IS_ENABLED(CONFIG_DRM_XE_STATS) + {"stats", .show = xe_gt_debugfs_simple_show, .data =
xe_gt_stats_print_info},drivers/gpu/drm/xe/xe_gt_debugfs.c +1
-0+#endif }; void xe_gt_debugfs_register(struct xe_gt *gt)drivers/gpu/drm/xe/xe_gt_stats.c new file +4
-0@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2024 Intel Corporation +*/
Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/xe/xe_gt_stats.c line 11
Quoted 7 lines
drivers/gpu/drm/xe/xe_gt_stats.c new file +7
-0+ +#include <linux/atomic.h> + +#include "xe_gt.h" +#include "xe_gt_stats.h" + +#ifdef CONFIG_DRM_XE_STATS doc is also missing here
Will resend with docs for public functions.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/xe/xe_gt_stats.c new file +1
-0+void xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_stats id,int incr)
+{what if id =
STATS_NUM?
Quoted 7 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_gt_stats.c line 19
Quoted 6 lines
+
atomic_add(incr, >->stats.counters[id]);drivers/gpu/drm/xe/xe_gt_stats.c new file +5
-0+} + +static const char *const stat_description[] = { +}; +and here
Agreed, I should add boundary checks.
Quoted 32 lines
Quoted 24 lines
Quoted 24 lines
drivers/gpu/drm/xe/xe_gt_stats.c new file +11
-0+int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p) +{ + enum xe_gt_counter_stats id; + + for (id = 0; id < XE_GT_COUNTER_STATS_NUM; ++id) + drm_printf(p, "%s: %d\n", stat_description[id], + atomic_read(>->stats.counters[id])); + + return 0; +} +#endif drivers/gpu/drm/xe/xe_gt_stats.h new file +5
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2024 Intel Corporation +*/ +Quoted 8 lines
drivers/gpu/drm/xe/xe_gt_stats.h line 12
Quoted 7 lines
drivers/gpu/drm/xe/xe_gt_stats.h new file +7
-0+#ifndef _XE_GT_STATS_H_ +#define _XE_GT_STATS_H_ + +#include <drm/drm_print.h> + +struct xe_gt ; +//struct drm_printer; Forgot to remove this.
Quoted 1 line
actually this forward decl should stay (instead of the full #include above)
Ok, I think in that case I have to move the include to the .c file.
Quoted 10 lines
Quoted 4 lines
drivers/gpu/drm/xe/xe_gt_stats.h line 14
Quoted 4 lines
drivers/gpu/drm/xe/xe_gt_stats.h new file +2
-0+ +enum xe_gt_counter_stats {nit: this file is "
xe_gt_stats" so type name should follow it:enum xe_gt_stats_id {same with enumerator names:
Quoted 8 lines
XE_GT_STATS_ID_TLB_INVAL,Quoted 1 line
drivers/gpu/drm/xe/xe_gt_stats.h line 15
Quoted 1 line
drivers/gpu/drm/xe/xe_gt_stats.h new file +1
-0+ XE_GT_COUNTER_STATS_NUM,hmm, if you really want to count stat ids using this last enumerator then make sure that functions that accepts such enum will not accept this NUM as index and maybe name it slightly differently than regular IDs:
__XE_GT_STATS_NUM_IDS,
I will adjust this series with above suggestions.
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/xe/xe_gt_stats.h new file +5
-0+}; + +#ifdef CONFIG_DRM_XE_STATS +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p); +void xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_statsstat, int incr);
drivers/gpu/drm/xe/xe_gt_stats.h new file +5
-0+#else +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p) +{ +} +
Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/xe/xe_gt_stats.h line 31
Quoted 7 lines
+void
xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_stats stat, int incr)drivers/gpu/drm/xe/xe_gt_stats.h new file +5
-0+{ +} + +#endif /* CONFIG_DRM_XE_STATS */ +#endif /* _XE_GT_STATS_H_ */ IIRC we don't use comments on closing guards
I will recheck and remove if so.
Thanks,
Nirmoy
Quoted 33 lines
Quoted 33 lines
Quoted 15 lines
drivers/gpu/drm/xe/xe_gt_types.h +1
-0@@ -10,6 +10,7 @@ #include "xe_gt_idle_types.h" #include "xe_gt_sriov_pf_types.h" #include "xe_gt_sriov_vf_types.h" +#include "xe_gt_stats.h" #include "xe_hw_engine_types.h" #include "xe_hw_fence_types.h" #include "xe_oa.h"drivers/gpu/drm/xe/xe_gt_types.h struct xe_gt { · line 140
Quoted 7 lines
drivers/gpu/drm/xe/xe_gt_types.h +4
-0@@ -133,6 +134,12 @@ struct xe_gt { u8 has_indirect_ring_state:1; } info; +#if IS_ENABLED(CONFIG_DRM_XE_STATS) + struct { + atomic_t counters[XE_GT_COUNTER_STATS_NUM]; + } stats; +#endif I forgot to add doc here. I will wait for reviews and resend with docs.
Regards,
Nirmoy
Quoted 4 lines
drivers/gpu/drm/xe/xe_gt_types.h +1
-0+ /*** @mmio: mmio info for GT. All GTs within a tile share the same * register space, but have their own copy of GSI registers at a
Patchwork
CI✓ CI.Patch_applied: success for series starting with [1/2] drm/xe/gt: Add APIs for printing stats over debugfs
In reply to Nirmoy Das== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/xe/gt: Add APIs for printing stats over debugfs
URL : https://patchwork.freedesktop.org/series/136950/
State : success
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 566483e0e0e0 drm-tip: 2024y-08m-06d-18h-17m-03s UTC integration manifest === git am output follows ===
Applying: drm/xe/gt: Add APIs for printing stats over debugfs
Applying: drm/xe: Add stats for tlb invalidation count
Patchwork
CI✗ CI.checkpatch: warning for series starting with [1/2] drm/xe/gt: Add APIs for printing stats over debugfs
In reply to Nirmoy Das== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/xe/gt: Add APIs for printing stats over debugfs
URL : https://patchwork.freedesktop.org/series/136950/
State : warning
== Summary ==
+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master 66551fd1be58212fb46d0bc97f2e5ae43c69b733
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit 582b705a7b839c0a041e78d924ee16aed79cd49e
Author: Nirmoy Das <[email protected]> Date: Tue Aug 6 21:45:04 2024 +0200
drm/xe: Add stats for tlb invalidation count
Add stats for tlb invalidadtion count which can be viewed with per GT stat debugfs file.
Example output:
cat /sys/kernel/debug/dri/0/gt0/stats
tlb_inval_count: 22
+ /mt/dim checkpatch 566483e0e0e0c2079789850d593701170659e292 drm-intel 399caa6d49af drm/xe/gt: Add APIs for printing stats over debugfs
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
-:70: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #70:
new file mode 100644
total: 0 errors, 1 warnings, 0 checks, 118 lines checked 582b705a7b83 drm/xe: Add stats for tlb invalidation count
Patchwork
CI✗ CI.KUnit: failure for series starting with [1/2] drm/xe/gt: Add APIs for printing stats over debugfs
In reply to Nirmoy Das== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/xe/gt: Add APIs for printing stats over debugfs
URL : https://patchwork.freedesktop.org/series/136950/
State : failure
== Summary ==
+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig ERROR:root:In file included from ../drivers/gpu/drm/xe/xe_gt_types.h:13,
from ../drivers/gpu/drm/xe/xe_device_types.h:17,
from ../drivers/gpu/drm/xe/xe_device.h:11,
from ../drivers/gpu/drm/xe/tests/xe_pci_test.c:13:
../drivers/gpu/drm/xe/xe_gt_stats.h:23:5: warning: no previous prototype for ‘xe_gt_stats_print_info’ [-Wmissing-prototypes]
23 | int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p)
| ^~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_gt_stats.h:27:6: warning: no previous prototype for ‘xe_gt_stats_incr’ [-Wmissing-prototypes]
27 | void xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_stats stat, int incr)
| ^~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_gt_types.h:13,
from ../drivers/gpu/drm/xe/xe_device_types.h:17,
from ../drivers/gpu/drm/xe/xe_device.h:11,
from ../drivers/gpu/drm/xe/tests/xe_pci_test.c:13:
../drivers/gpu/drm/xe/xe_gt_stats.h: In function ‘xe_gt_stats_print_info’:
../drivers/gpu/drm/xe/xe_gt_stats.h:25:1: error: control reaches end of non-void function [-Werror=return-type]
25 | }
| ^cc1: some warnings being treated as errors
make[8]: *** [../scripts/Makefile.build:244: drivers/gpu/drm/xe/tests/xe_pci_test.o] Error 1 make[8]: *** Waiting for unfinished jobs....
In file included from ../drivers/gpu/drm/xe/xe_gt_types.h:13,
from ../drivers/gpu/drm/xe/xe_device_types.h:17,
from ../drivers/gpu/drm/xe/xe_assert.h:13,
from ../drivers/gpu/drm/xe/xe_bb.c:9:
../drivers/gpu/drm/xe/xe_gt_stats.h:23:5: warning: no previous prototype for ‘xe_gt_stats_print_info’ [-Wmissing-prototypes]
23 | int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p)
| ^~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_gt_stats.h:27:6: warning: no previous prototype for ‘xe_gt_stats_incr’ [-Wmissing-prototypes]
27 | void xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_stats stat, int incr)
| ^~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_gt_types.h:13,
from ../drivers/gpu/drm/xe/xe_device_types.h:17,
from ../drivers/gpu/drm/xe/xe_assert.h:13,
from ../drivers/gpu/drm/xe/xe_bb.c:9:
../drivers/gpu/drm/xe/xe_gt_stats.h: In function ‘xe_gt_stats_print_info’:
../drivers/gpu/drm/xe/xe_gt_stats.h:25:1: error: control reaches end of non-void function [-Werror=return-type]
25 | }
| ^
In file included from ../drivers/gpu/drm/xe/xe_gt_types.h:13,
from ../drivers/gpu/drm/xe/xe_device_types.h:17,
from ../drivers/gpu/drm/xe/xe_device.h:11,
from ../drivers/gpu/drm/xe/tests/xe_rtp_test.c:16:
../drivers/gpu/drm/xe/xe_gt_stats.h:23:5: warning: no previous prototype for ‘xe_gt_stats_print_info’ [-Wmissing-prototypes]
23 | int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p)
| ^~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_gt_stats.h:27:6: warning: no previous prototype for ‘xe_gt_stats_incr’ [-Wmissing-prototypes]
27 | void xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_stats stat, int incr)
| ^~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
make[7]: *** [../scripts/Makefile.build:244: drivers/gpu/drm/xe/xe_bb.o] Error 1 make[7]: *** Waiting for unfinished jobs....
In file included from ../drivers/gpu/drm/xe/xe_gt_types.h:13,
from ../drivers/gpu/drm/xe/xe_device_types.h:17,
from ../drivers/gpu/drm/xe/xe_device.h:11,
from ../drivers/gpu/drm/xe/tests/xe_rtp_test.c:16:
../drivers/gpu/drm/xe/xe_gt_stats.h: In function ‘xe_gt_stats_print_info’:
../drivers/gpu/drm/xe/xe_gt_stats.h:25:1: error: control reaches end of non-void function [-Werror=return-type]
25 | }
| ^
In file included from ../drivers/gpu/drm/xe/xe_gt_types.h:13,
from ../drivers/gpu/drm/xe/xe_device_types.h:17,
from ../drivers/gpu/drm/xe/xe_device.h:11,
from ../drivers/gpu/drm/xe/tests/xe_wa_test.c:11:
../drivers/gpu/drm/xe/xe_gt_stats.h:23:5: warning: no previous prototype for ‘xe_gt_stats_print_info’ [-Wmissing-prototypes]
23 | int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p)
| ^~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_gt_stats.h:27:6: warning: no previous prototype for ‘xe_gt_stats_incr’ [-Wmissing-prototypes]
27 | void xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_stats stat, int incr)
| ^~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_gt_types.h:13,
from ../drivers/gpu/drm/xe/xe_device_types.h:17,
from ../drivers/gpu/drm/xe/xe_device.h:11,
from ../drivers/gpu/drm/xe/tests/xe_wa_test.c:11:
../drivers/gpu/drm/xe/xe_gt_stats.h: In function ‘xe_gt_stats_print_info’:
../drivers/gpu/drm/xe/xe_gt_stats.h:25:1: error: control reaches end of non-void function [-Werror=return-type]
25 | }
| ^cc1: some warnings being treated as errors
make[8]: *** [../scripts/Makefile.build:244: drivers/gpu/drm/xe/tests/xe_rtp_test.o] Error 1
cc1: some warnings being treated as errors
make[8]: *** [../scripts/Makefile.build:244: drivers/gpu/drm/xe/tests/xe_wa_test.o] Error 1 make[7]: *** [../scripts/Makefile.build:485: drivers/gpu/drm/xe/tests] Error 2 In file included from ../drivers/gpu/drm/xe/xe_gt_types.h:13,
from ../drivers/gpu/drm/xe/xe_device_types.h:17,
from ../drivers/gpu/drm/xe/xe_vm_types.h:16,
from ../drivers/gpu/drm/xe/xe_bo.h:13,
from ../drivers/gpu/drm/xe/xe_bo.c:6:
../drivers/gpu/drm/xe/xe_gt_stats.h:23:5: warning: no previous prototype for ‘xe_gt_stats_print_info’ [-Wmissing-prototypes]
23 | int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p)
| ^~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_gt_stats.h:27:6: warning: no previous prototype for ‘xe_gt_stats_incr’ [-Wmissing-prototypes]
27 | void xe_gt_stats_incr(struct xe_gt *gt, enum xe_gt_counter_stats stat, int incr)
| ^~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_gt_types.h:13,
from ../drivers/gpu/drm/xe/xe_device_types.h:17,
from ../drivers/gpu/drm/xe/xe_vm_types.h:16,
from ../drivers/gpu/drm/xe/xe_bo.h:13,
from ../drivers/gpu/drm/xe/xe_bo.c:6:
../drivers/gpu/drm/xe/xe_gt_stats.h: In function ‘xe_gt_stats_print_info’:
../drivers/gpu/drm/xe/xe_gt_stats.h:25:1: error: control reaches end of non-void function [-Werror=return-type]
25 | }
| ^cc1: some warnings being treated as errors
make[7]: *** [../scripts/Makefile.build:244: drivers/gpu/drm/xe/xe_bo.o] Error 1 make[6]: *** [../scripts/Makefile.build:485: drivers/gpu/drm/xe] Error 2 make[6]: *** Waiting for unfinished jobs....
make[5]: *** [../scripts/Makefile.build:485: drivers/gpu/drm] Error 2
make[4]: *** [../scripts/Makefile.build:485: drivers/gpu] Error 2
make[4]: *** Waiting for unfinished jobs....../lib/iomap.c:156:5: warning: no previous prototype for ‘ioread64_lo_hi’ [-Wmissing-prototypes]
156 | u64 ioread64_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:163:5: warning: no previous prototype for ‘ioread64_hi_lo’ [-Wmissing-prototypes]
163 | u64 ioread64_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:170:5: warning: no previous prototype for ‘ioread64be_lo_hi’ [-Wmissing-prototypes]
170 | u64 ioread64be_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:178:5: warning: no previous prototype for ‘ioread64be_hi_lo’ [-Wmissing-prototypes]
178 | u64 ioread64be_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:264:6: warning: no previous prototype for ‘iowrite64_lo_hi’ [-Wmissing-prototypes]
264 | void iowrite64_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:272:6: warning: no previous prototype for ‘iowrite64_hi_lo’ [-Wmissing-prototypes]
272 | void iowrite64_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:280:6: warning: no previous prototype for ‘iowrite64be_lo_hi’ [-Wmissing-prototypes]
280 | void iowrite64be_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~
../lib/iomap.c:288:6: warning: no previous prototype for ‘iowrite64be_hi_lo’ [-Wmissing-prototypes]
288 | void iowrite64be_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~make[3]: *** [../scripts/Makefile.build:485: drivers] Error 2 make[3]: *** Waiting for unfinished jobs.... make[2]: *** [/kernel/Makefile:1925: .] Error 2 make[1]: *** [/kernel/Makefile:224: __sub-make] Error 2
make: *** [Makefile:224: __sub-make] Error 2
[20:18:20] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig [20:18:24] Building KUnit Kernel ... Populating config with: $ make ARCH=um O=.kunit olddefconfig Building with: $ make ARCH=um O=.kunit --jobs=48 + cleanup ++ stat -c %u:%g /kernel + chown -R 1003:1003 /kernel
Matthew Brost
maintainerQuoted 5 lines · Nirmoy Das
Add skeleton APIs for recording and printing various stats over debugfs. This currently only added counter types stats which is backed by
atomic_tand wrapped withCONFIG_DRM_XE_STATSso this can be disabled on production system.
Yes, kernel doc which you pointed out.
Quoted 122 lines
Cc Matthew Brost <[email protected]>Cc Michal Wajdeczko <[email protected]>Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/xe/Kconfig.debug | 11 +++++++++++ drivers/gpu/drm/xe/Makefile | 2 ++ drivers/gpu/drm/xe/xe_gt_debugfs.c | 4 ++++ drivers/gpu/drm/xe/xe_gt_stats.c | 30 +++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_stats.h | 31 ++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_types.h | 7 +++++++ 6 files changed, 85 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_gt_stats.c create mode 100644 drivers/gpu/drm/xe/xe_gt_stats.hdrivers/gpu/drm/xe/Kconfig.debug +11
-0@@ -94,3 +94,14 @@ config DRM_XE_USERPTR_INVAL_INJECT Recomended for driver developers only. If in doubt, say "N". + +config DRM_XE_STATS + bool "Enable XE statistics" + default n + help + Choose this option to enable support for collecting and + displaying XE statistics as debugfs. + + Recommended for driver developers only. + + If in doubt, say "N".drivers/gpu/drm/xe/Makefile +2
-0@@ -143,6 +143,8 @@ xe-$(CONFIG_PCI_IOV) += \ xe_pci_sriov.o \ xe_sriov_pf.o +xe-$(CONFIG_DRM_XE_STATS) += xe_gt_stats.o + # include helpers for tests even when XE is built-in ifdef CONFIG_DRM_XE_KUNIT_TEST xe-y += tests/xe_kunit_helpers.odrivers/gpu/drm/xe/xe_gt_debugfs.c +4
-0@@ -17,6 +17,7 @@#include "xe_gt_mcr.h" #include "xe_gt_sriov_pf_debugfs.h" #include "xe_gt_sriov_vf_debugfs.h" +#include "xe_gt_stats.h" #include "xe_gt_topology.h" #include "xe_hw_engine.h" #include "xe_lrc.h" @@ -286,6 +287,9 @@ static const struct drm_info_list debugfs_list[] = { {"default_lrc_bcs", .show = xe_gt_debugfs_simple_show, .data = bcs_default_lrc}, {"default_lrc_vcs", .show = xe_gt_debugfs_simple_show, .data = vcs_default_lrc}, {"default_lrc_vecs", .show = xe_gt_debugfs_simple_show, .data = vecs_default_lrc}, +#if IS_ENABLED(CONFIG_DRM_XE_STATS) + {"stats", .show = xe_gt_debugfs_simple_show, .data = xe_gt_stats_print_info}, +#endif };void xe_gt_debugfs_register (struct xe_gt *gt)drivers/gpu/drm/xe/xe_gt_stats.c new file +30
-0@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2024 Intel Corporation +*/ + +#include <linux/atomic.h> + +#include "xe_gt.h" +#include "xe_gt_stats.h" + +#ifdef CONFIG_DRM_XE_STATS +void xe_gt_stats_incr (struct xe_gt *gt,enum xe_gt_counter_stats id,int incr) +{ +atomic_add (incr, >->stats.counters[id]); +} + +static const char *const stat_description[] = { +}; + +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p) +{ +enum xe_gt_counter_stats id; + +for (id =0 ; id <XE_GT_COUNTER_STATS_NUM ; ++id) +drm_printf (p,"%s: %d\n" , stat_description[id], +atomic_read (>->stats.counters[id])); + +return 0 ; +} +#endif drivers/gpu/drm/xe/xe_gt_stats.h new file +12
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2024 Intel Corporation +*/ + +#ifndef _XE_GT_STATS_H_ +#define _XE_GT_STATS_H_ + +#include <drm/drm_print.h> + +struct xe_gt ; +//struct drm_printer;
drivers/gpu/drm/xe/xe_gt_stats.h line 22
Quoted 10 lines
drivers/gpu/drm/xe/xe_gt_stats.h new file +10
-0+ +enum xe_gt_counter_stats { +XE_GT_COUNTER_STATS_NUM , +}; + +#ifdef CONFIG_DRM_XE_STATS +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p); +void xe_gt_stats_incr (struct xe_gt *gt,enum xe_gt_counter_stats stat,int incr); +#else +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p)
static inline int xe_gt_stats_print_info(...
This will fix CI too.
But overall LGTM and pretty much what I had in mind. We can device level stats too with this series being a template.
Matt
Quoted 37 lines
drivers/gpu/drm/xe/xe_gt_stats.h new file +9
-0+{ +} + +void xe_gt_stats_incr (struct xe_gt *gt,enum xe_gt_counter_stats stat,int incr) +{ +} + +#endif /* CONFIG_DRM_XE_STATS */ +#endif /* _XE_GT_STATS_H_ */ drivers/gpu/drm/xe/xe_gt_types.h +7
-0@@ -10,6 +10,7 @@#include "xe_gt_idle_types.h" #include "xe_gt_sriov_pf_types.h" #include "xe_gt_sriov_vf_types.h" +#include "xe_gt_stats.h" #include "xe_hw_engine_types.h" #include "xe_hw_fence_types.h" #include "xe_oa.h" @@ -133,6 +134,12 @@ struct xe_gt { u8 has_indirect_ring_state:1; } info; +#if IS_ENABLED (CONFIG_DRM_XE_STATS ) +struct { +atomic_t counters[XE_GT_COUNTER_STATS_NUM ]; + } stats; +#endif +/** * @mmio: mmio info for GT. All GTs within a tile share the same * register space, but have their own copy of GSI registers at a Signature · 1 line
2.42.0
Quoted 142 lines · Matthew Brost
Quoted 5 lines · Nirmoy Das
Add skeleton APIs for recording and printing various stats over debugfs. This currently only added counter types stats which is backed by
atomic_tand wrapped withCONFIG_DRM_XE_STATSso this can be disabled on production system.Yes, kernel doc which you pointed out.
Quoted 122 lines
Cc Matthew Brost<[email protected]>Cc Michal Wajdeczko<[email protected]>Signed-off-by Nirmoy Das<[email protected]>--- drivers/gpu/drm/xe/Kconfig.debug | 11 +++++++++++ drivers/gpu/drm/xe/Makefile | 2 ++ drivers/gpu/drm/xe/xe_gt_debugfs.c | 4 ++++ drivers/gpu/drm/xe/xe_gt_stats.c | 30 +++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_stats.h | 31 ++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_types.h | 7 +++++++ 6 files changed, 85 insertions(+)create mode 100644
drivers/gpu/drm/xe/xe_gt_stats.ccreate mode 100644drivers/gpu/drm/xe/xe_gt_stats.hdrivers/gpu/drm/xe/Kconfig.debug +11
-0@@ -94,3 +94,14 @@ config DRM_XE_USERPTR_INVAL_INJECT Recomended for driver developers only. If in doubt, say "N". + +config DRM_XE_STATS + bool "Enable XE statistics" + default n + help + Choose this option to enable support for collecting and + displaying XE statistics as debugfs. + + Recommended for driver developers only. + + If in doubt, say "N".drivers/gpu/drm/xe/Makefile +2
-0@@ -143,6 +143,8 @@ xe-$(CONFIG_PCI_IOV) += \ xe_pci_sriov.o \ xe_sriov_pf.o +xe-$(CONFIG_DRM_XE_STATS) += xe_gt_stats.o + # include helpers for tests even when XE is built-in ifdef CONFIG_DRM_XE_KUNIT_TEST xe-y += tests/xe_kunit_helpers.odrivers/gpu/drm/xe/xe_gt_debugfs.c +4
-0@@ -17,6 +17,7 @@#include "xe_gt_mcr.h" #include "xe_gt_sriov_pf_debugfs.h" #include "xe_gt_sriov_vf_debugfs.h" +#include "xe_gt_stats.h" #include "xe_gt_topology.h" #include "xe_hw_engine.h" #include "xe_lrc.h" @@ -286,6 +287,9 @@ static const struct drm_info_list debugfs_list[] = { {"default_lrc_bcs", .show = xe_gt_debugfs_simple_show, .data = bcs_default_lrc}, {"default_lrc_vcs", .show = xe_gt_debugfs_simple_show, .data = vcs_default_lrc}, {"default_lrc_vecs", .show = xe_gt_debugfs_simple_show, .data = vecs_default_lrc}, +#if IS_ENABLED(CONFIG_DRM_XE_STATS) + {"stats", .show = xe_gt_debugfs_simple_show, .data = xe_gt_stats_print_info}, +#endif };void xe_gt_debugfs_register (struct xe_gt *gt)drivers/gpu/drm/xe/xe_gt_stats.c new file +30
-0@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2024 Intel Corporation +*/ + +#include <linux/atomic.h> + +#include "xe_gt.h" +#include "xe_gt_stats.h" + +#ifdef CONFIG_DRM_XE_STATS +void xe_gt_stats_incr (struct xe_gt *gt,enum xe_gt_counter_stats id,int incr) +{ +atomic_add (incr, >->stats.counters[id]); +} + +static const char *const stat_description[] = { +}; + +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p) +{ +enum xe_gt_counter_stats id; + +for (id =0 ; id <XE_GT_COUNTER_STATS_NUM ; ++id) +drm_printf (p,"%s: %d\n" , stat_description[id], +atomic_read (>->stats.counters[id])); + +return 0 ; +} +#endif drivers/gpu/drm/xe/xe_gt_stats.h new file +12
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2024 Intel Corporation +*/ + +#ifndef _XE_GT_STATS_H_ +#define _XE_GT_STATS_H_ + +#include <drm/drm_print.h> + +struct xe_gt ; +//struct drm_printer; drivers/gpu/drm/xe/xe_gt_stats.h line 22
Quoted 10 lines
drivers/gpu/drm/xe/xe_gt_stats.h new file +10
-0+ +enum xe_gt_counter_stats { +XE_GT_COUNTER_STATS_NUM , +}; + +#ifdef CONFIG_DRM_XE_STATS +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p); +void xe_gt_stats_incr (struct xe_gt *gt,enum xe_gt_counter_stats stat,int incr); +#else +int xe_gt_stats_print_info (struct xe_gt *gt,struct drm_printer *p)static inline int xe_gt_stats_print_info(...
Quoted 1 line
This will fix CI too.
missed build test without CONFIG_DRM_XE_STATS :/
Quoted 2 lines
But overall LGTM and pretty much what I had in mind. We can device level stats too with this series being a template.
I will resend with Michal's suggestions and more docs.
Thanks,
Nirmoy
Quoted 40 lines
Matt
Quoted 37 lines
drivers/gpu/drm/xe/xe_gt_stats.h new file +9
-0+{ +} + +void xe_gt_stats_incr (struct xe_gt *gt,enum xe_gt_counter_stats stat,int incr) +{ +} + +#endif /* CONFIG_DRM_XE_STATS */ +#endif /* _XE_GT_STATS_H_ */ drivers/gpu/drm/xe/xe_gt_types.h +7
-0@@ -10,6 +10,7 @@#include "xe_gt_idle_types.h" #include "xe_gt_sriov_pf_types.h" #include "xe_gt_sriov_vf_types.h" +#include "xe_gt_stats.h" #include "xe_hw_engine_types.h" #include "xe_hw_fence_types.h" #include "xe_oa.h" @@ -133,6 +134,12 @@ struct xe_gt { u8 has_indirect_ring_state:1; } info; +#if IS_ENABLED (CONFIG_DRM_XE_STATS ) +struct { +atomic_t counters[XE_GT_COUNTER_STATS_NUM ]; + } stats; +#endif +/** * @mmio: mmio info for GT. All GTs within a tile share the same * register space, but have their own copy of GSI registers at a Signature · 1 line
2.42.0