11a01b4e5SHans Petter Selasky /*- 21a01b4e5SHans Petter Selasky * Copyright (c) 2016 Matt Macy (mmacy@nextbsd.org) 31a01b4e5SHans Petter Selasky * All rights reserved. 41a01b4e5SHans Petter Selasky * 51a01b4e5SHans Petter Selasky * Redistribution and use in source and binary forms, with or without 61a01b4e5SHans Petter Selasky * modification, are permitted provided that the following conditions 71a01b4e5SHans Petter Selasky * are met: 81a01b4e5SHans Petter Selasky * 1. Redistributions of source code must retain the above copyright 91a01b4e5SHans Petter Selasky * notice unmodified, this list of conditions, and the following 101a01b4e5SHans Petter Selasky * disclaimer. 111a01b4e5SHans Petter Selasky * 2. Redistributions in binary form must reproduce the above copyright 121a01b4e5SHans Petter Selasky * notice, this list of conditions and the following disclaimer in the 131a01b4e5SHans Petter Selasky * documentation and/or other materials provided with the distribution. 141a01b4e5SHans Petter Selasky * 151a01b4e5SHans Petter Selasky * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 161a01b4e5SHans Petter Selasky * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 171a01b4e5SHans Petter Selasky * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 181a01b4e5SHans Petter Selasky * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 191a01b4e5SHans Petter Selasky * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 201a01b4e5SHans Petter Selasky * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 211a01b4e5SHans Petter Selasky * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 221a01b4e5SHans Petter Selasky * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 231a01b4e5SHans Petter Selasky * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 241a01b4e5SHans Petter Selasky * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 251a01b4e5SHans Petter Selasky */ 261a01b4e5SHans Petter Selasky 271a01b4e5SHans Petter Selasky #include <sys/cdefs.h> 281a01b4e5SHans Petter Selasky __FBSDID("$FreeBSD$"); 291a01b4e5SHans Petter Selasky 301a01b4e5SHans Petter Selasky #include <sys/types.h> 311a01b4e5SHans Petter Selasky #include <sys/systm.h> 321a01b4e5SHans Petter Selasky #include <sys/malloc.h> 331a01b4e5SHans Petter Selasky #include <sys/kernel.h> 341a01b4e5SHans Petter Selasky #include <sys/lock.h> 351a01b4e5SHans Petter Selasky #include <sys/mutex.h> 361a01b4e5SHans Petter Selasky #include <sys/proc.h> 371a01b4e5SHans Petter Selasky #include <sys/sched.h> 381a01b4e5SHans Petter Selasky #include <sys/smp.h> 391a01b4e5SHans Petter Selasky #include <sys/queue.h> 401a01b4e5SHans Petter Selasky #include <sys/taskqueue.h> 41f3de9af6SHans Petter Selasky #include <sys/kdb.h> 421a01b4e5SHans Petter Selasky 431a01b4e5SHans Petter Selasky #include <ck_epoch.h> 441a01b4e5SHans Petter Selasky 451a01b4e5SHans Petter Selasky #include <linux/rcupdate.h> 461a01b4e5SHans Petter Selasky #include <linux/srcu.h> 471a01b4e5SHans Petter Selasky #include <linux/slab.h> 481a01b4e5SHans Petter Selasky #include <linux/kernel.h> 49f3de9af6SHans Petter Selasky #include <linux/compat.h> 501a01b4e5SHans Petter Selasky 51f3de9af6SHans Petter Selasky /* 52f3de9af6SHans Petter Selasky * By defining CONFIG_NO_RCU_SKIP LinuxKPI RCU locks and asserts will 53f3de9af6SHans Petter Selasky * not be skipped during panic(). 54f3de9af6SHans Petter Selasky */ 55f3de9af6SHans Petter Selasky #ifdef CONFIG_NO_RCU_SKIP 56f3de9af6SHans Petter Selasky #define RCU_SKIP(void) 0 57f3de9af6SHans Petter Selasky #else 58f3de9af6SHans Petter Selasky #define RCU_SKIP(void) unlikely(SCHEDULER_STOPPED() || kdb_active) 59f3de9af6SHans Petter Selasky #endif 601f827dabSHans Petter Selasky 611f827dabSHans Petter Selasky struct callback_head { 621f827dabSHans Petter Selasky STAILQ_ENTRY(callback_head) entry; 631f827dabSHans Petter Selasky rcu_callback_t func; 641f827dabSHans Petter Selasky }; 651f827dabSHans Petter Selasky 66f3de9af6SHans Petter Selasky struct linux_epoch_head { 67f3de9af6SHans Petter Selasky STAILQ_HEAD(, callback_head) cb_head; 68f3de9af6SHans Petter Selasky struct mtx lock; 69f3de9af6SHans Petter Selasky struct task task; 70f3de9af6SHans Petter Selasky } __aligned(CACHE_LINE_SIZE); 71f3de9af6SHans Petter Selasky 72f3de9af6SHans Petter Selasky struct linux_epoch_record { 731f827dabSHans Petter Selasky ck_epoch_record_t epoch_record; 74f3de9af6SHans Petter Selasky TAILQ_HEAD(, task_struct) ts_head; 75f3de9af6SHans Petter Selasky int cpuid; 76f3de9af6SHans Petter Selasky } __aligned(CACHE_LINE_SIZE); 771a01b4e5SHans Petter Selasky 781a01b4e5SHans Petter Selasky /* 791a01b4e5SHans Petter Selasky * Verify that "struct rcu_head" is big enough to hold "struct 801a01b4e5SHans Petter Selasky * callback_head". This has been done to avoid having to add special 811a01b4e5SHans Petter Selasky * compile flags for including ck_epoch.h to all clients of the 821a01b4e5SHans Petter Selasky * LinuxKPI. 831a01b4e5SHans Petter Selasky */ 84f3de9af6SHans Petter Selasky CTASSERT(sizeof(struct rcu_head) == sizeof(struct callback_head)); 851a01b4e5SHans Petter Selasky 861f827dabSHans Petter Selasky /* 871f827dabSHans Petter Selasky * Verify that "epoch_record" is at beginning of "struct 88f3de9af6SHans Petter Selasky * linux_epoch_record": 891f827dabSHans Petter Selasky */ 90f3de9af6SHans Petter Selasky CTASSERT(offsetof(struct linux_epoch_record, epoch_record) == 0); 911f827dabSHans Petter Selasky 921a01b4e5SHans Petter Selasky static ck_epoch_t linux_epoch; 93f3de9af6SHans Petter Selasky static struct linux_epoch_head linux_epoch_head; 94f3de9af6SHans Petter Selasky static DPCPU_DEFINE(struct linux_epoch_record, linux_epoch_record); 951f827dabSHans Petter Selasky 961f827dabSHans Petter Selasky static void linux_rcu_cleaner_func(void *, int); 971a01b4e5SHans Petter Selasky 981a01b4e5SHans Petter Selasky static void 991a01b4e5SHans Petter Selasky linux_rcu_runtime_init(void *arg __unused) 1001a01b4e5SHans Petter Selasky { 101f3de9af6SHans Petter Selasky struct linux_epoch_head *head; 1021a01b4e5SHans Petter Selasky int i; 1031a01b4e5SHans Petter Selasky 1041a01b4e5SHans Petter Selasky ck_epoch_init(&linux_epoch); 1051a01b4e5SHans Petter Selasky 106f3de9af6SHans Petter Selasky head = &linux_epoch_head; 107f3de9af6SHans Petter Selasky 108f3de9af6SHans Petter Selasky mtx_init(&head->lock, "LRCU-HEAD", NULL, MTX_DEF); 109f3de9af6SHans Petter Selasky TASK_INIT(&head->task, 0, linux_rcu_cleaner_func, NULL); 110f3de9af6SHans Petter Selasky STAILQ_INIT(&head->cb_head); 111f3de9af6SHans Petter Selasky 1121a01b4e5SHans Petter Selasky CPU_FOREACH(i) { 113f3de9af6SHans Petter Selasky struct linux_epoch_record *record; 1141f827dabSHans Petter Selasky 115f3de9af6SHans Petter Selasky record = &DPCPU_ID_GET(i, linux_epoch_record); 1161f827dabSHans Petter Selasky 117f3de9af6SHans Petter Selasky record->cpuid = i; 1187e8cd4e1SOlivier Houchard ck_epoch_register(&linux_epoch, &record->epoch_record, NULL); 119f3de9af6SHans Petter Selasky TAILQ_INIT(&record->ts_head); 1201a01b4e5SHans Petter Selasky } 1211a01b4e5SHans Petter Selasky } 122d8e073a9SHans Petter Selasky SYSINIT(linux_rcu_runtime, SI_SUB_CPU, SI_ORDER_ANY, linux_rcu_runtime_init, NULL); 1231a01b4e5SHans Petter Selasky 1241a01b4e5SHans Petter Selasky static void 1251a01b4e5SHans Petter Selasky linux_rcu_runtime_uninit(void *arg __unused) 1261a01b4e5SHans Petter Selasky { 127f3de9af6SHans Petter Selasky struct linux_epoch_head *head; 1281a01b4e5SHans Petter Selasky 129f3de9af6SHans Petter Selasky head = &linux_epoch_head; 1301a01b4e5SHans Petter Selasky 131f3de9af6SHans Petter Selasky /* destroy head lock */ 132f3de9af6SHans Petter Selasky mtx_destroy(&head->lock); 1331a01b4e5SHans Petter Selasky } 1341a01b4e5SHans Petter Selasky SYSUNINIT(linux_rcu_runtime, SI_SUB_LOCK, SI_ORDER_SECOND, linux_rcu_runtime_uninit, NULL); 1351a01b4e5SHans Petter Selasky 1361f827dabSHans Petter Selasky static void 137f3de9af6SHans Petter Selasky linux_rcu_cleaner_func(void *context __unused, int pending __unused) 1381f827dabSHans Petter Selasky { 139f3de9af6SHans Petter Selasky struct linux_epoch_head *head; 1401a01b4e5SHans Petter Selasky struct callback_head *rcu; 141f3de9af6SHans Petter Selasky STAILQ_HEAD(, callback_head) tmp_head; 1421f827dabSHans Petter Selasky 143f3de9af6SHans Petter Selasky linux_set_current(curthread); 144f3de9af6SHans Petter Selasky 145f3de9af6SHans Petter Selasky head = &linux_epoch_head; 1461f827dabSHans Petter Selasky 1471f827dabSHans Petter Selasky /* move current callbacks into own queue */ 148f3de9af6SHans Petter Selasky mtx_lock(&head->lock); 149f3de9af6SHans Petter Selasky STAILQ_INIT(&tmp_head); 150f3de9af6SHans Petter Selasky STAILQ_CONCAT(&tmp_head, &head->cb_head); 151f3de9af6SHans Petter Selasky mtx_unlock(&head->lock); 1521f827dabSHans Petter Selasky 1531f827dabSHans Petter Selasky /* synchronize */ 154f3de9af6SHans Petter Selasky linux_synchronize_rcu(); 1551f827dabSHans Petter Selasky 1561f827dabSHans Petter Selasky /* dispatch all callbacks, if any */ 157f3de9af6SHans Petter Selasky while ((rcu = STAILQ_FIRST(&tmp_head)) != NULL) { 1581a01b4e5SHans Petter Selasky uintptr_t offset; 1591a01b4e5SHans Petter Selasky 160f3de9af6SHans Petter Selasky STAILQ_REMOVE_HEAD(&tmp_head, entry); 1611a01b4e5SHans Petter Selasky 1621a01b4e5SHans Petter Selasky offset = (uintptr_t)rcu->func; 1631a01b4e5SHans Petter Selasky 1641a01b4e5SHans Petter Selasky if (offset < LINUX_KFREE_RCU_OFFSET_MAX) 1651a01b4e5SHans Petter Selasky kfree((char *)rcu - offset); 1661a01b4e5SHans Petter Selasky else 1671a01b4e5SHans Petter Selasky rcu->func((struct rcu_head *)rcu); 1681a01b4e5SHans Petter Selasky } 1691a01b4e5SHans Petter Selasky } 1701a01b4e5SHans Petter Selasky 1711a01b4e5SHans Petter Selasky void 1721a01b4e5SHans Petter Selasky linux_rcu_read_lock(void) 1731a01b4e5SHans Petter Selasky { 174f3de9af6SHans Petter Selasky struct linux_epoch_record *record; 175f3de9af6SHans Petter Selasky struct task_struct *ts; 176f3de9af6SHans Petter Selasky 177f3de9af6SHans Petter Selasky if (RCU_SKIP()) 178f3de9af6SHans Petter Selasky return; 1791a01b4e5SHans Petter Selasky 1801f827dabSHans Petter Selasky /* 1811f827dabSHans Petter Selasky * Pin thread to current CPU so that the unlock code gets the 182f3de9af6SHans Petter Selasky * same per-CPU epoch record: 1831f827dabSHans Petter Selasky */ 1841a01b4e5SHans Petter Selasky sched_pin(); 1851a01b4e5SHans Petter Selasky 186f3de9af6SHans Petter Selasky record = &DPCPU_GET(linux_epoch_record); 187f3de9af6SHans Petter Selasky ts = current; 1881f827dabSHans Petter Selasky 1891f827dabSHans Petter Selasky /* 1901f827dabSHans Petter Selasky * Use a critical section to prevent recursion inside 1911f827dabSHans Petter Selasky * ck_epoch_begin(). Else this function supports recursion. 1921f827dabSHans Petter Selasky */ 1931f827dabSHans Petter Selasky critical_enter(); 194f3de9af6SHans Petter Selasky ck_epoch_begin(&record->epoch_record, NULL); 195f3de9af6SHans Petter Selasky ts->rcu_recurse++; 196f3de9af6SHans Petter Selasky if (ts->rcu_recurse == 1) 197f3de9af6SHans Petter Selasky TAILQ_INSERT_TAIL(&record->ts_head, ts, rcu_entry); 1981f827dabSHans Petter Selasky critical_exit(); 1991a01b4e5SHans Petter Selasky } 2001a01b4e5SHans Petter Selasky 2011a01b4e5SHans Petter Selasky void 2021a01b4e5SHans Petter Selasky linux_rcu_read_unlock(void) 2031a01b4e5SHans Petter Selasky { 204f3de9af6SHans Petter Selasky struct linux_epoch_record *record; 205f3de9af6SHans Petter Selasky struct task_struct *ts; 2061a01b4e5SHans Petter Selasky 207f3de9af6SHans Petter Selasky if (RCU_SKIP()) 208f3de9af6SHans Petter Selasky return; 209f3de9af6SHans Petter Selasky 210f3de9af6SHans Petter Selasky record = &DPCPU_GET(linux_epoch_record); 211f3de9af6SHans Petter Selasky ts = current; 2121f827dabSHans Petter Selasky 2131f827dabSHans Petter Selasky /* 2141f827dabSHans Petter Selasky * Use a critical section to prevent recursion inside 2151f827dabSHans Petter Selasky * ck_epoch_end(). Else this function supports recursion. 2161f827dabSHans Petter Selasky */ 2171f827dabSHans Petter Selasky critical_enter(); 218f3de9af6SHans Petter Selasky ck_epoch_end(&record->epoch_record, NULL); 219f3de9af6SHans Petter Selasky ts->rcu_recurse--; 220f3de9af6SHans Petter Selasky if (ts->rcu_recurse == 0) 221f3de9af6SHans Petter Selasky TAILQ_REMOVE(&record->ts_head, ts, rcu_entry); 2221f827dabSHans Petter Selasky critical_exit(); 2231f827dabSHans Petter Selasky 2241a01b4e5SHans Petter Selasky sched_unpin(); 2251a01b4e5SHans Petter Selasky } 2261a01b4e5SHans Petter Selasky 227f3de9af6SHans Petter Selasky static void 228f3de9af6SHans Petter Selasky linux_synchronize_rcu_cb(ck_epoch_t *epoch __unused, ck_epoch_record_t *epoch_record, void *arg __unused) 229f3de9af6SHans Petter Selasky { 230f3de9af6SHans Petter Selasky struct linux_epoch_record *record = 231f3de9af6SHans Petter Selasky container_of(epoch_record, struct linux_epoch_record, epoch_record); 232f3de9af6SHans Petter Selasky struct thread *td = curthread; 233f3de9af6SHans Petter Selasky struct task_struct *ts; 234f3de9af6SHans Petter Selasky 235f3de9af6SHans Petter Selasky /* check if blocked on the current CPU */ 236f3de9af6SHans Petter Selasky if (record->cpuid == PCPU_GET(cpuid)) { 237f3de9af6SHans Petter Selasky bool is_sleeping = 0; 238f3de9af6SHans Petter Selasky u_char prio = 0; 239f3de9af6SHans Petter Selasky 240f3de9af6SHans Petter Selasky /* 241f3de9af6SHans Petter Selasky * Find the lowest priority or sleeping thread which 242f3de9af6SHans Petter Selasky * is blocking synchronization on this CPU core. All 243f3de9af6SHans Petter Selasky * the threads in the queue are CPU-pinned and cannot 244f3de9af6SHans Petter Selasky * go anywhere while the current thread is locked. 245f3de9af6SHans Petter Selasky */ 246f3de9af6SHans Petter Selasky TAILQ_FOREACH(ts, &record->ts_head, rcu_entry) { 247f3de9af6SHans Petter Selasky if (ts->task_thread->td_priority > prio) 248f3de9af6SHans Petter Selasky prio = ts->task_thread->td_priority; 249f3de9af6SHans Petter Selasky is_sleeping |= (ts->task_thread->td_inhibitors != 0); 250f3de9af6SHans Petter Selasky } 251f3de9af6SHans Petter Selasky 252f3de9af6SHans Petter Selasky if (is_sleeping) { 253f3de9af6SHans Petter Selasky thread_unlock(td); 254f3de9af6SHans Petter Selasky pause("W", 1); 255f3de9af6SHans Petter Selasky thread_lock(td); 256f3de9af6SHans Petter Selasky } else { 257f3de9af6SHans Petter Selasky /* set new thread priority */ 258f3de9af6SHans Petter Selasky sched_prio(td, prio); 259f3de9af6SHans Petter Selasky /* task switch */ 260f3de9af6SHans Petter Selasky mi_switch(SW_VOL | SWT_RELINQUISH, NULL); 261f3de9af6SHans Petter Selasky } 262f3de9af6SHans Petter Selasky } else { 263f3de9af6SHans Petter Selasky /* 264f3de9af6SHans Petter Selasky * To avoid spinning move execution to the other CPU 265f3de9af6SHans Petter Selasky * which is blocking synchronization. Set highest 266f3de9af6SHans Petter Selasky * thread priority so that code gets run. The thread 267f3de9af6SHans Petter Selasky * priority will be restored later. 268f3de9af6SHans Petter Selasky */ 269f3de9af6SHans Petter Selasky sched_prio(td, 0); 270f3de9af6SHans Petter Selasky sched_bind(td, record->cpuid); 271f3de9af6SHans Petter Selasky } 272f3de9af6SHans Petter Selasky } 273f3de9af6SHans Petter Selasky 2741a01b4e5SHans Petter Selasky void 2751a01b4e5SHans Petter Selasky linux_synchronize_rcu(void) 2761a01b4e5SHans Petter Selasky { 277f3de9af6SHans Petter Selasky struct thread *td; 278f3de9af6SHans Petter Selasky int was_bound; 279f3de9af6SHans Petter Selasky int old_cpu; 280f3de9af6SHans Petter Selasky int old_pinned; 281*3f743d78SHans Petter Selasky u_char old_prio; 282f3de9af6SHans Petter Selasky 283f3de9af6SHans Petter Selasky if (RCU_SKIP()) 284f3de9af6SHans Petter Selasky return; 285f3de9af6SHans Petter Selasky 286f3de9af6SHans Petter Selasky WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 287f3de9af6SHans Petter Selasky "linux_synchronize_rcu() can sleep"); 288f3de9af6SHans Petter Selasky 289f3de9af6SHans Petter Selasky td = curthread; 290f3de9af6SHans Petter Selasky 291f3de9af6SHans Petter Selasky DROP_GIANT(); 292f3de9af6SHans Petter Selasky 293f3de9af6SHans Petter Selasky /* 294f3de9af6SHans Petter Selasky * Synchronizing RCU might change the CPU core this function 295f3de9af6SHans Petter Selasky * is running on. Save current values: 296f3de9af6SHans Petter Selasky */ 297f3de9af6SHans Petter Selasky thread_lock(td); 298f3de9af6SHans Petter Selasky 299f3de9af6SHans Petter Selasky old_cpu = PCPU_GET(cpuid); 300f3de9af6SHans Petter Selasky old_pinned = td->td_pinned; 301*3f743d78SHans Petter Selasky old_prio = td->td_priority; 302f3de9af6SHans Petter Selasky td->td_pinned = 0; 303f3de9af6SHans Petter Selasky was_bound = sched_is_bound(td); 304f3de9af6SHans Petter Selasky sched_bind(td, old_cpu); 305f3de9af6SHans Petter Selasky 306f3de9af6SHans Petter Selasky ck_epoch_synchronize_wait(&linux_epoch, 307f3de9af6SHans Petter Selasky &linux_synchronize_rcu_cb, NULL); 308f3de9af6SHans Petter Selasky 309f3de9af6SHans Petter Selasky /* restore CPU binding, if any */ 310f3de9af6SHans Petter Selasky if (was_bound != 0) { 311f3de9af6SHans Petter Selasky sched_bind(td, old_cpu); 312f3de9af6SHans Petter Selasky } else { 313f3de9af6SHans Petter Selasky /* get thread back to initial CPU, if any */ 314f3de9af6SHans Petter Selasky if (old_pinned != 0) 315f3de9af6SHans Petter Selasky sched_bind(td, old_cpu); 316f3de9af6SHans Petter Selasky sched_unbind(td); 317f3de9af6SHans Petter Selasky } 318f3de9af6SHans Petter Selasky /* restore pinned after bind */ 319f3de9af6SHans Petter Selasky td->td_pinned = old_pinned; 320*3f743d78SHans Petter Selasky 321*3f743d78SHans Petter Selasky /* restore thread priority */ 322*3f743d78SHans Petter Selasky sched_prio(td, old_prio); 323f3de9af6SHans Petter Selasky thread_unlock(td); 324f3de9af6SHans Petter Selasky 325f3de9af6SHans Petter Selasky PICKUP_GIANT(); 3261a01b4e5SHans Petter Selasky } 3271a01b4e5SHans Petter Selasky 3281a01b4e5SHans Petter Selasky void 3291a01b4e5SHans Petter Selasky linux_rcu_barrier(void) 3301a01b4e5SHans Petter Selasky { 331f3de9af6SHans Petter Selasky struct linux_epoch_head *head; 3321a01b4e5SHans Petter Selasky 333f3de9af6SHans Petter Selasky linux_synchronize_rcu(); 3341f827dabSHans Petter Selasky 335f3de9af6SHans Petter Selasky head = &linux_epoch_head; 3361f827dabSHans Petter Selasky 3371f827dabSHans Petter Selasky /* wait for callbacks to complete */ 338f3de9af6SHans Petter Selasky taskqueue_drain(taskqueue_fast, &head->task); 3391a01b4e5SHans Petter Selasky } 3401a01b4e5SHans Petter Selasky 3411a01b4e5SHans Petter Selasky void 3421a01b4e5SHans Petter Selasky linux_call_rcu(struct rcu_head *context, rcu_callback_t func) 3431a01b4e5SHans Petter Selasky { 3441f827dabSHans Petter Selasky struct callback_head *rcu = (struct callback_head *)context; 345f3de9af6SHans Petter Selasky struct linux_epoch_head *head = &linux_epoch_head; 3461a01b4e5SHans Petter Selasky 347f3de9af6SHans Petter Selasky mtx_lock(&head->lock); 3481f827dabSHans Petter Selasky rcu->func = func; 349f3de9af6SHans Petter Selasky STAILQ_INSERT_TAIL(&head->cb_head, rcu, entry); 350f3de9af6SHans Petter Selasky taskqueue_enqueue(taskqueue_fast, &head->task); 351f3de9af6SHans Petter Selasky mtx_unlock(&head->lock); 3521a01b4e5SHans Petter Selasky } 3531a01b4e5SHans Petter Selasky 3541a01b4e5SHans Petter Selasky int 3551a01b4e5SHans Petter Selasky init_srcu_struct(struct srcu_struct *srcu) 3561a01b4e5SHans Petter Selasky { 3571a01b4e5SHans Petter Selasky return (0); 3581a01b4e5SHans Petter Selasky } 3591a01b4e5SHans Petter Selasky 3601a01b4e5SHans Petter Selasky void 3611a01b4e5SHans Petter Selasky cleanup_srcu_struct(struct srcu_struct *srcu) 3621a01b4e5SHans Petter Selasky { 3631a01b4e5SHans Petter Selasky } 3641a01b4e5SHans Petter Selasky 3651a01b4e5SHans Petter Selasky int 3661a01b4e5SHans Petter Selasky srcu_read_lock(struct srcu_struct *srcu) 3671a01b4e5SHans Petter Selasky { 368f3de9af6SHans Petter Selasky linux_rcu_read_lock(); 3691a01b4e5SHans Petter Selasky return (0); 3701a01b4e5SHans Petter Selasky } 3711a01b4e5SHans Petter Selasky 3721a01b4e5SHans Petter Selasky void 3731a01b4e5SHans Petter Selasky srcu_read_unlock(struct srcu_struct *srcu, int key __unused) 3741a01b4e5SHans Petter Selasky { 375f3de9af6SHans Petter Selasky linux_rcu_read_unlock(); 3761a01b4e5SHans Petter Selasky } 3771a01b4e5SHans Petter Selasky 3781a01b4e5SHans Petter Selasky void 3791a01b4e5SHans Petter Selasky synchronize_srcu(struct srcu_struct *srcu) 3801a01b4e5SHans Petter Selasky { 381f3de9af6SHans Petter Selasky linux_synchronize_rcu(); 3821f827dabSHans Petter Selasky } 3831f827dabSHans Petter Selasky 3841f827dabSHans Petter Selasky void 3851f827dabSHans Petter Selasky srcu_barrier(struct srcu_struct *srcu) 3861f827dabSHans Petter Selasky { 387f3de9af6SHans Petter Selasky linux_rcu_barrier(); 3881a01b4e5SHans Petter Selasky } 389