Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1171916rwe; Thu, 1 Sep 2022 13:48:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR4j6zdCcwUoJwH5m043CRfVt6LRIBuzfMTVesDPrNx1gNYIARgM29+ylUGy+NaHoC/bZTm6 X-Received: by 2002:a17:907:9483:b0:731:2be4:f73c with SMTP id dm3-20020a170907948300b007312be4f73cmr25522157ejc.380.1662065320929; Thu, 01 Sep 2022 13:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662065320; cv=none; d=google.com; s=arc-20160816; b=MmH/EJowGkOV9F1s9F8OISHpD1wLniW2jqHqlupWI2g3kBQyTVJd011ujcJRzSHTtq ochJ4l8FiogErwu0hH5QiRb0T+O2q3D+YpIz9cs3r285t8nwfrSXfmEPB00gI/Eh5RUP BLPFMjizRvLhMZkVj8jEkL327692Q6/YOaKmzOSzSRngdCHakbRaZug6rkA/9+Cf09Cx A/Ptq15Qib5sJLcdHoF7V7DcMohBSCCBvZ27Caov65sazSkuok/8UX6J9cOMz1ioDDP9 JNpjfPLij0tx0mVAMMBiHMpaiPLgFMnYsSJAG5bin3m+H79YUvXv57RZBhTRS7jp+dqr 9Yqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=3rgpNwOhkFzND6nXCguYHiOum8GrZt8wm1cXfoBldJ8=; b=e9cRkfEwOgWWLB6Si/c6I8ED+DfOq0b5OxwSjvSH/xK2AGIkDeO7VP7aLWrvUyf1aG 7O9BiuYmgefBjm+Pf7Gq9QF9160eySlHVLzn4LTka/PVsGkev6WRX9dTj2mcCYjQaMhh lvRqKflp2VfNMH4V9LbFpl/6RsRIfKLGHYBjFyP7HbISOtX/npeUe/JMg/ALWroupt0U nYlOQN/60H92cDVrcmi6yx8MiiWI0nihwoE6bNmY5USUY6VUVK8AsAowmVUpXaPxpgNz CEmOmPuRK0t+qWfQyXvZzzzd8dSeCvx5+YAiMc40X25d0xF6bfw7itzHAyiic52qcBRv upjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=jtQPXjxF; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs4-20020a1709073e8400b0073d8e4e8c77si165798ejc.1005.2022.09.01.13.48.15; Thu, 01 Sep 2022 13:48:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=jtQPXjxF; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234749AbiIAToR (ORCPT + 99 others); Thu, 1 Sep 2022 15:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234695AbiIAToP (ORCPT ); Thu, 1 Sep 2022 15:44:15 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E578696CE for ; Thu, 1 Sep 2022 12:44:12 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 98029223F5; Thu, 1 Sep 2022 19:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1662061450; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3rgpNwOhkFzND6nXCguYHiOum8GrZt8wm1cXfoBldJ8=; b=jtQPXjxF+G2s+Eb78kD1gtUPD738zRvrYJFGmwp2Wj9oNpRzq0LUh6gACFCYVq5OsYvq3e FZNXa5ADfyceBSPhN/4GJqYNvxH8G5VlEwSoc4pHQsPa2KlP+mfU13AmivmJyIwxh1pYAe 1T+cAaW06IfaUIZBpnqMLjpAprSGLCg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1662061450; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3rgpNwOhkFzND6nXCguYHiOum8GrZt8wm1cXfoBldJ8=; b=JP0Yj+0bK5i6uliRoPlkHphgNpGdipOYxOYks3F723a8MrFFbbn8/ilyJ63trMDlHbuKUy vBBPTzOFL6sUT0DA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 129FD13A89; Thu, 1 Sep 2022 19:44:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id RF4uAYoLEWMrYgAAMHmgww (envelope-from ); Thu, 01 Sep 2022 19:44:10 +0000 From: Petr Vorel To: linux-kernel@vger.kernel.org Cc: Petr Vorel , Andrew Morton , Eric Biederman , Greg Kroah-Hartman , "Rafael J. Wysocki" , David Sterba Subject: [PATCH v3 1/1] kernel/utsname_sysctl.c: Print kernel arch Date: Thu, 1 Sep 2022 21:44:03 +0200 Message-Id: <20220901194403.3819-1-pvorel@suse.cz> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Petr Vorel --- Changes v2->v3: * fix title in the subject @Andrew @Eric: FYI previously the sysfs file was in /sys/devices/system/cpu/, that's why I sent previous versions to Greg. Documentation/admin-guide/sysctl/kernel.rst | 5 +++++ kernel/utsname_sysctl.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index ee6572b1edad..bbaa85194695 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -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 =========== diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c index 4ca61d49885b..7ffdd2cd5ff9 100644 --- a/kernel/utsname_sysctl.c +++ b/kernel/utsname_sysctl.c @@ -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.35.3