util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masayoshi Mizuma <msys.mizuma@gmail.com>
To: util-linux@vger.kernel.org
Cc: Masayoshi Mizuma <msys.mizuma@gmail.com>,
	Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Subject: [PATCH v3 5/5] lscpu: show the number of physical socket on aarch64 machine without ACPI PPTT
Date: Fri, 20 Nov 2020 00:06:09 -0500	[thread overview]
Message-ID: <20201120050609.17409-6-msys.mizuma@gmail.com> (raw)
In-Reply-To: <20201120050609.17409-1-msys.mizuma@gmail.com>

From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>

Show the number of the number of physical socket even if the sysfs doesn't
have the physical socket information.

Note, lscpu shows the number of physical socket as 'Socket(s):' only if
root user runs it because accessing the DMI table requires root
privilege.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
---
 sys-utils/lscpu-arm.c | 2 ++
 sys-utils/lscpu.c     | 9 +++++++--
 sys-utils/lscpu.h     | 2 ++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c
index 9391cca54..9e259673c 100644
--- a/sys-utils/lscpu-arm.c
+++ b/sys-utils/lscpu-arm.c
@@ -360,6 +360,8 @@ static void arm_decode(struct lscpu_cxt *cxt, struct lscpu_cputype *ct)
 
 	arm_ids_decode(ct);
 	arm_rXpY_decode(ct);
+	if (cxt->is_cluster)
+		ct->nr_socket_on_cluster = get_number_of_physical_sockets_from_dmi();
 }
 
 static int lscpu_is_cluster_arm(struct lscpu_cxt *cxt)
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index b9b8940a8..85d1d0acb 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -862,10 +862,15 @@ print_summary_cputype(struct lscpu_cxt *cxt,
 		} else
 			add_summary_n(tb, sec, _("Book(s):"), ct->nbooks_per_drawer ?: ct->nbooks);
 	} else {
-		if (cxt->is_cluster)
+		if (cxt->is_cluster) {
+			if (ct->nr_socket_on_cluster > 0)
+				add_summary_n(tb, sec, _("Socket(s):"), ct->nr_socket_on_cluster);
+			else
+				add_summary_s(tb, sec, _("Socket(s):"), "-");
+
 			add_summary_n(tb, sec, _("Cluster(s):"),
 					ct->nsockets_per_book ?: ct->nsockets);
-		else
+		} else
 			add_summary_n(tb, sec, _("Socket(s):"),
 					ct->nsockets_per_book ?: ct->nsockets);
 	}
diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h
index 74c647e3a..623c07998 100644
--- a/sys-utils/lscpu.h
+++ b/sys-utils/lscpu.h
@@ -101,6 +101,8 @@ struct lscpu_cputype {
 			has_configured : 1,
 			has_polarization : 1,
 			has_addresses : 1;
+
+	size_t nr_socket_on_cluster; /* the number of sockets if the is_cluster is 1 */
 };
 
 /* dispatching modes */
-- 
2.27.0


  parent reply	other threads:[~2020-11-20  5:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-20  5:06 [PATCH v3 0/5] lscpu: Fix socket information on aarch64 machine Masayoshi Mizuma
2020-11-20  5:06 ` [PATCH v3 1/5] lscpu: use cluster on aarch64 machine which doesn't have ACPI PPTT Masayoshi Mizuma
2020-11-20  5:06 ` [PATCH v3 2/5] lscpu-virt: split hypervisor_from_dmi_table() Masayoshi Mizuma
2020-11-20  5:06 ` [PATCH v3 3/5] lscpu-dmi: Move some functions related to DMI to lscpu-dmi Masayoshi Mizuma
2020-11-20  5:06 ` [PATCH v3 4/5] lscpu: add helper to get physical sockets Masayoshi Mizuma
2020-11-20  5:06 ` Masayoshi Mizuma [this message]
2020-11-20  9:07 ` [PATCH v3 0/5] lscpu: Fix socket information on aarch64 machine Karel Zak

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=20201120050609.17409-6-msys.mizuma@gmail.com \
    --to=msys.mizuma@gmail.com \
    --cc=m.mizuma@jp.fujitsu.com \
    --cc=util-linux@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).