|
|
99c779 |
From 9a81309286a05f2b088c9898a0e3a16e807532be Mon Sep 17 00:00:00 2001
|
|
|
99c779 |
From: Chandni Verma <chandni@linux.vnet.ibm.com>
|
|
|
99c779 |
Date: Thu, 20 Oct 2016 19:24:46 +0530
|
|
|
99c779 |
Subject: [PATCH 26/43] cpuinfo: Rectify cpuinfo for IBM Power Systems
|
|
|
99c779 |
|
|
|
99c779 |
'/proc/cpuinfo' file on Power Systems represents online CPU threads,
|
|
|
99c779 |
not physical cores. Also we can dynamically change number of threads.
|
|
|
99c779 |
|
|
|
99c779 |
Previous patch added support to parse device tree and display core
|
|
|
99c779 |
information under CPU nodes.
|
|
|
99c779 |
|
|
|
99c779 |
This patch pulls useful info from cpuinfo file and updates CPU nodes.
|
|
|
99c779 |
- description : Processor description
|
|
|
99c779 |
- version : Processor version including subversion
|
|
|
99c779 |
|
|
|
99c779 |
Signed-off-by: Chandni Verma <chandni@linux.vnet.ibm.com>
|
|
|
99c779 |
[Code cleanup, updated description - Vasant]
|
|
|
99c779 |
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
|
|
|
99c779 |
---
|
|
|
99c779 |
src/core/cpuinfo.cc | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
99c779 |
1 file changed, 46 insertions(+), 1 deletion(-)
|
|
|
99c779 |
|
|
|
99c779 |
diff --git a/src/core/cpuinfo.cc b/src/core/cpuinfo.cc
|
|
|
99c779 |
index 5a2b8c0..8443adc 100644
|
|
|
99c779 |
--- a/src/core/cpuinfo.cc
|
|
|
99c779 |
+++ b/src/core/cpuinfo.cc
|
|
|
99c779 |
@@ -13,6 +13,13 @@ __ID("@(#) $Id$");
|
|
|
99c779 |
|
|
|
99c779 |
static int currentcpu = 0;
|
|
|
99c779 |
|
|
|
99c779 |
+static inline bool is_system_ppc_ibm(hwNode & node)
|
|
|
99c779 |
+{
|
|
|
99c779 |
+ string desc = node.getDescription();
|
|
|
99c779 |
+
|
|
|
99c779 |
+ return (desc == "PowerNV" || desc == "pSeries Guest" || desc == "pSeries LPAR");
|
|
|
99c779 |
+}
|
|
|
99c779 |
+
|
|
|
99c779 |
static hwNode *getcpu(hwNode & node,
|
|
|
99c779 |
int n = 0)
|
|
|
99c779 |
{
|
|
|
99c779 |
@@ -33,6 +40,13 @@ int n = 0)
|
|
|
99c779 |
return cpu;
|
|
|
99c779 |
}
|
|
|
99c779 |
|
|
|
99c779 |
+ /*
|
|
|
99c779 |
+ * device-tree.cc creates all CPU nodes on Power Systems.
|
|
|
99c779 |
+ * Hence do not create new CPU nodes here.
|
|
|
99c779 |
+ */
|
|
|
99c779 |
+ if (is_system_ppc_ibm(node))
|
|
|
99c779 |
+ return NULL;
|
|
|
99c779 |
+
|
|
|
99c779 |
hwNode *core = node.getChild("core");
|
|
|
99c779 |
|
|
|
99c779 |
if (core)
|
|
|
99c779 |
@@ -49,6 +63,20 @@ int n = 0)
|
|
|
99c779 |
|
|
|
99c779 |
|
|
|
99c779 |
#ifdef __powerpc__
|
|
|
99c779 |
+static void cpuinfo_ppc_ibm(hwNode & node,
|
|
|
99c779 |
+ const string & description, const string & version)
|
|
|
99c779 |
+{
|
|
|
99c779 |
+ hwNode *cpu = getcpu(node, currentcpu);
|
|
|
99c779 |
+
|
|
|
99c779 |
+ while (cpu)
|
|
|
99c779 |
+ {
|
|
|
99c779 |
+ cpu->setDescription(description);
|
|
|
99c779 |
+ cpu->setVersion(version);
|
|
|
99c779 |
+
|
|
|
99c779 |
+ cpu = getcpu(node, ++currentcpu);
|
|
|
99c779 |
+ }
|
|
|
99c779 |
+}
|
|
|
99c779 |
+
|
|
|
99c779 |
static void cpuinfo_ppc(hwNode & node,
|
|
|
99c779 |
string id,
|
|
|
99c779 |
string value)
|
|
|
99c779 |
@@ -570,6 +598,7 @@ bool scan_cpuinfo(hwNode & n)
|
|
|
99c779 |
char buffer[1024];
|
|
|
99c779 |
size_t count;
|
|
|
99c779 |
string cpuinfo_str = "";
|
|
|
99c779 |
+ string description = "", version = "";
|
|
|
99c779 |
|
|
|
99c779 |
while ((count = read(cpuinfo, buffer, sizeof(buffer))) > 0)
|
|
|
99c779 |
{
|
|
|
99c779 |
@@ -599,7 +628,23 @@ bool scan_cpuinfo(hwNode & n)
|
|
|
99c779 |
cpuinfo_x86(n, id, value);
|
|
|
99c779 |
#endif
|
|
|
99c779 |
#ifdef __powerpc__
|
|
|
99c779 |
- cpuinfo_ppc(n, id, value);
|
|
|
99c779 |
+
|
|
|
99c779 |
+ // All cores have same product name and version on power systems
|
|
|
99c779 |
+ if (is_system_ppc_ibm(n))
|
|
|
99c779 |
+ {
|
|
|
99c779 |
+ if (id == "cpu")
|
|
|
99c779 |
+ description = value;
|
|
|
99c779 |
+ if (id == "revision")
|
|
|
99c779 |
+ version = value;
|
|
|
99c779 |
+
|
|
|
99c779 |
+ if (description != "" && version != "")
|
|
|
99c779 |
+ {
|
|
|
99c779 |
+ cpuinfo_ppc_ibm(n, description, version);
|
|
|
99c779 |
+ break;
|
|
|
99c779 |
+ }
|
|
|
99c779 |
+ }
|
|
|
99c779 |
+ else
|
|
|
99c779 |
+ cpuinfo_ppc(n, id, value);
|
|
|
99c779 |
#endif
|
|
|
99c779 |
#ifdef __s390x__
|
|
|
99c779 |
cpuinfo_s390x(n, id, value);
|
|
|
99c779 |
--
|
|
|
99c779 |
2.10.2
|
|
|
99c779 |
|