Skip to content

Commit

Permalink
poll/select: initialize triggered field of struct poll_wqueues
Browse files Browse the repository at this point in the history
The triggered field of struct poll_wqueues introduced in commit
5f820f6 ("poll: allow f_op->poll to
sleep").

It was first set to 1 in pollwake() (now __pollwake() ), tested and
later set to 0 in poll_schedule_timeout(), but not initialized before.

As a result when the process needs to sleep, triggered was likely to be
non-zero even if pollwake() is not called before the first
poll_schedule_timeout(), meaning schedule_hrtimeout_range() would not be
called and an extra loop calling all ->poll() would be done.

This patch initialize triggered to 0 in poll_initwait() so the ->poll()
are not called twice before the process goes to sleep when it needs to.

Signed-off-by: Guillaume Knispel <gknispel@proformatique.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Guillaume Knispel authored and Linus Torvalds committed Aug 16, 2009
1 parent 5d12dc1 commit b2add73
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions fs/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ void poll_initwait(struct poll_wqueues *pwq)
{
init_poll_funcptr(&pwq->pt, __pollwait);
pwq->polling_task = current;
pwq->triggered = 0;
pwq->error = 0;
pwq->table = NULL;
pwq->inline_index = 0;
Expand Down

0 comments on commit b2add73

Please sign in to comment.