Paul E. McKenney | e260be6 | 2008-01-25 21:08:24 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Read-Copy Update mechanism for mutual exclusion (RT implementation) |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | * |
| 18 | * Copyright (C) IBM Corporation, 2006 |
| 19 | * |
| 20 | * Author: Paul McKenney <paulmck@us.ibm.com> |
| 21 | * |
| 22 | * Based on the original work by Paul McKenney <paul.mckenney@us.ibm.com> |
| 23 | * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen. |
| 24 | * Papers: |
| 25 | * http://www.rdrop.com/users/paulmck/paper/rclockpdcsproof.pdf |
| 26 | * http://lse.sourceforge.net/locking/rclock_OLS.2001.05.01c.sc.pdf (OLS2001) |
| 27 | * |
| 28 | * For detailed explanation of Read-Copy Update mechanism see - |
| 29 | * Documentation/RCU |
| 30 | * |
| 31 | */ |
| 32 | |
| 33 | #ifndef __LINUX_RCUPREEMPT_H |
| 34 | #define __LINUX_RCUPREEMPT_H |
| 35 | |
| 36 | #ifdef __KERNEL__ |
| 37 | |
| 38 | #include <linux/cache.h> |
| 39 | #include <linux/spinlock.h> |
| 40 | #include <linux/threads.h> |
| 41 | #include <linux/percpu.h> |
| 42 | #include <linux/cpumask.h> |
| 43 | #include <linux/seqlock.h> |
| 44 | |
| 45 | #define rcu_qsctr_inc(cpu) |
| 46 | #define rcu_bh_qsctr_inc(cpu) |
| 47 | #define call_rcu_bh(head, rcu) call_rcu(head, rcu) |
| 48 | |
Patrick McHardy | b55ab61 | 2008-02-08 04:21:59 -0800 | [diff] [blame] | 49 | extern void __rcu_read_lock(void) __acquires(RCU); |
| 50 | extern void __rcu_read_unlock(void) __releases(RCU); |
Paul E. McKenney | e260be6 | 2008-01-25 21:08:24 +0100 | [diff] [blame] | 51 | extern int rcu_pending(int cpu); |
| 52 | extern int rcu_needs_cpu(int cpu); |
| 53 | |
| 54 | #define __rcu_read_lock_bh() { rcu_read_lock(); local_bh_disable(); } |
| 55 | #define __rcu_read_unlock_bh() { local_bh_enable(); rcu_read_unlock(); } |
| 56 | |
| 57 | extern void __synchronize_sched(void); |
| 58 | |
| 59 | extern void __rcu_init(void); |
| 60 | extern void rcu_check_callbacks(int cpu, int user); |
| 61 | extern void rcu_restart_cpu(int cpu); |
| 62 | extern long rcu_batches_completed(void); |
| 63 | |
| 64 | /* |
| 65 | * Return the number of RCU batches processed thus far. Useful for debug |
| 66 | * and statistic. The _bh variant is identifcal to straight RCU |
| 67 | */ |
| 68 | static inline long rcu_batches_completed_bh(void) |
| 69 | { |
| 70 | return rcu_batches_completed(); |
| 71 | } |
| 72 | |
| 73 | #ifdef CONFIG_RCU_TRACE |
| 74 | struct rcupreempt_trace; |
| 75 | extern long *rcupreempt_flipctr(int cpu); |
| 76 | extern long rcupreempt_data_completed(void); |
| 77 | extern int rcupreempt_flip_flag(int cpu); |
| 78 | extern int rcupreempt_mb_flag(int cpu); |
| 79 | extern char *rcupreempt_try_flip_state_name(void); |
| 80 | extern struct rcupreempt_trace *rcupreempt_trace_cpu(int cpu); |
| 81 | #endif |
| 82 | |
| 83 | struct softirq_action; |
| 84 | |
Steven Rostedt | 2232c2d | 2008-02-29 18:46:50 +0100 | [diff] [blame] | 85 | #ifdef CONFIG_NO_HZ |
| 86 | DECLARE_PER_CPU(long, dynticks_progress_counter); |
| 87 | |
| 88 | static inline void rcu_enter_nohz(void) |
| 89 | { |
Paul E. McKenney | ae66be9 | 2008-03-19 17:00:57 -0700 | [diff] [blame] | 90 | smp_mb(); /* CPUs seeing ++ must see prior RCU read-side crit sects */ |
Steven Rostedt | 2232c2d | 2008-02-29 18:46:50 +0100 | [diff] [blame] | 91 | __get_cpu_var(dynticks_progress_counter)++; |
| 92 | WARN_ON(__get_cpu_var(dynticks_progress_counter) & 0x1); |
Steven Rostedt | 2232c2d | 2008-02-29 18:46:50 +0100 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | static inline void rcu_exit_nohz(void) |
| 96 | { |
Steven Rostedt | 2232c2d | 2008-02-29 18:46:50 +0100 | [diff] [blame] | 97 | __get_cpu_var(dynticks_progress_counter)++; |
Paul E. McKenney | ae66be9 | 2008-03-19 17:00:57 -0700 | [diff] [blame] | 98 | smp_mb(); /* CPUs seeing ++ must see later RCU read-side crit sects */ |
Steven Rostedt | 2232c2d | 2008-02-29 18:46:50 +0100 | [diff] [blame] | 99 | WARN_ON(!(__get_cpu_var(dynticks_progress_counter) & 0x1)); |
| 100 | } |
| 101 | |
| 102 | #else /* CONFIG_NO_HZ */ |
| 103 | #define rcu_enter_nohz() do { } while (0) |
| 104 | #define rcu_exit_nohz() do { } while (0) |
| 105 | #endif /* CONFIG_NO_HZ */ |
| 106 | |
Paul E. McKenney | e260be6 | 2008-01-25 21:08:24 +0100 | [diff] [blame] | 107 | #endif /* __KERNEL__ */ |
| 108 | #endif /* __LINUX_RCUPREEMPT_H */ |