From e984b97db0f5a21006baa3eaf877cccee8cbd95c Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Tue, 16 Jan 2024 12:13:49 +0100 Subject: [PATCH] s390-tools/cpumf: set exit code on pai data collection error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When pai records data it may fail in select() system call. This error is not reported and the pai program exits with success. Change this and exit with proper exit code. Fixes: d7b1cbad8b10 ("cpumf/pai: Add Processor Activity Instrumentation tool") Signed-off-by: Thomas Richter Acked-by: Sumanth Korikkar Signed-off-by: Jan Höppner --- cpumf/pai.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cpumf/pai.c b/cpumf/pai.c index 4c60e54c..9e794eab 100644 --- a/cpumf/pai.c +++ b/cpumf/pai.c @@ -320,7 +320,7 @@ static void readmap(int fd) * ring buffer per event, sleep some short time and always read all * ring buffer for new contents. */ -static void collect(unsigned long cnt) +static int collect(unsigned long cnt) { fd_set r_fds, e_fds, a_fds; struct pai_event *p; @@ -328,6 +328,7 @@ static void collect(unsigned long cnt) int rc, max_fd; do { + rc = -1; max_fd = -1; tv.tv_sec = read_interval / 1000; tv.tv_usec = (1000 * read_interval) % 1000000; @@ -357,6 +358,7 @@ static void collect(unsigned long cnt) } } } while (rc != -1 && --cnt > 0); + return rc; } static void lookup_event(__u64 evtnum, __u16 ctr, __u64 value) @@ -1123,12 +1125,12 @@ int main(int argc, char **argv) ev_install(group); ev_enable(); - collect(loop_count); + ch = collect(loop_count); ev_disable(); ev_deinstall(); ev_dealloc(); - return EXIT_SUCCESS; + return ch < 0 ? EXIT_FAILURE : EXIT_SUCCESS; } /* Must be reporting */