git: d0891e9cae62 - stable/13 - Hyper-V: vmbus: check if signaling host is needed in vmbus_rxbr_read
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 20 Oct 2023 10:34:37 UTC
The branch stable/13 has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=d0891e9cae629afebe1997c8912b79375221d9ac commit d0891e9cae629afebe1997c8912b79375221d9ac Author: Wei Hu <whu@FreeBSD.org> AuthorDate: 2023-10-20 08:58:20 +0000 Commit: Wei Hu <whu@FreeBSD.org> CommitDate: 2023-10-20 10:22:55 +0000 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 Sponsored by: Microsoft (cherry picked from commit 49fa9a64372b087cfd66459a20f4ffd25464b6a3) --- sys/dev/hyperv/vmbus/vmbus_br.c | 9 ++++++++- sys/dev/hyperv/vmbus/vmbus_brvar.h | 2 +- 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 997a5de1b230..6418f8e59cf8 100644 --- a/sys/dev/hyperv/vmbus/vmbus_br.c +++ b/sys/dev/hyperv/vmbus/vmbus_br.c @@ -682,7 +682,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; @@ -714,5 +715,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 883b74e92d95..97bdc12d80cb 100644 --- a/sys/dev/hyperv/vmbus/vmbus_brvar.h +++ b/sys/dev/hyperv/vmbus/vmbus_brvar.h @@ -127,7 +127,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 85f87a5dbf99..ff42f75a883f 100644 --- a/sys/dev/hyperv/vmbus/vmbus_chan.c +++ b/sys/dev/hyperv/vmbus/vmbus_chan.c @@ -1201,6 +1201,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) @@ -1231,9 +1232,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); } @@ -1242,6 +1246,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); @@ -1273,9 +1278,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); }