summaryrefslogtreecommitdiff
path: root/lib/igt_aux.c
diff options
context:
space:
mode:
authorImre Deak <imre.deak@intel.com>2017-10-13 14:30:08 +0300
committerImre Deak <imre.deak@intel.com>2017-10-16 13:35:36 +0300
commit40d6f19ff9c1d052c860365a98a8a074d5671142 (patch)
treec1d67948079af574a9546597e51a303dc94380d4 /lib/igt_aux.c
parentfb3bdfff0e90c6d8b20b6b7b3e044d19efeab38f (diff)
aux: Suspend signal helper for shell commands
The clone() system call with a larger executable (like /bin/sh) may have difficulty to make progress on some platforms if interrupted frequently. So suspend the signal helper process for the duration of the syscall. This is needed to solve an actual problem by the next patch. v2: - Clarify/fix code comments. (Chris) - Update igt_system_quiet() as well accordingly. Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Daniel Vetter <daniel.vetter@intel.com> Signed-off-by: Imre Deak <imre.deak@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> (v1)
Diffstat (limited to 'lib/igt_aux.c')
-rw-r--r--lib/igt_aux.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index fa6594c3..8dde9a12 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -350,6 +350,44 @@ void igt_stop_signal_helper(void)
sig_stat = 0;
}
+/**
+ * igt_suspend_signal_helper:
+ *
+ * Suspends the child process spawned with igt_fork_signal_helper(). This
+ * should be called before a critical section of code that has difficulty to
+ * make progress if interrupted frequently, like the clone() syscall called
+ * from a largish executable. igt_resume_signal_helper() must be called after
+ * the critical section to restart interruptions for the test.
+ */
+void igt_suspend_signal_helper(void)
+{
+ int status;
+
+ if (!signal_helper.running)
+ return;
+
+ kill(signal_helper.pid, SIGSTOP);
+ while (waitpid(signal_helper.pid, &status, WUNTRACED) == -1 &&
+ errno == EINTR)
+ ;
+}
+
+/**
+ * igt_resume_signal_helper:
+ *
+ * Resumes the child process spawned with igt_fork_signal_helper().
+ *
+ * This should be paired with igt_suspend_signal_helper() and called after the
+ * problematic code sensitive to signals.
+ */
+void igt_resume_signal_helper(void)
+{
+ if (!signal_helper.running)
+ return;
+
+ kill(signal_helper.pid, SIGCONT);
+}
+
static struct igt_helper_process shrink_helper;
static void __attribute__((noreturn)) shrink_helper_process(int fd, pid_t pid)
{