All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: linux-kernel@vger.kernel.org
Cc: Petr Vorel <pvorel@suse.cz>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	David Sterba <dsterba@suse.com>
Subject: [PATCH 1/1] drivers/base/cpu: Print kernel arch
Date: Wed, 27 Jul 2022 18:11:35 +0200	[thread overview]
Message-ID: <20220727161135.24531-1-pvorel@suse.cz> (raw)

Print kernel architecture in /sys/devices/system/cpu/arch
using UTS_MACHINE, i.e. member of struct uts_namespace.machine.

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.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 drivers/base/cpu.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 4c98849577d4..7c8032e3ff10 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -3,6 +3,7 @@
  * CPU subsystem support
  */
 
+#include <generated/compile.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -232,6 +233,13 @@ static ssize_t print_cpus_kernel_max(struct device *dev,
 }
 static DEVICE_ATTR(kernel_max, 0444, print_cpus_kernel_max, NULL);
 
+static ssize_t print_cpus_arch(struct device *dev,
+				     struct device_attribute *attr, char *buf)
+{
+	return sysfs_emit(buf, "%s\n", UTS_MACHINE);
+}
+static DEVICE_ATTR(arch, 0444, print_cpus_arch, NULL);
+
 /* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */
 unsigned int total_cpus;
 
@@ -464,6 +472,7 @@ static struct attribute *cpu_root_attrs[] = {
 	&cpu_attrs[1].attr.attr,
 	&cpu_attrs[2].attr.attr,
 	&dev_attr_kernel_max.attr,
+	&dev_attr_arch.attr,
 	&dev_attr_offline.attr,
 	&dev_attr_isolated.attr,
 #ifdef CONFIG_NO_HZ_FULL
-- 
2.37.1


             reply	other threads:[~2022-07-27 16:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-27 16:11 Petr Vorel [this message]
2022-07-27 16:40 ` [PATCH 1/1] drivers/base/cpu: Print kernel arch Greg Kroah-Hartman
2022-07-27 22:22   ` Petr Vorel
2022-07-28  6:59     ` Greg Kroah-Hartman
2022-07-28  7:35       ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220727161135.24531-1-pvorel@suse.cz \
    --to=pvorel@suse.cz \
    --cc=dsterba@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.