Date: Tue, 4 Feb 2025 13:52:03 GMT From: Wei Hu <whu@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: da1deb784d9a - main - Hyper-V: hn: rewrite hn rsc swtich to avoid sysctl hang Message-ID: <202502041352.514Dq3tT007031@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=da1deb784d9ad3a4015a3f91fa1a5ce394fd3fdb commit da1deb784d9ad3a4015a3f91fa1a5ce394fd3fdb Author: Wei Hu <whu@FreeBSD.org> AuthorDate: 2025-02-04 13:39:14 +0000 Commit: Wei Hu <whu@FreeBSD.org> CommitDate: 2025-02-04 13:39:14 +0000 Hyper-V: hn: rewrite hn rsc swtich to avoid sysctl hang Changing the rsc_switch flag using sysctl to turn rsc on or off could hang. The orignal code sends request to host to get the mtu setting. Sometimes the host fails to reply, causing the thread to sleep forever waiting for the host response. Use existing cached mtu from hn device instead to avoid calling host. Reported by: whu Tested by: whu MFC after: 1 week --- sys/dev/hyperv/netvsc/if_hn.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index 212b6bc0ff57..ab7671025107 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -2355,7 +2355,7 @@ hn_attach(device_t dev) } SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rsc_switch", - CTLTYPE_UINT | CTLFLAG_RW, sc, 0, hn_rsc_sysctl, "A", + CTLTYPE_UINT | CTLFLAG_RW, sc, 0, hn_rsc_sysctl, "I", "switch to rsc"); /* @@ -4523,24 +4523,22 @@ static int hn_rsc_sysctl(SYSCTL_HANDLER_ARGS) { struct hn_softc *sc = arg1; - uint32_t mtu; + int rsc_ctrl, mtu; int error; - HN_LOCK(sc); - error = hn_rndis_get_mtu(sc, &mtu); - if (error) { - if_printf(sc->hn_ifp, "failed to get mtu\n"); - goto back; - } - error = SYSCTL_OUT(req, &(sc->hn_rsc_ctrl), sizeof(sc->hn_rsc_ctrl)); + + rsc_ctrl = sc->hn_rsc_ctrl; + error = sysctl_handle_int(oidp, &rsc_ctrl, 0, req); if (error || req->newptr == NULL) - goto back; + return (error); + + if (sc->hn_rsc_ctrl != rsc_ctrl) { + HN_LOCK(sc); + sc->hn_rsc_ctrl = rsc_ctrl; + mtu = if_getmtu(sc->hn_ifp); + error = hn_rndis_reconf_offload(sc, mtu); + HN_UNLOCK(sc); + } - error = SYSCTL_IN(req, &(sc->hn_rsc_ctrl), sizeof(sc->hn_rsc_ctrl)); - if (error) - goto back; - error = hn_rndis_reconf_offload(sc, mtu); -back: - HN_UNLOCK(sc); return (error); } #ifndef RSS
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202502041352.514Dq3tT007031>