diff options
author | Wei Hu <whu@FreeBSD.org> | 2023-10-20 08:58:20 +0000 |
---|---|---|
committer | Wei Hu <whu@FreeBSD.org> | 2023-10-20 09:15:21 +0000 |
commit | 49fa9a64372b087cfd66459a20f4ffd25464b6a3 (patch) | |
tree | fc124c6e967990e3f35a829ba9c251108279e5f2 | |
parent | c1146e6ad67fb866c2472a1cbe5609fd939fd5ef (diff) | |
download | src-49fa9a64372b087cfd66459a20f4ffd25464b6a3.tar.gz src-49fa9a64372b087cfd66459a20f4ffd25464b6a3.zip |
Hyper-V: vmbus: check if signaling host is needed in vmbus_rxbr_read
It is observed that netvsc's send rings could stall on the latest
Azure Boost platforms. This is due to vmbus_rxbr_read() routine
doesn't check if host is waiting for more room to put data, which
leads to host side sleeping forever on this vmbus channel. The
problem was only observed on the latest platform because the host
requests larger buffer ring room to be available, which causes
the issue to happen much more easily.
Fix this by adding check in the vmbus_rxbr_read call and signaling
the host in the callers if check returns positively.
Reported by: NetApp
Tested by: whu
MFC after: 3 days
Sponsored by: Microsoft
-rw-r--r-- | sys/dev/hyperv/vmbus/vmbus_br.c | 9 | ||||
-rw-r--r-- | sys/dev/hyperv/vmbus/vmbus_brvar.h | 2 | ||||
-rw-r--r-- | sys/dev/hyperv/vmbus/vmbus_chan.c | 12 |
3 files changed, 19 insertions, 4 deletions
diff --git a/sys/dev/hyperv/vmbus/vmbus_br.c b/sys/dev/hyperv/vmbus/vmbus_br.c index 27adf71fd6ea..f663bb7c2ba5 100644 --- a/sys/dev/hyperv/vmbus/vmbus_br.c +++ b/sys/dev/hyperv/vmbus/vmbus_br.c @@ -684,7 +684,8 @@ vmbus_rxbr_idxadv(struct vmbus_rxbr *rbr, uint32_t idx_adv, * We assume (dlen + skip) == sizeof(channel packet). */ int -vmbus_rxbr_read(struct vmbus_rxbr *rbr, void *data, int dlen, uint32_t skip) +vmbus_rxbr_read(struct vmbus_rxbr *rbr, void *data, int dlen, uint32_t skip, + boolean_t *need_sig) { uint32_t rindex, br_dsize = rbr->rxbr_dsize; @@ -717,5 +718,11 @@ vmbus_rxbr_read(struct vmbus_rxbr *rbr, void *data, int dlen, uint32_t skip) mtx_unlock_spin(&rbr->rxbr_lock); + if (need_sig) { + *need_sig = + vmbus_rxbr_need_signal(rbr, + dlen + skip + sizeof(uint64_t)); + } + return (0); } diff --git a/sys/dev/hyperv/vmbus/vmbus_brvar.h b/sys/dev/hyperv/vmbus/vmbus_brvar.h index 8593c1886b0f..a04169f3291c 100644 --- a/sys/dev/hyperv/vmbus/vmbus_brvar.h +++ b/sys/dev/hyperv/vmbus/vmbus_brvar.h @@ -129,7 +129,7 @@ void vmbus_rxbr_deinit(struct vmbus_rxbr *rbr); void vmbus_rxbr_setup(struct vmbus_rxbr *rbr, void *buf, int blen); int vmbus_rxbr_peek(struct vmbus_rxbr *rbr, void *data, int dlen); int vmbus_rxbr_read(struct vmbus_rxbr *rbr, void *data, int dlen, - uint32_t skip); + uint32_t skip, boolean_t *need_sig); int vmbus_rxbr_idxadv(struct vmbus_rxbr *rbr, uint32_t idx_adv, boolean_t *need_sig); int vmbus_rxbr_idxadv_peek(struct vmbus_rxbr *rbr, void *data, diff --git a/sys/dev/hyperv/vmbus/vmbus_chan.c b/sys/dev/hyperv/vmbus/vmbus_chan.c index d5c4d357e9ec..ecb2e947c953 100644 --- a/sys/dev/hyperv/vmbus/vmbus_chan.c +++ b/sys/dev/hyperv/vmbus/vmbus_chan.c @@ -1205,6 +1205,7 @@ vmbus_chan_recv(struct vmbus_channel *chan, void *data, int *dlen0, { struct vmbus_chanpkt_hdr pkt; int error, dlen, hlen; + boolean_t sig_event; error = vmbus_rxbr_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); if (error) @@ -1235,9 +1236,12 @@ vmbus_chan_recv(struct vmbus_channel *chan, void *data, int *dlen0, *dlen0 = dlen; /* Skip packet header */ - error = vmbus_rxbr_read(&chan->ch_rxbr, data, dlen, hlen); + error = vmbus_rxbr_read(&chan->ch_rxbr, data, dlen, hlen, &sig_event); KASSERT(!error, ("vmbus_rxbr_read failed")); + if (!error && sig_event) + vmbus_chan_signal_rx(chan); + return (0); } @@ -1246,6 +1250,7 @@ vmbus_chan_recv_pkt(struct vmbus_channel *chan, struct vmbus_chanpkt_hdr *pkt, int *pktlen0) { int error, pktlen, pkt_hlen; + boolean_t sig_event; pkt_hlen = sizeof(*pkt); error = vmbus_rxbr_peek(&chan->ch_rxbr, pkt, pkt_hlen); @@ -1277,9 +1282,12 @@ vmbus_chan_recv_pkt(struct vmbus_channel *chan, * by the above vmbus_rxbr_peek(). */ error = vmbus_rxbr_read(&chan->ch_rxbr, pkt + 1, - pktlen - pkt_hlen, pkt_hlen); + pktlen - pkt_hlen, pkt_hlen, &sig_event); KASSERT(!error, ("vmbus_rxbr_read failed")); + if (!error && sig_event) + vmbus_chan_signal_rx(chan); + return (0); } |