Skip to content

Commit 016e40b

Browse files
committed
SUNRPC: Fix a race to wake a sync task
jira LE-3201 Rebuild_History Non-Buildable kernel-rt-4.18.0-553.22.1.rt7.363.el8_10 commit-author Benjamin Coddington <bcodding@redhat.com> commit ed0172a We've observed NFS clients with sync tasks sleeping in __rpc_execute waiting on RPC_TASK_QUEUED that have not responded to a wake-up from rpc_make_runnable(). I suspect this problem usually goes unnoticed, because on a busy client the task will eventually be re-awoken by another task completion or xprt event. However, if the state manager is draining the slot table, a sync task missing a wake-up can result in a hung client. We've been able to prove that the waker in rpc_make_runnable() successfully calls wake_up_bit() (ie- there's no race to tk_runstate), but the wake_up_bit() call fails to wake the waiter. I suspect the waker is missing the load of the bit's wait_queue_head, so waitqueue_active() is false. There are some very helpful comments about this problem above wake_up_bit(), prepare_to_wait(), and waitqueue_active(). Fix this by inserting smp_mb__after_atomic() before the wake_up_bit(), which pairs with prepare_to_wait() calling set_current_state(). Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> (cherry picked from commit ed0172a) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent b836ad7 commit 016e40b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/sunrpc/sched.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,10 @@ static void rpc_make_runnable(struct workqueue_struct *wq,
362362
if (RPC_IS_ASYNC(task)) {
363363
INIT_WORK(&task->u.tk_work, rpc_async_schedule);
364364
queue_work(wq, &task->u.tk_work);
365-
} else
365+
} else {
366+
smp_mb__after_atomic();
366367
wake_up_bit(&task->tk_runstate, RPC_TASK_QUEUED);
368+
}
367369
}
368370

369371
/*

0 commit comments

Comments
 (0)