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> 41*f3de9af6SHans 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> 49*f3de9af6SHans Petter Selasky #include <linux/compat.h> 501a01b4e5SHans Petter Selasky 51*f3de9af6SHans Petter Selasky /* 52*f3de9af6SHans Petter Selasky * By defining CONFIG_NO_RCU_SKIP LinuxKPI RCU locks and asserts will 53*f3de9af6SHans Petter Selasky * not be skipped during panic(). 54*f3de9af6SHans Petter Selasky */ 55*f3de9af6SHans Petter Selasky #ifdef CONFIG_NO_RCU_SKIP 56*f3de9af6SHans Petter Selasky #define RCU_SKIP(void) 0 57*f3de9af6SHans Petter Selasky #else 58*f3de9af6SHans Petter Selasky #define RCU_SKIP(void) unlikely(SCHEDULER_STOPPED() || kdb_active) 59*f3de9af6SHans 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 66*f3de9af6SHans Petter Selasky struct linux_epoch_head { 67*f3de9af6SHans Petter Selasky STAILQ_HEAD(, callback_head) cb_head; 68*f3de9af6SHans Petter Selasky struct mtx lock; 69*f3de9af6SHans Petter Selasky struct task task; 70*f3de9af6SHans Petter Selasky } __aligned(CACHE_LINE_SIZE); 71*f3de9af6SHans Petter Selasky 72*f3de9af6SHans Petter Selasky struct linux_epoch_record { 731f827dabSHans Petter Selasky ck_epoch_record_t epoch_record; 74*f3de9af6SHans Petter Selasky TAILQ_HEAD(, task_struct) ts_head; 75*f3de9af6SHans Petter Selasky int cpuid; 76*f3de9af6SHans 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 */ 84*f3de9af6SHans 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 88*f3de9af6SHans Petter Selasky * linux_epoch_record": 891f827dabSHans Petter Selasky */ 90*f3de9af6SHans Petter Selasky CTASSERT(offsetof(struct linux_epoch_record, epoch_record) == 0); 911f827dabSHans Petter Selasky 921a01b4e5SHans Petter Selasky static ck_epoch_t linux_epoch; 93*f3de9af6SHans Petter Selasky static struct linux_epoch_head linux_epoch_head; 94*f3de9af6SHans 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 { 101*f3de9af6SHans 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 106*f3de9af6SHans Petter Selasky head = &linux_epoch_head; 107*f3de9af6SHans Petter Selasky 108*f3de9af6SHans Petter Selasky mtx_init(&head->lock, "LRCU-HEAD", NULL, MTX_DEF); 109*f3de9af6SHans Petter Selasky TASK_INIT(&head->task, 0, linux_rcu_cleaner_func, NULL); 110*f3de9af6SHans Petter Selasky STAILQ_INIT(&head->cb_head); 111*f3de9af6SHans Petter Selasky 1121a01b4e5SHans Petter Selasky CPU_FOREACH(i) { 113*f3de9af6SHans Petter Selasky struct linux_epoch_record *record; 1141f827dabSHans Petter Selasky 115*f3de9af6SHans Petter Selasky record = &DPCPU_ID_GET(i, linux_epoch_record); 1161f827dabSHans Petter Selasky 117*f3de9af6SHans Petter Selasky record->cpuid = i; 1187e8cd4e1SOlivier Houchard ck_epoch_register(&linux_epoch, &record->epoch_record, NULL); 119*f3de9af6SHans Petter Selasky TAILQ_INIT(&record->ts_head); 1201a01b4e5SHans Petter Selasky } 1211a01b4e5SHans Petter Selasky } 1221a01b4e5SHans Petter Selasky SYSINIT(linux_rcu_runtime, SI_SUB_LOCK, SI_ORDER_SECOND, 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 { 127*f3de9af6SHans Petter Selasky struct linux_epoch_head *head; 1281a01b4e5SHans Petter Selasky 129*f3de9af6SHans Petter Selasky head = &linux_epoch_head; 1301a01b4e5SHans Petter Selasky 131*f3de9af6SHans Petter Selasky /* destroy head lock */ 132*f3de9af6SHans 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 137*f3de9af6SHans Petter Selasky linux_rcu_cleaner_func(void *context __unused, int pending __unused) 1381f827dabSHans Petter Selasky { 139*f3de9af6SHans Petter Selasky struct linux_epoch_head *head; 1401a01b4e5SHans Petter Selasky struct callback_head *rcu; 141*f3de9af6SHans Petter Selasky STAILQ_HEAD(, callback_head) tmp_head; 1421f827dabSHans Petter Selasky 143*f3de9af6SHans Petter Selasky linux_set_current(curthread); 144*f3de9af6SHans Petter Selasky 145*f3de9af6SHans Petter Selasky head = &linux_epoch_head; 1461f827dabSHans Petter Selasky 1471f827dabSHans Petter Selasky /* move current callbacks into own queue */ 148*f3de9af6SHans Petter Selasky mtx_lock(&head->lock); 149*f3de9af6SHans Petter Selasky STAILQ_INIT(&tmp_head); 150*f3de9af6SHans Petter Selasky STAILQ_CONCAT(&tmp_head, &head->cb_head); 151*f3de9af6SHans Petter Selasky mtx_unlock(&head->lock); 1521f827dabSHans Petter Selasky 1531f827dabSHans Petter Selasky /* synchronize */ 154*f3de9af6SHans Petter Selasky linux_synchronize_rcu(); 1551f827dabSHans Petter Selasky 1561f827dabSHans Petter Selasky /* dispatch all callbacks, if any */ 157*f3de9af6SHans Petter Selasky while ((rcu = STAILQ_FIRST(&tmp_head)) != NULL) { 1581a01b4e5SHans Petter Selasky uintptr_t offset; 1591a01b4e5SHans Petter Selasky 160*f3de9af6SHans 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 { 174*f3de9af6SHans Petter Selasky struct linux_epoch_record *record; 175*f3de9af6SHans Petter Selasky struct task_struct *ts; 176*f3de9af6SHans Petter Selasky 177*f3de9af6SHans Petter Selasky if (RCU_SKIP()) 178*f3de9af6SHans Petter Selasky return; 1791a01b4e5SHans Petter Selasky 1801f827dabSHans Petter Selasky /* 1811f827dabSHans Petter Selasky * Pin thread to current CPU so that the unlock code gets the 182*f3de9af6SHans Petter Selasky * same per-CPU epoch record: 1831f827dabSHans Petter Selasky */ 1841a01b4e5SHans Petter Selasky sched_pin(); 1851a01b4e5SHans Petter Selasky 186*f3de9af6SHans Petter Selasky record = &DPCPU_GET(linux_epoch_record); 187*f3de9af6SHans 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(); 194*f3de9af6SHans Petter Selasky ck_epoch_begin(&record->epoch_record, NULL); 195*f3de9af6SHans Petter Selasky ts->rcu_recurse++; 196*f3de9af6SHans Petter Selasky if (ts->rcu_recurse == 1) 197*f3de9af6SHans 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 { 204*f3de9af6SHans Petter Selasky struct linux_epoch_record *record; 205*f3de9af6SHans Petter Selasky struct task_struct *ts; 2061a01b4e5SHans Petter Selasky 207*f3de9af6SHans Petter Selasky if (RCU_SKIP()) 208*f3de9af6SHans Petter Selasky return; 209*f3de9af6SHans Petter Selasky 210*f3de9af6SHans Petter Selasky record = &DPCPU_GET(linux_epoch_record); 211*f3de9af6SHans 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(); 218*f3de9af6SHans Petter Selasky ck_epoch_end(&record->epoch_record, NULL); 219*f3de9af6SHans Petter Selasky ts->rcu_recurse--; 220*f3de9af6SHans Petter Selasky if (ts->rcu_recurse == 0) 221*f3de9af6SHans 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 227*f3de9af6SHans Petter Selasky static void 228*f3de9af6SHans Petter Selasky linux_synchronize_rcu_cb(ck_epoch_t *epoch __unused, ck_epoch_record_t *epoch_record, void *arg __unused) 229*f3de9af6SHans Petter Selasky { 230*f3de9af6SHans Petter Selasky struct linux_epoch_record *record = 231*f3de9af6SHans Petter Selasky container_of(epoch_record, struct linux_epoch_record, epoch_record); 232*f3de9af6SHans Petter Selasky struct thread *td = curthread; 233*f3de9af6SHans Petter Selasky struct task_struct *ts; 234*f3de9af6SHans Petter Selasky 235*f3de9af6SHans Petter Selasky /* check if blocked on the current CPU */ 236*f3de9af6SHans Petter Selasky if (record->cpuid == PCPU_GET(cpuid)) { 237*f3de9af6SHans Petter Selasky bool is_sleeping = 0; 238*f3de9af6SHans Petter Selasky u_char prio = 0; 239*f3de9af6SHans Petter Selasky u_char old_prio; 240*f3de9af6SHans Petter Selasky 241*f3de9af6SHans Petter Selasky /* 242*f3de9af6SHans Petter Selasky * Find the lowest priority or sleeping thread which 243*f3de9af6SHans Petter Selasky * is blocking synchronization on this CPU core. All 244*f3de9af6SHans Petter Selasky * the threads in the queue are CPU-pinned and cannot 245*f3de9af6SHans Petter Selasky * go anywhere while the current thread is locked. 246*f3de9af6SHans Petter Selasky */ 247*f3de9af6SHans Petter Selasky TAILQ_FOREACH(ts, &record->ts_head, rcu_entry) { 248*f3de9af6SHans Petter Selasky if (ts->task_thread->td_priority > prio) 249*f3de9af6SHans Petter Selasky prio = ts->task_thread->td_priority; 250*f3de9af6SHans Petter Selasky is_sleeping |= (ts->task_thread->td_inhibitors != 0); 251*f3de9af6SHans Petter Selasky } 252*f3de9af6SHans Petter Selasky 253*f3de9af6SHans Petter Selasky if (is_sleeping) { 254*f3de9af6SHans Petter Selasky thread_unlock(td); 255*f3de9af6SHans Petter Selasky pause("W", 1); 256*f3de9af6SHans Petter Selasky thread_lock(td); 257*f3de9af6SHans Petter Selasky } else { 258*f3de9af6SHans Petter Selasky old_prio = td->td_priority; 259*f3de9af6SHans Petter Selasky /* set new thread priority */ 260*f3de9af6SHans Petter Selasky sched_prio(td, prio); 261*f3de9af6SHans Petter Selasky /* task switch */ 262*f3de9af6SHans Petter Selasky mi_switch(SW_VOL | SWT_RELINQUISH, NULL); 263*f3de9af6SHans Petter Selasky /* restore thread priority */ 264*f3de9af6SHans Petter Selasky sched_prio(td, old_prio); 265*f3de9af6SHans Petter Selasky } 266*f3de9af6SHans Petter Selasky } else { 267*f3de9af6SHans Petter Selasky /* 268*f3de9af6SHans Petter Selasky * To avoid spinning move execution to the other CPU 269*f3de9af6SHans Petter Selasky * which is blocking synchronization. Set highest 270*f3de9af6SHans Petter Selasky * thread priority so that code gets run. The thread 271*f3de9af6SHans Petter Selasky * priority will be restored later. 272*f3de9af6SHans Petter Selasky */ 273*f3de9af6SHans Petter Selasky sched_prio(td, 0); 274*f3de9af6SHans Petter Selasky sched_bind(td, record->cpuid); 275*f3de9af6SHans Petter Selasky } 276*f3de9af6SHans Petter Selasky } 277*f3de9af6SHans Petter Selasky 2781a01b4e5SHans Petter Selasky void 2791a01b4e5SHans Petter Selasky linux_synchronize_rcu(void) 2801a01b4e5SHans Petter Selasky { 281*f3de9af6SHans Petter Selasky struct thread *td; 282*f3de9af6SHans Petter Selasky int was_bound; 283*f3de9af6SHans Petter Selasky int old_cpu; 284*f3de9af6SHans Petter Selasky int old_pinned; 285*f3de9af6SHans Petter Selasky 286*f3de9af6SHans Petter Selasky if (RCU_SKIP()) 287*f3de9af6SHans Petter Selasky return; 288*f3de9af6SHans Petter Selasky 289*f3de9af6SHans Petter Selasky WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 290*f3de9af6SHans Petter Selasky "linux_synchronize_rcu() can sleep"); 291*f3de9af6SHans Petter Selasky 292*f3de9af6SHans Petter Selasky td = curthread; 293*f3de9af6SHans Petter Selasky 294*f3de9af6SHans Petter Selasky DROP_GIANT(); 295*f3de9af6SHans Petter Selasky 296*f3de9af6SHans Petter Selasky /* 297*f3de9af6SHans Petter Selasky * Synchronizing RCU might change the CPU core this function 298*f3de9af6SHans Petter Selasky * is running on. Save current values: 299*f3de9af6SHans Petter Selasky */ 300*f3de9af6SHans Petter Selasky thread_lock(td); 301*f3de9af6SHans Petter Selasky 302*f3de9af6SHans Petter Selasky old_cpu = PCPU_GET(cpuid); 303*f3de9af6SHans Petter Selasky old_pinned = td->td_pinned; 304*f3de9af6SHans Petter Selasky td->td_pinned = 0; 305*f3de9af6SHans Petter Selasky was_bound = sched_is_bound(td); 306*f3de9af6SHans Petter Selasky sched_bind(td, old_cpu); 307*f3de9af6SHans Petter Selasky 308*f3de9af6SHans Petter Selasky ck_epoch_synchronize_wait(&linux_epoch, 309*f3de9af6SHans Petter Selasky &linux_synchronize_rcu_cb, NULL); 310*f3de9af6SHans Petter Selasky 311*f3de9af6SHans Petter Selasky /* restore CPU binding, if any */ 312*f3de9af6SHans Petter Selasky if (was_bound != 0) { 313*f3de9af6SHans Petter Selasky sched_bind(td, old_cpu); 314*f3de9af6SHans Petter Selasky } else { 315*f3de9af6SHans Petter Selasky /* get thread back to initial CPU, if any */ 316*f3de9af6SHans Petter Selasky if (old_pinned != 0) 317*f3de9af6SHans Petter Selasky sched_bind(td, old_cpu); 318*f3de9af6SHans Petter Selasky sched_unbind(td); 319*f3de9af6SHans Petter Selasky } 320*f3de9af6SHans Petter Selasky /* restore pinned after bind */ 321*f3de9af6SHans Petter Selasky td->td_pinned = old_pinned; 322*f3de9af6SHans Petter Selasky thread_unlock(td); 323*f3de9af6SHans Petter Selasky 324*f3de9af6SHans Petter Selasky PICKUP_GIANT(); 3251a01b4e5SHans Petter Selasky } 3261a01b4e5SHans Petter Selasky 3271a01b4e5SHans Petter Selasky void 3281a01b4e5SHans Petter Selasky linux_rcu_barrier(void) 3291a01b4e5SHans Petter Selasky { 330*f3de9af6SHans Petter Selasky struct linux_epoch_head *head; 3311a01b4e5SHans Petter Selasky 332*f3de9af6SHans Petter Selasky linux_synchronize_rcu(); 3331f827dabSHans Petter Selasky 334*f3de9af6SHans Petter Selasky head = &linux_epoch_head; 3351f827dabSHans Petter Selasky 3361f827dabSHans Petter Selasky /* wait for callbacks to complete */ 337*f3de9af6SHans Petter Selasky taskqueue_drain(taskqueue_fast, &head->task); 3381a01b4e5SHans Petter Selasky } 3391a01b4e5SHans Petter Selasky 3401a01b4e5SHans Petter Selasky void 3411a01b4e5SHans Petter Selasky linux_call_rcu(struct rcu_head *context, rcu_callback_t func) 3421a01b4e5SHans Petter Selasky { 3431f827dabSHans Petter Selasky struct callback_head *rcu = (struct callback_head *)context; 344*f3de9af6SHans Petter Selasky struct linux_epoch_head *head = &linux_epoch_head; 3451a01b4e5SHans Petter Selasky 346*f3de9af6SHans Petter Selasky mtx_lock(&head->lock); 3471f827dabSHans Petter Selasky rcu->func = func; 348*f3de9af6SHans Petter Selasky STAILQ_INSERT_TAIL(&head->cb_head, rcu, entry); 349*f3de9af6SHans Petter Selasky taskqueue_enqueue(taskqueue_fast, &head->task); 350*f3de9af6SHans Petter Selasky mtx_unlock(&head->lock); 3511a01b4e5SHans Petter Selasky } 3521a01b4e5SHans Petter Selasky 3531a01b4e5SHans Petter Selasky int 3541a01b4e5SHans Petter Selasky init_srcu_struct(struct srcu_struct *srcu) 3551a01b4e5SHans Petter Selasky { 3561a01b4e5SHans Petter Selasky return (0); 3571a01b4e5SHans Petter Selasky } 3581a01b4e5SHans Petter Selasky 3591a01b4e5SHans Petter Selasky void 3601a01b4e5SHans Petter Selasky cleanup_srcu_struct(struct srcu_struct *srcu) 3611a01b4e5SHans Petter Selasky { 3621a01b4e5SHans Petter Selasky } 3631a01b4e5SHans Petter Selasky 3641a01b4e5SHans Petter Selasky int 3651a01b4e5SHans Petter Selasky srcu_read_lock(struct srcu_struct *srcu) 3661a01b4e5SHans Petter Selasky { 367*f3de9af6SHans Petter Selasky linux_rcu_read_lock(); 3681a01b4e5SHans Petter Selasky return (0); 3691a01b4e5SHans Petter Selasky } 3701a01b4e5SHans Petter Selasky 3711a01b4e5SHans Petter Selasky void 3721a01b4e5SHans Petter Selasky srcu_read_unlock(struct srcu_struct *srcu, int key __unused) 3731a01b4e5SHans Petter Selasky { 374*f3de9af6SHans Petter Selasky linux_rcu_read_unlock(); 3751a01b4e5SHans Petter Selasky } 3761a01b4e5SHans Petter Selasky 3771a01b4e5SHans Petter Selasky void 3781a01b4e5SHans Petter Selasky synchronize_srcu(struct srcu_struct *srcu) 3791a01b4e5SHans Petter Selasky { 380*f3de9af6SHans Petter Selasky linux_synchronize_rcu(); 3811f827dabSHans Petter Selasky } 3821f827dabSHans Petter Selasky 3831f827dabSHans Petter Selasky void 3841f827dabSHans Petter Selasky srcu_barrier(struct srcu_struct *srcu) 3851f827dabSHans Petter Selasky { 386*f3de9af6SHans Petter Selasky linux_rcu_barrier(); 3871a01b4e5SHans Petter Selasky } 388