mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* During high load wait_event_timeout might return a wrong value
@ 2015-11-10  7:18 Kalle Kankare
  2015-11-10 11:09 ` Peter Zijlstra
  0 siblings, 1 reply; 2+ messages in thread
From: Kalle Kankare @ 2015-11-10  7:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Peter Zijlstra

Hi,

The problem is that the call to might_sleep might sleep and the return value of wait_event_timeout does not account for the time slept in there.

The might_sleep includes a call to __schedule if CONFIG_PREEMPT_VOLUNTARY is defined.

A problematic scenario can be like the following:

- A driver calls wait_event_timeout with timeout = 10 jiffies, starts sleeping in might_sleep.
- An interrupt handler sets the condition true at 5 jiffies and calls wake_up for the waitqueue.
- Due to high load the might_sleep wakes up at 100 jiffies.
- In the next if the __wait_cond_timeout returns 1 without manipulating __ret.
- wait_event_timeout returns 10 where it should have returned 1 to denote that a timeout was reached.

Or am I misunderstanding what the return value should be ?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-10 11:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-10  7:18 During high load wait_event_timeout might return a wrong value Kalle Kankare
2015-11-10 11:09 ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®