public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/3] Wait for any pid in order to reap failure quicker
Date: Fri, 11 Jul 2014 12:56:43 +0100	[thread overview]
Message-ID: <53BFD0FB.3060505@linux.intel.com> (raw)
In-Reply-To: <1405071640-29692-1-git-send-email-chris@chris-wilson.co.uk>


On 07/11/2014 10:40 AM, Chris Wilson wrote:
> When waiting for the forked tests, we can respond quicker to a failure
> (such as oom) by waiting for any child to exit rather than waiting for
> each child in order. Then when we see that a test failed, we can kill
> all other children before aborting.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>   lib/igt_core.c | 42 +++++++++++++++++++++++++++++++-----------
>   1 file changed, 31 insertions(+), 11 deletions(-)
>
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 7ac7ebe..e5dc78b 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -915,32 +915,52 @@ bool __igt_fork(void)
>    */
>   void igt_waitchildren(void)
>   {
> +	int err = 0;
> +	int count;
> +
>   	assert(!test_child);
>
> -	for (int nc = 0; nc < num_test_children; nc++) {
> +	count = 0;
> +	while (count < num_test_children) {
>   		int status = -1;
> -		while (waitpid(test_children[nc], &status, 0) == -1 &&
> -		       errno == EINTR)
> -			;
> +		pid_t pid;
> +		int c;
>
> -		if (status != 0) {
> +		pid = wait(&status);
> +		if (pid == -1)
> +			continue;

Not sure if it would make sense to be more defensive and maybe assert on 
some errors from wait(2) here (like ECHILD). But it is the same as 
before the patch so doesn't really matter.

> +
> +		for (c = 0; c < num_test_children; c++)
> +			if (pid == test_children[c])
> +				break;
> +		if (c == num_test_children)
> +			continue;
> +
> +		if (err == 0 && status != 0) {
>   			if (WIFEXITED(status)) {
>   				printf("child %i failed with exit status %i\n",
> -				       nc, WEXITSTATUS(status));
> -				igt_fail(WEXITSTATUS(status));
> +				       c, WEXITSTATUS(status));
> +				err = WEXITSTATUS(status);
>   			} else if (WIFSIGNALED(status)) {
>   				printf("child %i died with signal %i, %s\n",
> -				       nc, WTERMSIG(status),
> +				       c, WTERMSIG(status),
>   				       strsignal(WTERMSIG(status)));
> -				igt_fail(99);
> +				err = 128 + WTERMSIG(status);
>   			} else {
> -				printf("Unhandled failure in child %i\n", nc);
> -				abort();
> +				printf("Unhandled failure [%d] in child %i\n", status, c);
> +				err = 256;
>   			}
> +
> +			for (c = 0; c < num_test_children; c++)
> +				kill(test_children[c], SIGKILL);
>   		}
> +
> +		count++;
>   	}
>
>   	num_test_children = 0;
> +	if (err)
> +		igt_fail(err);
>   }
>
>   /* exit handler code */
>

Looks fine.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

      parent reply	other threads:[~2014-07-11 11:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-11  9:40 [PATCH 1/3] Wait for any pid in order to reap failure quicker Chris Wilson
2014-07-11  9:40 ` [PATCH 2/3] igt/gem_userptr_blits: Shared memory allocations Chris Wilson
2014-07-11 10:30   ` Tvrtko Ursulin
2014-07-11  9:40 ` [PATCH 3/3] igt/gem_userptr_blits: Verify that userptr bo work on unshared memory Chris Wilson
2014-07-11 10:45   ` Tvrtko Ursulin
2014-07-11 11:56 ` Tvrtko Ursulin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53BFD0FB.3060505@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox