165 lines
4.8 KiB
Diff
165 lines
4.8 KiB
Diff
From ec05852c7d2e10c924e9521c32fe002e0f8cde71 Mon Sep 17 00:00:00 2001
|
|
Message-Id: <ec05852c7d2e10c924e9521c32fe002e0f8cde71.1587532692.git.kamalesh@linux.vnet.ibm.com>
|
|
In-Reply-To: <cover.1587532692.git.kamalesh@linux.vnet.ibm.com>
|
|
References: <cover.1587532692.git.kamalesh@linux.vnet.ibm.com>
|
|
From: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
|
|
Date: Tue, 21 Apr 2020 08:08:12 -0500
|
|
Subject: [PATCH V4 10/14] lparstat: Add helpers to derive PURR/SPURR values
|
|
To: powerpc-utils-devel@googlegroups.com
|
|
Cc: Tyrel Datwyler <tyreld@linux.ibm.com>,
|
|
Nathan Lynch <nathanl@linux.ibm.com>,
|
|
Naveen N . Rao <naveen.n.rao@linux.vnet.ibm.com>,
|
|
Gautham R . Shenoy <ego@linux.vnet.ibm.com>,
|
|
Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
|
|
|
|
For every interval specified by the user, the PURR/SPURR delta values
|
|
are needed to be calculated. Add helpers to derive them.
|
|
|
|
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
|
|
---
|
|
src/lparstat.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
src/lparstat.h | 22 +++++++++++++
|
|
2 files changed, 109 insertions(+)
|
|
|
|
diff --git a/src/lparstat.c b/src/lparstat.c
|
|
index 7628afa..84a6544 100644
|
|
--- a/src/lparstat.c
|
|
+++ b/src/lparstat.c
|
|
@@ -471,6 +471,93 @@ void get_cpu_app(struct sysentry *unused_se, char *buf)
|
|
sprintf(buf, "%.2f", app);
|
|
}
|
|
|
|
+static double round_off_freq(void)
|
|
+{
|
|
+ double effective_freq, nominal_freq, freq;
|
|
+ struct sysentry *se;
|
|
+
|
|
+ se = get_sysentry("effective_freq");
|
|
+ effective_freq = strtod(se->value, NULL);
|
|
+
|
|
+ se = get_sysentry("nominal_freq");
|
|
+ nominal_freq = strtod(se->value, NULL);
|
|
+
|
|
+ freq = ((int)((effective_freq/nominal_freq * 100)+ 0.44) -
|
|
+ (effective_freq/nominal_freq * 100)) /
|
|
+ (effective_freq/nominal_freq * 100) * 100;
|
|
+
|
|
+ return freq;
|
|
+}
|
|
+
|
|
+void get_cpu_util_purr(struct sysentry *unused_se, char *buf)
|
|
+{
|
|
+ double delta_tb, delta_purr, delta_idle_purr;
|
|
+ double physc;
|
|
+
|
|
+ delta_tb = get_scaled_tb();
|
|
+ delta_purr = get_delta_value("purr");
|
|
+ delta_idle_purr = get_delta_value("idle_purr");
|
|
+
|
|
+ physc = (delta_purr - delta_idle_purr) / delta_tb;
|
|
+ physc *= 100.00;
|
|
+
|
|
+ sprintf(buf, "%.2f", physc);
|
|
+}
|
|
+
|
|
+void get_cpu_idle_purr(struct sysentry *unused_se, char *buf)
|
|
+{
|
|
+ double delta_tb, delta_purr, delta_idle_purr;
|
|
+ double physc, idle;
|
|
+
|
|
+ delta_tb = get_scaled_tb();
|
|
+ delta_purr = get_delta_value("purr");
|
|
+ delta_idle_purr = get_delta_value("idle_purr");
|
|
+
|
|
+ physc = (delta_purr - delta_idle_purr) / delta_tb;
|
|
+ idle = (delta_purr / delta_tb) - physc;
|
|
+ idle *= 100.00;
|
|
+
|
|
+ sprintf(buf, "%.2f", idle);
|
|
+}
|
|
+
|
|
+void get_cpu_util_spurr(struct sysentry *unused_se, char *buf)
|
|
+{
|
|
+ double delta_tb, delta_spurr, delta_idle_spurr;
|
|
+ double physc, rfreq;
|
|
+
|
|
+ delta_tb = get_scaled_tb();
|
|
+ delta_spurr = get_delta_value("spurr");
|
|
+ delta_idle_spurr = get_delta_value("idle_spurr");
|
|
+
|
|
+ physc = (delta_spurr - delta_idle_spurr) / delta_tb;
|
|
+ physc *= 100.00;
|
|
+
|
|
+ rfreq = round_off_freq();
|
|
+ physc += ((physc * rfreq) / 100);
|
|
+
|
|
+ sprintf(buf, "%.2f", physc);
|
|
+}
|
|
+
|
|
+void get_cpu_idle_spurr(struct sysentry *unused_se, char *buf)
|
|
+{
|
|
+ double delta_tb, delta_spurr, delta_idle_spurr;
|
|
+ double physc, idle;
|
|
+ double rfreq;
|
|
+
|
|
+ delta_tb = get_scaled_tb();
|
|
+ delta_spurr = get_delta_value("spurr");
|
|
+ delta_idle_spurr = get_delta_value("idle_spurr");
|
|
+
|
|
+ physc = (delta_spurr - delta_idle_spurr) / delta_tb;
|
|
+ idle = (delta_spurr / delta_tb) - physc;
|
|
+ idle *= 100.00;
|
|
+
|
|
+ rfreq = round_off_freq();
|
|
+ idle += ((idle * rfreq) / 100);
|
|
+
|
|
+ sprintf(buf, "%.2f", idle);
|
|
+}
|
|
+
|
|
int parse_lparcfg()
|
|
{
|
|
FILE *f;
|
|
diff --git a/src/lparstat.h b/src/lparstat.h
|
|
index 5e91d67..9b7117f 100644
|
|
--- a/src/lparstat.h
|
|
+++ b/src/lparstat.h
|
|
@@ -60,6 +60,10 @@ extern void get_cpu_physc(struct sysentry *, char *);
|
|
extern void get_per_entc(struct sysentry *, char *);
|
|
extern void get_cpu_app(struct sysentry *, char *);
|
|
extern void get_sys_uptime(struct sysentry *, char *);
|
|
+extern void get_cpu_util_purr(struct sysentry *unused_se, char *buf);
|
|
+extern void get_cpu_idle_purr(struct sysentry *unused_se, char *buf);
|
|
+extern void get_cpu_util_spurr(struct sysentry *unused_se, char *buf);
|
|
+extern void get_cpu_idle_spurr(struct sysentry *uunused_se, char *buf);
|
|
|
|
struct sysentry system_data[] = {
|
|
/* System Names */
|
|
@@ -280,6 +284,24 @@ struct sysentry system_data[] = {
|
|
{.name = "idle_spurr",
|
|
.descr = "Scaled Processor Utilization Resource Idle Values"},
|
|
|
|
+ /* Dervied from above sysfs values */
|
|
+ /* PURR Utilization */
|
|
+ {.name = "purr_cpu_util",
|
|
+ .descr = "Physical CPU consumed - PURR",
|
|
+ .get = &get_cpu_util_purr},
|
|
+ /* PURR Idle time */
|
|
+ {.name = "purr_cpu_idle",
|
|
+ .descr = "Idle CPU value - PURR",
|
|
+ .get = &get_cpu_idle_purr},
|
|
+ /* SPURR Utilization */
|
|
+ {.name = "spurr_cpu_util",
|
|
+ .descr = "Physical CPU consumed - SPURR",
|
|
+ .get = &get_cpu_util_spurr},
|
|
+ /* SPURR Idle time */
|
|
+ {.name = "spurr_cpu_idle",
|
|
+ .descr = "Idle CPU value - SPURR",
|
|
+ .get = &get_cpu_idle_spurr},
|
|
+
|
|
{.name[0] = '\0'},
|
|
};
|
|
|
|
--
|
|
2.25.3
|
|
|