* [PATCH] ksysfs: Expose hardware name
@ 2026-02-23 13:34 Richard Weinberger
2026-02-23 13:49 ` Greg KH
2026-02-23 13:55 ` John Ogness
0 siblings, 2 replies; 7+ messages in thread
From: Richard Weinberger @ 2026-02-23 13:34 UTC (permalink / raw)
To: linux-kernel
Cc: bhe, sourabhjain, akpm, senozhatsky, john.ogness, rostedt,
pmladek, gregkh, upstream+linux, Richard Weinberger
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@nod.at>
---
.../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/Documentation/ABI/testing/sysfs-kernel-hardware_name b/Documentation/ABI/testing/sysfs-kernel-hardware_name
new file mode 100644
index 000000000000..21d130da1932
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-kernel-hardware_name
@@ -0,0 +1,8 @@
+What: /sys/kernel/hardware_name
+Date: Feb 2026
+KernelVersion: 7.1
+Contact: Richard Weinberger <richard@nod.at>
+Description:
+ The hardware name as shown in stack traces.
+
+ Access: Read
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 63d516c873b4..b8929495e35e 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -13,6 +13,7 @@ struct console;
extern const char linux_banner[];
extern const char linux_proc_banner[];
+extern char dump_stack_arch_desc_str[128];
extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
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
+
/*
* Make /sys/kernel/notes give the raw contents of our kernel .notes section.
*/
@@ -205,6 +215,9 @@ static struct attribute * kernel_attrs[] = {
#ifndef CONFIG_TINY_RCU
&rcu_expedited_attr.attr,
&rcu_normal_attr.attr,
+#endif
+#ifdef CONFIG_PRINTK
+ &hardware_name_attr.attr,
#endif
NULL
};
diff --git a/lib/dump_stack.c b/lib/dump_stack.c
index f0c78b5b5324..bce41e603cff 100644
--- a/lib/dump_stack.c
+++ b/lib/dump_stack.c
@@ -15,7 +15,7 @@
#include <linux/utsname.h>
#include <linux/stop_machine.h>
-static char dump_stack_arch_desc_str[128];
+char dump_stack_arch_desc_str[128];
/**
* dump_stack_set_arch_desc - set arch-specific str to show with task dumps
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] ksysfs: Expose hardware name
2026-02-23 13:34 [PATCH] ksysfs: Expose hardware name Richard Weinberger
@ 2026-02-23 13:49 ` Greg KH
2026-02-23 13:53 ` Richard Weinberger
2026-02-23 13:55 ` John Ogness
1 sibling, 1 reply; 7+ messages in thread
From: Greg KH @ 2026-02-23 13:49 UTC (permalink / raw)
To: Richard Weinberger
Cc: linux-kernel, bhe, sourabhjain, akpm, senozhatsky, john.ogness,
rostedt, pmladek, upstream+linux
On Mon, Feb 23, 2026 at 02:34:48PM +0100, Richard Weinberger 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.
No objection from me, but now that this is a global symbol in the
kernel, "dump_" seems like an odd prefix for this. How about
"linux_hardware_name" to match up with the sysfs file name?
</bikeshed>
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ksysfs: Expose hardware name
2026-02-23 13:49 ` Greg KH
@ 2026-02-23 13:53 ` Richard Weinberger
0 siblings, 0 replies; 7+ messages in thread
From: Richard Weinberger @ 2026-02-23 13:53 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-kernel, bhe, sourabhjain, Andrew Morton, senozhatsky,
John Ogness, Steven Rostedt, Petr Mladek, upstream+linux
----- Ursprüngliche Mail -----
> Von: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
> An: "richard" <richard@nod.at>
> CC: "linux-kernel" <linux-kernel@vger.kernel.org>, "bhe" <bhe@redhat.com>, sourabhjain@linux.ibm.com, "Andrew Morton"
> <akpm@linux-foundation.org>, "senozhatsky" <senozhatsky@chromium.org>, "John Ogness" <john.ogness@linutronix.de>,
> "Steven Rostedt" <rostedt@goodmis.org>, "Petr Mladek" <pmladek@suse.com>, upstream+linux@sigma-star.at
> Gesendet: Montag, 23. Februar 2026 14:49:31
> Betreff: Re: [PATCH] ksysfs: Expose hardware name
> On Mon, Feb 23, 2026 at 02:34:48PM +0100, Richard Weinberger 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.
>
> No objection from me, but now that this is a global symbol in the
> kernel, "dump_" seems like an odd prefix for this. How about
> "linux_hardware_name" to match up with the sysfs file name?
I don't care much. The reason why I kept the variable as-is is because
the function to set it is dump_stack_set_arch_desc().
So the prefix makes kinda sense.
Thanks,
//richard
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ksysfs: Expose hardware name
2026-02-23 13:34 [PATCH] ksysfs: Expose hardware name Richard Weinberger
2026-02-23 13:49 ` Greg KH
@ 2026-02-23 13:55 ` John Ogness
2026-02-23 14:20 ` Richard Weinberger
1 sibling, 1 reply; 7+ messages in thread
From: John Ogness @ 2026-02-23 13:55 UTC (permalink / raw)
To: Richard Weinberger, linux-kernel
Cc: bhe, sourabhjain, akpm, senozhatsky, rostedt, pmladek, gregkh,
upstream+linux, Richard Weinberger
Hi Richard,
On 2026-02-23, Richard Weinberger <richard@nod.at> 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@nod.at>
> ---
> .../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
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] ksysfs: Expose hardware name
2026-02-23 13:55 ` John Ogness
@ 2026-02-23 14:20 ` Richard Weinberger
2026-02-25 9:00 ` Steven Rostedt
0 siblings, 1 reply; 7+ messages in thread
From: Richard Weinberger @ 2026-02-23 14:20 UTC (permalink / raw)
To: John Ogness
Cc: linux-kernel, bhe, sourabhjain, Andrew Morton, senozhatsky,
Steven Rostedt, Petr Mladek, Greg Kroah-Hartman, upstream+linux
----- Ursprüngliche Mail -----
> Von: "John Ogness" <john.ogness@linutronix.de>
> An: "richard" <richard@nod.at>, "linux-kernel" <linux-kernel@vger.kernel.org>
>
> 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?
Sure. I was surprised too that lib/dump_stack.c depends on CONFIG_PRINTK.
Thanks,
//richard
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ksysfs: Expose hardware name
2026-02-23 14:20 ` Richard Weinberger
@ 2026-02-25 9:00 ` Steven Rostedt
2026-03-12 14:17 ` Petr Mladek
0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2026-02-25 9:00 UTC (permalink / raw)
To: Richard Weinberger
Cc: John Ogness, linux-kernel, bhe, sourabhjain, Andrew Morton,
senozhatsky, Petr Mladek, Greg Kroah-Hartman, upstream+linux
On Mon, 23 Feb 2026 15:20:22 +0100 (CET)
Richard Weinberger <richard@nod.at> wrote:
> ----- Ursprüngliche Mail -----
> > Von: "John Ogness" <john.ogness@linutronix.de>
> > An: "richard" <richard@nod.at>, "linux-kernel" <linux-kernel@vger.kernel.org>
> >
> > 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?
>
> Sure. I was surprised too that lib/dump_stack.c depends on CONFIG_PRINTK.
>
Or possibly we should make dump_stack.c not depend on CONFIG_PRINTK.
I'm guessing that it was done that way because it expects to dump the
stack to the console?
(haven't looked at the code yet)
-- Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ksysfs: Expose hardware name
2026-02-25 9:00 ` Steven Rostedt
@ 2026-03-12 14:17 ` Petr Mladek
0 siblings, 0 replies; 7+ messages in thread
From: Petr Mladek @ 2026-03-12 14:17 UTC (permalink / raw)
To: Steven Rostedt
Cc: Richard Weinberger, John Ogness, linux-kernel, bhe, sourabhjain,
Andrew Morton, senozhatsky, Greg Kroah-Hartman, upstream+linux
On Wed 2026-02-25 04:00:59, Steven Rostedt wrote:
> On Mon, 23 Feb 2026 15:20:22 +0100 (CET)
> Richard Weinberger <richard@nod.at> wrote:
>
> > ----- Ursprüngliche Mail -----
> > > Von: "John Ogness" <john.ogness@linutronix.de>
> > > An: "richard" <richard@nod.at>, "linux-kernel" <linux-kernel@vger.kernel.org>
> > >
> > > 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?
> >
> > Sure. I was surprised too that lib/dump_stack.c depends on CONFIG_PRINTK.
> >
>
> Or possibly we should make dump_stack.c not depend on CONFIG_PRINTK.
> I'm guessing that it was done that way because it expects to dump the
> stack to the console?
My guess is that dump_stack.c depends on CONFIG_PRINTK because
the stack is stored using printk(). Nothing is stored when
printk() is a NOP ;-)
A clean solution would be to move dump_stack_arch_desc_str
and dump_stack_set_arch_desc() somewhere else (ksysfs.c ?)
and rename them to hardware_name and set_hardware_name().
Best Regards,
Petr
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-12 14:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23 13:34 [PATCH] ksysfs: Expose hardware name Richard Weinberger
2026-02-23 13:49 ` Greg KH
2026-02-23 13:53 ` Richard Weinberger
2026-02-23 13:55 ` John Ogness
2026-02-23 14:20 ` Richard Weinberger
2026-02-25 9:00 ` Steven Rostedt
2026-03-12 14:17 ` Petr Mladek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox