[Intel-gfx] [IGT PATCH 1/2] aux: Suspend signal helper for shell commands

Chris Wilson chris at chris-wilson.co.uk
Thu Oct 12 13:51:47 UTC 2017


Quoting Imre Deak (2017-10-12 14:22:06)
> 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.
> 
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Daniel Vetter <daniel.vetter at intel.com>
> Signed-off-by: Imre Deak <imre.deak at intel.com>
> ---
>  lib/igt_aux.c  | 38 ++++++++++++++++++++++++++++++++++++++
>  lib/igt_aux.h  |  2 ++
>  lib/igt_core.c |  9 +++++++++
>  3 files changed, 49 insertions(+)
> 
> diff --git a/lib/igt_aux.c b/lib/igt_aux.c
> index fa6594c3..36dfab43 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 code that has difficulty to make progress if
> + * interrupted frequently, like the clone() syscall spawning a large
> + * 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_suspend_signal_helper:

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);
> +}

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the Intel-gfx mailing list