From: Nadav Har'El <n...@scylladb.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

sched: ignore thread in wrong wakeup queue

With this patch, if handle_incoming_wakeups() discovers in a CPU's wakeup
queue a thread which does not actually belong to it, it simply ignores it.

This case should never happen. However, in a following patch we add the
ability to pin (migrate) a waiting thread, and that operating might race
with a wake() of the same thread, resulting in the thread remaining on
the old cpu's wakeup queues, and we better ignore it there.

Signed-off-by: Nadav Har'El <n...@scylladb.com>
Message-Id: <1469628899-5537-1-git-send-email-...@scylladb.com>

---
diff --git a/core/sched.cc b/core/sched.cc
--- a/core/sched.cc
+++ b/core/sched.cc
@@ -443,6 +443,9 @@ void cpu::handle_incoming_wakeups()
                     // Special case of current thread being woken before
                     // having a chance to be scheduled out.
                     t._detached_state->st.store(thread::status::running);
+                } else if (t.tcpu() != this) {
+ // Thread was woken on the wrong cpu. Can be a side-effect
+                    // of sched::thread::pin(thread*, cpu*). Do nothing.
                 } else {
                     t._detached_state->st.store(thread::status::queued);
                     // Make sure the CPU-local runtime measure is suitably

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to