rteval-loads/SOURCES/0007-stress-mq-add-SIGEV_SIGNAL-events-to-exercise-kernel.patch
2022-02-03 05:25:55 +00:00

80 lines
2.0 KiB
Diff

From ed1ec01953a173f45d930e923b2e23daa5a1dc00 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Mon, 18 May 2020 10:38:19 +0100
Subject: [PATCH 07/28] stress-mq: add SIGEV_SIGNAL events to exercise kernel
Increase kernel coverage by also using SIGEV_SIGNAL mq events
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-mq.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/stress-mq.c b/stress-mq.c
index 2424748bb055..9b46a4683e77 100644
--- a/stress-mq.c
+++ b/stress-mq.c
@@ -62,6 +62,13 @@ static void stress_mq_notify_func(union sigval s)
(void)s;
}
+#if defined(SIGUSR2)
+static void MLOCKED_TEXT stress_sigusr2_handler(int signum)
+{
+ (void)signum;
+}
+#endif
+
/*
* stress_mq
* stress POSIX message queues
@@ -78,6 +85,11 @@ static int stress_mq(const stress_args_t *args)
time_t time_start;
struct timespec abs_timeout;
+#if defined(SIGUSR2)
+ if (stress_sighandler(args->name, SIGUSR2, stress_sigusr2_handler, NULL) < 0)
+ return EXIT_NO_RESOURCE;
+#endif
+
if (!stress_get_setting("mq-size", &mq_size)) {
if (g_opt_flags & OPT_FLAGS_MAXIMIZE)
mq_size = MAX_MQ_SIZE;
@@ -159,10 +171,6 @@ again:
struct sigevent sigev;
uint64_t values[PRIOS_MAX];
- (void)memset(&sigev, 0, sizeof sigev);
- sigev.sigev_notify = SIGEV_THREAD;
- sigev.sigev_notify_function = stress_mq_notify_func;
- sigev.sigev_notify_attributes = NULL;
(void)setpgid(0, g_pgrp);
stress_parent_died_alarm();
@@ -203,6 +211,22 @@ again:
args->name, errno, strerror(errno));
#endif
+ (void)memset(&sigev, 0, sizeof sigev);
+ switch (stress_mwc1()) {
+ case 0:
+#if defined(SIGUSR2)
+ sigev.sigev_notify = SIGEV_SIGNAL;
+ sigev.sigev_signo = SIGUSR2;
+ break;
+#else
+ CASE_FALLTHROUGH;
+#endif
+ default:
+ sigev.sigev_notify = SIGEV_THREAD;
+ sigev.sigev_notify_function = stress_mq_notify_func;
+ sigev.sigev_notify_attributes = NULL;
+ break;
+ }
(void)mq_notify(mq, &sigev);
}
--
2.21.3