diff options
author | Dmitry Chagin <dchagin@FreeBSD.org> | 2023-05-29 08:09:17 +0000 |
---|---|---|
committer | Dmitry Chagin <dchagin@FreeBSD.org> | 2023-05-29 08:09:17 +0000 |
commit | 723e25f12893ea6af0c387b0a5070451cc79e20b (patch) | |
tree | 42a97612dbed228925c110a87c9828dbc170d1e2 | |
parent | 0a09cfb3f7664a2f573b57ffe876539da0e8c637 (diff) | |
download | src-723e25f12893ea6af0c387b0a5070451cc79e20b.tar.gz src-723e25f12893ea6af0c387b0a5070451cc79e20b.zip |
avx_sig: Print statistics by interval enstead of by pressing ^T
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D40311
-rw-r--r-- | tools/test/avx_sig/avx_sig.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/tools/test/avx_sig/avx_sig.c b/tools/test/avx_sig/avx_sig.c index 2cfc535c3e2f..6c6250f1c25d 100644 --- a/tools/test/avx_sig/avx_sig.c +++ b/tools/test/avx_sig/avx_sig.c @@ -36,6 +36,11 @@ #include <string.h> #include <unistd.h> +/* SIGALRM interval in seconds. */ +#ifndef TIMO +#define TIMO 5 +#endif + #ifndef __unused #define __unused __attribute__((__unused__)) #endif @@ -79,19 +84,17 @@ sigusr1_handler(int sig __unused, siginfo_t *si __unused, void *m __unused) atomic_fetch_add_explicit(&sigs, 1, memory_order_relaxed); } -#ifdef SIGINFO static void -siginfo_handler(int sig __unused) +sigalrm_handler(int sig __unused) { struct rusage r; if (getrusage(RUSAGE_SELF, &r) == 0) { - printf("%lu vctx %lu nvctx %lu nsigs ", - r.ru_nvcsw, r.ru_nivcsw, r.ru_nsignals); + printf("%lu vctx %lu nvctx %lu nsigs %u SIGUSR1\n", + r.ru_nvcsw, r.ru_nivcsw, r.ru_nsignals, sigs); } - printf("%u SIGUSR1\n", sigs); + alarm(TIMO); } -#endif static struct xmm zero_xmm = {}; @@ -183,14 +186,12 @@ main(void) struct sigaction sa; int error, i, ncpu; -#ifdef SIGINFO bzero(&sa, sizeof(sa)); - sa.sa_handler = siginfo_handler; - if (sigaction(SIGINFO, &sa, NULL) == -1) { - fprintf(stderr, "sigaction SIGINFO %s\n", strerror(errno)); + sa.sa_handler = sigalrm_handler; + if (sigaction(SIGALRM, &sa, NULL) == -1) { + fprintf(stderr, "sigaction SIGALRM %s\n", strerror(errno)); exit(1); } -#endif bzero(&sa, sizeof(sa)); sa.sa_sigaction = sigusr1_handler; @@ -216,6 +217,7 @@ main(void) } } + alarm(TIMO); for (;;) { for (i = 0; i < ncpu; i++) { my_pause(); |