summaryrefslogtreecommitdiff
path: root/sys/kern/sched_bsd.c
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2019-02-26 14:24:22 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2019-02-26 14:24:22 +0000
commit8c7f578cb27e63d93d0469407f24a5c538a38605 (patch)
treea27980560b7dc8fe0af18c16bc283b3f486b3b51 /sys/kern/sched_bsd.c
parenta6a6c0baf8380d18184846e4b72d48148614a92e (diff)
Introduce safe memory reclamation, a mechanism for reclaiming shared
objects that readers can access without locking. This provides a basis for read-copy-update operations. Readers access SMR-protected shared objects inside SMR read-side critical section where sleeping is not allowed. To reclaim an SMR-protected object, the writer has to ensure mutual exclusion of other writers, remove the object's shared reference and wait until read-side references cannot exist any longer. As an alternative to waiting, the writer can schedule a callback that gets invoked when reclamation is safe. The mechanism relies on CPU quiescent states to determine when an SMR-protected object is ready for reclamation. The <sys/smr.h> header additionally provides an implementation of singly- and doubly-linked lists that can be used together with SMR. These lists allow lockless read access with a concurrent writer. Discussed with many OK mpi@ sashan@
Diffstat (limited to 'sys/kern/sched_bsd.c')
-rw-r--r--sys/kern/sched_bsd.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/sched_bsd.c b/sys/kern/sched_bsd.c
index 635f10664a5..00a08861b59 100644
--- a/sys/kern/sched_bsd.c
+++ b/sys/kern/sched_bsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sched_bsd.c,v 1.49 2019/01/28 11:48:13 mpi Exp $ */
+/* $OpenBSD: sched_bsd.c,v 1.50 2019/02/26 14:24:21 visa Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*-
@@ -47,6 +47,7 @@
#include <uvm/uvm_extern.h>
#include <sys/sched.h>
#include <sys/timeout.h>
+#include <sys/smr.h>
#ifdef KTRACE
#include <sys/ktrace.h>
@@ -417,6 +418,8 @@ mi_switch(void)
SCHED_ASSERT_UNLOCKED();
+ smr_idle();
+
/*
* We're running again; record our new start time. We might
* be running on a new CPU now, so don't use the cache'd