From 6e17009c7e4276b3a90aada07e7c9835e9a788be Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 23 Oct 2014 11:27:58 -0400 Subject: [PATCH] workqueue: ensure worker is removed from waitqueue upon unregister Signed-off-by: Mathieu Desnoyers --- urcu/workqueue-fifo.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/urcu/workqueue-fifo.h b/urcu/workqueue-fifo.h index 6256bff..1292e04 100644 --- a/urcu/workqueue-fifo.h +++ b/urcu/workqueue-fifo.h @@ -159,13 +159,10 @@ void urcu_worker_unregister(struct urcu_workqueue *queue, } /* - * Wait for grace period before freeing or reusing - * "worker" because used by RCU linked list. - * Also prevents ABA for waitqueue stack dequeue: matches RCU - * read-side critical sections around dequeue and move all - * operations on waitqueue). + * Make sure we are removed from waitqueue. */ - synchronize_rcu(); + if (CMM_LOAD_SHARED(worker->wait_node.node.next)) + __urcu_workqueue_wakeup_all(queue); /* * Put any local work we still have back into the workqueue. @@ -184,6 +181,15 @@ void urcu_worker_unregister(struct urcu_workqueue *queue, (void) urcu_dequeue_wake_single(&queue->waitqueue); rcu_read_unlock(); /* Protect stack dequeue */ } + + /* + * Wait for grace period before freeing or reusing + * "worker" because used by RCU linked list. + * Also prevents ABA for waitqueue stack dequeue: matches RCU + * read-side critical sections around dequeue and move all + * operations on waitqueue). + */ + synchronize_rcu(); } /* -- 2.34.1