Re: [PATCH v4 11/32] drm/xe/log: Index all SIGID printk messages
Michal Wajdeczko <[email protected]>
| Newsgroups | org.freedesktop.lists.intel-xe |
|---|---|
| Message-ID | <[email protected]> |
On 8/13/2026 2:54 PM, Michal Wajdeczko wrote: > > > On 8/13/2026 2:31 PM, Mallesh, Koujalagi wrote: >> >> On 13-08-2026 12:44 am, Michal Wajdeczko wrote: >>> When CONFIG_PRINTK_INDEX is enabled, it is expected that all device >>> level printk messages are indexed for audit. While usually this is >>> done automatically behind the scenes when code is using regular >>> dev_printk macros, since we are generating different dmesg messages >>> inside xe_log_emit() based on the severity, component and location, >>> we only get those entries in /sys/kernel/debug/printk/index/xe: >>> >>> <3> drivers/gpu/drm/xe/xe_log.c:142 log_dmesg_vprintk "%s %s: [drm] *ERROR* %pV" >>> <6> drivers/gpu/drm/xe/xe_log.c:140 log_dmesg_vprintk "%s %s: [drm] %pV" >>> >>> Explicitly generate printk index using dev_printk_index_emit() with >>> some generic prefix that includes the SIGID tag. >>> >>> Suggested-by: Jani Nikula <[email protected]> >>> Signed-off-by: Michal Wajdeczko <[email protected]> >>> Cc: Jani Nikula <[email protected]> >>> Cc: Rodrigo Vivi <[email protected]> >>> --- >>> drivers/gpu/drm/xe/xe_log.c | 8 ++++---- >>> drivers/gpu/drm/xe/xe_log.h | 14 +++++++++++--- >>> 2 files changed, 15 insertions(+), 7 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/xe/xe_log.c b/drivers/gpu/drm/xe/xe_log.c >>> index 0b423ed121cd..50a9b35e5b3e 100644 >>> --- a/drivers/gpu/drm/xe/xe_log.c >>> +++ b/drivers/gpu/drm/xe/xe_log.c >>> @@ -177,7 +177,7 @@ static void log_emit_dmesg(struct pci_dev *pdev, int cper_sev, enum xe_sigid sig >>> } >>> /** >>> - * xe_log_emit() - Emit a structured SIGID log entry >>> + * __xe_log_emit() - Emit a structured SIGID log entry >>> * @pdev: the &pci_dev device >>> * @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...) >>> * @sigid: signature identifier, see &enum xe_sigid >>> @@ -206,9 +206,9 @@ static void log_emit_dmesg(struct pci_dev *pdev, int cper_sev, enum xe_sigid sig >>> * <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=106 (-ETIMEDOUT) Engine 'rcs0' hung >>> * <6> xe 0000:03:00.0: [drm] SIGID=103 In survivability mode >>> */ >>> -void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid, >>> - u32 component, u32 location, const void *data, size_t len, >>> - const char *fmt, ...) >>> +void __xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid, >>> + u32 component, u32 location, const void *data, size_t len, >>> + const char *fmt, ...) >>> { >>> struct va_format vaf; >>> va_list args; >>> diff --git a/drivers/gpu/drm/xe/xe_log.h b/drivers/gpu/drm/xe/xe_log.h >>> index 0928b0866617..53fe2bb7ddd3 100644 >>> --- a/drivers/gpu/drm/xe/xe_log.h >>> +++ b/drivers/gpu/drm/xe/xe_log.h >>> @@ -16,9 +16,17 @@ >>> struct pci_dev; >>> __printf(8, 9) >>> -void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid, >>> - u32 component, u32 location, const void *data, size_t len, >>> - const char *fmt, ...); >>> +void __xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid, >>> + u32 component, u32 location, const void *data, size_t len, >>> + const char *fmt, ...); >>> + >>> +#define __xe_log_emit_printk_index(fmt) \ >>> + dev_printk_index_emit(NULL, "[drm]%s SIGID=%u %s(%s)%s%s%s: " fmt); >> We need to change format for a. error path b. blob path c. plain or info path right? > > well, that's not doable as final format/output depends on the > severity and data value, which could be non-const at compile > time, while printk-index requires this to emit right entry > > I can change that to a something more generic (and unfriendly), like: > > dev_printk_index_emit(NULL, "%sSIGID=%u %s" fmt); > > but that will catch and match all our outputs. and this is how this will look like for current series: $ sudo cat /sys/kernel/debug/printk/index/xe | grep SIGID <3> drivers/gpu/drm/xe/xe_device.c:1481 xe_device_declare_wedged "%s %s: %s SIGID=%u %sDevice declared wedged!\n" <3> drivers/gpu/drm/xe/xe_gt.c:977 gt_reset_worker "%s %s: %s SIGID=%u %sreset failed\n" <6> drivers/gpu/drm/xe/xe_gt.c:968 gt_reset_worker "%s %s: %s SIGID=%u %sreset done\n" <6> drivers/gpu/drm/xe/xe_gt.c:929 gt_reset_worker "%s %s: %s SIGID=%u %sreset started\n" <3> drivers/gpu/drm/xe/xe_guc.c:1620 xe_guc_mmio_send_recv "%s %s: %s SIGID=%u %sMMIO request %#x: unexpected reply %#x\n" <3> drivers/gpu/drm/xe/xe_guc.c:1612 xe_guc_mmio_send_recv "%s %s: %s SIGID=%u %sMMIO request %#x: failure %#x hint %#x\n" <3> drivers/gpu/drm/xe/xe_guc.c:1556 xe_guc_mmio_send_recv "%s %s: %s SIGID=%u %sMMIO request %#x: no reply %#x\n" <3> drivers/gpu/drm/xe/xe_guc.c:1546 xe_guc_mmio_send_recv "%s %s: %s SIGID=%u %sMMIO request %#x: lost, too many retries %u\n" <3> drivers/gpu/drm/xe/xe_pagefault.c:631 xe_pagefault_queue_work "%s %s: %s SIGID=%u %sUnsuccessful response\n" <3> drivers/gpu/drm/xe/xe_pagefault.c:332 xe_pagefault_queue_add "%s %s: %s SIGID=%u %sQueue full!\n" <3> drivers/gpu/drm/xe/xe_pci.c:1181 xe_pci_probe "%s %s: %s SIGID=%u %sdriver loading failed for device '%04x'\n" <6> drivers/gpu/drm/xe/xe_pci.c:1171 xe_pci_probe "%s %s: %s SIGID=%u %sdriver loading blocked for device '%04x'\n" <3> drivers/gpu/drm/xe/xe_pci_error.c:102 xe_pci_error_slot_reset "%s %s: %s SIGID=%u %sCannot re-enable PCI device after reset\n" <3> drivers/gpu/drm/xe/xe_pcode.c:321 xe_pcode_ready "%s %s: %s SIGID=%u %sinitialization timedout after %ld seconds\n" <3> drivers/gpu/drm/xe/xe_pcode.c:221 xe_pcode_request "%s %s: %s SIGID=%u %stimeout, retrying with preemption disabled\n" <3> drivers/gpu/drm/xe/xe_pcode.c:65 pcode_mailbox_status "%s %s: %s SIGID=%u %sMailbox failed: %s\n" <6> drivers/gpu/drm/xe/xe_survivability_mode.c:440 log_survivability_info "%s %s: %s SIGID=%u %s%s: %#x\n" <3> drivers/gpu/drm/xe/xe_survivability_mode.c:433 log_survivability_info "%s %s: %s SIGID=%u %sBoot Status: %s (%u)\n" <6> drivers/gpu/drm/xe/xe_survivability_mode.c:422 xe_survivability_mode_runtime_enable "%s %s: %s SIGID=%u %sFirmware flash required!\n" <6> drivers/gpu/drm/xe/xe_survivability_mode.c:417 xe_survivability_mode_runtime_enable "%s %s: %s SIGID=%u %sRuntime Mode enabled!\n" <3> drivers/gpu/drm/xe/xe_survivability_mode.c:409 xe_survivability_mode_runtime_enable "%s %s: %s SIGID=%u %sRuntime Mode not supported!\n" <3> drivers/gpu/drm/xe/xe_survivability_mode.c:344 enable_boot_survivability_mode "%s %s: %s SIGID=%u %sFailed to enable Boot Mode!\n" <6> drivers/gpu/drm/xe/xe_survivability_mode.c:339 enable_boot_survivability_mode "%s %s: %s SIGID=%u %sBoot Mode enabled!\n" <3> drivers/gpu/drm/xe/xe_survivability_mode.c:334 enable_boot_survivability_mode "%s %s: %s SIGID=%u %sBoot Mode enabled!\n" <3> drivers/gpu/drm/xe/xe_survivability_mode.c:302 create_survivability_sysfs "%s %s: %s SIGID=%u %sFailed to create sysfs files!\n" > > @Jani, are you OK with that? > >>> + >>> +#define xe_log_emit(pdev, sev, sig, comp, loc, data, len, fmt, args...) ({ \ >>> + __xe_log_emit_printk_index(fmt); \ >>> + __xe_log_emit((pdev), (sev), (sig), (comp), (loc), (data), (len), fmt, ##args); \ >>> +}) >> >> nit: use do{} while (0) >> >> Reviewed-by: Mallesh Koujalagi <[email protected]> >> >>> #define xe_log_emit_fatal(pdev, sig, comp, loc, data, len, fmt, args...) \ >>> xe_log_emit((pdev), CPER_SEV_FATAL, (sig), (comp), (loc), \ >