Skip to content

Commit 26bebd5

Browse files
trondmypdgregkh
authored andcommitted
SUNRPC: Don't call __UDPX_INC_STATS() from a preemptible context
[ Upstream commit 0afa6b4 ] Calling __UDPX_INC_STATS() from a preemptible context leads to a warning of the form: BUG: using __this_cpu_add() in preemptible [00000000] code: kworker/u5:0/31 caller is xs_udp_data_receive_workfn+0x194/0x270 CPU: 1 PID: 31 Comm: kworker/u5:0 Not tainted 4.15.0-rc8-00076-g90ea9f1 #2 Workqueue: xprtiod xs_udp_data_receive_workfn Call Trace: dump_stack+0x85/0xc1 check_preemption_disabled+0xce/0xe0 xs_udp_data_receive_workfn+0x194/0x270 process_one_work+0x318/0x620 worker_thread+0x20a/0x390 ? process_one_work+0x620/0x620 kthread+0x120/0x130 ? __kthread_bind_mask+0x60/0x60 ret_from_fork+0x24/0x30 Since we're taking a spinlock in those functions anyway, let's fix the issue by moving the call so that it occurs under the spinlock. Reported-by: kernel test robot <[email protected]> Signed-off-by: Trond Myklebust <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f58e4ec commit 26bebd5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/sunrpc/xprtsock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,18 +1069,18 @@ static void xs_udp_data_read_skb(struct rpc_xprt *xprt,
10691069

10701070
/* Suck it into the iovec, verify checksum if not done by hw. */
10711071
if (csum_partial_copy_to_xdr(&rovr->rq_private_buf, skb)) {
1072-
__UDPX_INC_STATS(sk, UDP_MIB_INERRORS);
10731072
spin_lock(&xprt->recv_lock);
1073+
__UDPX_INC_STATS(sk, UDP_MIB_INERRORS);
10741074
goto out_unpin;
10751075
}
10761076

1077-
__UDPX_INC_STATS(sk, UDP_MIB_INDATAGRAMS);
10781077

10791078
spin_lock_bh(&xprt->transport_lock);
10801079
xprt_adjust_cwnd(xprt, task, copied);
10811080
spin_unlock_bh(&xprt->transport_lock);
10821081
spin_lock(&xprt->recv_lock);
10831082
xprt_complete_rqst(task, copied);
1083+
__UDPX_INC_STATS(sk, UDP_MIB_INDATAGRAMS);
10841084
out_unpin:
10851085
xprt_unpin_rqst(rovr);
10861086
out_unlock:

0 commit comments

Comments
 (0)