From: Trond Myklebust Date: Mon, 25 Mar 2013 15:23:40 +0000 (-0400) Subject: SUNRPC: Add barriers to ensure read ordering in rpc_wake_up_task_queue_locked X-Git-Tag: v3.2.43~48 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4e58995c3f1bedc7acfe5e2d2a9f7deebcbdb82f;p=thirdparty%2Fkernel%2Fstable.git SUNRPC: Add barriers to ensure read ordering in rpc_wake_up_task_queue_locked commit 1166fde6a923c30f4351515b6a9a1efc513e7d00 upstream. We need to be careful when testing task->tk_waitqueue in rpc_wake_up_task_queue_locked, because it can be changed while we are holding the queue->lock. By adding appropriate memory barriers, we can ensure that it is safe to test task->tk_waitqueue for equality if the RPC_TASK_QUEUED bit is set. Signed-off-by: Trond Myklebust Signed-off-by: Ben Hutchings --- diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 18c5a50222105..dc6af2748e25d 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -139,6 +139,8 @@ static void __rpc_add_wait_queue(struct rpc_wait_queue *queue, list_add_tail(&task->u.tk_wait.list, &queue->tasks[0]); task->tk_waitqueue = queue; queue->qlen++; + /* barrier matches the read in rpc_wake_up_task_queue_locked() */ + smp_wmb(); rpc_set_queued(task); dprintk("RPC: %5u added to queue %p \"%s\"\n", @@ -389,8 +391,11 @@ static void __rpc_do_wake_up_task(struct rpc_wait_queue *queue, struct rpc_task */ static void rpc_wake_up_task_queue_locked(struct rpc_wait_queue *queue, struct rpc_task *task) { - if (RPC_IS_QUEUED(task) && task->tk_waitqueue == queue) - __rpc_do_wake_up_task(queue, task); + if (RPC_IS_QUEUED(task)) { + smp_rmb(); + if (task->tk_waitqueue == queue) + __rpc_do_wake_up_task(queue, task); + } } /*