diff options
author | 2019-02-26 14:24:21 +0000 | |
---|---|---|
committer | 2019-02-26 14:24:21 +0000 | |
commit | f23964605d2da2a65556dd4a4f1a69acff61c930 (patch) | |
tree | 4786ba402ca4540f153014bdecd57aa5f55df5c8 /sys/kern/kern_sched.c | |
parent | ikectl's built-in CA command for simple configurations has a fixed certificate (diff) | |
download | wireguard-openbsd-f23964605d2da2a65556dd4a4f1a69acff61c930.tar.xz wireguard-openbsd-f23964605d2da2a65556dd4a4f1a69acff61c930.zip |
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/kern_sched.c')
-rw-r--r-- | sys/kern/kern_sched.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index 552a2fd85c0..73ec5bdf683 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sched.c,v 1.54 2018/11/17 23:10:08 cheloha Exp $ */ +/* $OpenBSD: kern_sched.c,v 1.55 2019/02/26 14:24:21 visa Exp $ */ /* * Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org> * @@ -25,6 +25,7 @@ #include <sys/signalvar.h> #include <sys/mutex.h> #include <sys/task.h> +#include <sys/smr.h> #include <uvm/uvm_extern.h> @@ -105,6 +106,8 @@ sched_init_cpu(struct cpu_info *ci) return; #endif cpuset_add(&sched_all_cpus, ci); + + SIMPLEQ_INIT(&spc->spc_deferred); } void @@ -172,6 +175,8 @@ sched_idle(void *v) splassert(IPL_NONE); + smr_idle(); + cpuset_add(&sched_idle_cpus, ci); cpu_idle_enter(); while (spc->spc_whichqs == 0) { |