[igt-dev] [PATCH] lib/igt_dummyload: Use timerfd rather than SIGEV_THREAD

Chris Wilson chris at chris-wilson.co.uk
Tue Mar 31 11:41:55 UTC 2020


Quoting Michał Winiarski (2020-03-31 12:19:11)
> -static void notify(union sigval arg)
> +static void *timer_thread(void *data)
>  {
> -       igt_spin_t *spin = arg.sival_ptr;
> +       igt_spin_t *spin = data;
> +       struct pollfd pfd;
> +       int ret;
>  
> -       igt_spin_end(spin);
> +       pfd.fd = spin->timerfd;
> +       pfd.events = POLLIN;
> +
> +       ret = poll(&pfd, 1, -1);
> +       if (ret >= 0)
> +               igt_spin_end(spin);

uint64_t count;

if (read(spin->timer_fd, &count, sizeof(count)) > 0)
	igt_spin_end(spin);

would suffice. Not sure of the comparative latency.

However, that would allow us to close(spin->timerfd) first in
cancellation, would should report -ECANCELLED quickest.

So overall, I'm left with the worry of a thread per timeout. Though we
do typically only use one spinner timeout at a time, so it's merely the
overhead of creating a thread which should not be significant.

Ok, so just the question of poll() vs read() [and corresponding cleanup
order] and we're good.
-Chris


More information about the igt-dev mailing list