Patch "SUNRPC: Fix a race to wake a sync task" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    SUNRPC: Fix a race to wake a sync task

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     sunrpc-fix-a-race-to-wake-a-sync-task.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit bc5c75d2572217d6c2172157e14058c1e89d5727
Author: Benjamin Coddington <bcodding@xxxxxxxxxx>
Date:   Wed Jul 17 10:49:33 2024 -0400

    SUNRPC: Fix a race to wake a sync task
    
    [ Upstream commit ed0172af5d6fc07d1b40ca82f5ca3979300369f7 ]
    
    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@xxxxxxxxxx>
    Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 9af919364a001..92d88aa62085b 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -349,8 +349,10 @@ static void rpc_make_runnable(struct workqueue_struct *wq,
 	if (RPC_IS_ASYNC(task)) {
 		INIT_WORK(&task->u.tk_work, rpc_async_schedule);
 		queue_work(wq, &task->u.tk_work);
-	} else
+	} else {
+		smp_mb__after_atomic();
 		wake_up_bit(&task->tk_runstate, RPC_TASK_QUEUED);
+	}
 }
 
 /*




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux