[PATCH]lscpu: Read available CPUs max and min frequencies

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Problem: On power syatems "lscpu frequency-info" command was always 
reading CPU0 max and min frequencies. If CPU0 is guarded or offline 
then it used to display max and min frequencies as NULL.

Solution: This patch will check for the available/online CPUs
and read the max/min frequencies of that CPU

Test Results:

Before Patch:

#lscpu (CPU0 is guarded/offline)
Architecture:          ppc64le
Byte Order:            Little Endian
CPU(s):                120
On-line CPU(s) list:   8-127
Thread(s) per core:    8
Core(s) per socket:    3
Socket(s):             4
NUMA node(s):          4
Model:                 2.1 (pvr 004b 0201)
Model name:            POWER8E (raw), altivec supported
CPU max MHz:           (null)
CPU min MHz:           (null)
L1d cache:             64K
L1i cache:             32K
L2 cache:              512K
L3 cache:              8192K
NUMA node0 CPU(s):     8-31
NUMA node1 CPU(s):     32-63
NUMA node16 CPU(s):    64-95
NUMA node17 CPU(s):    96-127

With Patch:

# ./lscpu
Architecture:          ppc64le
Byte Order:            Little Endian
CPU(s):                120
On-line CPU(s) list:   8-127
Thread(s) per core:    8
Core(s) per socket:    3
Socket(s):             4
NUMA node(s):          4
Model:                 2.1 (pvr 004b 0201)
Model name:            POWER8E (raw), altivec supported
CPU max MHz:           4322.0000
CPU min MHz:           2061.0000
L1d cache:             64K
L1i cache:             32K
L2 cache:              512K
L3 cache:              8192K
NUMA node0 CPU(s):     8-31
NUMA node1 CPU(s):     32-63
NUMA node16 CPU(s):    64-95
NUMA node17 CPU(s):    96-127

Signed-off-by: Mamatha Inamdar <mamatha4@xxxxxxxxxxxxxxxxxx>
---
 sys-utils/lscpu.c |   18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 683fd66..7f92b20 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -1775,7 +1775,7 @@ static void
 print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 {
 	char buf[512];
-	int i;
+	int i = 0;
 	size_t setsize = CPU_ALLOC_SIZE(maxcpus);
 
 	print_s(_("Architecture:"), desc->arch);
@@ -1898,9 +1898,21 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 	if (desc->static_mhz)
 		print_s(_("CPU static MHz:"), desc->static_mhz);
 	if (desc->maxmhz)
-		print_s(_("CPU max MHz:"), desc->maxmhz[0]);
+		for (i = 0; i < desc->ncpuspos; i++) {
+			/*Check for the first online CPU */
+			if (desc->present &&
+				CPU_ISSET(real_cpu_num(desc, i), desc->present))
+				break;
+			}
+	print_s(_("CPU max MHz:"), desc->maxmhz[i]);
 	if (desc->minmhz)
-		print_s(_("CPU min MHz:"), desc->minmhz[0]);
+		for (i = 0; i < desc->ncpuspos; i++) {
+		/*Check for the first online CPU */
+			if (desc->present &&
+				CPU_ISSET(real_cpu_num(desc, i), desc->present))
+				break;
+		}
+	print_s(_("CPU min MHz:"), desc->minmhz[i]);
 	if (desc->bogomips)
 		print_s(_("BogoMIPS:"), desc->bogomips);
 	if (desc->virtflag) {

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux