Skip to contentSkip to conversation

drivers/base/cpu: Print kernel arch

PATCH In review Petr Vorel 2 participants 10 messages Jul 29, 2022 – Sep 1, 2022 Documentation

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH v2 1/1 drivers/base/cpu: Print kernel arch

Print the machine hardware name (UTS_MACHINE) in /proc/sys/kernel/arch.

This helps people who debug kernel with initramfs with minimal environment (i.e. without coreutils or even busybox) or allow to open sysfs file instead of run 'uname -m' in high level languages.

---
 Documentation/admin-guide/sysctl/kernel.rst | 5 +++++
 kernel/utsname_sysctl.c                     | 7 +++++++
 2 files changed, 12 insertions(+)
Documentation/admin-guide/sysctl/kernel.rst +5 -0
index ddccd1077462..70a0acf07101 100644
@@ -65,6 +65,11 @@ combining the following values:
 4 s3_beep
 = =======
 
+arch
+====
+
+The machine hardware name, the same output as ``uname -m``
+(e.g. ``x86_64`` or ``aarch64``).
 
 auto_msgmni
 ===========
kernel/utsname_sysctl.c +7 -0
index 4ca61d49885b..7ffdd2cd5ff9 100644
@@ -73,6 +73,13 @@ static DEFINE_CTL_TABLE_POLL(hostname_poll);
 static DEFINE_CTL_TABLE_POLL(domainname_poll);
 
 static struct ctl_table uts_kern_table[] = {
+	{
+		.procname	= "arch",
+		.data		= init_uts_ns.name.machine,
+		.maxlen		= sizeof(init_uts_ns.name.machine),
+		.mode		= 0444,
+		.proc_handler	= proc_do_uts_string,
+	},
 	{
 		.procname	= "ostype",
 		.data		= init_uts_ns.name.sysname,
Signature · 1 line
2.37.1
author
#1 lore raw

Hi all,

Quoted 8 lines

Print the machine hardware name (UTS_MACHINE) in /proc/sys/kernel/arch.

This helps people who debug kernel with initramfs with minimal environment (i.e. without coreutils or even busybox) or allow to open sysfs file instead of run 'uname -m' in high level languages.

---

Changes v1->v2:
* Add file into /proc/sys/kernel/ (previously it was in /sys/devices/system/cpu/). There are
* Update Documentation/ABI/ (Greg)

Kind regards,
Petr

Quoted 37 lines

Documentation/admin-guide/sysctl/kernel.rst | 5 +++++ kernel/utsname_sysctl.c | 7 +++++++ 2 files changed, 12 insertions(+)

Documentation/admin-guide/sysctl/kernel.rst +5 -0
index ddccd1077462..70a0acf07101 100644
@@ -65,6 +65,11 @@ combining the following values:
 4 s3_beep
 = =======
 
+arch
+====
+
+The machine hardware name, the same output as ``uname -m``
+(e.g. ``x86_64`` or ``aarch64``).
 
 auto_msgmni
 ===========
kernel/utsname_sysctl.c +7 -0
index 4ca61d49885b..7ffdd2cd5ff9 100644
@@ -73,6 +73,13 @@ static DEFINE_CTL_TABLE_POLL(hostname_poll);
 static DEFINE_CTL_TABLE_POLL(domainname_poll);
 
 static struct ctl_table uts_kern_table[] = {
+	{
+		.procname	= "arch",
+		.data		= init_uts_ns.name.machine,
+		.maxlen		= sizeof(init_uts_ns.name.machine),
+		.mode		= 0444,
+		.proc_handler	= proc_do_uts_string,
+	},
 	{
 		.procname	= "ostype",
 		.data		= init_uts_ns.name.sysname,
#2 lore raw
Quoted 8 lines · Petr Vorel

Hi all,

Quoted 5 lines

Print the machine hardware name (UTS_MACHINE) in /proc/sys/kernel/arch.

This helps people who debug kernel with initramfs with minimal environment (i.e. without coreutils or even busybox) or allow to open sysfs file instead of run 'uname -m' in high level languages.

Quoted 6 lines
Quoted 2 lines

---

Changes v1->v2:
* Add file into /proc/sys/kernel/ (previously it was in /sys/devices/system/cpu/). There are

Looks like this line ended too soon?

Quoted 1 line

* Update Documentation/ABI/ (Greg)

This looks good to me, I'll queue it up after the next -rc1 is out unless someone objects.

greg k-h

author
#3 lore raw

Hi Greg,

Quoted 9 lines · Petr Vorel
Quoted 7 lines

Hi all,

Quoted 5 lines

Print the machine hardware name (UTS_MACHINE) in /proc/sys/kernel/arch.

This helps people who debug kernel with initramfs with minimal environment (i.e. without coreutils or even busybox) or allow to open sysfs file instead of run 'uname -m' in high level languages.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

---

Changes v1->v2:
* Add file into /proc/sys/kernel/ (previously it was in /sys/devices/system/cpu/). There are

Looks like this line ended too soon?

OK, Friday. I'm sorry to be too abstracted today.
I was about to explain the reason - that there are other related files osrelease, ostype.

Quoted 4 lines
Quoted 1 line

* Update Documentation/ABI/ (Greg)

This looks good to me, I'll queue it up after the next -rc1 is out unless someone objects.

Thanks!

Kind regards,
Petr

Quoted 1 line

greg k-h

author
#4 lore raw
In reply to Greg Kroah-Hartman
Quoted 16 lines · Petr Vorel
Quoted 8 lines

Hi all,

Quoted 5 lines

Print the machine hardware name (UTS_MACHINE) in /proc/sys/kernel/arch.

This helps people who debug kernel with initramfs with minimal environment (i.e. without coreutils or even busybox) or allow to open sysfs file instead of run 'uname -m' in high level languages.

Quoted 6 lines
Quoted 2 lines

---

Changes v1->v2:
* Add file into /proc/sys/kernel/ (previously it was in /sys/devices/system/cpu/). There are

Quoted 6 lines

Looks like this line ended too soon?

Quoted 1 line

* Update Documentation/ABI/ (Greg)

This looks good to me, I'll queue it up after the next -rc1 is out unless someone objects.

Hi Greg,

gently ping just to make sure you didn't forget on it. I'm sorry if I overlooked it (search in next tree and your git trees) or if you remember and are too busy (fully understand).

Kind regards,
Petr

Quoted 1 line

greg k-h

#5 lore raw
Quoted 20 lines · Petr Vorel
Quoted 19 lines · Petr Vorel
Quoted 8 lines

Hi all,

Quoted 5 lines

Print the machine hardware name (UTS_MACHINE) in /proc/sys/kernel/arch.

This helps people who debug kernel with initramfs with minimal environment (i.e. without coreutils or even busybox) or allow to open sysfs file instead of run 'uname -m' in high level languages.

Quoted 6 lines
Quoted 2 lines

---

Changes v1->v2:
* Add file into /proc/sys/kernel/ (previously it was in /sys/devices/system/cpu/). There are

Looks like this line ended too soon?

Quoted 1 line

* Update Documentation/ABI/ (Greg)

Quoted 8 lines
Quoted 2 lines

This looks good to me, I'll queue it up after the next -rc1 is out unless someone objects.

Hi Greg,

gently ping just to make sure you didn't forget on it. I'm sorry if I overlooked it (search in next tree and your git trees) or if you remember and are too busy (fully understand).

It's only been 2 days since -rc1 is out, and here's my todo queue right now:
❯ mdfrm -c ~/mail/todo/
1733 messages in /home/gregkh/mail/todo/

It's in good company :)

thanks,

greg k-h

author
#6 lore raw
Quoted 30 lines · Petr Vorel
Quoted 20 lines
Quoted 19 lines · Petr Vorel
Quoted 8 lines

Hi all,

Quoted 5 lines

Print the machine hardware name (UTS_MACHINE) in /proc/sys/kernel/arch.

This helps people who debug kernel with initramfs with minimal environment (i.e. without coreutils or even busybox) or allow to open sysfs file instead of run 'uname -m' in high level languages.

Quoted 6 lines
Quoted 2 lines

---

Changes v1->v2:
* Add file into /proc/sys/kernel/ (previously it was in /sys/devices/system/cpu/). There are

Looks like this line ended too soon?

Quoted 1 line

* Update Documentation/ABI/ (Greg)

Quoted 8 lines
Quoted 2 lines

This looks good to me, I'll queue it up after the next -rc1 is out unless someone objects.

Hi Greg,

gently ping just to make sure you didn't forget on it. I'm sorry if I overlooked it (search in next tree and your git trees) or if you remember and are too busy (fully understand).

Quoted 6 lines

It's only been 2 days since -rc1 is out, and here's my todo queue right now:
❯ mdfrm -c ~/mail/todo/
1733 messages in /home/gregkh/mail/todo/

It's in good company :)

Lol, thanks for info, I'm very sorry I was impatient.

Petr

Quoted 3 lines

thanks,

greg k-h

#7 lore raw
In reply to Petr Vorel
Quoted 11 lines · Petr Vorel

Print the machine hardware name (UTS_MACHINE) in /proc/sys/kernel/arch.

This helps people who debug kernel with initramfs with minimal environment (i.e. without coreutils or even busybox) or allow to open sysfs file instead of run 'uname -m' in high level languages.

---
 Documentation/admin-guide/sysctl/kernel.rst | 5 +++++
 kernel/utsname_sysctl.c                     | 7 +++++++
 2 files changed, 12 insertions(+)

Wait, why does the subject line say "drivers/base/cpu"? That's not a file being touched in this commit at all, so this isn't for me to take :(

thanks,

greg k-h

author
#8 lore raw

Hi Greg,

[ Cc Eric Biederman as the author of kernel/utsname_sysctl.c ]

Quoted 13 lines · Petr Vorel
Quoted 11 lines

Print the machine hardware name (UTS_MACHINE) in /proc/sys/kernel/arch.

This helps people who debug kernel with initramfs with minimal environment (i.e. without coreutils or even busybox) or allow to open sysfs file instead of run 'uname -m' in high level languages.

---
 Documentation/admin-guide/sysctl/kernel.rst | 5 +++++
 kernel/utsname_sysctl.c                     | 7 +++++++
 2 files changed, 12 insertions(+)
Quoted 3 lines

Wait, why does the subject line say "drivers/base/cpu"? That's not a file being touched in this commit at all, so this isn't for me to take :(

Thanks for info. My bad, I forget to update the subject. I can send v3 with corrected subject, but who is going to take this?

$ ./scripts/get_maintainer.pl kernel/utsname_sysctl.c
[email protected] (open list)

There is listed Author: Eric Biederman, so is it him to Cc ?

Kind regards,
Petr

Quoted 3 lines

thanks,

greg k-h

#9 lore raw
Quoted 21 lines · Petr Vorel

Hi Greg,

[ Cc Eric Biederman as the author of kernel/utsname_sysctl.c ]

Quoted 13 lines · Petr Vorel
Quoted 11 lines

Print the machine hardware name (UTS_MACHINE) in /proc/sys/kernel/arch.

This helps people who debug kernel with initramfs with minimal environment (i.e. without coreutils or even busybox) or allow to open sysfs file instead of run 'uname -m' in high level languages.

---
 Documentation/admin-guide/sysctl/kernel.rst | 5 +++++
 kernel/utsname_sysctl.c                     | 7 +++++++
 2 files changed, 12 insertions(+)
Quoted 3 lines

Wait, why does the subject line say "drivers/base/cpu"? That's not a file being touched in this commit at all, so this isn't for me to take :(

Quoted 7 lines

Thanks for info. My bad, I forget to update the subject. I can send v3 with corrected subject, but who is going to take this?

$ ./scripts/get_maintainer.pl kernel/utsname_sysctl.c
[email protected] (open list)

There is listed Author: Eric Biederman, so is it him to Cc ?

Yeah, that would be best, or maybe Andrew?