Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:Update
python-libmount.12160
util-linux-lscpu-read-cpu-max-min-freq.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File util-linux-lscpu-read-cpu-max-min-freq.patch of Package python-libmount.12160
From fc07d9f5aba7c58d9793a6c781d569316dfd25f6 Mon Sep 17 00:00:00 2001 From: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com> Date: Thu, 27 Apr 2017 15:52:59 +0530 Subject: [PATCH] lscpu: Read available CPUs max and min frequencies Problem:"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. This patch will read overall CPU max and min frequencies. 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 [kzak@redhat.com: - cpu_{max,min}_mhz() refactoring] Signed-off-by: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com> Signed-off-by: Karel Zak <kzak@redhat.com> --- sys-utils/lscpu.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 5 deletions(-) Index: util-linux-2.28/sys-utils/lscpu.c =================================================================== --- util-linux-2.28.orig/sys-utils/lscpu.c +++ util-linux-2.28/sys-utils/lscpu.c @@ -1109,6 +1109,47 @@ read_configured(struct lscpu_desc *desc, desc->configured[idx] = path_read_s32(_PATH_SYS_CPU "/cpu%d/configure", num); } +/* Read overall maximum frequency of cpu */ +static void +cpu_max_mhz(struct lscpu_desc *desc, char *max_freq) +{ + int i; + float cpu_freq = atof(desc->maxmhz[0]); + + if (desc->present) { + for (i = 1; i < desc->ncpuspos; i++) { + if (CPU_ISSET(real_cpu_num(desc, i), desc->present)) { + float freq = atof(desc->maxmhz[i]); + + if (freq > cpu_freq) + cpu_freq = freq; + } + } + } + sprintf(max_freq, "%.4f", cpu_freq); +} + +/* Read overall minimum frequency of cpu */ +static void +cpu_min_mhz(struct lscpu_desc *desc, char *min_freq) +{ + int i; + float cpu_freq = atof(desc->minmhz[0]); + + if (desc->present) { + for (i = 1; i < desc->ncpuspos; i++) { + if (CPU_ISSET(real_cpu_num(desc, i), desc->present)) { + float freq = atof(desc->minmhz[i]); + + if (freq < cpu_freq) + cpu_freq = freq; + } + } + } + sprintf(min_freq, "%.4f", cpu_freq); +} + + static void read_max_mhz(struct lscpu_desc *desc, int idx) { @@ -1600,7 +1641,9 @@ static void print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod) { char buf[512]; - int i; + int i = 0; + char max_freq[32]; + char min_freq[32]; size_t setsize = CPU_ALLOC_SIZE(maxcpus); print_s(_("Architecture:"), desc->arch); @@ -1704,10 +1747,14 @@ print_summary(struct lscpu_desc *desc, s print_s(_("Stepping:"), desc->stepping); if (desc->mhz) print_s(_("CPU MHz:"), desc->mhz); - if (desc->maxmhz) - print_s(_("CPU max MHz:"), desc->maxmhz[0]); - if (desc->minmhz) - print_s(_("CPU min MHz:"), desc->minmhz[0]); + if (desc->maxmhz){ + cpu_max_mhz(desc, max_freq); + print_s(_("CPU max MHz:"), max_freq); + } + if (desc->minmhz){ + cpu_min_mhz(desc, min_freq); + print_s(_("CPU min MHz:"), min_freq); + } if (desc->bogomips) print_s(_("BogoMIPS:"), desc->bogomips); if (desc->virtflag) {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor