Re: [PATCH] ksysfs: Expose hardware name
From: John Ogness
Date: Mon Feb 23 2026 - 09:00:14 EST
Hi Richard,
On 2026-02-23, Richard Weinberger <richard@xxxxxx> wrote:
> Userspace tools often require a short, descriptive name of the hardware
> platform. Currently, this information is fragmented: Device Tree-based
> platforms typically use /proc/device-tree/model, while x86 platforms
> combine multiple values from /sys/class/dmi/id/. There is no uniform,
> platform-agnostic way to retrieve this string.
>
> The kernel already maintains dump_stack_arch_desc_str[], which contains
> the model name or DMI values used for the "Hardware name:" field in
> stack traces.
>
> Expose dump_stack_arch_desc_str[] at /sys/kernel/hardware_name to
> provide userspace with a consistent interface for identifying the
> underlying hardware.
>
> Signed-off-by: Richard Weinberger <richard@xxxxxx>
> ---
> .../ABI/testing/sysfs-kernel-hardware_name | 8 ++++++++
> include/linux/printk.h | 1 +
> kernel/ksysfs.c | 13 +++++++++++++
> lib/dump_stack.c | 2 +-
> 4 files changed, 23 insertions(+), 1 deletion(-)
> create mode 100644 Documentation/ABI/testing/sysfs-kernel-hardware_name
>
> diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
> index a9e6354d9e25..af7265754183 100644
> --- a/kernel/ksysfs.c
> +++ b/kernel/ksysfs.c
> @@ -176,6 +176,16 @@ static ssize_t rcu_normal_store(struct kobject *kobj,
> KERNEL_ATTR_RW(rcu_normal);
> #endif /* #ifndef CONFIG_TINY_RCU */
>
> +#ifdef CONFIG_PRINTK
> +/* hardware name */
> +static ssize_t hardware_name_show(struct kobject *kobj,
> + struct kobj_attribute *attr, char *buf)
> +{
> + return sysfs_emit(buf, "%s\n", dump_stack_arch_desc_str);
> +}
> +KERNEL_ATTR_RO(hardware_name);
> +#endif
It seems a bit odd to make this a dependency of CONFIG_PRINTK. Perhaps
@dump_stack_arch_desc_str and dump_stack_set_arch_desc() should move out
of lib/dump_stack.c if this new sysfs attribute is accepted?
John Ogness