All of lore.kernel.org
 help / color / mirror / Atom feed
* add_wait_queue() (unintentional?) behavior change in v4.13
@ 2017-11-30  0:58 Omar Sandoval
  2017-11-30  2:37 ` Linus Torvalds
  2017-12-06  2:35 ` Fubo Chen
  0 siblings, 2 replies; 8+ messages in thread
From: Omar Sandoval @ 2017-11-30  0:58 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linus Torvalds, linux-kernel, Jens Axboe

Hi, Ingo,

Commit 50816c48997a ("sched/wait: Standardize internal naming of
wait-queue entries") changed the behavior of add_wait_queue() from
inserting the wait entry at the head of the wait queue to the tail of
the wait queue. This is the relevant hunk:

-void add_wait_queue(wait_queue_head_t *q, wait_queue_entry_t *wait)
+void add_wait_queue(wait_queue_head_t *q, struct wait_queue_entry *wq_entry)
 {
        unsigned long flags;

-       wait->flags &= ~WQ_FLAG_EXCLUSIVE;
+       wq_entry->flags &= ~WQ_FLAG_EXCLUSIVE;
        spin_lock_irqsave(&q->lock, flags);
-       __add_wait_queue(q, wait);
+       __add_wait_queue_entry_tail(q, wq_entry);
        spin_unlock_irqrestore(&q->lock, flags);
 }
 EXPORT_SYMBOL(add_wait_queue);

Note the change from __add_wait_queue() to
__add_wait_queue_entry_tail(). I'm assuming this was a typo since the
commit message doesn't mention any functional changes. This patch
restores the old behavior:

diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c
index 98feab7933c7..929ecb7d6b78 100644
--- a/kernel/sched/wait.c
+++ b/kernel/sched/wait.c
@@ -27,7 +27,7 @@ void add_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq
 
 	wq_entry->flags &= ~WQ_FLAG_EXCLUSIVE;
 	spin_lock_irqsave(&wq_head->lock, flags);
-	__add_wait_queue_entry_tail(wq_head, wq_entry);
+	__add_wait_queue(wq_head, wq_entry);
 	spin_unlock_irqrestore(&wq_head->lock, flags);
 }
 EXPORT_SYMBOL(add_wait_queue);

I didn't go through and audit callers of add_wait_queue(), but from a
quick code read this makes it so that non-exclusive waiters will not be
woken up if they are behind enough exclusive waiters, and I bet that'll
cause some bugs.

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

end of thread, other threads:[~2017-12-06 20:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-30  0:58 add_wait_queue() (unintentional?) behavior change in v4.13 Omar Sandoval
2017-11-30  2:37 ` Linus Torvalds
2017-12-06  7:15   ` [PATCH] sched/wait: fix add_wait_queue() behavior change Omar Sandoval
2017-12-06 16:11     ` Jens Axboe
2017-12-06 16:46       ` Ingo Molnar
2017-12-06 20:28     ` [tip:sched/core] sched/wait: Fix add_wait_queue() behavioral change tip-bot for Omar Sandoval
2017-12-06 16:43   ` add_wait_queue() (unintentional?) behavior change in v4.13 Ingo Molnar
2017-12-06  2:35 ` Fubo Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.