Skip to content

Commit f9411eb

Browse files
committed
rcu: Separate the RCU synchronization types and APIs into <linux/rcupdate_wait.h>
So rcupdate.h is a pretty complex header, in particular it includes <linux/completion.h> which includes <linux/wait.h> - creating a dependency that includes <linux/wait.h> in <linux/sched.h>, which prevents the isolation of <linux/sched.h> from the derived <linux/wait.h> header. Solve part of the problem by decoupling rcupdate.h from completions: this can be done by separating out the rcu_synchronize types and APIs, and updating their usage sites. Since this is a mostly RCU-internal types this will not just simplify <linux/sched.h>'s dependencies, but will make all the hundreds of .c files that include rcupdate.h but not completions or wait.h build faster. ( For rcutiny this means that two dependent APIs have to be uninlined, but that shouldn't be much of a problem as they are rare variants. ) Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 4b53a34 commit f9411eb

10 files changed

Lines changed: 71 additions & 52 deletions

File tree

‎fs/autofs4/autofs_i.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/mutex.h>
1515
#include <linux/spinlock.h>
1616
#include <linux/list.h>
17+
#include <linux/completion.h>
1718

1819
/* This is the range of ioctl() numbers we claim as ours */
1920
#define AUTOFS_IOC_FIRST AUTOFS_IOC_READY

‎include/linux/dcache.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/rcupdate.h>
1212
#include <linux/lockref.h>
1313
#include <linux/stringhash.h>
14+
#include <linux/wait.h>
1415

1516
struct path;
1617
struct vfsmount;

‎include/linux/rcupdate.h‎

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include <linux/cpumask.h>
4141
#include <linux/seqlock.h>
4242
#include <linux/lockdep.h>
43-
#include <linux/completion.h>
4443
#include <linux/debugobjects.h>
4544
#include <linux/bug.h>
4645
#include <linux/compiler.h>
@@ -226,45 +225,6 @@ void call_rcu_sched(struct rcu_head *head,
226225

227226
void synchronize_sched(void);
228227

229-
/*
230-
* Structure allowing asynchronous waiting on RCU.
231-
*/
232-
struct rcu_synchronize {
233-
struct rcu_head head;
234-
struct completion completion;
235-
};
236-
void wakeme_after_rcu(struct rcu_head *head);
237-
238-
void __wait_rcu_gp(bool checktiny, int n, call_rcu_func_t *crcu_array,
239-
struct rcu_synchronize *rs_array);
240-
241-
#define _wait_rcu_gp(checktiny, ...) \
242-
do { \
243-
call_rcu_func_t __crcu_array[] = { __VA_ARGS__ }; \
244-
struct rcu_synchronize __rs_array[ARRAY_SIZE(__crcu_array)]; \
245-
__wait_rcu_gp(checktiny, ARRAY_SIZE(__crcu_array), \
246-
__crcu_array, __rs_array); \
247-
} while (0)
248-
249-
#define wait_rcu_gp(...) _wait_rcu_gp(false, __VA_ARGS__)
250-
251-
/**
252-
* synchronize_rcu_mult - Wait concurrently for multiple grace periods
253-
* @...: List of call_rcu() functions for the flavors to wait on.
254-
*
255-
* This macro waits concurrently for multiple flavors of RCU grace periods.
256-
* For example, synchronize_rcu_mult(call_rcu, call_rcu_bh) would wait
257-
* on concurrent RCU and RCU-bh grace periods. Waiting on a give SRCU
258-
* domain requires you to write a wrapper function for that SRCU domain's
259-
* call_srcu() function, supplying the corresponding srcu_struct.
260-
*
261-
* If Tiny RCU, tell _wait_rcu_gp() not to bother waiting for RCU
262-
* or RCU-bh, given that anywhere synchronize_rcu_mult() can be called
263-
* is automatically a grace period.
264-
*/
265-
#define synchronize_rcu_mult(...) \
266-
_wait_rcu_gp(IS_ENABLED(CONFIG_TINY_RCU), __VA_ARGS__)
267-
268228
/**
269229
* call_rcu_tasks() - Queue an RCU for invocation task-based grace period
270230
* @head: structure to be used for queueing the RCU updates.

‎include/linux/rcupdate_wait.h‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#ifndef _LINUX_SCHED_RCUPDATE_WAIT_H
2+
#define _LINUX_SCHED_RCUPDATE_WAIT_H
3+
4+
/*
5+
* RCU synchronization types and methods:
6+
*/
7+
8+
#include <linux/rcupdate.h>
9+
#include <linux/completion.h>
10+
11+
/*
12+
* Structure allowing asynchronous waiting on RCU.
13+
*/
14+
struct rcu_synchronize {
15+
struct rcu_head head;
16+
struct completion completion;
17+
};
18+
void wakeme_after_rcu(struct rcu_head *head);
19+
20+
void __wait_rcu_gp(bool checktiny, int n, call_rcu_func_t *crcu_array,
21+
struct rcu_synchronize *rs_array);
22+
23+
#define _wait_rcu_gp(checktiny, ...) \
24+
do { \
25+
call_rcu_func_t __crcu_array[] = { __VA_ARGS__ }; \
26+
struct rcu_synchronize __rs_array[ARRAY_SIZE(__crcu_array)]; \
27+
__wait_rcu_gp(checktiny, ARRAY_SIZE(__crcu_array), \
28+
__crcu_array, __rs_array); \
29+
} while (0)
30+
31+
#define wait_rcu_gp(...) _wait_rcu_gp(false, __VA_ARGS__)
32+
33+
/**
34+
* synchronize_rcu_mult - Wait concurrently for multiple grace periods
35+
* @...: List of call_rcu() functions for the flavors to wait on.
36+
*
37+
* This macro waits concurrently for multiple flavors of RCU grace periods.
38+
* For example, synchronize_rcu_mult(call_rcu, call_rcu_bh) would wait
39+
* on concurrent RCU and RCU-bh grace periods. Waiting on a give SRCU
40+
* domain requires you to write a wrapper function for that SRCU domain's
41+
* call_srcu() function, supplying the corresponding srcu_struct.
42+
*
43+
* If Tiny RCU, tell _wait_rcu_gp() not to bother waiting for RCU
44+
* or RCU-bh, given that anywhere synchronize_rcu_mult() can be called
45+
* is automatically a grace period.
46+
*/
47+
#define synchronize_rcu_mult(...) \
48+
_wait_rcu_gp(IS_ENABLED(CONFIG_TINY_RCU), __VA_ARGS__)
49+
50+
#endif /* _LINUX_SCHED_RCUPDATE_WAIT_H */

‎include/linux/rcutiny.h‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,8 @@ static inline void cond_synchronize_sched(unsigned long oldstate)
5353
might_sleep();
5454
}
5555

56-
static inline void rcu_barrier_bh(void)
57-
{
58-
wait_rcu_gp(call_rcu_bh);
59-
}
60-
61-
static inline void rcu_barrier_sched(void)
62-
{
63-
wait_rcu_gp(call_rcu_sched);
64-
}
56+
extern void rcu_barrier_bh(void);
57+
extern void rcu_barrier_sched(void);
6558

6659
static inline void synchronize_rcu_expedited(void)
6760
{

‎kernel/rcu/srcu.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <linux/mutex.h>
3131
#include <linux/percpu.h>
3232
#include <linux/preempt.h>
33-
#include <linux/rcupdate.h>
33+
#include <linux/rcupdate_wait.h>
3434
#include <linux/sched.h>
3535
#include <linux/smp.h>
3636
#include <linux/delay.h>

‎kernel/rcu/tiny.c‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <linux/completion.h>
2626
#include <linux/interrupt.h>
2727
#include <linux/notifier.h>
28-
#include <linux/rcupdate.h>
28+
#include <linux/rcupdate_wait.h>
2929
#include <linux/kernel.h>
3030
#include <linux/export.h>
3131
#include <linux/mutex.h>
@@ -47,6 +47,18 @@ static void __call_rcu(struct rcu_head *head,
4747

4848
#include "tiny_plugin.h"
4949

50+
void rcu_barrier_bh(void)
51+
{
52+
wait_rcu_gp(call_rcu_bh);
53+
}
54+
EXPORT_SYMBOL(rcu_barrier_bh);
55+
56+
void rcu_barrier_sched(void)
57+
{
58+
wait_rcu_gp(call_rcu_sched);
59+
}
60+
EXPORT_SYMBOL(rcu_barrier_sched);
61+
5062
#if defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE)
5163

5264
/*

‎kernel/rcu/tree.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include <linux/init.h>
3333
#include <linux/spinlock.h>
3434
#include <linux/smp.h>
35-
#include <linux/rcupdate.h>
35+
#include <linux/rcupdate_wait.h>
3636
#include <linux/interrupt.h>
3737
#include <linux/sched.h>
3838
#include <linux/nmi.h>

‎kernel/rcu/update.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include <linux/moduleparam.h>
5050
#include <linux/kthread.h>
5151
#include <linux/tick.h>
52+
#include <linux/rcupdate_wait.h>
5253

5354
#define CREATE_TRACE_POINTS
5455

‎kernel/sched/core.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/delayacct.h>
1111
#include <linux/init_task.h>
1212
#include <linux/context_tracking.h>
13+
#include <linux/rcupdate_wait.h>
1314

1415
#include <linux/blkdev.h>
1516
#include <linux/kprobes.h>

0 commit comments

Comments
 (0)