summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcheloha <cheloha@openbsd.org>2020-12-04 18:05:26 +0000
committercheloha <cheloha@openbsd.org>2020-12-04 18:05:26 +0000
commitb6a411b5fdd3d66559c59c9d53afc82589d3d4a2 (patch)
treea4ed81372f43ea4cdf30e61235e156253b3e18ce
parentsync (diff)
downloadwireguard-openbsd-b6a411b5fdd3d66559c59c9d53afc82589d3d4a2.tar.xz
wireguard-openbsd-b6a411b5fdd3d66559c59c9d53afc82589d3d4a2.zip
hvn(4): msleep(9) -> msleep_nsec(9)
In hvn_alloc_cmd() we may spin waiting for a free rndis_cmd. We check the list once per tick and block with msleep(9) if there aren't any free objects. In practice though we don't need to poll for a free rndis_cmd because our sleep is protected by a mutex, so we can't miss a wakeup(9). That is, it's safe to use msleep_nsec(9) here and not set a timeout (INFSLP). Tested by Andre Stoebe <as@nul.space> (Hyper-V on Windows 10). "LGTM" mikeb@, ok mpi@
-rw-r--r--sys/dev/pv/if_hvn.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/dev/pv/if_hvn.c b/sys/dev/pv/if_hvn.c
index ec96bc788d0..d497f0bf631 100644
--- a/sys/dev/pv/if_hvn.c
+++ b/sys/dev/pv/if_hvn.c
@@ -1127,8 +1127,8 @@ hvn_alloc_cmd(struct hvn_softc *sc)
mtx_enter(&sc->sc_cntl_fqlck);
while ((rc = TAILQ_FIRST(&sc->sc_cntl_fq)) == NULL)
- msleep(&sc->sc_cntl_fq, &sc->sc_cntl_fqlck,
- PRIBIO, "nvsalloc", 1);
+ msleep_nsec(&sc->sc_cntl_fq, &sc->sc_cntl_fqlck,
+ PRIBIO, "nvsalloc", INFSLP);
TAILQ_REMOVE(&sc->sc_cntl_fq, rc, rc_entry);
mtx_leave(&sc->sc_cntl_fqlck);
return (rc);