|
|
5113bc |
From 79866c4b187e9ccf37fe333e9865a8575f4a3a16 Mon Sep 17 00:00:00 2001
|
|
|
5113bc |
From: Karel Zak <kzak@redhat.com>
|
|
|
5113bc |
Date: Wed, 6 Jun 2018 10:10:20 +0200
|
|
|
5113bc |
Subject: [PATCH 169/173] lscpu: fix mzx/min MHz reporting
|
|
|
5113bc |
|
|
|
5113bc |
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1579439
|
|
|
5113bc |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
5113bc |
---
|
|
|
5113bc |
sys-utils/lscpu.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
|
|
|
5113bc |
1 file changed, 48 insertions(+), 2 deletions(-)
|
|
|
5113bc |
|
|
|
5113bc |
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
|
|
|
5113bc |
index 1ee73f34a..4c15de1d4 100644
|
|
|
5113bc |
--- a/sys-utils/lscpu.c
|
|
|
5113bc |
+++ b/sys-utils/lscpu.c
|
|
|
5113bc |
@@ -1251,6 +1251,52 @@ read_configured(struct lscpu_desc *desc, int idx)
|
|
|
5113bc |
desc->configured[idx] = path_read_s32(_PATH_SYS_CPU "/cpu%d/configure", num);
|
|
|
5113bc |
}
|
|
|
5113bc |
|
|
|
5113bc |
+/* Read overall maximum frequency of cpu */
|
|
|
5113bc |
+static char *
|
|
|
5113bc |
+cpu_max_mhz(struct lscpu_desc *desc, char *buf, size_t bufsz)
|
|
|
5113bc |
+{
|
|
|
5113bc |
+ int i;
|
|
|
5113bc |
+ float cpu_freq = 0.0;
|
|
|
5113bc |
+ size_t setsize = CPU_ALLOC_SIZE(maxcpus);
|
|
|
5113bc |
+
|
|
|
5113bc |
+ if (desc->present) {
|
|
|
5113bc |
+ for (i = 0; i < desc->ncpuspos; i++) {
|
|
|
5113bc |
+ if (CPU_ISSET_S(real_cpu_num(desc, i), setsize, desc->present)
|
|
|
5113bc |
+ && desc->maxmhz[i]) {
|
|
|
5113bc |
+ float freq = atof(desc->maxmhz[i]);
|
|
|
5113bc |
+
|
|
|
5113bc |
+ if (freq > cpu_freq)
|
|
|
5113bc |
+ cpu_freq = freq;
|
|
|
5113bc |
+ }
|
|
|
5113bc |
+ }
|
|
|
5113bc |
+ }
|
|
|
5113bc |
+ snprintf(buf, bufsz, "%.4f", cpu_freq);
|
|
|
5113bc |
+ return buf;
|
|
|
5113bc |
+}
|
|
|
5113bc |
+
|
|
|
5113bc |
+/* Read overall minimum frequency of cpu */
|
|
|
5113bc |
+static char *
|
|
|
5113bc |
+cpu_min_mhz(struct lscpu_desc *desc, char *buf, size_t bufsz)
|
|
|
5113bc |
+{
|
|
|
5113bc |
+ int i;
|
|
|
5113bc |
+ float cpu_freq = -1.0;
|
|
|
5113bc |
+ size_t setsize = CPU_ALLOC_SIZE(maxcpus);
|
|
|
5113bc |
+
|
|
|
5113bc |
+ if (desc->present) {
|
|
|
5113bc |
+ for (i = 0; i < desc->ncpuspos; i++) {
|
|
|
5113bc |
+ if (CPU_ISSET_S(real_cpu_num(desc, i), setsize, desc->present)
|
|
|
5113bc |
+ && desc->minmhz[i]) {
|
|
|
5113bc |
+ float freq = atof(desc->minmhz[i]);
|
|
|
5113bc |
+
|
|
|
5113bc |
+ if (cpu_freq < 0.0 || freq < cpu_freq)
|
|
|
5113bc |
+ cpu_freq = freq;
|
|
|
5113bc |
+ }
|
|
|
5113bc |
+ }
|
|
|
5113bc |
+ }
|
|
|
5113bc |
+ snprintf(buf, bufsz, "%.4f", cpu_freq);
|
|
|
5113bc |
+ return buf;
|
|
|
5113bc |
+}
|
|
|
5113bc |
+
|
|
|
5113bc |
static void
|
|
|
5113bc |
read_max_mhz(struct lscpu_desc *desc, int idx)
|
|
|
5113bc |
{
|
|
|
5113bc |
@@ -1898,9 +1944,9 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
|
|
|
5113bc |
if (desc->static_mhz)
|
|
|
5113bc |
print_s(_("CPU static MHz:"), desc->static_mhz);
|
|
|
5113bc |
if (desc->maxmhz && desc->maxmhz[0])
|
|
|
5113bc |
- print_s(_("CPU max MHz:"), desc->maxmhz[0]);
|
|
|
5113bc |
+ print_s(_("CPU max MHz:"), cpu_max_mhz(desc, buf, sizeof(buf)));
|
|
|
5113bc |
if (desc->minmhz && desc->minmhz[0])
|
|
|
5113bc |
- print_s(_("CPU min MHz:"), desc->minmhz[0]);
|
|
|
5113bc |
+ print_s(_("CPU min MHz:"), cpu_min_mhz(desc, buf, sizeof(buf)));
|
|
|
5113bc |
if (desc->bogomips)
|
|
|
5113bc |
print_s(_("BogoMIPS:"), desc->bogomips);
|
|
|
5113bc |
if (desc->virtflag) {
|
|
|
5113bc |
--
|
|
|
5113bc |
2.14.4
|
|
|
5113bc |
|