Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-19 Thread Thomas Gleixner
On Tue, 19 Nov 2013, Peter Zijlstra wrote: > On Tue, Nov 19, 2013 at 07:58:51PM +1100, NeilBrown wrote: > > /* > > * TODO: Make sure that we wait at least required delay but why we > > * have to extend it one tick more? > > */ > >

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-19 Thread Peter Zijlstra
On Tue, Nov 19, 2013 at 07:58:51PM +1100, NeilBrown wrote: > /* >* TODO: Make sure that we wait at least required delay but why we >* have to extend it one tick more? >*/ > schedule_timeout_interruptible(msecs_to_jiffies(delay) + 2); What makes me sad is that

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-19 Thread NeilBrown
On Tue, 19 Nov 2013 09:25:48 +0100 Peter Zijlstra wrote: > On Tue, Nov 19, 2013 at 10:44:38AM +1100, NeilBrown wrote: > > We have loops that have > > timeout = schedule_timeout(timeout) > > in the middle and if we change the semantics of schedule_timeout() to round > > up, those loops could

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-19 Thread Peter Zijlstra
On Mon, Nov 18, 2013 at 05:49:02PM -0700, Jonathan Corbet wrote: > On Tue, 19 Nov 2013 00:42:09 +0100 > Peter Zijlstra wrote: > > > 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

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-19 Thread Peter Zijlstra
On Tue, Nov 19, 2013 at 10:44:38AM +1100, NeilBrown wrote: > We have loops that have > timeout = schedule_timeout(timeout) > in the middle and if we change the semantics of schedule_timeout() to round > up, those loops could wait quite a bit longer than expected. Depends on what you expect;

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-19 Thread Peter Zijlstra
On Tue, Nov 19, 2013 at 10:44:38AM +1100, NeilBrown wrote: We have loops that have timeout = schedule_timeout(timeout) in the middle and if we change the semantics of schedule_timeout() to round up, those loops could wait quite a bit longer than expected. Depends on what you expect; most

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-19 Thread Peter Zijlstra
On Mon, Nov 18, 2013 at 05:49:02PM -0700, Jonathan Corbet wrote: On Tue, 19 Nov 2013 00:42:09 +0100 Peter Zijlstra pet...@infradead.org wrote: 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

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-19 Thread NeilBrown
On Tue, 19 Nov 2013 09:25:48 +0100 Peter Zijlstra pet...@infradead.org wrote: On Tue, Nov 19, 2013 at 10:44:38AM +1100, NeilBrown wrote: We have loops that have timeout = schedule_timeout(timeout) in the middle and if we change the semantics of schedule_timeout() to round up, those

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-19 Thread Peter Zijlstra
On Tue, Nov 19, 2013 at 07:58:51PM +1100, NeilBrown wrote: /* * TODO: Make sure that we wait at least required delay but why we * have to extend it one tick more? */ schedule_timeout_interruptible(msecs_to_jiffies(delay) + 2); What makes me sad is that

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-19 Thread Thomas Gleixner
On Tue, 19 Nov 2013, Peter Zijlstra wrote: On Tue, Nov 19, 2013 at 07:58:51PM +1100, NeilBrown wrote: /* * TODO: Make sure that we wait at least required delay but why we * have to extend it one tick more? */ schedule_timeout_interruptible(msecs_to_jiffies(delay)

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-18 Thread Ingo Molnar
* Jonathan Corbet wrote: > On Tue, 19 Nov 2013 00:42:09 +0100 > Peter Zijlstra wrote: > > > 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

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-18 Thread Jonathan Corbet
On Tue, 19 Nov 2013 00:42:09 +0100 Peter Zijlstra wrote: > 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. That can lead to situations like the

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-18 Thread NeilBrown
On Mon, 18 Nov 2013 15:27:46 -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(>auxadc_done, > > msecs_to_jiffies(5)); > > > > would wait at least 5 msecs for the auxadc_done

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-18 Thread Peter Zijlstra
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(>auxadc_done, > > msecs_to_jiffies(5)); > > > > would wait at least 5 msecs for the

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-18 Thread Andrew Morton
On Sun, 17 Nov 2013 08:06:03 +1100 NeilBrown wrote: > It would be reasonable to assume that > > wait_for_completion_timeout(>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,

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-18 Thread Andrew Morton
On Sun, 17 Nov 2013 08:06:03 +1100 NeilBrown ne...@suse.de 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,

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-18 Thread Peter Zijlstra
On Mon, Nov 18, 2013 at 03:27:46PM -0800, Andrew Morton wrote: On Sun, 17 Nov 2013 08:06:03 +1100 NeilBrown ne...@suse.de 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

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-18 Thread NeilBrown
On Mon, 18 Nov 2013 15:27:46 -0800 Andrew Morton a...@linux-foundation.org wrote: On Sun, 17 Nov 2013 08:06:03 +1100 NeilBrown ne...@suse.de wrote: It would be reasonable to assume that wait_for_completion_timeout(wm8350-auxadc_done, msecs_to_jiffies(5)); would wait at

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-18 Thread Jonathan Corbet
On Tue, 19 Nov 2013 00:42:09 +0100 Peter Zijlstra pet...@infradead.org wrote: 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. That can lead to

Re: [PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-18 Thread Ingo Molnar
* Jonathan Corbet cor...@lwn.net wrote: On Tue, 19 Nov 2013 00:42:09 +0100 Peter Zijlstra pet...@infradead.org wrote: 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

[PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-16 Thread NeilBrown
It would be reasonable to assume that wait_for_completion_timeout(>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

[PATCH/RFC] wait_for_completion_timeout() considered harmful.

2013-11-16 Thread NeilBrown
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