summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcheloha <cheloha@openbsd.org>2020-01-03 20:11:11 +0000
committercheloha <cheloha@openbsd.org>2020-01-03 20:11:11 +0000
commitf64d60d7e79eced538eba14c0952d171f14d839c (patch)
treef35e6e7f764ee358773cf801499fe197b278616a
parentMove code into new hv_config(), defer to commands needing it (diff)
downloadwireguard-openbsd-f64d60d7e79eced538eba14c0952d171f14d839c.tar.xz
wireguard-openbsd-f64d60d7e79eced538eba14c0952d171f14d839c.zip
timeout(9): delay thread wakeup(9) decision to end of softclock() loop
The process-context timeout(s) in question might be cancelled before we leave the loop, leading to a spurious wakeup(9). ok mpi@
-rw-r--r--sys/kern/kern_timeout.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
index 9239d8e5f8b..037ed311051 100644
--- a/sys/kern/kern_timeout.c
+++ b/sys/kern/kern_timeout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_timeout.c,v 1.69 2020/01/03 02:16:38 cheloha Exp $ */
+/* $OpenBSD: kern_timeout.c,v 1.70 2020/01/03 20:11:11 cheloha Exp $ */
/*
* Copyright (c) 2001 Thomas Nordin <nordin@openbsd.org>
* Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
@@ -499,10 +499,9 @@ timeout_run(struct timeout *to)
void
softclock(void *arg)
{
- int delta;
struct circq *bucket;
struct timeout *to;
- int needsproc = 0;
+ int delta, needsproc;
mtx_enter(&timeout_mutex);
while (!CIRCQ_EMPTY(&timeout_todo)) {
@@ -528,13 +527,13 @@ softclock(void *arg)
tostat.tos_late++;
if (ISSET(to->to_flags, TIMEOUT_PROC)) {
CIRCQ_INSERT_TAIL(&timeout_proc, &to->to_list);
- needsproc = 1;
continue;
}
timeout_run(to);
tostat.tos_run_softclock++;
}
tostat.tos_softclocks++;
+ needsproc = !CIRCQ_EMPTY(&timeout_proc);
mtx_leave(&timeout_mutex);
if (needsproc)