Skip to contentSkip to conversation

drm/xe: shrink and compress GuC snapshot dumps

PATCH Superseded Zhanjun Dong 2 participants 6 messages May 7

Subsystems (2)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover drm/xe: shrink and compress GuC snapshot dumps

GuC snapshot output is currently expensive in both size and latency: large log buffers are emitted as raw ascii85, and the surrounding dump text includes a bit of avoidable noise. This series makes xe snapshot dumps more compact and easier to handle by compressing the large binary payloads, tightening the textual output, and trimming the default GuC log size.

Select ZSTD_COMPRESS in DRM_XE so the xe module pulls in the zstd compressor when built.

Reduces the default GuC log buffer from 8MB to 2MB, which still preserves useful history while cutting dump latency and dmesg load; with typical compression, the emitted payload drops further.

Zhanjun Dong (3):
drm/xe/guc: Compress GuC log and CTB dump with zstd drm/xe: Remove extra newlines from LRC snapshot dump drm/xe/guc: Reduce GuC log size from 8MB to 2MB

 drivers/gpu/drm/xe/Kconfig      |   1 +
 drivers/gpu/drm/xe/xe_guc_ct.c  |   9 ++-
 drivers/gpu/drm/xe/xe_guc_log.c | 110 ++++++++++++++++++++++++++++----
 drivers/gpu/drm/xe/xe_guc_log.h |   5 +-
 drivers/gpu/drm/xe/xe_lrc.c     |   4 +-
 5 files changed, 108 insertions(+), 21 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/3 drm/xe/guc: Compress GuC log and CTB dump with zstd

Replace the raw ascii85 dumps of GuC log snapshots with a zstd-compressed ascii85 stream and reuse the same helper for CTB snapshot output.

Use zstd streaming with default level-3 parameters and an estimated source size of 0 so the compression workspace stays bounded even for multi-megabyte logs.

Select ZSTD_COMPRESS in DRM_XE so the xe module pulls in the zstd compressor when built.

---
 drivers/gpu/drm/xe/Kconfig      |   1 +
 drivers/gpu/drm/xe/xe_guc_ct.c  |   9 ++-
 drivers/gpu/drm/xe/xe_guc_log.c | 110 ++++++++++++++++++++++++++++----
 drivers/gpu/drm/xe/xe_guc_log.h |   3 +
 4 files changed, 105 insertions(+), 18 deletions(-)
drivers/gpu/drm/xe/Kconfig +1 -0
index 4d7dcaff2b91..b160cb73c647 100644
@@ -33,6 +33,7 @@ config DRM_XE
 	select ACPI_WMI if X86 && ACPI
 	select SYNC_FILE
 	select CRC32
+	select ZSTD_COMPRESS
 	select SND_HDA_I915 if SND_HDA_CORE
 	select CEC_CORE if CEC_NOTIFIER
 	select VMAP_PFN
drivers/gpu/drm/xe/xe_guc_ct.c +4 -5
index 21e0dad9a481..d1f2fd597ebd 100644
@@ -2112,11 +2112,10 @@ void xe_guc_ct_snapshot_print(struct xe_guc_ct_snapshot *snapshot,
 		drm_printf(p, "\tg2h outstanding: %d\n",
 			   snapshot->g2h_outstanding);
 
-		if (snapshot->ctb) {
-			drm_printf(p, "[CTB].length: 0x%zx\n", snapshot->ctb_size);
-			xe_print_blob_ascii85(p, "[CTB].data", '\n',
-					      snapshot->ctb, 0, snapshot->ctb_size);
-		}
+		if (snapshot->ctb)
+			xe_guc_print_blob_zstd(p, "[CTB]", "[CTB].data",
+					       &snapshot->ctb, 1,
+					       snapshot->ctb_size, snapshot->ctb_size);
 	} else {
 		drm_puts(p, "CT disabled\n");
 	}
drivers/gpu/drm/xe/xe_guc_log.c +97 -13

134 lines not on this page · raw message

drivers/gpu/drm/xe/xe_guc_log.h +3 -0
index 4649a260755e..d231def50692 100644
@@ -59,6 +59,9 @@ void xe_guc_log_print(struct xe_guc_log *log, struct drm_printer *p);
 void xe_guc_log_print_lfd(struct xe_guc_log *log, struct drm_printer *p);
 void xe_guc_log_print_dmesg(struct xe_guc_log *log);
 struct xe_guc_log_snapshot *xe_guc_log_snapshot_capture(struct xe_guc_log *log, bool atomic);
+void xe_guc_print_blob_zstd(struct drm_printer *p, const char *length_label,
+			    const char *data_label, void **chunks, int num_chunks,
+			    size_t chunk_size, size_t total_size);
 void xe_guc_log_snapshot_print(struct xe_guc_log_snapshot *snapshot, struct drm_printer *p);
 void xe_guc_log_snapshot_free(struct xe_guc_log_snapshot *snapshot);
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/3 drm/xe: Remove extra newlines from LRC snapshot dump

In reply to Zhanjun Dong

The LRC snapshot printer adds an extra newline before the replay offset and replay length lines. This leaves blank lines in the HWCTX section of the dump.

Remove the stray newlines so the snapshot output remains compact and consistently formatted.

---
 drivers/gpu/drm/xe/xe_lrc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_lrc.c +2 -2
index fdfe2ed5f683..3e137e3e5cfb 100644
@@ -2531,8 +2531,8 @@ void xe_lrc_snapshot_print(struct xe_lrc_snapshot *snapshot, struct drm_printer
 	}
 
 	drm_printf(p, "\n\t[HWCTX].length: 0x%lx\n", snapshot->lrc_size - LRC_PPHWSP_SIZE);
-	drm_printf(p, "\n\t[HWCTX].replay_offset: 0x%lx\n", snapshot->replay_offset);
-	drm_printf(p, "\n\t[HWCTX].replay_length: 0x%lx\n", snapshot->replay_size);
+	drm_printf(p, "\t[HWCTX].replay_offset: 0x%lx\n", snapshot->replay_offset);
+	drm_printf(p, "\t[HWCTX].replay_length: 0x%lx\n", snapshot->replay_size);
 
 	drm_puts(p, "\t[HWCTX].data: ");
 	for (; i < snapshot->lrc_size; i += sizeof(u32)) {
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/3 drm/xe/guc: Reduce GuC log size from 8MB to 2MB

In reply to Zhanjun Dong

Reduce the default log buffer size to improve system responsiveness and readability. The previous 8MB threshold caused significant delays during log output and imposed a heavy load when printing to dmesg.

By reducing the size to 2MB, we maintain a sufficient history while ensuring faster flushing. With a typical 4:1 compression ratio, this 2MB buffer will result in approximately 512KB of compressed data, providing an efficient balance between log depth and system performance.

---
 drivers/gpu/drm/xe/xe_guc_log.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_guc_log.h +1 -1
index d231def50692..44e81a54681f 100644
@@ -17,7 +17,7 @@ struct xe_device;
 #define XE_GUC_LOG_CRASH_DUMP_BUFFER_SIZE	SZ_1M
 #define XE_GUC_LOG_STATE_CAPTURE_BUFFER_SIZE	SZ_2M
 #elif IS_ENABLED(CONFIG_DRM_XE_DEBUG)
-#define XE_GUC_LOG_EVENT_DATA_BUFFER_SIZE	SZ_8M
+#define XE_GUC_LOG_EVENT_DATA_BUFFER_SIZE	SZ_2M
 #define XE_GUC_LOG_CRASH_DUMP_BUFFER_SIZE	SZ_1M
 #define XE_GUC_LOG_STATE_CAPTURE_BUFFER_SIZE	SZ_1M
 #else
Signature · 1 line
2.34.1
#4 lore raw

✗ CI.checkpatch: warning for drm/xe: shrink and compress GuC snapshot dumps

In reply to Zhanjun Dong
== Series Details ==

== Series Details ==

Series: drm/xe: shrink and compress GuC snapshot dumps
URL : https://patchwork.freedesktop.org/series/166158/
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 061140b9bc586ae7f40abc1249c97e1cc72d1b9d
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit aa81d75f52ddaf19338a4a7de84fa89d81c44d4e

Author: Zhanjun Dong <[email protected]>
Date:   Thu May 7 14:06:18 2026 -0400

drm/xe/guc: Reduce GuC log size from 8MB to 2MB

Reduce the default log buffer size to improve system responsiveness and readability. The previous 8MB threshold caused significant delays during log output and imposed a heavy load when printing to dmesg.

By reducing the size to 2MB, we maintain a sufficient history while ensuring faster flushing. With a typical 4:1 compression ratio, this 2MB buffer will result in approximately 512KB of compressed data, providing an efficient balance between log depth and system performance.

+ /mt/dim checkpatch 36eddf6e5c9411ad95c4939b092ed1ea77f13d61 drm-intel 5bf096c20610 drm/xe/guc: Compress GuC log and CTB dump with zstd -:104: CHECK:CAMELCASE: Avoid CamelCase: <cParams>
#104: FILE: drivers/gpu/drm/xe/xe_guc_log.c:266:
+ wksp_size = zstd_cstream_workspace_bound(&params.cParams);

total: 0 errors, 0 warnings, 1 checks, 165 lines checked 6260a1cbb201 drm/xe: Remove extra newlines from LRC snapshot dump aa81d75f52dd drm/xe/guc: Reduce GuC log size from 8MB to 2MB

#5 lore raw

✗ CI.KUnit: failure for drm/xe: shrink and compress GuC snapshot dumps

In reply to Zhanjun Dong
== Series Details ==

== Series Details ==

Series: drm/xe: shrink and compress GuC snapshot dumps
URL : https://patchwork.freedesktop.org/series/166158/
State : failure

== Summary ==

+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig ERROR:root:/usr/bin/ld: drivers/gpu/drm/xe/xe_guc_log.o: in function `xe_guc_print_blob_zstd':
xe_guc_log.c:(.text+0x5c6): undefined reference to `zstd_is_error'
/usr/bin/ld: xe_guc_log.c:(.text+0x75c): undefined reference to zstd_get_error_name' /usr/bin/ld: xe_guc_log.c:(.text+0x790): undefined reference to zstd_is_error' /usr/bin/ld: xe_guc_log.c:(.text+0x7b2): undefined reference to `zstd_get_error_name'
collect2: error: ld returned 1 exit status
make[3]: *** [../scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 1 make[2]: *** [/kernel/Makefile:1335: vmlinux] Error 2
make[1]: *** [/kernel/Makefile:248: __sub-make] Error 2
make: *** [Makefile:248: __sub-make] Error 2

[18:43:14] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:

$ make ARCH=um O=.kunit olddefconfig
[18:43:18] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=48
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel