summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2020-12-04 18:05:27 +0000
committercheloha <cheloha@cvs.openbsd.org>2020-12-04 18:05:27 +0000
commit18ffe49f077e7283c6d54147088baccfa787c81c (patch)
treed9373a348eabe4206d6d2b8346393c6e0b7b8256
parentf4be7796000f3c16856e0c1bc46b238711ca5e5c (diff)
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);