mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kalle Kankare <kalle.kankare@vincit.fi>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@redhat.com>, Peter Zijlstra <peterz@infradead.org>
Subject: During high load wait_event_timeout might return a wrong value
Date: Tue, 10 Nov 2015 09:18:12 +0200	[thread overview]
Message-ID: <20151110091812.1e7f326e@kalleka-typewriter> (raw)

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 ?

             reply	other threads:[~2015-11-10  7:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-10  7:18 Kalle Kankare [this message]
2015-11-10 11:09 ` Peter Zijlstra

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=20151110091812.1e7f326e@kalleka-typewriter \
    --to=kalle.kankare@vincit.fi \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.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 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®