powerpc-utils/0007-lparstat-Add-helper-function-to-calculate-delta.patch
Than Ngo 6119fdc606 - Track and expose idle PURR and SPURR ticks
- ofpathname: speed up l2of_scsi()
- ofpathname: failed to boot
- update lparstat man page with -E option
- enable support for ibm,drc-info property
2020-07-09 15:15:41 +02:00

52 lines
1.5 KiB
Diff

From b79f34df37d605954beaa381e6309d50386434b2 Mon Sep 17 00:00:00 2001
Message-Id: <b79f34df37d605954beaa381e6309d50386434b2.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:02:51 -0500
Subject: [PATCH V4 07/14] lparstat: Add helper function to calculate delta
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>
Add a helper function for one of the most often used arithmetics of
calculating delta of a sysentry.
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
---
src/lparstat.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/lparstat.c b/src/lparstat.c
index 7c55a8c..152e5fa 100644
--- a/src/lparstat.c
+++ b/src/lparstat.c
@@ -226,6 +226,21 @@ static void sig_int_handler(int signal)
exit(1);
}
+long long get_delta_value(char *se_name)
+{
+ long long value, old_value;
+ struct sysentry *se;
+
+ se = get_sysentry(se_name);
+ if (se->value[0] == '\0')
+ return 0LL;
+
+ value = strtoll(se->value, NULL, 0);
+ old_value = strtoll(se->old_value, NULL, 0);
+
+ return (value - old_value);
+}
+
void get_time()
{
struct timeval t;
--
2.25.3