[PATCH] printk: Add a short description string to kmsg_dump()
Jocelyn Falempe
jfalempe at redhat.com
Thu Jun 27 07:29:25 UTC 2024
On 26/06/2024 10:00, Petr Mladek wrote:
> On Tue 2024-06-25 14:39:29, Jocelyn Falempe wrote:
>> kmsg_dump doesn't forward the panic reason string to the kmsg_dumper
>> callback.
>> This patch adds a new parameter "const char *desc" to the kmsg_dumper
>> dump() callback, and update all drivers that are using it.
>>
>> To avoid updating all kmsg_dump() call, it adds a kmsg_dump_desc()
>> function and a macro for backward compatibility.
>>
>> I've written this for drm_panic, but it can be useful for other
>> kmsg_dumper.
>> It allows to see the panic reason, like "sysrq triggered crash"
>> or "VFS: Unable to mount root fs on xxxx" on the drm panic screen.
>>
>> Signed-off-by: Jocelyn Falempe <jfalempe at redhat.com>
>> ---
>> arch/powerpc/kernel/nvram_64.c | 3 ++-
>> arch/powerpc/platforms/powernv/opal-kmsg.c | 3 ++-
>> drivers/gpu/drm/drm_panic.c | 3 ++-
>> drivers/hv/hv_common.c | 3 ++-
>> drivers/mtd/mtdoops.c | 3 ++-
>> fs/pstore/platform.c | 3 ++-
>> include/linux/kmsg_dump.h | 13 ++++++++++---
>> kernel/panic.c | 2 +-
>> kernel/printk/printk.c | 8 +++++---
>> 9 files changed, 28 insertions(+), 13 deletions(-)
>
> The parameter is added into all dumpers. I guess that it would be
> used only drm_panic() because it is graphics and might be "fancy".
> The others simply dump the log buffer and the reason is in
> the dumped log as well.
Ok, I also tried to retrieve the reason from the dumped log, but that's
really fragile.
>
> Anyway, the passed buffer is static. Alternative solution would
> be to make it global and export it like, for example, panic_cpu.
It's not a static buffer, because the string is generated at runtime.
eg: https://elixir.bootlin.com/linux/latest/source/arch/arm/mm/init.c#L158
So it will be hard to avoid race conditions.
>
> Best Regards,
> Petr
>
More information about the dri-devel
mailing list