All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: DRI mailing list <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] xf86drm.c: add counter for ioctl restarting
Date: Fri, 13 Apr 2012 17:45:34 +0300	[thread overview]
Message-ID: <20120413144534.GP4917@intel.com> (raw)
In-Reply-To: <20120413134216.GG4525@phenom.ffwll.local>

On Fri, Apr 13, 2012 at 03:42:16PM +0200, Daniel Vetter wrote:
> On Fri, Apr 13, 2012 at 05:26:42PM +0400, Anton V. Boyarshinov wrote:
> > In some cases ioclt->alarm->ioctl loop can be infinite:
> > ioctl(7, 0x40086482, 0xbfb62738)        = ? ERESTARTSYS (To be restarted)
> > --- SIGALRM (Alarm clock) @ 0 (0) ---
> > sigreturn()                             = ? (mask now [])
> > ioctl(7, 0x40086482, 0xbfb62738)        = ? ERESTARTSYS (To be restarted)
> > and forever.
> > 
> > It seems, that limiting ioctl restarting by some resonable number of trys
> > is a dirty but working way to prevent Xorg lockups.
> > 
> > Signed-off-by: Anton V. Boyarshinov <boyarsh@altlinux.org>
> > ---
> >  xf86drm.c |    3 ++-
> >  1 files changed, 2 insertions(+), 1 deletions(-)
> > 
> > diff --git a/xf86drm.c b/xf86drm.c
> > index 6ea068f..9663f21 100644
> > --- a/xf86drm.c
> > +++ b/xf86drm.c
> > @@ -162,10 +162,11 @@ int
> >  drmIoctl(int fd, unsigned long request, void *arg)
> >  {
> >      int	ret;
> > +    int count=0;
> >  
> >      do {
> >  	ret = ioctl(fd, request, arg);
> > -    } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
> > +    } while (ret == -1 && (errno == EINTR || errno == EAGAIN) && ++count < 100 );
> 
> We rely on restarting after signals when blocking for the gpu, busy gpu
> plus mouse wiggling can easily reach that.
> 
> NACKed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> Obviously if we have a dead gpu, we need to break out of this loop. But
> detecting a dead gpu (and returning an appropriate error like EIO) is the
> kernel's job.

The problem with EINTR is that someone else could be poking at the
device at the same time, causing the restarted ioctls to wait some
more, and again be interrupted by a signal. Or the hardware could
be itself responsible for this problem.

I ran into this issue once with a "wait for vblank" ioctl,
which had a fixed relative timeout value. So every time I would
start to wait, a signal would arrive causing the vblank to be
missed. The restarted ioctl would then start waiting using the
original timeout, allowing the signal to interrupt it again.

Any syscall which has a relative timeout should be desgigned so that
the timeout gets updated by the kernel when interrupted, so that the
originally specified timeout would really be the total timeout.

-- 
Ville Syrjälä
Intel OTC

  reply	other threads:[~2012-04-13 14:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-13 13:26 [PATCH] xf86drm.c: add counter for ioctl restarting Anton V. Boyarshinov
2012-04-13 13:40 ` Chris Wilson
2012-04-16  8:45   ` Anton V. Boyarshinov
2012-04-13 13:42 ` Daniel Vetter
2012-04-13 14:45   ` Ville Syrjälä [this message]
2012-04-16  8:54   ` Anton V. Boyarshinov
2012-04-16 14:12     ` Adam Jackson
2012-04-16 15:05       ` Anton V. Boyarshinov

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=20120413144534.GP4917@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.