* [PATCH 0/3] drm/xe: shrink and compress GuC snapshot dumps
@ 2026-05-07 18:06 Zhanjun Dong
2026-05-07 18:06 ` [PATCH 1/3] drm/xe/guc: Compress GuC log and CTB dump with zstd Zhanjun Dong
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Zhanjun Dong @ 2026-05-07 18:06 UTC (permalink / raw)
To: intel-xe; +Cc: Zhanjun Dong
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.
Signed-off-by: Zhanjun Dong <zhanjun.dong@intel.com>
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(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/3] drm/xe/guc: Compress GuC log and CTB dump with zstd 2026-05-07 18:06 [PATCH 0/3] drm/xe: shrink and compress GuC snapshot dumps Zhanjun Dong @ 2026-05-07 18:06 ` Zhanjun Dong 2026-05-07 18:06 ` [PATCH 2/3] drm/xe: Remove extra newlines from LRC snapshot dump Zhanjun Dong ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: Zhanjun Dong @ 2026-05-07 18:06 UTC (permalink / raw) To: intel-xe; +Cc: Zhanjun Dong 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. Signed-off-by: Zhanjun Dong <zhanjun.dong@intel.com> --- 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(-) diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig index 4d7dcaff2b91..b160cb73c647 100644 --- a/drivers/gpu/drm/xe/Kconfig +++ b/drivers/gpu/drm/xe/Kconfig @@ -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 diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c index 21e0dad9a481..d1f2fd597ebd 100644 --- a/drivers/gpu/drm/xe/xe_guc_ct.c +++ b/drivers/gpu/drm/xe/xe_guc_ct.c @@ -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"); } diff --git a/drivers/gpu/drm/xe/xe_guc_log.c b/drivers/gpu/drm/xe/xe_guc_log.c index 538d4df0f7aa..abcafce0349a 100644 --- a/drivers/gpu/drm/xe/xe_guc_log.c +++ b/drivers/gpu/drm/xe/xe_guc_log.c @@ -6,6 +6,7 @@ #include "xe_guc_log.h" #include <linux/fault-inject.h> +#include <linux/zstd.h> #include <linux/utsname.h> #include <drm/drm_managed.h> @@ -225,6 +226,99 @@ struct xe_guc_log_snapshot *xe_guc_log_snapshot_capture(struct xe_guc_log *log, return snapshot; } +/** + * xe_guc_print_blob_zstd - Compress binary data with zstd streaming and emit it as ascii85 + * @p: drm_printer for output + * @length_label: label prefix for the length/metadata line (e.g. "[LOG]" or "[CTB]") + * @data_label: label for the ascii85 blob (e.g. "[LOG].data" or "[CTB].data") + * @chunks: array of pointers to source data chunks + * @num_chunks: number of elements in @chunks + * @chunk_size: nominal size of each chunk; the last chunk may hold fewer valid bytes + * @total_size: total uncompressed byte count across all chunks + * + * Compresses @total_size bytes using zstd level-3 streaming compression and + * prints the result via @p using ascii85 encoding. On failure the function + * returns without printing the data blob. + */ +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) +{ + zstd_parameters params; + zstd_cstream *cstream; + zstd_out_buffer outbuf; + size_t wksp_size, dst_size; + size_t remain; + void *wksp; + size_t ret; + char *dst; + int i; + + /* + * Pass 0 as estimated_src_size to use zstd level-3 defaults + * (windowLog=18, 256KB window). Passing the full total_size would + * cause zstd to inflate windowLog proportionally (e.g. windowLog=24 + * for a 19MB log), making the workspace tens of MB. With 0, the + * workspace stays ~1.5MB, well within kmalloc limits. + */ + params = zstd_get_params(3, 0); + + wksp_size = zstd_cstream_workspace_bound(¶ms.cParams); + wksp = kvzalloc(wksp_size, GFP_KERNEL); + if (!wksp) + return; + + dst_size = zstd_compress_bound(total_size); + dst = kvzalloc(dst_size, GFP_KERNEL); + if (!dst) + goto err_wksp; + + cstream = zstd_init_cstream(¶ms, 0, wksp, wksp_size); + if (!cstream) { + pr_err("xe_guc: failed to init zstd cstream\n"); + goto err_dst; + } + + outbuf.dst = dst; + outbuf.size = dst_size; + outbuf.pos = 0; + + remain = total_size; + for (i = 0; i < num_chunks && remain; i++) { + size_t size = min(chunk_size, remain); + zstd_in_buffer inbuf = { .src = chunks[i], .size = size, .pos = 0 }; + + while (inbuf.pos < inbuf.size) { + ret = zstd_compress_stream(cstream, &outbuf, &inbuf); + if (zstd_is_error(ret)) { + pr_err("xe_guc: zstd_compress_stream failed: %s\n", + zstd_get_error_name(ret)); + goto err_dst; + } + } + remain -= size; + } + + do { + ret = zstd_end_stream(cstream, &outbuf); + if (zstd_is_error(ret)) { + pr_err("xe_guc: zstd_end_stream failed: %s\n", + zstd_get_error_name(ret)); + goto err_dst; + } + } while (ret > 0 && outbuf.pos < outbuf.size); + + drm_printf(p, "%s.length: 0x%zx -> 0x%zx Algo: ZSTD\n", + length_label, total_size, outbuf.pos); + xe_print_blob_ascii85(p, data_label, '\n', dst, 0, + DIV_ROUND_UP(outbuf.pos, sizeof(u32)) * sizeof(u32)); + +err_dst: + kvfree(dst); +err_wksp: + kvfree(wksp); +} + /** * xe_guc_log_snapshot_print - dump a previously saved copy of the GuC log to some useful location * @snapshot: a snapshot of the GuC log @@ -232,9 +326,6 @@ struct xe_guc_log_snapshot *xe_guc_log_snapshot_capture(struct xe_guc_log *log, */ void xe_guc_log_snapshot_print(struct xe_guc_log_snapshot *snapshot, struct drm_printer *p) { - size_t remain; - int i; - if (!snapshot) { drm_printf(p, "GuC log snapshot not allocated!\n"); return; @@ -248,16 +339,9 @@ void xe_guc_log_snapshot_print(struct xe_guc_log_snapshot *snapshot, struct drm_ drm_printf(p, "GuC timestamp: 0x%08llX [%llu]\n", snapshot->stamp, snapshot->stamp); drm_printf(p, "Log level: %u\n", snapshot->level); - drm_printf(p, "[LOG].length: 0x%zx\n", snapshot->size); - remain = snapshot->size; - for (i = 0; i < snapshot->num_chunks; i++) { - size_t size = min(GUC_LOG_CHUNK_SIZE, remain); - const char *prefix = i ? NULL : "[LOG].data"; - char suffix = i == snapshot->num_chunks - 1 ? '\n' : 0; - - xe_print_blob_ascii85(p, prefix, suffix, snapshot->copy[i], 0, size); - remain -= size; - } + xe_guc_print_blob_zstd(p, "[LOG]", "[LOG].data", + snapshot->copy, snapshot->num_chunks, + GUC_LOG_CHUNK_SIZE, snapshot->size); } static inline void lfd_output_binary(struct drm_printer *p, char *buf, int buf_size) diff --git a/drivers/gpu/drm/xe/xe_guc_log.h b/drivers/gpu/drm/xe/xe_guc_log.h index 4649a260755e..d231def50692 100644 --- a/drivers/gpu/drm/xe/xe_guc_log.h +++ b/drivers/gpu/drm/xe/xe_guc_log.h @@ -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); -- 2.34.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] drm/xe: Remove extra newlines from LRC snapshot dump 2026-05-07 18:06 [PATCH 0/3] drm/xe: shrink and compress GuC snapshot dumps Zhanjun Dong 2026-05-07 18:06 ` [PATCH 1/3] drm/xe/guc: Compress GuC log and CTB dump with zstd Zhanjun Dong @ 2026-05-07 18:06 ` Zhanjun Dong 2026-05-07 18:06 ` [PATCH 3/3] drm/xe/guc: Reduce GuC log size from 8MB to 2MB Zhanjun Dong ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: Zhanjun Dong @ 2026-05-07 18:06 UTC (permalink / raw) To: intel-xe; +Cc: 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. Signed-off-by: Zhanjun Dong <zhanjun.dong@intel.com> --- drivers/gpu/drm/xe/xe_lrc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c index fdfe2ed5f683..3e137e3e5cfb 100644 --- a/drivers/gpu/drm/xe/xe_lrc.c +++ b/drivers/gpu/drm/xe/xe_lrc.c @@ -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)) { -- 2.34.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] drm/xe/guc: Reduce GuC log size from 8MB to 2MB 2026-05-07 18:06 [PATCH 0/3] drm/xe: shrink and compress GuC snapshot dumps Zhanjun Dong 2026-05-07 18:06 ` [PATCH 1/3] drm/xe/guc: Compress GuC log and CTB dump with zstd Zhanjun Dong 2026-05-07 18:06 ` [PATCH 2/3] drm/xe: Remove extra newlines from LRC snapshot dump Zhanjun Dong @ 2026-05-07 18:06 ` Zhanjun Dong 2026-05-07 18:43 ` ✗ CI.checkpatch: warning for drm/xe: shrink and compress GuC snapshot dumps Patchwork 2026-05-07 18:43 ` ✗ CI.KUnit: failure " Patchwork 4 siblings, 0 replies; 6+ messages in thread From: Zhanjun Dong @ 2026-05-07 18:06 UTC (permalink / raw) To: intel-xe; +Cc: 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. Signed-off-by: Zhanjun Dong <zhanjun.dong@intel.com> --- drivers/gpu/drm/xe/xe_guc_log.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/xe/xe_guc_log.h b/drivers/gpu/drm/xe/xe_guc_log.h index d231def50692..44e81a54681f 100644 --- a/drivers/gpu/drm/xe/xe_guc_log.h +++ b/drivers/gpu/drm/xe/xe_guc_log.h @@ -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 -- 2.34.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* ✗ CI.checkpatch: warning for drm/xe: shrink and compress GuC snapshot dumps 2026-05-07 18:06 [PATCH 0/3] drm/xe: shrink and compress GuC snapshot dumps Zhanjun Dong ` (2 preceding siblings ...) 2026-05-07 18:06 ` [PATCH 3/3] drm/xe/guc: Reduce GuC log size from 8MB to 2MB Zhanjun Dong @ 2026-05-07 18:43 ` Patchwork 2026-05-07 18:43 ` ✗ CI.KUnit: failure " Patchwork 4 siblings, 0 replies; 6+ messages in thread From: Patchwork @ 2026-05-07 18:43 UTC (permalink / raw) To: Zhanjun Dong; +Cc: intel-xe == 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 <zhanjun.dong@intel.com> 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. Signed-off-by: Zhanjun Dong <zhanjun.dong@intel.com> + /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(¶ms.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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* ✗ CI.KUnit: failure for drm/xe: shrink and compress GuC snapshot dumps 2026-05-07 18:06 [PATCH 0/3] drm/xe: shrink and compress GuC snapshot dumps Zhanjun Dong ` (3 preceding siblings ...) 2026-05-07 18:43 ` ✗ CI.checkpatch: warning for drm/xe: shrink and compress GuC snapshot dumps Patchwork @ 2026-05-07 18:43 ` Patchwork 4 siblings, 0 replies; 6+ messages in thread From: Patchwork @ 2026-05-07 18:43 UTC (permalink / raw) To: Zhanjun Dong; +Cc: intel-xe == 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-05-07 18:43 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-05-07 18:06 [PATCH 0/3] drm/xe: shrink and compress GuC snapshot dumps Zhanjun Dong 2026-05-07 18:06 ` [PATCH 1/3] drm/xe/guc: Compress GuC log and CTB dump with zstd Zhanjun Dong 2026-05-07 18:06 ` [PATCH 2/3] drm/xe: Remove extra newlines from LRC snapshot dump Zhanjun Dong 2026-05-07 18:06 ` [PATCH 3/3] drm/xe/guc: Reduce GuC log size from 8MB to 2MB Zhanjun Dong 2026-05-07 18:43 ` ✗ CI.checkpatch: warning for drm/xe: shrink and compress GuC snapshot dumps Patchwork 2026-05-07 18:43 ` ✗ CI.KUnit: failure " Patchwork
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox