powerpc-utils/SOURCES/0009-lparstat-Add-helper-to-calculate-scaled-timebase.patch
2021-11-25 11:51:14 +00:00

58 lines
1.7 KiB
Diff

From 39cb3fba241a3fa77be3b3065e638aa4d807dae7 Mon Sep 17 00:00:00 2001
Message-Id: <39cb3fba241a3fa77be3b3065e638aa4d807dae7.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:06:40 -0500
Subject: [PATCH V4 09/14] lparstat: Add helper to calculate scaled timebase
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>
Timebase is used to derive system wide CPU utilization, scale it to
the number of online cores too like the PURR/SPURR registers values
accumulated across all online CPU cores. This helper also scales the
timebase register value to the interval passed.
Timebase = (Timebase * Elapsed Time) * online cores
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
---
src/lparstat.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/lparstat.c b/src/lparstat.c
index 0f9dffc..7628afa 100644
--- a/src/lparstat.c
+++ b/src/lparstat.c
@@ -294,6 +294,23 @@ int get_time_base()
return 0;
}
+double get_scaled_tb(void)
+{
+ double elapsed, timebase;
+ struct sysentry *se;
+ int online_cores;
+
+ se = get_sysentry("online_cores");
+ online_cores = atoi(se->value);
+
+ elapsed = elapsed_time() / 1000000.0;
+
+ se = get_sysentry("timebase");
+ timebase = atoi(se->value);
+
+ return (timebase * elapsed) * online_cores;
+}
+
void get_sys_uptime(struct sysentry *unused_se, char *uptime)
{
FILE *f;
--
2.25.3