xref: /linux/include/linux/rcutiny.h (revision 83684c4e4d62cb02b2e4d0d18963d1035439278e)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Read-Copy Update mechanism for mutual exclusion, the Bloatwatch edition.
4  *
5  * Copyright IBM Corporation, 2008
6  *
7  * Author: Paul E. McKenney <paulmck@linux.ibm.com>
8  *
9  * For detailed explanation of Read-Copy Update mechanism see -
10  *		Documentation/RCU
11  */
12 #ifndef __LINUX_TINY_H
13 #define __LINUX_TINY_H
14 
15 #include <asm/param.h> /* for HZ */
16 
17 // Maximum number of rcu_gp_seq values corresponding to
18 // not-yet-completed RCU grace periods.
19 #define NUM_ACTIVE_RCU_POLL_FULL_OLDSTATE 2
20 
21 /*
22  * Are the two oldstate values the same?  See the Tree RCU version for
23  * docbook header.
24  */
same_state_synchronize_rcu_full(struct rcu_gp_seq * rgosp1,struct rcu_gp_seq * rgosp2)25 static inline bool same_state_synchronize_rcu_full(struct rcu_gp_seq *rgosp1,
26 						   struct rcu_gp_seq *rgosp2)
27 {
28 	return rgosp1->norm == rgosp2->norm;
29 }
30 
31 unsigned long get_state_synchronize_rcu(void);
32 
get_state_synchronize_rcu_full(struct rcu_gp_seq * gsp)33 static inline void get_state_synchronize_rcu_full(struct rcu_gp_seq *gsp)
34 {
35 	gsp->norm = get_state_synchronize_rcu();
36 }
37 
38 unsigned long start_poll_synchronize_rcu(void);
39 
start_poll_synchronize_rcu_full(struct rcu_gp_seq * gsp)40 static inline void start_poll_synchronize_rcu_full(struct rcu_gp_seq *gsp)
41 {
42 	gsp->norm = start_poll_synchronize_rcu();
43 }
44 
45 bool poll_state_synchronize_rcu(unsigned long oldstate);
46 
poll_state_synchronize_rcu_full(struct rcu_gp_seq * gsp)47 static inline bool poll_state_synchronize_rcu_full(struct rcu_gp_seq *gsp)
48 {
49 	return poll_state_synchronize_rcu(gsp->norm);
50 }
51 
cond_synchronize_rcu(unsigned long oldstate)52 static inline void cond_synchronize_rcu(unsigned long oldstate)
53 {
54 	might_sleep();
55 }
56 
cond_synchronize_rcu_full(struct rcu_gp_seq * gsp)57 static inline void cond_synchronize_rcu_full(struct rcu_gp_seq *gsp)
58 {
59 	cond_synchronize_rcu(gsp->norm);
60 }
61 
start_poll_synchronize_rcu_expedited(void)62 static inline unsigned long start_poll_synchronize_rcu_expedited(void)
63 {
64 	return start_poll_synchronize_rcu();
65 }
66 
start_poll_synchronize_rcu_expedited_full(struct rcu_gp_seq * gsp)67 static inline void start_poll_synchronize_rcu_expedited_full(struct rcu_gp_seq *gsp)
68 {
69 	gsp->norm = start_poll_synchronize_rcu_expedited();
70 }
71 
cond_synchronize_rcu_expedited(unsigned long oldstate)72 static inline void cond_synchronize_rcu_expedited(unsigned long oldstate)
73 {
74 	cond_synchronize_rcu(oldstate);
75 }
76 
cond_synchronize_rcu_expedited_full(struct rcu_gp_seq * gsp)77 static inline void cond_synchronize_rcu_expedited_full(struct rcu_gp_seq *gsp)
78 {
79 	cond_synchronize_rcu_expedited(gsp->norm);
80 }
81 
82 extern void rcu_barrier(void);
83 
synchronize_rcu_expedited(void)84 static inline void synchronize_rcu_expedited(void)
85 {
86 	synchronize_rcu();
87 }
88 
89 void rcu_qs(void);
90 
rcu_softirq_qs(void)91 static inline void rcu_softirq_qs(void)
92 {
93 	rcu_qs();
94 }
95 
96 #define rcu_note_context_switch(preempt) \
97 	do { \
98 		rcu_qs(); \
99 		rcu_tasks_qs(current, (preempt)); \
100 	} while (0)
101 
rcu_needs_cpu(void)102 static inline int rcu_needs_cpu(void)
103 {
104 	return 0;
105 }
106 
rcu_request_urgent_qs_task(struct task_struct * t)107 static inline void rcu_request_urgent_qs_task(struct task_struct *t) { }
108 
109 /*
110  * Take advantage of the fact that there is only one CPU, which
111  * allows us to ignore virtualization-based context switches.
112  */
rcu_virt_note_context_switch(void)113 static inline void rcu_virt_note_context_switch(void) { }
rcu_cpu_stall_reset(void)114 static inline void rcu_cpu_stall_reset(void) { }
rcu_jiffies_till_stall_check(void)115 static inline int rcu_jiffies_till_stall_check(void) { return 21 * HZ; }
rcu_irq_exit_check_preempt(void)116 static inline void rcu_irq_exit_check_preempt(void) { }
exit_rcu(void)117 static inline void exit_rcu(void) { }
rcu_preempt_need_deferred_qs(struct task_struct * t)118 static inline bool rcu_preempt_need_deferred_qs(struct task_struct *t)
119 {
120 	return false;
121 }
rcu_preempt_deferred_qs(struct task_struct * t)122 static inline void rcu_preempt_deferred_qs(struct task_struct *t) { }
123 void rcu_scheduler_starting(void);
rcu_end_inkernel_boot(void)124 static inline void rcu_end_inkernel_boot(void) { }
rcu_inkernel_boot_has_ended(void)125 static inline bool rcu_inkernel_boot_has_ended(void) { return true; }
rcu_is_watching(void)126 static inline bool rcu_is_watching(void) { return true; }
rcu_momentary_eqs(void)127 static inline void rcu_momentary_eqs(void) { }
128 
129 /* Avoid RCU read-side critical sections leaking across. */
rcu_all_qs(void)130 static inline void rcu_all_qs(void) { barrier(); }
131 
132 /* RCUtree hotplug events */
133 #define rcutree_prepare_cpu      NULL
134 #define rcutree_online_cpu       NULL
135 #define rcutree_offline_cpu      NULL
136 #define rcutree_dead_cpu         NULL
137 #define rcutree_dying_cpu        NULL
rcutree_report_cpu_starting(unsigned int cpu)138 static inline void rcutree_report_cpu_starting(unsigned int cpu) { }
139 
140 #endif /* __LINUX_RCUTINY_H */
141