[lkml]   [2013]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH/RFC] wait_for_completion_timeout() considered harmful.
On Mon, Nov 18, 2013 at 03:27:46PM -0800, Andrew Morton wrote:
> On Sun, 17 Nov 2013 08:06:03 +1100 NeilBrown <> wrote:
> > It would be reasonable to assume that
> >
> > wait_for_completion_timeout(&wm8350->auxadc_done, msecs_to_jiffies(5));
> >
> > would wait at least 5 msecs for the auxadc_done to complete. But it does not.
> > With a HZ of 200 or less, msecs_to_jiffies(5) has value '1', and so this
> > will only wait until the next "timer tick", which could happen immediately.
> >
> > This can lead to incorrect results - and has done so in out-of-tree patches
> > for drivers/misc/bmp085.c which uses a very similar construct to enable interrupt
> > based result collection.
> >
> > The documentation for several *_timeout* functions claim they will wait for
> > "timeout jiffies" to have elapsed where this is not the case. They will
> > actually wait for "timeout" jiffies to have started implying an elapsed time
> > between (timeout-1) and (timeout).
> >
> > This patch corrects some of this documentation, and adds a collection of
> > wait_for_completion*_msecs()
> > interfaces which wait at least the given number of milliseconds for the
> > completion (or a signal).
> Mutter. wait_for_x(..., 5ms) should wait for a minimum of 5ms, no matter
> what.
> So I'd suggest we make that happen, rather than adding some new interfaces?

Yeah, also the completion interface is just one of many that's buggered
this way.

I briefly talked to Thomas about this earlier today and we need to fix
this at a lower level -- the quick 'n dirty solution is to add 1 jiffy
down in the timer-wheel when we enqueue these things.

And yes, we very much don't want to create new interfaces with similar
but slightly different semantics, that's just asking for trouble.

 \ /
  Last update: 2013-11-19 01:41    [W:0.071 / U:2.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site