[Intel-gfx] [PATCH i-g-t] lib: Use read() for timerfd timeout detection

Chris Wilson chris at chris-wilson.co.uk
Tue Apr 14 21:54:38 UTC 2020


Quoting Dixit, Ashutosh (2020-04-14 22:37:44)
> On Tue, 14 Apr 2020 12:05:09 -0700, Chris Wilson wrote:
> >
> > The poll() is proving unreliable, where our tests timeout without the
> > spinner being terminated. Let's try a blocking read instead!
> 
> Weird, wondering if all we need to do is set TFD_NONBLOCK on the fd?
> 
> >
> > Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/1676
> > Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> > ---
> >  lib/igt_dummyload.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
> > index 99ca84ad8..a59afd45b 100644
> > --- a/lib/igt_dummyload.c
> > +++ b/lib/igt_dummyload.c
> > @@ -399,12 +399,13 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts)
> >  static void *timer_thread(void *data)
> >  {
> >       igt_spin_t *spin = data;
> > -     struct pollfd pfd = {
> > -             .fd = spin->timerfd,
> > -             .events = POLLIN,
> > -     };
> > +     uint64_t overruns = 0;
> > +     int ret;
> >
> > -     if (poll(&pfd, 1, -1) >= 0)
> > +     do {
> > +             ret = read(spin->timerfd, &overruns, sizeof(overruns));
> > +     } while (ret == -1 && errno == EINTR);
> 
> do {} while (!overruns) and skip if () below?

I was concerned with how this should interact with pthread_cancel.
I'm not sure when that causes us to return.
-Chris


More information about the Intel-gfx mailing list