Commit 5c09d127 authored by Ingo Molnar's avatar Ingo Molnar

Merge branch 'rcu/next' of...

Merge branch 'rcu/next' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu into core/rcu

Pull the RCU tree from Paul E. McKenney:

"The major features of this series are:

1.	Preventing latency spikes of more than 200 microseconds for
	kernels built with NR_CPUS=4096, which is reportedly becoming
	the default for some distros.  This is a first step, as it does
	not help with systems that actually -have- 4096 CPUs (work on
	this case is in progress, but is not yet ready for mainline).
	This category also includes improving concurrency of rcu_barrier(),
	placed here due to conflicts.  Posted to LKML at:
	https://lkml.org/lkml/2012/6/22/381.  Note that patches 18-22
	of that series have been defered to 3.7, as they have not yet
	proven themselves to be mainline-ready (and yes, these are the
	ones intended to get rid of RCU's latency spikes for systems
	that actually have 4096 CPUs).
2.	Updates to documentation and rcutorture fixes, the latter category
	including improvements to rcu_barrier() testing.  Posted to LKML at:
	http://lkml.indiana.edu/hypermail/linux/kernel/1206.1/04094.html.
3.	Miscellaneous fixes posted to LKML at:
	https://lkml.org/lkml/2012/6/22/500, with the exception of the
	last commit, which was posted here:
	http://www.gossamer-threads.com/lists/linux/kernel/1561830
4.	RCU_FAST_NO_HZ fixes and improvements.  Posted to LKML at:
	http://lkml.indiana.edu/hypermail/linux/kernel/1206.1/00006.html
	and http://www.gossamer-threads.com/lists/linux/kernel/1561833.
	The first four patches of the first series went into 3.5 to fix
	a regression.
5.	Code-style fixes.  These were posted to LKML at
	http://lkml.indiana.edu/hypermail/linux/kernel/1205.2/01180.html and
	http://lkml.indiana.edu/hypermail/linux/kernel/1205.2/01181.html.
"
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents c4aed353 5cf05ad7
...@@ -162,9 +162,9 @@ over a rather long period of time, but improvements are always welcome! ...@@ -162,9 +162,9 @@ over a rather long period of time, but improvements are always welcome!
when publicizing a pointer to a structure that can when publicizing a pointer to a structure that can
be traversed by an RCU read-side critical section. be traversed by an RCU read-side critical section.
5. If call_rcu(), or a related primitive such as call_rcu_bh() or 5. If call_rcu(), or a related primitive such as call_rcu_bh(),
call_rcu_sched(), is used, the callback function must be call_rcu_sched(), or call_srcu() is used, the callback function
written to be called from softirq context. In particular, must be written to be called from softirq context. In particular,
it cannot block. it cannot block.
6. Since synchronize_rcu() can block, it cannot be called from 6. Since synchronize_rcu() can block, it cannot be called from
...@@ -202,11 +202,12 @@ over a rather long period of time, but improvements are always welcome! ...@@ -202,11 +202,12 @@ over a rather long period of time, but improvements are always welcome!
updater uses call_rcu_sched() or synchronize_sched(), then updater uses call_rcu_sched() or synchronize_sched(), then
the corresponding readers must disable preemption, possibly the corresponding readers must disable preemption, possibly
by calling rcu_read_lock_sched() and rcu_read_unlock_sched(). by calling rcu_read_lock_sched() and rcu_read_unlock_sched().
If the updater uses synchronize_srcu(), the the corresponding If the updater uses synchronize_srcu() or call_srcu(),
readers must use srcu_read_lock() and srcu_read_unlock(), the the corresponding readers must use srcu_read_lock() and
and with the same srcu_struct. The rules for the expedited srcu_read_unlock(), and with the same srcu_struct. The rules for
primitives are the same as for their non-expedited counterparts. the expedited primitives are the same as for their non-expedited
Mixing things up will result in confusion and broken kernels. counterparts. Mixing things up will result in confusion and
broken kernels.
One exception to this rule: rcu_read_lock() and rcu_read_unlock() One exception to this rule: rcu_read_lock() and rcu_read_unlock()
may be substituted for rcu_read_lock_bh() and rcu_read_unlock_bh() may be substituted for rcu_read_lock_bh() and rcu_read_unlock_bh()
...@@ -333,14 +334,14 @@ over a rather long period of time, but improvements are always welcome! ...@@ -333,14 +334,14 @@ over a rather long period of time, but improvements are always welcome!
victim CPU from ever going offline.) victim CPU from ever going offline.)
14. SRCU (srcu_read_lock(), srcu_read_unlock(), srcu_dereference(), 14. SRCU (srcu_read_lock(), srcu_read_unlock(), srcu_dereference(),
synchronize_srcu(), and synchronize_srcu_expedited()) may only synchronize_srcu(), synchronize_srcu_expedited(), and call_srcu())
be invoked from process context. Unlike other forms of RCU, it may only be invoked from process context. Unlike other forms of
-is- permissible to block in an SRCU read-side critical section RCU, it -is- permissible to block in an SRCU read-side critical
(demarked by srcu_read_lock() and srcu_read_unlock()), hence the section (demarked by srcu_read_lock() and srcu_read_unlock()),
"SRCU": "sleepable RCU". Please note that if you don't need hence the "SRCU": "sleepable RCU". Please note that if you
to sleep in read-side critical sections, you should be using don't need to sleep in read-side critical sections, you should be
RCU rather than SRCU, because RCU is almost always faster and using RCU rather than SRCU, because RCU is almost always faster
easier to use than is SRCU. and easier to use than is SRCU.
If you need to enter your read-side critical section in a If you need to enter your read-side critical section in a
hardirq or exception handler, and then exit that same read-side hardirq or exception handler, and then exit that same read-side
...@@ -353,8 +354,8 @@ over a rather long period of time, but improvements are always welcome! ...@@ -353,8 +354,8 @@ over a rather long period of time, but improvements are always welcome!
cleanup_srcu_struct(). These are passed a "struct srcu_struct" cleanup_srcu_struct(). These are passed a "struct srcu_struct"
that defines the scope of a given SRCU domain. Once initialized, that defines the scope of a given SRCU domain. Once initialized,
the srcu_struct is passed to srcu_read_lock(), srcu_read_unlock() the srcu_struct is passed to srcu_read_lock(), srcu_read_unlock()
synchronize_srcu(), and synchronize_srcu_expedited(). A given synchronize_srcu(), synchronize_srcu_expedited(), and call_srcu().
synchronize_srcu() waits only for SRCU read-side critical A given synchronize_srcu() waits only for SRCU read-side critical
sections governed by srcu_read_lock() and srcu_read_unlock() sections governed by srcu_read_lock() and srcu_read_unlock()
calls that have been passed the same srcu_struct. This property calls that have been passed the same srcu_struct. This property
is what makes sleeping read-side critical sections tolerable -- is what makes sleeping read-side critical sections tolerable --
...@@ -374,7 +375,7 @@ over a rather long period of time, but improvements are always welcome! ...@@ -374,7 +375,7 @@ over a rather long period of time, but improvements are always welcome!
requiring SRCU's read-side deadlock immunity or low read-side requiring SRCU's read-side deadlock immunity or low read-side
realtime latency. realtime latency.
Note that, rcu_assign_pointer() relates to SRCU just as they do Note that, rcu_assign_pointer() relates to SRCU just as it does
to other forms of RCU. to other forms of RCU.
15. The whole point of call_rcu(), synchronize_rcu(), and friends 15. The whole point of call_rcu(), synchronize_rcu(), and friends
......
...@@ -79,8 +79,6 @@ complete. Pseudo-code using rcu_barrier() is as follows: ...@@ -79,8 +79,6 @@ complete. Pseudo-code using rcu_barrier() is as follows:
2. Execute rcu_barrier(). 2. Execute rcu_barrier().
3. Allow the module to be unloaded. 3. Allow the module to be unloaded.
Quick Quiz #1: Why is there no srcu_barrier()?
The rcutorture module makes use of rcu_barrier in its exit function The rcutorture module makes use of rcu_barrier in its exit function
as follows: as follows:
...@@ -162,7 +160,7 @@ for any pre-existing callbacks to complete. ...@@ -162,7 +160,7 @@ for any pre-existing callbacks to complete.
Then lines 55-62 print status and do operation-specific cleanup, and Then lines 55-62 print status and do operation-specific cleanup, and
then return, permitting the module-unload operation to be completed. then return, permitting the module-unload operation to be completed.
Quick Quiz #2: Is there any other situation where rcu_barrier() might Quick Quiz #1: Is there any other situation where rcu_barrier() might
be required? be required?
Your module might have additional complications. For example, if your Your module might have additional complications. For example, if your
...@@ -242,7 +240,7 @@ reaches zero, as follows: ...@@ -242,7 +240,7 @@ reaches zero, as follows:
4 complete(&rcu_barrier_completion); 4 complete(&rcu_barrier_completion);
5 } 5 }
Quick Quiz #3: What happens if CPU 0's rcu_barrier_func() executes Quick Quiz #2: What happens if CPU 0's rcu_barrier_func() executes
immediately (thus incrementing rcu_barrier_cpu_count to the immediately (thus incrementing rcu_barrier_cpu_count to the
value one), but the other CPU's rcu_barrier_func() invocations value one), but the other CPU's rcu_barrier_func() invocations
are delayed for a full grace period? Couldn't this result in are delayed for a full grace period? Couldn't this result in
...@@ -259,12 +257,7 @@ so that your module may be safely unloaded. ...@@ -259,12 +257,7 @@ so that your module may be safely unloaded.
Answers to Quick Quizzes Answers to Quick Quizzes
Quick Quiz #1: Why is there no srcu_barrier()? Quick Quiz #1: Is there any other situation where rcu_barrier() might
Answer: Since there is no call_srcu(), there can be no outstanding SRCU
callbacks. Therefore, there is no need to wait for them.
Quick Quiz #2: Is there any other situation where rcu_barrier() might
be required? be required?
Answer: Interestingly enough, rcu_barrier() was not originally Answer: Interestingly enough, rcu_barrier() was not originally
...@@ -278,7 +271,7 @@ Answer: Interestingly enough, rcu_barrier() was not originally ...@@ -278,7 +271,7 @@ Answer: Interestingly enough, rcu_barrier() was not originally
implementing rcutorture, and found that rcu_barrier() solves implementing rcutorture, and found that rcu_barrier() solves
this problem as well. this problem as well.
Quick Quiz #3: What happens if CPU 0's rcu_barrier_func() executes Quick Quiz #2: What happens if CPU 0's rcu_barrier_func() executes
immediately (thus incrementing rcu_barrier_cpu_count to the immediately (thus incrementing rcu_barrier_cpu_count to the
value one), but the other CPU's rcu_barrier_func() invocations value one), but the other CPU's rcu_barrier_func() invocations
are delayed for a full grace period? Couldn't this result in are delayed for a full grace period? Couldn't this result in
......
...@@ -174,11 +174,20 @@ torture_type The type of RCU to test, with string values as follows: ...@@ -174,11 +174,20 @@ torture_type The type of RCU to test, with string values as follows:
and synchronize_rcu_bh_expedited(). and synchronize_rcu_bh_expedited().
"srcu": srcu_read_lock(), srcu_read_unlock() and "srcu": srcu_read_lock(), srcu_read_unlock() and
call_srcu().
"srcu_sync": srcu_read_lock(), srcu_read_unlock() and
synchronize_srcu(). synchronize_srcu().
"srcu_expedited": srcu_read_lock(), srcu_read_unlock() and "srcu_expedited": srcu_read_lock(), srcu_read_unlock() and
synchronize_srcu_expedited(). synchronize_srcu_expedited().
"srcu_raw": srcu_read_lock_raw(), srcu_read_unlock_raw(),
and call_srcu().
"srcu_raw_sync": srcu_read_lock_raw(), srcu_read_unlock_raw(),
and synchronize_srcu().
"sched": preempt_disable(), preempt_enable(), and "sched": preempt_disable(), preempt_enable(), and
call_rcu_sched(). call_rcu_sched().
......
...@@ -833,9 +833,9 @@ sched: Critical sections Grace period Barrier ...@@ -833,9 +833,9 @@ sched: Critical sections Grace period Barrier
SRCU: Critical sections Grace period Barrier SRCU: Critical sections Grace period Barrier
srcu_read_lock synchronize_srcu N/A srcu_read_lock synchronize_srcu srcu_barrier
srcu_read_unlock synchronize_srcu_expedited srcu_read_unlock call_srcu
srcu_read_lock_raw srcu_read_lock_raw synchronize_srcu_expedited
srcu_read_unlock_raw srcu_read_unlock_raw
srcu_dereference srcu_dereference
......
...@@ -2367,6 +2367,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted. ...@@ -2367,6 +2367,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
Set maximum number of finished RCU callbacks to process Set maximum number of finished RCU callbacks to process
in one batch. in one batch.
rcutree.fanout_leaf= [KNL,BOOT]
Increase the number of CPUs assigned to each
leaf rcu_node structure. Useful for very large
systems.
rcutree.qhimark= [KNL,BOOT] rcutree.qhimark= [KNL,BOOT]
Set threshold of queued Set threshold of queued
RCU callbacks over which batch limiting is disabled. RCU callbacks over which batch limiting is disabled.
......
...@@ -705,7 +705,6 @@ static void stack_proc(void *arg) ...@@ -705,7 +705,6 @@ static void stack_proc(void *arg)
struct task_struct *from = current, *to = arg; struct task_struct *from = current, *to = arg;
to->thread.saved_task = from; to->thread.saved_task = from;
rcu_switch_from(from);
switch_to(from, to, from); switch_to(from, to, from);
} }
......
...@@ -168,8 +168,8 @@ extern struct cred init_cred; ...@@ -168,8 +168,8 @@ extern struct cred init_cred;
.children = LIST_HEAD_INIT(tsk.children), \ .children = LIST_HEAD_INIT(tsk.children), \
.sibling = LIST_HEAD_INIT(tsk.sibling), \ .sibling = LIST_HEAD_INIT(tsk.sibling), \
.group_leader = &tsk, \ .group_leader = &tsk, \
RCU_INIT_POINTER(.real_cred, &init_cred), \ RCU_POINTER_INITIALIZER(real_cred, &init_cred), \
RCU_INIT_POINTER(.cred, &init_cred), \ RCU_POINTER_INITIALIZER(cred, &init_cred), \
.comm = INIT_TASK_COMM, \ .comm = INIT_TASK_COMM, \
.thread = INIT_THREAD, \ .thread = INIT_THREAD, \
.fs = &init_fs, \ .fs = &init_fs, \
......
...@@ -303,7 +303,9 @@ static inline bool key_is_instantiated(const struct key *key) ...@@ -303,7 +303,9 @@ static inline bool key_is_instantiated(const struct key *key)
rwsem_is_locked(&((struct key *)(KEY))->sem))) rwsem_is_locked(&((struct key *)(KEY))->sem)))
#define rcu_assign_keypointer(KEY, PAYLOAD) \ #define rcu_assign_keypointer(KEY, PAYLOAD) \
(rcu_assign_pointer((KEY)->payload.rcudata, PAYLOAD)) do { \
rcu_assign_pointer((KEY)->payload.rcudata, (PAYLOAD)); \
} while (0)
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
extern ctl_table key_sysctls[]; extern ctl_table key_sysctls[];
......
...@@ -147,6 +147,7 @@ extern void synchronize_sched(void); ...@@ -147,6 +147,7 @@ extern void synchronize_sched(void);
extern void __rcu_read_lock(void); extern void __rcu_read_lock(void);
extern void __rcu_read_unlock(void); extern void __rcu_read_unlock(void);
extern void rcu_read_unlock_special(struct task_struct *t);
void synchronize_rcu(void); void synchronize_rcu(void);
/* /*
...@@ -184,7 +185,6 @@ static inline int rcu_preempt_depth(void) ...@@ -184,7 +185,6 @@ static inline int rcu_preempt_depth(void)
/* Internal to kernel */ /* Internal to kernel */
extern void rcu_sched_qs(int cpu); extern void rcu_sched_qs(int cpu);
extern void rcu_bh_qs(int cpu); extern void rcu_bh_qs(int cpu);
extern void rcu_preempt_note_context_switch(void);
extern void rcu_check_callbacks(int cpu, int user); extern void rcu_check_callbacks(int cpu, int user);
struct notifier_block; struct notifier_block;
extern void rcu_idle_enter(void); extern void rcu_idle_enter(void);
...@@ -256,6 +256,10 @@ static inline void destroy_rcu_head_on_stack(struct rcu_head *head) ...@@ -256,6 +256,10 @@ static inline void destroy_rcu_head_on_stack(struct rcu_head *head)
} }
#endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */ #endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
#if defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_SMP)
extern int rcu_is_cpu_idle(void);
#endif /* #if defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_SMP) */
#if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PROVE_RCU) #if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PROVE_RCU)
bool rcu_lockdep_current_cpu_online(void); bool rcu_lockdep_current_cpu_online(void);
#else /* #if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PROVE_RCU) */ #else /* #if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PROVE_RCU) */
...@@ -267,15 +271,6 @@ static inline bool rcu_lockdep_current_cpu_online(void) ...@@ -267,15 +271,6 @@ static inline bool rcu_lockdep_current_cpu_online(void)
#ifdef CONFIG_DEBUG_LOCK_ALLOC #ifdef CONFIG_DEBUG_LOCK_ALLOC
#ifdef CONFIG_PROVE_RCU
extern int rcu_is_cpu_idle(void);
#else /* !CONFIG_PROVE_RCU */
static inline int rcu_is_cpu_idle(void)
{
return 0;
}
#endif /* else !CONFIG_PROVE_RCU */
static inline void rcu_lock_acquire(struct lockdep_map *map) static inline void rcu_lock_acquire(struct lockdep_map *map)
{ {
lock_acquire(map, 0, 0, 2, 1, NULL, _THIS_IP_); lock_acquire(map, 0, 0, 2, 1, NULL, _THIS_IP_);
...@@ -432,8 +427,7 @@ extern int rcu_my_thread_group_empty(void); ...@@ -432,8 +427,7 @@ extern int rcu_my_thread_group_empty(void);
static inline void rcu_preempt_sleep_check(void) static inline void rcu_preempt_sleep_check(void)
{ {
rcu_lockdep_assert(!lock_is_held(&rcu_lock_map), rcu_lockdep_assert(!lock_is_held(&rcu_lock_map),
"Illegal context switch in RCU read-side " "Illegal context switch in RCU read-side critical section");
"critical section");
} }
#else /* #ifdef CONFIG_PROVE_RCU */ #else /* #ifdef CONFIG_PROVE_RCU */
static inline void rcu_preempt_sleep_check(void) static inline void rcu_preempt_sleep_check(void)
...@@ -514,10 +508,10 @@ static inline void rcu_preempt_sleep_check(void) ...@@ -514,10 +508,10 @@ static inline void rcu_preempt_sleep_check(void)
(_________p1); \ (_________p1); \
}) })
#define __rcu_assign_pointer(p, v, space) \ #define __rcu_assign_pointer(p, v, space) \
({ \ do { \
smp_wmb(); \ smp_wmb(); \
(p) = (typeof(*v) __force space *)(v); \ (p) = (typeof(*v) __force space *)(v); \
}) } while (0)
/** /**
...@@ -852,7 +846,7 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) ...@@ -852,7 +846,7 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
* *
* Assigns the specified value to the specified RCU-protected * Assigns the specified value to the specified RCU-protected
* pointer, ensuring that any concurrent RCU readers will see * pointer, ensuring that any concurrent RCU readers will see
* any prior initialization. Returns the value assigned. * any prior initialization.
* *
* Inserts memory barriers on architectures that require them * Inserts memory barriers on architectures that require them
* (which is most of them), and also prevents the compiler from * (which is most of them), and also prevents the compiler from
...@@ -904,25 +898,17 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) ...@@ -904,25 +898,17 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
* the reader-accessible portions of the linked structure. * the reader-accessible portions of the linked structure.
*/ */
#define RCU_INIT_POINTER(p, v) \ #define RCU_INIT_POINTER(p, v) \
p = (typeof(*v) __force __rcu *)(v) do { \
p = (typeof(*v) __force __rcu *)(v); \
static __always_inline bool __is_kfree_rcu_offset(unsigned long offset) } while (0)
{
return offset < 4096;
}
static __always_inline
void __kfree_rcu(struct rcu_head *head, unsigned long offset)
{
typedef void (*rcu_callback)(struct rcu_head *);
BUILD_BUG_ON(!__builtin_constant_p(offset));
/* See the kfree_rcu() header comment. */
BUILD_BUG_ON(!__is_kfree_rcu_offset(offset));
kfree_call_rcu(head, (rcu_callback)offset); /**
} * RCU_POINTER_INITIALIZER() - statically initialize an RCU protected pointer
*
* GCC-style initialization for an RCU-protected pointer in a structure field.
*/
#define RCU_POINTER_INITIALIZER(p, v) \
.p = (typeof(*v) __force __rcu *)(v)
/* /*
* Does the specified offset indicate that the corresponding rcu_head * Does the specified offset indicate that the corresponding rcu_head
...@@ -936,7 +922,7 @@ void __kfree_rcu(struct rcu_head *head, unsigned long offset) ...@@ -936,7 +922,7 @@ void __kfree_rcu(struct rcu_head *head, unsigned long offset)
#define __kfree_rcu(head, offset) \ #define __kfree_rcu(head, offset) \
do { \ do { \
BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \ BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \
call_rcu(head, (void (*)(struct rcu_head *))(unsigned long)(offset)); \ kfree_call_rcu(head, (void (*)(struct rcu_head *))(unsigned long)(offset)); \
} while (0) } while (0)
/** /**
......
...@@ -87,6 +87,10 @@ static inline void kfree_call_rcu(struct rcu_head *head, ...@@ -87,6 +87,10 @@ static inline void kfree_call_rcu(struct rcu_head *head,
#ifdef CONFIG_TINY_RCU #ifdef CONFIG_TINY_RCU
static inline void rcu_preempt_note_context_switch(void)
{
}
static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies) static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies)
{ {
*delta_jiffies = ULONG_MAX; *delta_jiffies = ULONG_MAX;
...@@ -95,6 +99,7 @@ static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies) ...@@ -95,6 +99,7 @@ static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies)
#else /* #ifdef CONFIG_TINY_RCU */ #else /* #ifdef CONFIG_TINY_RCU */
void rcu_preempt_note_context_switch(void);
int rcu_preempt_needs_cpu(void); int rcu_preempt_needs_cpu(void);
static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies) static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies)
...@@ -108,6 +113,7 @@ static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies) ...@@ -108,6 +113,7 @@ static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies)
static inline void rcu_note_context_switch(int cpu) static inline void rcu_note_context_switch(int cpu)
{ {
rcu_sched_qs(cpu); rcu_sched_qs(cpu);
rcu_preempt_note_context_switch();
} }
/* /*
......
...@@ -1871,22 +1871,12 @@ static inline void rcu_copy_process(struct task_struct *p) ...@@ -1871,22 +1871,12 @@ static inline void rcu_copy_process(struct task_struct *p)
INIT_LIST_HEAD(&p->rcu_node_entry); INIT_LIST_HEAD(&p->rcu_node_entry);
} }
static inline void rcu_switch_from(struct task_struct *prev)
{
if (prev->rcu_read_lock_nesting != 0)
rcu_preempt_note_context_switch();
}
#else #else
static inline void rcu_copy_process(struct task_struct *p) static inline void rcu_copy_process(struct task_struct *p)
{ {
} }
static inline void rcu_switch_from(struct task_struct *prev)
{
}
#endif #endif
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
......
...@@ -541,6 +541,50 @@ TRACE_EVENT(rcu_torture_read, ...@@ -541,6 +541,50 @@ TRACE_EVENT(rcu_torture_read,
__entry->rcutorturename, __entry->rhp) __entry->rcutorturename, __entry->rhp)
); );
/*
* Tracepoint for _rcu_barrier() execution. The string "s" describes
* the _rcu_barrier phase:
* "Begin": rcu_barrier_callback() started.
* "Check": rcu_barrier_callback() checking for piggybacking.
* "EarlyExit": rcu_barrier_callback() piggybacked, thus early exit.
* "Inc1": rcu_barrier_callback() piggyback check counter incremented.
* "Offline": rcu_barrier_callback() found offline CPU
* "OnlineQ": rcu_barrier_callback() found online CPU with callbacks.
* "OnlineNQ": rcu_barrier_callback() found online CPU, no callbacks.
* "IRQ": An rcu_barrier_callback() callback posted on remote CPU.
* "CB": An rcu_barrier_callback() invoked a callback, not the last.
* "LastCB": An rcu_barrier_callback() invoked the last callback.
* "Inc2": rcu_barrier_callback() piggyback check counter incremented.
* The "cpu" argument is the CPU or -1 if meaningless, the "cnt" argument
* is the count of remaining callbacks, and "done" is the piggybacking count.
*/
TRACE_EVENT(rcu_barrier,
TP_PROTO(char *rcuname, char *s, int cpu, int cnt, unsigned long done),
TP_ARGS(rcuname, s, cpu, cnt, done),
TP_STRUCT__entry(
__field(char *, rcuname)
__field(char *, s)
__field(int, cpu)
__field(int, cnt)
__field(unsigned long, done)
),
TP_fast_assign(
__entry->rcuname = rcuname;
__entry->s = s;
__entry->cpu = cpu;
__entry->cnt = cnt;
__entry->done = done;
),
TP_printk("%s %s cpu %d remaining %d # %lu",
__entry->rcuname, __entry->s, __entry->cpu, __entry->cnt,
__entry->done)
);
#else /* #ifdef CONFIG_RCU_TRACE */ #else /* #ifdef CONFIG_RCU_TRACE */
#define trace_rcu_grace_period(rcuname, gpnum, gpevent) do { } while (0) #define trace_rcu_grace_period(rcuname, gpnum, gpevent) do { } while (0)
...@@ -564,6 +608,7 @@ TRACE_EVENT(rcu_torture_read, ...@@ -564,6 +608,7 @@ TRACE_EVENT(rcu_torture_read,
#define trace_rcu_batch_end(rcuname, callbacks_invoked, cb, nr, iit, risk) \ #define trace_rcu_batch_end(rcuname, callbacks_invoked, cb, nr, iit, risk) \
do { } while (0) do { } while (0)
#define trace_rcu_torture_read(rcutorturename, rhp) do { } while (0) #define trace_rcu_torture_read(rcutorturename, rhp) do { } while (0)
#define trace_rcu_barrier(name, s, cpu, cnt, done) do { } while (0)
#endif /* #else #ifdef CONFIG_RCU_TRACE */ #endif /* #else #ifdef CONFIG_RCU_TRACE */
......
...@@ -53,6 +53,50 @@ ...@@ -53,6 +53,50 @@
#ifdef CONFIG_PREEMPT_RCU #ifdef CONFIG_PREEMPT_RCU
/*
* Preemptible RCU implementation for rcu_read_lock().
* Just increment ->rcu_read_lock_nesting, shared state will be updated
* if we block.
*/
void __rcu_read_lock(void)
{
current->rcu_read_lock_nesting++;
barrier(); /* critical section after entry code. */
}
EXPORT_SYMBOL_GPL(__rcu_read_lock);
/*
* Preemptible RCU implementation for rcu_read_unlock().
* Decrement ->rcu_read_lock_nesting. If the result is zero (outermost
* rcu_read_unlock()) and ->rcu_read_unlock_special is non-zero, then
* invoke rcu_read_unlock_special() to clean up after a context switch
* in an RCU read-side critical section and other special cases.
*/
void __rcu_read_unlock(void)
{
struct task_struct *t = current;
if (t->rcu_read_lock_nesting != 1) {
--t->rcu_read_lock_nesting;
} else {
barrier(); /* critical section before exit code. */
t->rcu_read_lock_nesting = INT_MIN;
barrier(); /* assign before ->rcu_read_unlock_special load */
if (unlikely(ACCESS_ONCE(t->rcu_read_unlock_special)))
rcu_read_unlock_special(t);
barrier(); /* ->rcu_read_unlock_special load before assign */
t->rcu_read_lock_nesting = 0;
}
#ifdef CONFIG_PROVE_LOCKING
{
int rrln = ACCESS_ONCE(t->rcu_read_lock_nesting);
WARN_ON_ONCE(rrln < 0 && rrln > INT_MIN / 2);
}
#endif /* #ifdef CONFIG_PROVE_LOCKING */
}
EXPORT_SYMBOL_GPL(__rcu_read_unlock);
/* /*
* Check for a task exiting while in a preemptible-RCU read-side * Check for a task exiting while in a preemptible-RCU read-side
* critical section, clean up if so. No need to issue warnings, * critical section, clean up if so. No need to issue warnings,
......
...@@ -172,7 +172,7 @@ void rcu_irq_enter(void) ...@@ -172,7 +172,7 @@ void rcu_irq_enter(void)
local_irq_restore(flags); local_irq_restore(flags);
} }
#ifdef CONFIG_PROVE_RCU #ifdef CONFIG_DEBUG_LOCK_ALLOC
/* /*
* Test whether RCU thinks that the current CPU is idle. * Test whether RCU thinks that the current CPU is idle.
...@@ -183,7 +183,7 @@ int rcu_is_cpu_idle(void) ...@@ -183,7 +183,7 @@ int rcu_is_cpu_idle(void)
} }
EXPORT_SYMBOL(rcu_is_cpu_idle); EXPORT_SYMBOL(rcu_is_cpu_idle);
#endif /* #ifdef CONFIG_PROVE_RCU */ #endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
/* /*
* Test whether the current CPU was interrupted from idle. Nested * Test whether the current CPU was interrupted from idle. Nested
......
...@@ -132,7 +132,6 @@ static struct rcu_preempt_ctrlblk rcu_preempt_ctrlblk = { ...@@ -132,7 +132,6 @@ static struct rcu_preempt_ctrlblk rcu_preempt_ctrlblk = {
RCU_TRACE(.rcb.name = "rcu_preempt") RCU_TRACE(.rcb.name = "rcu_preempt")
}; };
static void rcu_read_unlock_special(struct task_struct *t);
static int rcu_preempted_readers_exp(void); static int rcu_preempted_readers_exp(void);
static void rcu_report_exp_done(void); static void rcu_report_exp_done(void);
...@@ -351,8 +350,9 @@ static int rcu_initiate_boost(void) ...@@ -351,8 +350,9 @@ static int rcu_initiate_boost(void)
rcu_preempt_ctrlblk.boost_tasks = rcu_preempt_ctrlblk.boost_tasks =
rcu_preempt_ctrlblk.gp_tasks; rcu_preempt_ctrlblk.gp_tasks;
invoke_rcu_callbacks(); invoke_rcu_callbacks();
} else } else {
RCU_TRACE(rcu_initiate_boost_trace()); RCU_TRACE(rcu_initiate_boost_trace());
}
return 1; return 1;
} }
...@@ -526,24 +526,12 @@ void rcu_preempt_note_context_switch(void) ...@@ -526,24 +526,12 @@ void rcu_preempt_note_context_switch(void)
local_irq_restore(flags); local_irq_restore(flags);
} }
/*
* Tiny-preemptible RCU implementation for rcu_read_lock().
* Just increment ->rcu_read_lock_nesting, shared state will be updated
* if we block.
*/
void __rcu_read_lock(void)
{
current->rcu_read_lock_nesting++;
barrier(); /* needed if we ever invoke rcu_read_lock in rcutiny.c */
}
EXPORT_SYMBOL_GPL(__rcu_read_lock);
/* /*
* Handle special cases during rcu_read_unlock(), such as needing to * Handle special cases during rcu_read_unlock(), such as needing to
* notify RCU core processing or task having blocked during the RCU * notify RCU core processing or task having blocked during the RCU
* read-side critical section. * read-side critical section.
*/ */
static noinline void rcu_read_unlock_special(struct task_struct *t) void rcu_read_unlock_special(struct task_struct *t)
{ {
int empty; int empty;
int empty_exp; int empty_exp;
...@@ -626,38 +614,6 @@ static noinline void rcu_read_unlock_special(struct task_struct *t) ...@@ -626,38 +614,6 @@ static noinline void rcu_read_unlock_special(struct task_struct *t)
local_irq_restore(flags); local_irq_restore(flags);
} }
/*
* Tiny-preemptible RCU implementation for rcu_read_unlock().
* Decrement ->rcu_read_lock_nesting. If the result is zero (outermost
* rcu_read_unlock()) and ->rcu_read_unlock_special is non-zero, then
* invoke rcu_read_unlock_special() to clean up after a context switch
* in an RCU read-side critical section and other special cases.
*/
void __rcu_read_unlock(void)
{
struct task_struct *t = current;
barrier(); /* needed if we ever invoke rcu_read_unlock in rcutiny.c */
if (t->rcu_read_lock_nesting != 1)
--t->rcu_read_lock_nesting;
else {
t->rcu_read_lock_nesting = INT_MIN;
barrier(); /* assign before ->rcu_read_unlock_special load */
if (unlikely(ACCESS_ONCE(t->rcu_read_unlock_special)))
rcu_read_unlock_special(t);
barrier(); /* ->rcu_read_unlock_special load before assign */
t->rcu_read_lock_nesting = 0;
}
#ifdef CONFIG_PROVE_LOCKING
{
int rrln = ACCESS_ONCE(t->rcu_read_lock_nesting);
WARN_ON_ONCE(rrln < 0 && rrln > INT_MIN / 2);
}
#endif /* #ifdef CONFIG_PROVE_LOCKING */
}
EXPORT_SYMBOL_GPL(__rcu_read_unlock);
/* /*
* Check for a quiescent state from the current CPU. When a task blocks, * Check for a quiescent state from the current CPU. When a task blocks,
* the task is recorded in the rcu_preempt_ctrlblk structure, which is * the task is recorded in the rcu_preempt_ctrlblk structure, which is
...@@ -823,9 +779,9 @@ void synchronize_rcu_expedited(void) ...@@ -823,9 +779,9 @@ void synchronize_rcu_expedited(void)
rpcp->exp_tasks = NULL; rpcp->exp_tasks = NULL;
/* Wait for tail of ->blkd_tasks list to drain. */ /* Wait for tail of ->blkd_tasks list to drain. */
if (!rcu_preempted_readers_exp()) if (!rcu_preempted_readers_exp()) {
local_irq_restore(flags); local_irq_restore(flags);
else { } else {
rcu_initiate_boost(); rcu_initiate_boost();
local_irq_restore(flags); local_irq_restore(flags);
wait_event(sync_rcu_preempt_exp_wq, wait_event(sync_rcu_preempt_exp_wq,
...@@ -846,8 +802,6 @@ EXPORT_SYMBOL_GPL(synchronize_rcu_expedited); ...@@ -846,8 +802,6 @@ EXPORT_SYMBOL_GPL(synchronize_rcu_expedited);
*/ */
int rcu_preempt_needs_cpu(void) int rcu_preempt_needs_cpu(void)
{ {
if (!rcu_preempt_running_reader())
rcu_preempt_cpu_qs();
return rcu_preempt_ctrlblk.rcb.rcucblist != NULL; return rcu_preempt_ctrlblk.rcb.rcucblist != NULL;
} }
......
...@@ -49,8 +49,7 @@ ...@@ -49,8 +49,7 @@
#include <asm/byteorder.h> #include <asm/byteorder.h>
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com> and " MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com> and Josh Triplett <josh@freedesktop.org>");
"Josh Triplett <josh@freedesktop.org>");
static int nreaders = -1; /* # reader threads, defaults to 2*ncpus */ static int nreaders = -1; /* # reader threads, defaults to 2*ncpus */
static int nfakewriters = 4; /* # fake writer threads */ static int nfakewriters = 4; /* # fake writer threads */
...@@ -206,6 +205,7 @@ static unsigned long boost_starttime; /* jiffies of next boost test start. */ ...@@ -206,6 +205,7 @@ static unsigned long boost_starttime; /* jiffies of next boost test start. */
DEFINE_MUTEX(boost_mutex); /* protect setting boost_starttime */ DEFINE_MUTEX(boost_mutex); /* protect setting boost_starttime */
/* and boost task create/destroy. */ /* and boost task create/destroy. */
static atomic_t barrier_cbs_count; /* Barrier callbacks registered. */ static atomic_t barrier_cbs_count; /* Barrier callbacks registered. */
static bool barrier_phase; /* Test phase. */
static atomic_t barrier_cbs_invoked; /* Barrier callbacks invoked. */ static atomic_t barrier_cbs_invoked; /* Barrier callbacks invoked. */
static wait_queue_head_t *barrier_cbs_wq; /* Coordinate barrier testing. */ static wait_queue_head_t *barrier_cbs_wq; /* Coordinate barrier testing. */
static DECLARE_WAIT_QUEUE_HEAD(barrier_wq); static DECLARE_WAIT_QUEUE_HEAD(barrier_wq);
...@@ -407,8 +407,9 @@ rcu_torture_cb(struct rcu_head *p) ...@@ -407,8 +407,9 @@ rcu_torture_cb(struct rcu_head *p)
if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) { if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
rp->rtort_mbtest = 0; rp->rtort_mbtest = 0;
rcu_torture_free(rp); rcu_torture_free(rp);
} else } else {
cur_ops->deferred_free(rp); cur_ops->deferred_free(rp);
}
} }
static int rcu_no_completed(void) static int rcu_no_completed(void)
...@@ -635,6 +636,17 @@ static void srcu_torture_synchronize(void) ...@@ -635,6 +636,17 @@ static void srcu_torture_synchronize(void)
synchronize_srcu(&srcu_ctl); synchronize_srcu(&srcu_ctl);
} }
static void srcu_torture_call(struct rcu_head *head,
void (*func)(struct rcu_head *head))
{
call_srcu(&srcu_ctl, head, func);
}
static void srcu_torture_barrier(void)
{
srcu_barrier(&srcu_ctl);
}
static int srcu_torture_stats(char *page) static int srcu_torture_stats(char *page)
{ {
int cnt = 0; int cnt = 0;
...@@ -661,8 +673,8 @@ static struct rcu_torture_ops srcu_ops = { ...@@ -661,8 +673,8 @@ static struct rcu_torture_ops srcu_ops = {
.completed = srcu_torture_completed, .completed = srcu_torture_completed,
.deferred_free = srcu_torture_deferred_free, .deferred_free = srcu_torture_deferred_free,
.sync = srcu_torture_synchronize, .sync = srcu_torture_synchronize,
.call = NULL, .call = srcu_torture_call,
.cb_barrier = NULL, .cb_barrier = srcu_torture_barrier,
.stats = srcu_torture_stats, .stats = srcu_torture_stats,
.name = "srcu" .name = "srcu"
}; };
...@@ -1013,6 +1025,10 @@ rcu_torture_fakewriter(void *arg) ...@@ -1013,6 +1025,10 @@ rcu_torture_fakewriter(void *arg)
do { do {
schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10); schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10);
udelay(rcu_random(&rand) & 0x3ff); udelay(rcu_random(&rand) & 0x3ff);
if (cur_ops->cb_barrier != NULL &&
rcu_random(&rand) % (nfakewriters * 8) == 0)
cur_ops->cb_barrier();
else
cur_ops->sync(); cur_ops->sync();
rcu_stutter_wait("rcu_torture_fakewriter"); rcu_stutter_wait("rcu_torture_fakewriter");
} while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP); } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
...@@ -1183,27 +1199,27 @@ rcu_torture_printk(char *page) ...@@ -1183,27 +1199,27 @@ rcu_torture_printk(char *page)
} }
cnt += sprintf(&page[cnt], "%s%s ", torture_type, TORTURE_FLAG); cnt += sprintf(&page[cnt], "%s%s ", torture_type, TORTURE_FLAG);
cnt += sprintf(&page[cnt], cnt += sprintf(&page[cnt],
"rtc: %p ver: %lu tfle: %d rta: %d rtaf: %d rtf: %d " "rtc: %p ver: %lu tfle: %d rta: %d rtaf: %d rtf: %d ",
"rtmbe: %d rtbke: %ld rtbre: %ld "
"rtbf: %ld rtb: %ld nt: %ld "
"onoff: %ld/%ld:%ld/%ld "
"barrier: %ld/%ld:%ld",
rcu_torture_current, rcu_torture_current,
rcu_torture_current_version, rcu_torture_current_version,
list_empty(&rcu_torture_freelist), list_empty(&rcu_torture_freelist),
atomic_read(&n_rcu_torture_alloc), atomic_read(&n_rcu_torture_alloc),
atomic_read(&n_rcu_torture_alloc_fail), atomic_read(&n_rcu_torture_alloc_fail),
atomic_read(&n_rcu_torture_free), atomic_read(&n_rcu_torture_free));
cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
atomic_read(&n_rcu_torture_mberror), atomic_read(&n_rcu_torture_mberror),
n_rcu_torture_boost_ktrerror, n_rcu_torture_boost_ktrerror,
n_rcu_torture_boost_rterror, n_rcu_torture_boost_rterror);
cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
n_rcu_torture_boost_failure, n_rcu_torture_boost_failure,
n_rcu_torture_boosts, n_rcu_torture_boosts,
n_rcu_torture_timers, n_rcu_torture_timers);
cnt += sprintf(&page[cnt], "onoff: %ld/%ld:%ld/%ld ",
n_online_successes, n_online_successes,
n_online_attempts, n_online_attempts,
n_offline_successes, n_offline_successes,
n_offline_attempts, n_offline_attempts);
cnt += sprintf(&page[cnt], "barrier: %ld/%ld:%ld",
n_barrier_successes, n_barrier_successes,
n_barrier_attempts, n_barrier_attempts,
n_rcu_torture_barrier_error); n_rcu_torture_barrier_error);
...@@ -1445,8 +1461,7 @@ rcu_torture_shutdown(void *arg) ...@@ -1445,8 +1461,7 @@ rcu_torture_shutdown(void *arg)
delta = shutdown_time - jiffies_snap; delta = shutdown_time - jiffies_snap;
if (verbose) if (verbose)
printk(KERN_ALERT "%s" TORTURE_FLAG printk(KERN_ALERT "%s" TORTURE_FLAG
"rcu_torture_shutdown task: %lu " "rcu_torture_shutdown task: %lu jiffies remaining\n",
"jiffies remaining\n",
torture_type, delta); torture_type, delta);
schedule_timeout_interruptible(delta); schedule_timeout_interruptible(delta);
jiffies_snap = ACCESS_ONCE(jiffies); jiffies_snap = ACCESS_ONCE(jiffies);
...@@ -1498,8 +1513,7 @@ rcu_torture_onoff(void *arg) ...@@ -1498,8 +1513,7 @@ rcu_torture_onoff(void *arg)
if (cpu_down(cpu) == 0) { if (cpu_down(cpu) == 0) {
if (verbose) if (verbose)
printk(KERN_ALERT "%s" TORTURE_FLAG printk(KERN_ALERT "%s" TORTURE_FLAG
"rcu_torture_onoff task: " "rcu_torture_onoff task: offlined %d\n",
"offlined %d\n",
torture_type, cpu); torture_type, cpu);
n_offline_successes++; n_offline_successes++;
} }
...@@ -1512,8 +1526,7 @@ rcu_torture_onoff(void *arg) ...@@ -1512,8 +1526,7 @@ rcu_torture_onoff(void *arg)
if (cpu_up(cpu) == 0) { if (cpu_up(cpu) == 0) {
if (verbose) if (verbose)
printk(KERN_ALERT "%s" TORTURE_FLAG printk(KERN_ALERT "%s" TORTURE_FLAG
"rcu_torture_onoff task: " "rcu_torture_onoff task: onlined %d\n",
"onlined %d\n",
torture_type, cpu); torture_type, cpu);
n_online_successes++; n_online_successes++;
} }
...@@ -1631,6 +1644,7 @@ void rcu_torture_barrier_cbf(struct rcu_head *rcu) ...@@ -1631,6 +1644,7 @@ void rcu_torture_barrier_cbf(struct rcu_head *rcu)
static int rcu_torture_barrier_cbs(void *arg) static int rcu_torture_barrier_cbs(void *arg)
{ {
long myid = (long)arg; long myid = (long)arg;
bool lastphase = 0;
struct rcu_head rcu; struct rcu_head rcu;
init_rcu_head_on_stack(&rcu); init_rcu_head_on_stack(&rcu);
...@@ -1638,9 +1652,11 @@ static int rcu_torture_barrier_cbs(void *arg) ...@@ -1638,9 +1652,11 @@ static int rcu_torture_barrier_cbs(void *arg)
set_user_nice(current, 19); set_user_nice(current, 19);
do { do {
wait_event(barrier_cbs_wq[myid], wait_event(barrier_cbs_wq[myid],
atomic_read(&barrier_cbs_count) == n_barrier_cbs || barrier_phase != lastphase ||
kthread_should_stop() || kthread_should_stop() ||
fullstop != FULLSTOP_DONTSTOP); fullstop != FULLSTOP_DONTSTOP);
lastphase = barrier_phase;
smp_mb(); /* ensure barrier_phase load before ->call(). */
if (kthread_should_stop() || fullstop != FULLSTOP_DONTSTOP) if (kthread_should_stop() || fullstop != FULLSTOP_DONTSTOP)
break; break;
cur_ops->call(&rcu, rcu_torture_barrier_cbf); cur_ops->call(&rcu, rcu_torture_barrier_cbf);
...@@ -1665,7 +1681,8 @@ static int rcu_torture_barrier(void *arg) ...@@ -1665,7 +1681,8 @@ static int rcu_torture_barrier(void *arg)
do { do {
atomic_set(&barrier_cbs_invoked, 0); atomic_set(&barrier_cbs_invoked, 0);
atomic_set(&barrier_cbs_count, n_barrier_cbs); atomic_set(&barrier_cbs_count, n_barrier_cbs);
/* wake_up() path contains the required barriers. */ smp_mb(); /* Ensure barrier_phase after prior assignments. */
barrier_phase = !barrier_phase;
for (i = 0; i < n_barrier_cbs; i++) for (i = 0; i < n_barrier_cbs; i++)
wake_up(&barrier_cbs_wq[i]); wake_up(&barrier_cbs_wq[i]);
wait_event(barrier_wq, wait_event(barrier_wq,
...@@ -1684,7 +1701,7 @@ static int rcu_torture_barrier(void *arg) ...@@ -1684,7 +1701,7 @@ static int rcu_torture_barrier(void *arg)
schedule_timeout_interruptible(HZ / 10); schedule_timeout_interruptible(HZ / 10);
} while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP); } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
VERBOSE_PRINTK_STRING("rcu_torture_barrier task stopping"); VERBOSE_PRINTK_STRING("rcu_torture_barrier task stopping");
rcutorture_shutdown_absorb("rcu_torture_barrier_cbs"); rcutorture_shutdown_absorb("rcu_torture_barrier");
while (!kthread_should_stop()) while (!kthread_should_stop())
schedule_timeout_interruptible(1); schedule_timeout_interruptible(1);
return 0; return 0;
...@@ -1908,8 +1925,8 @@ rcu_torture_init(void) ...@@ -1908,8 +1925,8 @@ rcu_torture_init(void)
static struct rcu_torture_ops *torture_ops[] = static struct rcu_torture_ops *torture_ops[] =
{ &rcu_ops, &rcu_sync_ops, &rcu_expedited_ops, { &rcu_ops, &rcu_sync_ops, &rcu_expedited_ops,
&rcu_bh_ops, &rcu_bh_sync_ops, &rcu_bh_expedited_ops, &rcu_bh_ops, &rcu_bh_sync_ops, &rcu_bh_expedited_ops,
&srcu_ops, &srcu_sync_ops, &srcu_raw_ops, &srcu_ops, &srcu_sync_ops, &srcu_expedited_ops,
&srcu_raw_sync_ops, &srcu_expedited_ops, &srcu_raw_ops, &srcu_raw_sync_ops,
&sched_ops, &sched_sync_ops, &sched_expedited_ops, }; &sched_ops, &sched_sync_ops, &sched_expedited_ops, };
mutex_lock(&fullstop_mutex); mutex_lock(&fullstop_mutex);
...@@ -1931,8 +1948,7 @@ rcu_torture_init(void) ...@@ -1931,8 +1948,7 @@ rcu_torture_init(void)
return -EINVAL; return -EINVAL;
} }
if (cur_ops->fqs == NULL && fqs_duration != 0) { if (cur_ops->fqs == NULL && fqs_duration != 0) {
printk(KERN_ALERT "rcu-torture: ->fqs NULL and non-zero " printk(KERN_ALERT "rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n");
"fqs_duration, fqs disabled.\n");
fqs_duration = 0; fqs_duration = 0;
} }
if (cur_ops->init) if (cur_ops->init)
......
...@@ -60,36 +60,44 @@ ...@@ -60,36 +60,44 @@
/* Data structures. */ /* Data structures. */
static struct lock_class_key rcu_node_class[NUM_RCU_LVLS]; static struct lock_class_key rcu_node_class[RCU_NUM_LVLS];
#define RCU_STATE_INITIALIZER(structname) { \ #define RCU_STATE_INITIALIZER(sname, cr) { \
.level = { &structname##_state.node[0] }, \ .level = { &sname##_state.node[0] }, \
.levelcnt = { \ .call = cr, \
NUM_RCU_LVL_0, /* root of hierarchy. */ \
NUM_RCU_LVL_1, \
NUM_RCU_LVL_2, \
NUM_RCU_LVL_3, \
NUM_RCU_LVL_4, /* == MAX_RCU_LVLS */ \
}, \
.fqs_state = RCU_GP_IDLE, \ .fqs_state = RCU_GP_IDLE, \
.gpnum = -300, \ .gpnum = -300, \
.completed = -300, \ .completed = -300, \
.onofflock = __RAW_SPIN_LOCK_UNLOCKED(&structname##_state.onofflock), \ .onofflock = __RAW_SPIN_LOCK_UNLOCKED(&sname##_state.onofflock), \
.orphan_nxttail = &structname##_state.orphan_nxtlist, \ .orphan_nxttail = &sname##_state.orphan_nxtlist, \
.orphan_donetail = &structname##_state.orphan_donelist, \ .orphan_donetail = &sname##_state.orphan_donelist, \
.fqslock = __RAW_SPIN_LOCK_UNLOCKED(&structname##_state.fqslock), \ .barrier_mutex = __MUTEX_INITIALIZER(sname##_state.barrier_mutex), \
.n_force_qs = 0, \ .fqslock = __RAW_SPIN_LOCK_UNLOCKED(&sname##_state.fqslock), \
.n_force_qs_ngp = 0, \ .name = #sname, \
.name = #structname, \
} }
struct rcu_state rcu_sched_state = RCU_STATE_INITIALIZER(rcu_sched); struct rcu_state rcu_sched_state =
RCU_STATE_INITIALIZER(rcu_sched, call_rcu_sched);
DEFINE_PER_CPU(struct rcu_data, rcu_sched_data); DEFINE_PER_CPU(struct rcu_data, rcu_sched_data);
struct rcu_state rcu_bh_state = RCU_STATE_INITIALIZER(rcu_bh); struct rcu_state rcu_bh_state = RCU_STATE_INITIALIZER(rcu_bh, call_rcu_bh);
DEFINE_PER_CPU(struct rcu_data, rcu_bh_data); DEFINE_PER_CPU(struct rcu_data, rcu_bh_data);
static struct rcu_state *rcu_state; static struct rcu_state *rcu_state;
LIST_HEAD(rcu_struct_flavors);
/* Increase (but not decrease) the CONFIG_RCU_FANOUT_LEAF at boot time. */
static int rcu_fanout_leaf = CONFIG_RCU_FANOUT_LEAF;
module_param(rcu_fanout_leaf, int, 0);
int rcu_num_lvls __read_mostly = RCU_NUM_LVLS;
static int num_rcu_lvl[] = { /* Number of rcu_nodes at specified level. */
NUM_RCU_LVL_0,
NUM_RCU_LVL_1,
NUM_RCU_LVL_2,
NUM_RCU_LVL_3,
NUM_RCU_LVL_4,
};
int rcu_num_nodes __read_mostly = NUM_RCU_NODES; /* Total # rcu_nodes in use. */
/* /*
* The rcu_scheduler_active variable transitions from zero to one just * The rcu_scheduler_active variable transitions from zero to one just
...@@ -147,13 +155,6 @@ static void invoke_rcu_callbacks(struct rcu_state *rsp, struct rcu_data *rdp); ...@@ -147,13 +155,6 @@ static void invoke_rcu_callbacks(struct rcu_state *rsp, struct rcu_data *rdp);
unsigned long rcutorture_testseq; unsigned long rcutorture_testseq;
unsigned long rcutorture_vernum; unsigned long rcutorture_vernum;
/* State information for rcu_barrier() and friends. */
static DEFINE_PER_CPU(struct rcu_head, rcu_barrier_head) = {NULL};
static atomic_t rcu_barrier_cpu_count;
static DEFINE_MUTEX(rcu_barrier_mutex);
static struct completion rcu_barrier_completion;
/* /*
* Return true if an RCU grace period is in progress. The ACCESS_ONCE()s * Return true if an RCU grace period is in progress. The ACCESS_ONCE()s
* permit this function to be invoked without holding the root rcu_node * permit this function to be invoked without holding the root rcu_node
...@@ -201,6 +202,7 @@ void rcu_note_context_switch(int cpu) ...@@ -201,6 +202,7 @@ void rcu_note_context_switch(int cpu)
{ {
trace_rcu_utilization("Start context switch"); trace_rcu_utilization("Start context switch");
rcu_sched_qs(cpu); rcu_sched_qs(cpu);
rcu_preempt_note_context_switch(cpu);
trace_rcu_utilization("End context switch"); trace_rcu_utilization("End context switch");
} }
EXPORT_SYMBOL_GPL(rcu_note_context_switch); EXPORT_SYMBOL_GPL(rcu_note_context_switch);
...@@ -357,7 +359,7 @@ static void rcu_idle_enter_common(struct rcu_dynticks *rdtp, long long oldval) ...@@ -357,7 +359,7 @@ static void rcu_idle_enter_common(struct rcu_dynticks *rdtp, long long oldval)
struct task_struct *idle = idle_task(smp_processor_id()); struct task_struct *idle = idle_task(smp_processor_id());
trace_rcu_dyntick("Error on entry: not idle task", oldval, 0); trace_rcu_dyntick("Error on entry: not idle task", oldval, 0);
ftrace_dump(DUMP_ALL); ftrace_dump(DUMP_ORIG);
WARN_ONCE(1, "Current pid: %d comm: %s / Idle pid: %d comm: %s", WARN_ONCE(1, "Current pid: %d comm: %s / Idle pid: %d comm: %s",
current->pid, current->comm, current->pid, current->comm,
idle->pid, idle->comm); /* must be idle task! */ idle->pid, idle->comm); /* must be idle task! */
...@@ -467,7 +469,7 @@ static void rcu_idle_exit_common(struct rcu_dynticks *rdtp, long long oldval) ...@@ -467,7 +469,7 @@ static void rcu_idle_exit_common(struct rcu_dynticks *rdtp, long long oldval)
trace_rcu_dyntick("Error on exit: not idle task", trace_rcu_dyntick("Error on exit: not idle task",
oldval, rdtp->dynticks_nesting); oldval, rdtp->dynticks_nesting);
ftrace_dump(DUMP_ALL); ftrace_dump(DUMP_ORIG);
WARN_ONCE(1, "Current pid: %d comm: %s / Idle pid: %d comm: %s", WARN_ONCE(1, "Current pid: %d comm: %s / Idle pid: %d comm: %s",
current->pid, current->comm, current->pid, current->comm,
idle->pid, idle->comm); /* must be idle task! */ idle->pid, idle->comm); /* must be idle task! */
...@@ -584,8 +586,6 @@ void rcu_nmi_exit(void) ...@@ -584,8 +586,6 @@ void rcu_nmi_exit(void)
WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1); WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
} }
#ifdef CONFIG_PROVE_RCU
/** /**
* rcu_is_cpu_idle - see if RCU thinks that the current CPU is idle * rcu_is_cpu_idle - see if RCU thinks that the current CPU is idle
* *
...@@ -603,7 +603,7 @@ int rcu_is_cpu_idle(void) ...@@ -603,7 +603,7 @@ int rcu_is_cpu_idle(void)
} }
EXPORT_SYMBOL(rcu_is_cpu_idle); EXPORT_SYMBOL(rcu_is_cpu_idle);
#ifdef CONFIG_HOTPLUG_CPU #if defined(CONFIG_PROVE_RCU) && defined(CONFIG_HOTPLUG_CPU)
/* /*
* Is the current CPU online? Disable preemption to avoid false positives * Is the current CPU online? Disable preemption to avoid false positives
...@@ -644,9 +644,7 @@ bool rcu_lockdep_current_cpu_online(void) ...@@ -644,9 +644,7 @@ bool rcu_lockdep_current_cpu_online(void)
} }
EXPORT_SYMBOL_GPL(rcu_lockdep_current_cpu_online); EXPORT_SYMBOL_GPL(rcu_lockdep_current_cpu_online);
#endif /* #ifdef CONFIG_HOTPLUG_CPU */ #endif /* #if defined(CONFIG_PROVE_RCU) && defined(CONFIG_HOTPLUG_CPU) */
#endif /* #ifdef CONFIG_PROVE_RCU */
/** /**
* rcu_is_cpu_rrupt_from_idle - see if idle or immediately interrupted from idle * rcu_is_cpu_rrupt_from_idle - see if idle or immediately interrupted from idle
...@@ -732,7 +730,7 @@ static void print_other_cpu_stall(struct rcu_state *rsp) ...@@ -732,7 +730,7 @@ static void print_other_cpu_stall(struct rcu_state *rsp)
int cpu; int cpu;
long delta; long delta;
unsigned long flags; unsigned long flags;
int ndetected; int ndetected = 0;
struct rcu_node *rnp = rcu_get_root(rsp); struct rcu_node *rnp = rcu_get_root(rsp);
/* Only let one CPU complain about others per time interval. */ /* Only let one CPU complain about others per time interval. */
...@@ -773,7 +771,7 @@ static void print_other_cpu_stall(struct rcu_state *rsp) ...@@ -773,7 +771,7 @@ static void print_other_cpu_stall(struct rcu_state *rsp)
*/ */
rnp = rcu_get_root(rsp); rnp = rcu_get_root(rsp);
raw_spin_lock_irqsave(&rnp->lock, flags); raw_spin_lock_irqsave(&rnp->lock, flags);
ndetected = rcu_print_task_stall(rnp); ndetected += rcu_print_task_stall(rnp);
raw_spin_unlock_irqrestore(&rnp->lock, flags); raw_spin_unlock_irqrestore(&rnp->lock, flags);
print_cpu_stall_info_end(); print_cpu_stall_info_end();
...@@ -859,9 +857,10 @@ static int rcu_panic(struct notifier_block *this, unsigned long ev, void *ptr) ...@@ -859,9 +857,10 @@ static int rcu_panic(struct notifier_block *this, unsigned long ev, void *ptr)
*/ */
void rcu_cpu_stall_reset(void) void rcu_cpu_stall_reset(void)
{ {
rcu_sched_state.jiffies_stall = jiffies + ULONG_MAX / 2; struct rcu_state *rsp;
rcu_bh_state.jiffies_stall = jiffies + ULONG_MAX / 2;
rcu_preempt_stall_reset(); for_each_rcu_flavor(rsp)
rsp->jiffies_stall = jiffies + ULONG_MAX / 2;
} }
static struct notifier_block rcu_panic_block = { static struct notifier_block rcu_panic_block = {
...@@ -893,8 +892,9 @@ static void __note_new_gpnum(struct rcu_state *rsp, struct rcu_node *rnp, struct ...@@ -893,8 +892,9 @@ static void __note_new_gpnum(struct rcu_state *rsp, struct rcu_node *rnp, struct
if (rnp->qsmask & rdp->grpmask) { if (rnp->qsmask & rdp->grpmask) {
rdp->qs_pending = 1; rdp->qs_pending = 1;
rdp->passed_quiesce = 0; rdp->passed_quiesce = 0;
} else } else {
rdp->qs_pending = 0; rdp->qs_pending = 0;
}
zero_cpu_stall_ticks(rdp); zero_cpu_stall_ticks(rdp);
} }
} }
...@@ -935,6 +935,18 @@ check_for_new_grace_period(struct rcu_state *rsp, struct rcu_data *rdp) ...@@ -935,6 +935,18 @@ check_for_new_grace_period(struct rcu_state *rsp, struct rcu_data *rdp)
return ret; return ret;
} }
/*
* Initialize the specified rcu_data structure's callback list to empty.
*/
static void init_callback_list(struct rcu_data *rdp)
{
int i;
rdp->nxtlist = NULL;
for (i = 0; i < RCU_NEXT_SIZE; i++)
rdp->nxttail[i] = &rdp->nxtlist;
}
/* /*
* Advance this CPU's callbacks, but only if the current grace period * Advance this CPU's callbacks, but only if the current grace period
* has ended. This may be called only from the CPU to whom the rdp * has ended. This may be called only from the CPU to whom the rdp
...@@ -1327,8 +1339,6 @@ static void ...@@ -1327,8 +1339,6 @@ static void
rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp, rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
struct rcu_node *rnp, struct rcu_data *rdp) struct rcu_node *rnp, struct rcu_data *rdp)
{ {
int i;
/* /*
* Orphan the callbacks. First adjust the counts. This is safe * Orphan the callbacks. First adjust the counts. This is safe
* because ->onofflock excludes _rcu_barrier()'s adoption of * because ->onofflock excludes _rcu_barrier()'s adoption of
...@@ -1339,7 +1349,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp, ...@@ -1339,7 +1349,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
rsp->qlen += rdp->qlen; rsp->qlen += rdp->qlen;
rdp->n_cbs_orphaned += rdp->qlen; rdp->n_cbs_orphaned += rdp->qlen;
rdp->qlen_lazy = 0; rdp->qlen_lazy = 0;
rdp->qlen = 0; ACCESS_ONCE(rdp->qlen) = 0;
} }
/* /*
...@@ -1368,9 +1378,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp, ...@@ -1368,9 +1378,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
} }
/* Finally, initialize the rcu_data structure's list to empty. */ /* Finally, initialize the rcu_data structure's list to empty. */
rdp->nxtlist = NULL; init_callback_list(rdp);
for (i = 0; i < RCU_NEXT_SIZE; i++)
rdp->nxttail[i] = &rdp->nxtlist;
} }
/* /*
...@@ -1504,6 +1512,9 @@ static void rcu_cleanup_dead_cpu(int cpu, struct rcu_state *rsp) ...@@ -1504,6 +1512,9 @@ static void rcu_cleanup_dead_cpu(int cpu, struct rcu_state *rsp)
raw_spin_unlock_irqrestore(&rnp->lock, flags); raw_spin_unlock_irqrestore(&rnp->lock, flags);
if (need_report & RCU_OFL_TASKS_EXP_GP) if (need_report & RCU_OFL_TASKS_EXP_GP)
rcu_report_exp_rnp(rsp, rnp, true); rcu_report_exp_rnp(rsp, rnp, true);
WARN_ONCE(rdp->qlen != 0 || rdp->nxtlist != NULL,
"rcu_cleanup_dead_cpu: Callbacks on offline CPU %d: qlen=%lu, nxtlist=%p\n",
cpu, rdp->qlen, rdp->nxtlist);
} }
#else /* #ifdef CONFIG_HOTPLUG_CPU */ #else /* #ifdef CONFIG_HOTPLUG_CPU */
...@@ -1591,7 +1602,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp) ...@@ -1591,7 +1602,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
} }
smp_mb(); /* List handling before counting for rcu_barrier(). */ smp_mb(); /* List handling before counting for rcu_barrier(). */
rdp->qlen_lazy -= count_lazy; rdp->qlen_lazy -= count_lazy;
rdp->qlen -= count; ACCESS_ONCE(rdp->qlen) -= count;
rdp->n_cbs_invoked += count; rdp->n_cbs_invoked += count;
/* Reinstate batch limit if we have worked down the excess. */ /* Reinstate batch limit if we have worked down the excess. */
...@@ -1604,6 +1615,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp) ...@@ -1604,6 +1615,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
rdp->n_force_qs_snap = rsp->n_force_qs; rdp->n_force_qs_snap = rsp->n_force_qs;
} else if (rdp->qlen < rdp->qlen_last_fqs_check - qhimark) } else if (rdp->qlen < rdp->qlen_last_fqs_check - qhimark)
rdp->qlen_last_fqs_check = rdp->qlen; rdp->qlen_last_fqs_check = rdp->qlen;
WARN_ON_ONCE((rdp->nxtlist == NULL) != (rdp->qlen == 0));
local_irq_restore(flags); local_irq_restore(flags);
...@@ -1744,8 +1756,6 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed) ...@@ -1744,8 +1756,6 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed)
break; /* grace period idle or initializing, ignore. */ break; /* grace period idle or initializing, ignore. */
case RCU_SAVE_DYNTICK: case RCU_SAVE_DYNTICK:
if (RCU_SIGNAL_INIT != RCU_SAVE_DYNTICK)
break; /* So gcc recognizes the dead code. */
raw_spin_unlock(&rnp->lock); /* irqs remain disabled */ raw_spin_unlock(&rnp->lock); /* irqs remain disabled */
...@@ -1787,9 +1797,10 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed) ...@@ -1787,9 +1797,10 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed)
* whom the rdp belongs. * whom the rdp belongs.
*/ */
static void static void
__rcu_process_callbacks(struct rcu_state *rsp, struct rcu_data *rdp) __rcu_process_callbacks(struct rcu_state *rsp)
{ {
unsigned long flags; unsigned long flags;
struct rcu_data *rdp = __this_cpu_ptr(rsp->rda);
WARN_ON_ONCE(rdp->beenonline == 0); WARN_ON_ONCE(rdp->beenonline == 0);
...@@ -1825,11 +1836,11 @@ __rcu_process_callbacks(struct rcu_state *rsp, struct rcu_data *rdp) ...@@ -1825,11 +1836,11 @@ __rcu_process_callbacks(struct rcu_state *rsp, struct rcu_data *rdp)
*/ */
static void rcu_process_callbacks(struct softirq_action *unused) static void rcu_process_callbacks(struct softirq_action *unused)
{ {
struct rcu_state *rsp;
trace_rcu_utilization("Start RCU core"); trace_rcu_utilization("Start RCU core");
__rcu_process_callbacks(&rcu_sched_state, for_each_rcu_flavor(rsp)
&__get_cpu_var(rcu_sched_data)); __rcu_process_callbacks(rsp);
__rcu_process_callbacks(&rcu_bh_state, &__get_cpu_var(rcu_bh_data));
rcu_preempt_process_callbacks();
trace_rcu_utilization("End RCU core"); trace_rcu_utilization("End RCU core");
} }
...@@ -1856,6 +1867,56 @@ static void invoke_rcu_core(void) ...@@ -1856,6 +1867,56 @@ static void invoke_rcu_core(void)
raise_softirq(RCU_SOFTIRQ); raise_softirq(RCU_SOFTIRQ);
} }
/*
* Handle any core-RCU processing required by a call_rcu() invocation.
*/
static void __call_rcu_core(struct rcu_state *rsp, struct rcu_data *rdp,
struct rcu_head *head, unsigned long flags)
{
/*
* If called from an extended quiescent state, invoke the RCU
* core in order to force a re-evaluation of RCU's idleness.
*/
if (rcu_is_cpu_idle() && cpu_online(smp_processor_id()))
invoke_rcu_core();
/* If interrupts were disabled or CPU offline, don't invoke RCU core. */
if (irqs_disabled_flags(flags) || cpu_is_offline(smp_processor_id()))
return;
/*
* Force the grace period if too many callbacks or too long waiting.
* Enforce hysteresis, and don't invoke force_quiescent_state()
* if some other CPU has recently done so. Also, don't bother
* invoking force_quiescent_state() if the newly enqueued callback
* is the only one waiting for a grace period to complete.
*/
if (unlikely(rdp->qlen > rdp->qlen_last_fqs_check + qhimark)) {
/* Are we ignoring a completed grace period? */
rcu_process_gp_end(rsp, rdp);
check_for_new_grace_period(rsp, rdp);
/* Start a new grace period if one not already started. */
if (!rcu_gp_in_progress(rsp)) {
unsigned long nestflag;
struct rcu_node *rnp_root = rcu_get_root(rsp);
raw_spin_lock_irqsave(&rnp_root->lock, nestflag);
rcu_start_gp(rsp, nestflag); /* rlses rnp_root->lock */
} else {
/* Give the grace period a kick. */
rdp->blimit = LONG_MAX;
if (rsp->n_force_qs == rdp->n_force_qs_snap &&
*rdp->nxttail[RCU_DONE_TAIL] != head)
force_quiescent_state(rsp, 0);
rdp->n_force_qs_snap = rsp->n_force_qs;
rdp->qlen_last_fqs_check = rdp->qlen;
}
} else if (ULONG_CMP_LT(ACCESS_ONCE(rsp->jiffies_force_qs), jiffies))
force_quiescent_state(rsp, 1);
}
static void static void
__call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu), __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
struct rcu_state *rsp, bool lazy) struct rcu_state *rsp, bool lazy)
...@@ -1880,7 +1941,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu), ...@@ -1880,7 +1941,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
rdp = this_cpu_ptr(rsp->rda); rdp = this_cpu_ptr(rsp->rda);
/* Add the callback to our list. */ /* Add the callback to our list. */
rdp->qlen++; ACCESS_ONCE(rdp->qlen)++;
if (lazy) if (lazy)
rdp->qlen_lazy++; rdp->qlen_lazy++;
else else
...@@ -1895,43 +1956,8 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu), ...@@ -1895,43 +1956,8 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
else else
trace_rcu_callback(rsp->name, head, rdp->qlen_lazy, rdp->qlen); trace_rcu_callback(rsp->name, head, rdp->qlen_lazy, rdp->qlen);
/* If interrupts were disabled, don't dive into RCU core. */ /* Go handle any RCU core processing required. */
if (irqs_disabled_flags(flags)) { __call_rcu_core(rsp, rdp, head, flags);
local_irq_restore(flags);
return;
}
/*
* Force the grace period if too many callbacks or too long waiting.
* Enforce hysteresis, and don't invoke force_quiescent_state()
* if some other CPU has recently done so. Also, don't bother
* invoking force_quiescent_state() if the newly enqueued callback
* is the only one waiting for a grace period to complete.
*/
if (unlikely(rdp->qlen > rdp->qlen_last_fqs_check + qhimark)) {
/* Are we ignoring a completed grace period? */
rcu_process_gp_end(rsp, rdp);
check_for_new_grace_period(rsp, rdp);
/* Start a new grace period if one not already started. */
if (!rcu_gp_in_progress(rsp)) {
unsigned long nestflag;
struct rcu_node *rnp_root = rcu_get_root(rsp);
raw_spin_lock_irqsave(&rnp_root->lock, nestflag);
rcu_start_gp(rsp, nestflag); /* rlses rnp_root->lock */
} else {
/* Give the grace period a kick. */
rdp->blimit = LONG_MAX;
if (rsp->n_force_qs == rdp->n_force_qs_snap &&
*rdp->nxttail[RCU_DONE_TAIL] != head)
force_quiescent_state(rsp, 0);
rdp->n_force_qs_snap = rsp->n_force_qs;
rdp->qlen_last_fqs_check = rdp->qlen;
}
} else if (ULONG_CMP_LT(ACCESS_ONCE(rsp->jiffies_force_qs), jiffies))
force_quiescent_state(rsp, 1);
local_irq_restore(flags); local_irq_restore(flags);
} }
...@@ -1961,28 +1987,16 @@ EXPORT_SYMBOL_GPL(call_rcu_bh); ...@@ -1961,28 +1987,16 @@ EXPORT_SYMBOL_GPL(call_rcu_bh);
* occasionally incorrectly indicate that there are multiple CPUs online * occasionally incorrectly indicate that there are multiple CPUs online
* when there was in fact only one the whole time, as this just adds * when there was in fact only one the whole time, as this just adds
* some overhead: RCU still operates correctly. * some overhead: RCU still operates correctly.
*
* Of course, sampling num_online_cpus() with preemption enabled can
* give erroneous results if there are concurrent CPU-hotplug operations.
* For example, given a demonic sequence of preemptions in num_online_cpus()
* and CPU-hotplug operations, there could be two or more CPUs online at
* all times, but num_online_cpus() might well return one (or even zero).
*
* However, all such demonic sequences require at least one CPU-offline
* operation. Furthermore, rcu_blocking_is_gp() giving the wrong answer
* is only a problem if there is an RCU read-side critical section executing
* throughout. But RCU-sched and RCU-bh read-side critical sections
* disable either preemption or bh, which prevents a CPU from going offline.
* Therefore, the only way that rcu_blocking_is_gp() can incorrectly return
* that there is only one CPU when in fact there was more than one throughout
* is when there were no RCU readers in the system. If there are no
* RCU readers, the grace period by definition can be of zero length,
* regardless of the number of online CPUs.
*/ */
static inline int rcu_blocking_is_gp(void) static inline int rcu_blocking_is_gp(void)
{ {
int ret;
might_sleep(); /* Check for RCU read-side critical section. */ might_sleep(); /* Check for RCU read-side critical section. */
return num_online_cpus() <= 1; preempt_disable();
ret = num_online_cpus() <= 1;
preempt_enable();
return ret;
} }
/** /**
...@@ -2117,9 +2131,9 @@ void synchronize_sched_expedited(void) ...@@ -2117,9 +2131,9 @@ void synchronize_sched_expedited(void)
put_online_cpus(); put_online_cpus();
/* No joy, try again later. Or just synchronize_sched(). */ /* No joy, try again later. Or just synchronize_sched(). */
if (trycount++ < 10) if (trycount++ < 10) {
udelay(trycount * num_online_cpus()); udelay(trycount * num_online_cpus());
else { } else {
synchronize_sched(); synchronize_sched();
return; return;
} }
...@@ -2240,9 +2254,12 @@ static int __rcu_pending(struct rcu_state *rsp, struct rcu_data *rdp) ...@@ -2240,9 +2254,12 @@ static int __rcu_pending(struct rcu_state *rsp, struct rcu_data *rdp)
*/ */
static int rcu_pending(int cpu) static int rcu_pending(int cpu)
{ {
return __rcu_pending(&rcu_sched_state, &per_cpu(rcu_sched_data, cpu)) || struct rcu_state *rsp;
__rcu_pending(&rcu_bh_state, &per_cpu(rcu_bh_data, cpu)) ||
rcu_preempt_pending(cpu); for_each_rcu_flavor(rsp)
if (__rcu_pending(rsp, per_cpu_ptr(rsp->rda, cpu)))
return 1;
return 0;
} }
/* /*
...@@ -2252,20 +2269,41 @@ static int rcu_pending(int cpu) ...@@ -2252,20 +2269,41 @@ static int rcu_pending(int cpu)
*/ */
static int rcu_cpu_has_callbacks(int cpu) static int rcu_cpu_has_callbacks(int cpu)
{ {
struct rcu_state *rsp;
/* RCU callbacks either ready or pending? */ /* RCU callbacks either ready or pending? */
return per_cpu(rcu_sched_data, cpu).nxtlist || for_each_rcu_flavor(rsp)
per_cpu(rcu_bh_data, cpu).nxtlist || if (per_cpu_ptr(rsp->rda, cpu)->nxtlist)
rcu_preempt_cpu_has_callbacks(cpu); return 1;
return 0;
}
/*
* Helper function for _rcu_barrier() tracing. If tracing is disabled,
* the compiler is expected to optimize this away.
*/
static void _rcu_barrier_trace(struct rcu_state *rsp, char *s,
int cpu, unsigned long done)
{
trace_rcu_barrier(rsp->name, s, cpu,
atomic_read(&rsp->barrier_cpu_count), done);
} }
/* /*
* RCU callback function for _rcu_barrier(). If we are last, wake * RCU callback function for _rcu_barrier(). If we are last, wake
* up the task executing _rcu_barrier(). * up the task executing _rcu_barrier().
*/ */
static void rcu_barrier_callback(struct rcu_head *notused) static void rcu_barrier_callback(struct rcu_head *rhp)
{ {
if (atomic_dec_and_test(&rcu_barrier_cpu_count)) struct rcu_data *rdp = container_of(rhp, struct rcu_data, barrier_head);
complete(&rcu_barrier_completion); struct rcu_state *rsp = rdp->rsp;
if (atomic_dec_and_test(&rsp->barrier_cpu_count)) {
_rcu_barrier_trace(rsp, "LastCB", -1, rsp->n_barrier_done);
complete(&rsp->barrier_completion);
} else {
_rcu_barrier_trace(rsp, "CB", -1, rsp->n_barrier_done);
}
} }
/* /*
...@@ -2273,35 +2311,63 @@ static void rcu_barrier_callback(struct rcu_head *notused) ...@@ -2273,35 +2311,63 @@ static void rcu_barrier_callback(struct rcu_head *notused)
*/ */
static void rcu_barrier_func(void *type) static void rcu_barrier_func(void *type)
{ {
int cpu = smp_processor_id(); struct rcu_state *rsp = type;
struct rcu_head *head = &per_cpu(rcu_barrier_head, cpu); struct rcu_data *rdp = __this_cpu_ptr(rsp->rda);
void (*call_rcu_func)(struct rcu_head *head,
void (*func)(struct rcu_head *head));
atomic_inc(&rcu_barrier_cpu_count); _rcu_barrier_trace(rsp, "IRQ", -1, rsp->n_barrier_done);
call_rcu_func = type; atomic_inc(&rsp->barrier_cpu_count);
call_rcu_func(head, rcu_barrier_callback); rsp->call(&rdp->barrier_head, rcu_barrier_callback);
} }
/* /*
* Orchestrate the specified type of RCU barrier, waiting for all * Orchestrate the specified type of RCU barrier, waiting for all
* RCU callbacks of the specified type to complete. * RCU callbacks of the specified type to complete.
*/ */
static void _rcu_barrier(struct rcu_state *rsp, static void _rcu_barrier(struct rcu_state *rsp)
void (*call_rcu_func)(struct rcu_head *head,
void (*func)(struct rcu_head *head)))
{ {
int cpu; int cpu;
unsigned long flags; unsigned long flags;
struct rcu_data *rdp; struct rcu_data *rdp;
struct rcu_head rh; struct rcu_data rd;
unsigned long snap = ACCESS_ONCE(rsp->n_barrier_done);
unsigned long snap_done;
init_rcu_head_on_stack(&rh); init_rcu_head_on_stack(&rd.barrier_head);
_rcu_barrier_trace(rsp, "Begin", -1, snap);
/* Take mutex to serialize concurrent rcu_barrier() requests. */ /* Take mutex to serialize concurrent rcu_barrier() requests. */
mutex_lock(&rcu_barrier_mutex); mutex_lock(&rsp->barrier_mutex);
smp_mb(); /* Prevent any prior operations from leaking in. */ /*
* Ensure that all prior references, including to ->n_barrier_done,
* are ordered before the _rcu_barrier() machinery.
*/
smp_mb(); /* See above block comment. */
/*
* Recheck ->n_barrier_done to see if others did our work for us.
* This means checking ->n_barrier_done for an even-to-odd-to-even
* transition. The "if" expression below therefore rounds the old
* value up to the next even number and adds two before comparing.
*/
snap_done = ACCESS_ONCE(rsp->n_barrier_done);
_rcu_barrier_trace(rsp, "Check", -1, snap_done);
if (ULONG_CMP_GE(snap_done, ((snap + 1) & ~0x1) + 2)) {
_rcu_barrier_trace(rsp, "EarlyExit", -1, snap_done);
smp_mb(); /* caller's subsequent code after above check. */
mutex_unlock(&rsp->barrier_mutex);
return;
}
/*
* Increment ->n_barrier_done to avoid duplicate work. Use
* ACCESS_ONCE() to prevent the compiler from speculating
* the increment to precede the early-exit check.
*/
ACCESS_ONCE(rsp->n_barrier_done)++;
WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
_rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
/* /*
* Initialize the count to one rather than to zero in order to * Initialize the count to one rather than to zero in order to
...@@ -2320,8 +2386,8 @@ static void _rcu_barrier(struct rcu_state *rsp, ...@@ -2320,8 +2386,8 @@ static void _rcu_barrier(struct rcu_state *rsp,
* 6. Both rcu_barrier_callback() callbacks are invoked, awakening * 6. Both rcu_barrier_callback() callbacks are invoked, awakening
* us -- but before CPU 1's orphaned callbacks are invoked!!! * us -- but before CPU 1's orphaned callbacks are invoked!!!
*/ */
init_completion(&rcu_barrier_completion); init_completion(&rsp->barrier_completion);
atomic_set(&rcu_barrier_cpu_count, 1); atomic_set(&rsp->barrier_cpu_count, 1);
raw_spin_lock_irqsave(&rsp->onofflock, flags); raw_spin_lock_irqsave(&rsp->onofflock, flags);
rsp->rcu_barrier_in_progress = current; rsp->rcu_barrier_in_progress = current;
raw_spin_unlock_irqrestore(&rsp->onofflock, flags); raw_spin_unlock_irqrestore(&rsp->onofflock, flags);
...@@ -2337,14 +2403,19 @@ static void _rcu_barrier(struct rcu_state *rsp, ...@@ -2337,14 +2403,19 @@ static void _rcu_barrier(struct rcu_state *rsp,
preempt_disable(); preempt_disable();
rdp = per_cpu_ptr(rsp->rda, cpu); rdp = per_cpu_ptr(rsp->rda, cpu);
if (cpu_is_offline(cpu)) { if (cpu_is_offline(cpu)) {
_rcu_barrier_trace(rsp, "Offline", cpu,
rsp->n_barrier_done);
preempt_enable(); preempt_enable();
while (cpu_is_offline(cpu) && ACCESS_ONCE(rdp->qlen)) while (cpu_is_offline(cpu) && ACCESS_ONCE(rdp->qlen))
schedule_timeout_interruptible(1); schedule_timeout_interruptible(1);
} else if (ACCESS_ONCE(rdp->qlen)) { } else if (ACCESS_ONCE(rdp->qlen)) {
smp_call_function_single(cpu, rcu_barrier_func, _rcu_barrier_trace(rsp, "OnlineQ", cpu,
(void *)call_rcu_func, 1); rsp->n_barrier_done);
smp_call_function_single(cpu, rcu_barrier_func, rsp, 1);
preempt_enable(); preempt_enable();
} else { } else {
_rcu_barrier_trace(rsp, "OnlineNQ", cpu,
rsp->n_barrier_done);
preempt_enable(); preempt_enable();
} }
} }
...@@ -2361,24 +2432,32 @@ static void _rcu_barrier(struct rcu_state *rsp, ...@@ -2361,24 +2432,32 @@ static void _rcu_barrier(struct rcu_state *rsp,
rcu_adopt_orphan_cbs(rsp); rcu_adopt_orphan_cbs(rsp);
rsp->rcu_barrier_in_progress = NULL; rsp->rcu_barrier_in_progress = NULL;
raw_spin_unlock_irqrestore(&rsp->onofflock, flags); raw_spin_unlock_irqrestore(&rsp->onofflock, flags);
atomic_inc(&rcu_barrier_cpu_count); atomic_inc(&rsp->barrier_cpu_count);
smp_mb__after_atomic_inc(); /* Ensure atomic_inc() before callback. */ smp_mb__after_atomic_inc(); /* Ensure atomic_inc() before callback. */
call_rcu_func(&rh, rcu_barrier_callback); rd.rsp = rsp;
rsp->call(&rd.barrier_head, rcu_barrier_callback);
/* /*
* Now that we have an rcu_barrier_callback() callback on each * Now that we have an rcu_barrier_callback() callback on each
* CPU, and thus each counted, remove the initial count. * CPU, and thus each counted, remove the initial count.
*/ */
if (atomic_dec_and_test(&rcu_barrier_cpu_count)) if (atomic_dec_and_test(&rsp->barrier_cpu_count))
complete(&rcu_barrier_completion); complete(&rsp->barrier_completion);
/* Increment ->n_barrier_done to prevent duplicate work. */
smp_mb(); /* Keep increment after above mechanism. */
ACCESS_ONCE(rsp->n_barrier_done)++;
WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
_rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
smp_mb(); /* Keep increment before caller's subsequent code. */
/* Wait for all rcu_barrier_callback() callbacks to be invoked. */ /* Wait for all rcu_barrier_callback() callbacks to be invoked. */
wait_for_completion(&rcu_barrier_completion); wait_for_completion(&rsp->barrier_completion);
/* Other rcu_barrier() invocations can now safely proceed. */ /* Other rcu_barrier() invocations can now safely proceed. */
mutex_unlock(&rcu_barrier_mutex); mutex_unlock(&rsp->barrier_mutex);
destroy_rcu_head_on_stack(&rh); destroy_rcu_head_on_stack(&rd.barrier_head);
} }
/** /**
...@@ -2386,7 +2465,7 @@ static void _rcu_barrier(struct rcu_state *rsp, ...@@ -2386,7 +2465,7 @@ static void _rcu_barrier(struct rcu_state *rsp,
*/ */
void rcu_barrier_bh(void) void rcu_barrier_bh(void)
{ {
_rcu_barrier(&rcu_bh_state, call_rcu_bh); _rcu_barrier(&rcu_bh_state);
} }
EXPORT_SYMBOL_GPL(rcu_barrier_bh); EXPORT_SYMBOL_GPL(rcu_barrier_bh);
...@@ -2395,7 +2474,7 @@ EXPORT_SYMBOL_GPL(rcu_barrier_bh); ...@@ -2395,7 +2474,7 @@ EXPORT_SYMBOL_GPL(rcu_barrier_bh);
*/ */
void rcu_barrier_sched(void) void rcu_barrier_sched(void)
{ {
_rcu_barrier(&rcu_sched_state, call_rcu_sched); _rcu_barrier(&rcu_sched_state);
} }
EXPORT_SYMBOL_GPL(rcu_barrier_sched); EXPORT_SYMBOL_GPL(rcu_barrier_sched);
...@@ -2406,18 +2485,15 @@ static void __init ...@@ -2406,18 +2485,15 @@ static void __init
rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp) rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
{ {
unsigned long flags; unsigned long flags;
int i;
struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu); struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
struct rcu_node *rnp = rcu_get_root(rsp); struct rcu_node *rnp = rcu_get_root(rsp);
/* Set up local state, ensuring consistent view of global state. */ /* Set up local state, ensuring consistent view of global state. */
raw_spin_lock_irqsave(&rnp->lock, flags); raw_spin_lock_irqsave(&rnp->lock, flags);
rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo); rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
rdp->nxtlist = NULL; init_callback_list(rdp);
for (i = 0; i < RCU_NEXT_SIZE; i++)
rdp->nxttail[i] = &rdp->nxtlist;
rdp->qlen_lazy = 0; rdp->qlen_lazy = 0;
rdp->qlen = 0; ACCESS_ONCE(rdp->qlen) = 0;
rdp->dynticks = &per_cpu(rcu_dynticks, cpu); rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE); WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1); WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
...@@ -2491,9 +2567,11 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible) ...@@ -2491,9 +2567,11 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
static void __cpuinit rcu_prepare_cpu(int cpu) static void __cpuinit rcu_prepare_cpu(int cpu)
{ {
rcu_init_percpu_data(cpu, &rcu_sched_state, 0); struct rcu_state *rsp;
rcu_init_percpu_data(cpu, &rcu_bh_state, 0);
rcu_preempt_init_percpu_data(cpu); for_each_rcu_flavor(rsp)
rcu_init_percpu_data(cpu, rsp,
strcmp(rsp->name, "rcu_preempt") == 0);
} }
/* /*
...@@ -2505,6 +2583,7 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self, ...@@ -2505,6 +2583,7 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self,
long cpu = (long)hcpu; long cpu = (long)hcpu;
struct rcu_data *rdp = per_cpu_ptr(rcu_state->rda, cpu); struct rcu_data *rdp = per_cpu_ptr(rcu_state->rda, cpu);
struct rcu_node *rnp = rdp->mynode; struct rcu_node *rnp = rdp->mynode;
struct rcu_state *rsp;
trace_rcu_utilization("Start CPU hotplug"); trace_rcu_utilization("Start CPU hotplug");
switch (action) { switch (action) {
...@@ -2529,18 +2608,16 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self, ...@@ -2529,18 +2608,16 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self,
* touch any data without introducing corruption. We send the * touch any data without introducing corruption. We send the
* dying CPU's callbacks to an arbitrarily chosen online CPU. * dying CPU's callbacks to an arbitrarily chosen online CPU.
*/ */
rcu_cleanup_dying_cpu(&rcu_bh_state); for_each_rcu_flavor(rsp)
rcu_cleanup_dying_cpu(&rcu_sched_state); rcu_cleanup_dying_cpu(rsp);
rcu_preempt_cleanup_dying_cpu();
rcu_cleanup_after_idle(cpu); rcu_cleanup_after_idle(cpu);
break; break;
case CPU_DEAD: case CPU_DEAD:
case CPU_DEAD_FROZEN: case CPU_DEAD_FROZEN:
case CPU_UP_CANCELED: case CPU_UP_CANCELED:
case CPU_UP_CANCELED_FROZEN: case CPU_UP_CANCELED_FROZEN:
rcu_cleanup_dead_cpu(cpu, &rcu_bh_state); for_each_rcu_flavor(rsp)
rcu_cleanup_dead_cpu(cpu, &rcu_sched_state); rcu_cleanup_dead_cpu(cpu, rsp);
rcu_preempt_cleanup_dead_cpu(cpu);
break; break;
default: default:
break; break;
...@@ -2573,9 +2650,9 @@ static void __init rcu_init_levelspread(struct rcu_state *rsp) ...@@ -2573,9 +2650,9 @@ static void __init rcu_init_levelspread(struct rcu_state *rsp)
{ {
int i; int i;
for (i = NUM_RCU_LVLS - 1; i > 0; i--) for (i = rcu_num_lvls - 1; i > 0; i--)
rsp->levelspread[i] = CONFIG_RCU_FANOUT; rsp->levelspread[i] = CONFIG_RCU_FANOUT;
rsp->levelspread[0] = CONFIG_RCU_FANOUT_LEAF; rsp->levelspread[0] = rcu_fanout_leaf;
} }
#else /* #ifdef CONFIG_RCU_FANOUT_EXACT */ #else /* #ifdef CONFIG_RCU_FANOUT_EXACT */
static void __init rcu_init_levelspread(struct rcu_state *rsp) static void __init rcu_init_levelspread(struct rcu_state *rsp)
...@@ -2585,7 +2662,7 @@ static void __init rcu_init_levelspread(struct rcu_state *rsp) ...@@ -2585,7 +2662,7 @@ static void __init rcu_init_levelspread(struct rcu_state *rsp)
int i; int i;
cprv = NR_CPUS; cprv = NR_CPUS;
for (i = NUM_RCU_LVLS - 1; i >= 0; i--) { for (i = rcu_num_lvls - 1; i >= 0; i--) {
ccur = rsp->levelcnt[i]; ccur = rsp->levelcnt[i];
rsp->levelspread[i] = (cprv + ccur - 1) / ccur; rsp->levelspread[i] = (cprv + ccur - 1) / ccur;
cprv = ccur; cprv = ccur;
...@@ -2612,13 +2689,15 @@ static void __init rcu_init_one(struct rcu_state *rsp, ...@@ -2612,13 +2689,15 @@ static void __init rcu_init_one(struct rcu_state *rsp,
/* Initialize the level-tracking arrays. */ /* Initialize the level-tracking arrays. */
for (i = 1; i < NUM_RCU_LVLS; i++) for (i = 0; i < rcu_num_lvls; i++)
rsp->levelcnt[i] = num_rcu_lvl[i];
for (i = 1; i < rcu_num_lvls; i++)
rsp->level[i] = rsp->level[i - 1] + rsp->levelcnt[i - 1]; rsp->level[i] = rsp->level[i - 1] + rsp->levelcnt[i - 1];
rcu_init_levelspread(rsp); rcu_init_levelspread(rsp);
/* Initialize the elements themselves, starting from the leaves. */ /* Initialize the elements themselves, starting from the leaves. */
for (i = NUM_RCU_LVLS - 1; i >= 0; i--) { for (i = rcu_num_lvls - 1; i >= 0; i--) {
cpustride *= rsp->levelspread[i]; cpustride *= rsp->levelspread[i];
rnp = rsp->level[i]; rnp = rsp->level[i];
for (j = 0; j < rsp->levelcnt[i]; j++, rnp++) { for (j = 0; j < rsp->levelcnt[i]; j++, rnp++) {
...@@ -2648,13 +2727,74 @@ static void __init rcu_init_one(struct rcu_state *rsp, ...@@ -2648,13 +2727,74 @@ static void __init rcu_init_one(struct rcu_state *rsp,
} }
rsp->rda = rda; rsp->rda = rda;
rnp = rsp->level[NUM_RCU_LVLS - 1]; rnp = rsp->level[rcu_num_lvls - 1];
for_each_possible_cpu(i) { for_each_possible_cpu(i) {
while (i > rnp->grphi) while (i > rnp->grphi)
rnp++; rnp++;
per_cpu_ptr(rsp->rda, i)->mynode = rnp; per_cpu_ptr(rsp->rda, i)->mynode = rnp;
rcu_boot_init_percpu_data(i, rsp); rcu_boot_init_percpu_data(i, rsp);
} }
list_add(&rsp->flavors, &rcu_struct_flavors);
}
/*
* Compute the rcu_node tree geometry from kernel parameters. This cannot
* replace the definitions in rcutree.h because those are needed to size
* the ->node array in the rcu_state structure.
*/
static void __init rcu_init_geometry(void)
{
int i;
int j;
int n = nr_cpu_ids;
int rcu_capacity[MAX_RCU_LVLS + 1];
/* If the compile-time values are accurate, just leave. */
if (rcu_fanout_leaf == CONFIG_RCU_FANOUT_LEAF)
return;
/*
* Compute number of nodes that can be handled an rcu_node tree
* with the given number of levels. Setting rcu_capacity[0] makes
* some of the arithmetic easier.
*/
rcu_capacity[0] = 1;
rcu_capacity[1] = rcu_fanout_leaf;
for (i = 2; i <= MAX_RCU_LVLS; i++)
rcu_capacity[i] = rcu_capacity[i - 1] * CONFIG_RCU_FANOUT;
/*
* The boot-time rcu_fanout_leaf parameter is only permitted
* to increase the leaf-level fanout, not decrease it. Of course,
* the leaf-level fanout cannot exceed the number of bits in
* the rcu_node masks. Finally, the tree must be able to accommodate
* the configured number of CPUs. Complain and fall back to the
* compile-time values if these limits are exceeded.
*/
if (rcu_fanout_leaf < CONFIG_RCU_FANOUT_LEAF ||
rcu_fanout_leaf > sizeof(unsigned long) * 8 ||
n > rcu_capacity[MAX_RCU_LVLS]) {
WARN_ON(1);
return;
}
/* Calculate the number of rcu_nodes at each level of the tree. */
for (i = 1; i <= MAX_RCU_LVLS; i++)
if (n <= rcu_capacity[i]) {
for (j = 0; j <= i; j++)
num_rcu_lvl[j] =
DIV_ROUND_UP(n, rcu_capacity[i - j]);
rcu_num_lvls = i;
for (j = i + 1; j <= MAX_RCU_LVLS; j++)
num_rcu_lvl[j] = 0;
break;
}
/* Calculate the total number of rcu_node structures. */
rcu_num_nodes = 0;
for (i = 0; i <= MAX_RCU_LVLS; i++)
rcu_num_nodes += num_rcu_lvl[i];
rcu_num_nodes -= n;
} }
void __init rcu_init(void) void __init rcu_init(void)
...@@ -2662,6 +2802,7 @@ void __init rcu_init(void) ...@@ -2662,6 +2802,7 @@ void __init rcu_init(void)
int cpu; int cpu;
rcu_bootup_announce(); rcu_bootup_announce();
rcu_init_geometry();
rcu_init_one(&rcu_sched_state, &rcu_sched_data); rcu_init_one(&rcu_sched_state, &rcu_sched_data);
rcu_init_one(&rcu_bh_state, &rcu_bh_data); rcu_init_one(&rcu_bh_state, &rcu_bh_data);
__rcu_init_preempt(); __rcu_init_preempt();
......
...@@ -42,28 +42,28 @@ ...@@ -42,28 +42,28 @@
#define RCU_FANOUT_4 (RCU_FANOUT_3 * CONFIG_RCU_FANOUT) #define RCU_FANOUT_4 (RCU_FANOUT_3 * CONFIG_RCU_FANOUT)
#if NR_CPUS <= RCU_FANOUT_1 #if NR_CPUS <= RCU_FANOUT_1
# define NUM_RCU_LVLS 1 # define RCU_NUM_LVLS 1
# define NUM_RCU_LVL_0 1 # define NUM_RCU_LVL_0 1
# define NUM_RCU_LVL_1 (NR_CPUS) # define NUM_RCU_LVL_1 (NR_CPUS)
# define NUM_RCU_LVL_2 0 # define NUM_RCU_LVL_2 0
# define NUM_RCU_LVL_3 0 # define NUM_RCU_LVL_3 0
# define NUM_RCU_LVL_4 0 # define NUM_RCU_LVL_4 0
#elif NR_CPUS <= RCU_FANOUT_2 #elif NR_CPUS <= RCU_FANOUT_2
# define NUM_RCU_LVLS 2 # define RCU_NUM_LVLS 2
# define NUM_RCU_LVL_0 1 # define NUM_RCU_LVL_0 1
# define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1)
# define NUM_RCU_LVL_2 (NR_CPUS) # define NUM_RCU_LVL_2 (NR_CPUS)
# define NUM_RCU_LVL_3 0 # define NUM_RCU_LVL_3 0
# define NUM_RCU_LVL_4 0 # define NUM_RCU_LVL_4 0
#elif NR_CPUS <= RCU_FANOUT_3 #elif NR_CPUS <= RCU_FANOUT_3
# define NUM_RCU_LVLS 3 # define RCU_NUM_LVLS 3
# define NUM_RCU_LVL_0 1 # define NUM_RCU_LVL_0 1
# define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2) # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2)
# define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1)
# define NUM_RCU_LVL_3 (NR_CPUS) # define NUM_RCU_LVL_3 (NR_CPUS)
# define NUM_RCU_LVL_4 0 # define NUM_RCU_LVL_4 0
#elif NR_CPUS <= RCU_FANOUT_4 #elif NR_CPUS <= RCU_FANOUT_4
# define NUM_RCU_LVLS 4 # define RCU_NUM_LVLS 4
# define NUM_RCU_LVL_0 1 # define NUM_RCU_LVL_0 1
# define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_3) # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_3)
# define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2) # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2)
...@@ -76,6 +76,9 @@ ...@@ -76,6 +76,9 @@
#define RCU_SUM (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2 + NUM_RCU_LVL_3 + NUM_RCU_LVL_4) #define RCU_SUM (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2 + NUM_RCU_LVL_3 + NUM_RCU_LVL_4)
#define NUM_RCU_NODES (RCU_SUM - NR_CPUS) #define NUM_RCU_NODES (RCU_SUM - NR_CPUS)
extern int rcu_num_lvls;
extern int rcu_num_nodes;
/* /*
* Dynticks per-CPU state. * Dynticks per-CPU state.
*/ */
...@@ -97,6 +100,7 @@ struct rcu_dynticks { ...@@ -97,6 +100,7 @@ struct rcu_dynticks {
/* # times non-lazy CBs posted to CPU. */ /* # times non-lazy CBs posted to CPU. */
unsigned long nonlazy_posted_snap; unsigned long nonlazy_posted_snap;
/* idle-period nonlazy_posted snapshot. */ /* idle-period nonlazy_posted snapshot. */
int tick_nohz_enabled_snap; /* Previously seen value from sysfs. */
#endif /* #ifdef CONFIG_RCU_FAST_NO_HZ */ #endif /* #ifdef CONFIG_RCU_FAST_NO_HZ */
}; };
...@@ -206,7 +210,7 @@ struct rcu_node { ...@@ -206,7 +210,7 @@ struct rcu_node {
*/ */
#define rcu_for_each_node_breadth_first(rsp, rnp) \ #define rcu_for_each_node_breadth_first(rsp, rnp) \
for ((rnp) = &(rsp)->node[0]; \ for ((rnp) = &(rsp)->node[0]; \
(rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++) (rnp) < &(rsp)->node[rcu_num_nodes]; (rnp)++)
/* /*
* Do a breadth-first scan of the non-leaf rcu_node structures for the * Do a breadth-first scan of the non-leaf rcu_node structures for the
...@@ -215,7 +219,7 @@ struct rcu_node { ...@@ -215,7 +219,7 @@ struct rcu_node {
*/ */
#define rcu_for_each_nonleaf_node_breadth_first(rsp, rnp) \ #define rcu_for_each_nonleaf_node_breadth_first(rsp, rnp) \
for ((rnp) = &(rsp)->node[0]; \ for ((rnp) = &(rsp)->node[0]; \
(rnp) < (rsp)->level[NUM_RCU_LVLS - 1]; (rnp)++) (rnp) < (rsp)->level[rcu_num_lvls - 1]; (rnp)++)
/* /*
* Scan the leaves of the rcu_node hierarchy for the specified rcu_state * Scan the leaves of the rcu_node hierarchy for the specified rcu_state
...@@ -224,8 +228,8 @@ struct rcu_node { ...@@ -224,8 +228,8 @@ struct rcu_node {
* It is still a leaf node, even if it is also the root node. * It is still a leaf node, even if it is also the root node.
*/ */
#define rcu_for_each_leaf_node(rsp, rnp) \ #define rcu_for_each_leaf_node(rsp, rnp) \
for ((rnp) = (rsp)->level[NUM_RCU_LVLS - 1]; \ for ((rnp) = (rsp)->level[rcu_num_lvls - 1]; \
(rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++) (rnp) < &(rsp)->node[rcu_num_nodes]; (rnp)++)
/* Index values for nxttail array in struct rcu_data. */ /* Index values for nxttail array in struct rcu_data. */
#define RCU_DONE_TAIL 0 /* Also RCU_WAIT head. */ #define RCU_DONE_TAIL 0 /* Also RCU_WAIT head. */
...@@ -311,6 +315,9 @@ struct rcu_data { ...@@ -311,6 +315,9 @@ struct rcu_data {
unsigned long n_rp_need_fqs; unsigned long n_rp_need_fqs;
unsigned long n_rp_need_nothing; unsigned long n_rp_need_nothing;
/* 6) _rcu_barrier() callback. */
struct rcu_head barrier_head;
int cpu; int cpu;
struct rcu_state *rsp; struct rcu_state *rsp;
}; };
...@@ -357,10 +364,12 @@ do { \ ...@@ -357,10 +364,12 @@ do { \
*/ */
struct rcu_state { struct rcu_state {
struct rcu_node node[NUM_RCU_NODES]; /* Hierarchy. */ struct rcu_node node[NUM_RCU_NODES]; /* Hierarchy. */
struct rcu_node *level[NUM_RCU_LVLS]; /* Hierarchy levels. */ struct rcu_node *level[RCU_NUM_LVLS]; /* Hierarchy levels. */
u32 levelcnt[MAX_RCU_LVLS + 1]; /* # nodes in each level. */ u32 levelcnt[MAX_RCU_LVLS + 1]; /* # nodes in each level. */
u8 levelspread[NUM_RCU_LVLS]; /* kids/node in each level. */ u8 levelspread[RCU_NUM_LVLS]; /* kids/node in each level. */
struct rcu_data __percpu *rda; /* pointer of percu rcu_data. */ struct rcu_data __percpu *rda; /* pointer of percu rcu_data. */
void (*call)(struct rcu_head *head, /* call_rcu() flavor. */
void (*func)(struct rcu_head *head));
/* The following fields are guarded by the root rcu_node's lock. */ /* The following fields are guarded by the root rcu_node's lock. */
...@@ -392,6 +401,11 @@ struct rcu_state { ...@@ -392,6 +401,11 @@ struct rcu_state {
struct task_struct *rcu_barrier_in_progress; struct task_struct *rcu_barrier_in_progress;
/* Task doing rcu_barrier(), */ /* Task doing rcu_barrier(), */
/* or NULL if no barrier. */ /* or NULL if no barrier. */
struct mutex barrier_mutex; /* Guards barrier fields. */
atomic_t barrier_cpu_count; /* # CPUs waiting on. */
struct completion barrier_completion; /* Wake at barrier end. */
unsigned long n_barrier_done; /* ++ at start and end of */
/* _rcu_barrier(). */
raw_spinlock_t fqslock; /* Only one task forcing */ raw_spinlock_t fqslock; /* Only one task forcing */
/* quiescent states. */ /* quiescent states. */
unsigned long jiffies_force_qs; /* Time at which to invoke */ unsigned long jiffies_force_qs; /* Time at which to invoke */
...@@ -409,8 +423,13 @@ struct rcu_state { ...@@ -409,8 +423,13 @@ struct rcu_state {
unsigned long gp_max; /* Maximum GP duration in */ unsigned long gp_max; /* Maximum GP duration in */
/* jiffies. */ /* jiffies. */
char *name; /* Name of structure. */ char *name; /* Name of structure. */
struct list_head flavors; /* List of RCU flavors. */
}; };
extern struct list_head rcu_struct_flavors;
#define for_each_rcu_flavor(rsp) \
list_for_each_entry((rsp), &rcu_struct_flavors, flavors)
/* Return values for rcu_preempt_offline_tasks(). */ /* Return values for rcu_preempt_offline_tasks(). */
#define RCU_OFL_TASKS_NORM_GP 0x1 /* Tasks blocking normal */ #define RCU_OFL_TASKS_NORM_GP 0x1 /* Tasks blocking normal */
...@@ -444,6 +463,7 @@ DECLARE_PER_CPU(char, rcu_cpu_has_work); ...@@ -444,6 +463,7 @@ DECLARE_PER_CPU(char, rcu_cpu_has_work);
/* Forward declarations for rcutree_plugin.h */ /* Forward declarations for rcutree_plugin.h */
static void rcu_bootup_announce(void); static void rcu_bootup_announce(void);
long rcu_batches_completed(void); long rcu_batches_completed(void);
static void rcu_preempt_note_context_switch(int cpu);
static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp); static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp);
#ifdef CONFIG_HOTPLUG_CPU #ifdef CONFIG_HOTPLUG_CPU
static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp, static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp,
...@@ -452,25 +472,18 @@ static void rcu_stop_cpu_kthread(int cpu); ...@@ -452,25 +472,18 @@ static void rcu_stop_cpu_kthread(int cpu);
#endif /* #ifdef CONFIG_HOTPLUG_CPU */ #endif /* #ifdef CONFIG_HOTPLUG_CPU */
static void rcu_print_detail_task_stall(struct rcu_state *rsp); static void rcu_print_detail_task_stall(struct rcu_state *rsp);
static int rcu_print_task_stall(struct rcu_node *rnp); static int rcu_print_task_stall(struct rcu_node *rnp);
static void rcu_preempt_stall_reset(void);
static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp); static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp);
#ifdef CONFIG_HOTPLUG_CPU #ifdef CONFIG_HOTPLUG_CPU
static int rcu_preempt_offline_tasks(struct rcu_state *rsp, static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
struct rcu_node *rnp, struct rcu_node *rnp,
struct rcu_data *rdp); struct rcu_data *rdp);
#endif /* #ifdef CONFIG_HOTPLUG_CPU */ #endif /* #ifdef CONFIG_HOTPLUG_CPU */
static void rcu_preempt_cleanup_dead_cpu(int cpu);
static void rcu_preempt_check_callbacks(int cpu); static void rcu_preempt_check_callbacks(int cpu);
static void rcu_preempt_process_callbacks(void);
void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu)); void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu));
#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_TREE_PREEMPT_RCU) #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_TREE_PREEMPT_RCU)
static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp, static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp,
bool wake); bool wake);
#endif /* #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_TREE_PREEMPT_RCU) */ #endif /* #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_TREE_PREEMPT_RCU) */
static int rcu_preempt_pending(int cpu);
static int rcu_preempt_cpu_has_callbacks(int cpu);
static void __cpuinit rcu_preempt_init_percpu_data(int cpu);
static void rcu_preempt_cleanup_dying_cpu(void);
static void __init __rcu_init_preempt(void); static void __init __rcu_init_preempt(void);
static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags); static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags);
static void rcu_preempt_boost_start_gp(struct rcu_node *rnp); static void rcu_preempt_boost_start_gp(struct rcu_node *rnp);
......
...@@ -68,17 +68,21 @@ static void __init rcu_bootup_announce_oddness(void) ...@@ -68,17 +68,21 @@ static void __init rcu_bootup_announce_oddness(void)
printk(KERN_INFO "\tAdditional per-CPU info printed with stalls.\n"); printk(KERN_INFO "\tAdditional per-CPU info printed with stalls.\n");
#endif #endif
#if NUM_RCU_LVL_4 != 0 #if NUM_RCU_LVL_4 != 0
printk(KERN_INFO "\tExperimental four-level hierarchy is enabled.\n"); printk(KERN_INFO "\tFour-level hierarchy is enabled.\n");
#endif #endif
if (rcu_fanout_leaf != CONFIG_RCU_FANOUT_LEAF)
printk(KERN_INFO "\tExperimental boot-time adjustment of leaf fanout to %d.\n", rcu_fanout_leaf);
if (nr_cpu_ids != NR_CPUS)
printk(KERN_INFO "\tRCU restricting CPUs from NR_CPUS=%d to nr_cpu_ids=%d.\n", NR_CPUS, nr_cpu_ids);
} }
#ifdef CONFIG_TREE_PREEMPT_RCU #ifdef CONFIG_TREE_PREEMPT_RCU
struct rcu_state rcu_preempt_state = RCU_STATE_INITIALIZER(rcu_preempt); struct rcu_state rcu_preempt_state =
RCU_STATE_INITIALIZER(rcu_preempt, call_rcu);
DEFINE_PER_CPU(struct rcu_data, rcu_preempt_data); DEFINE_PER_CPU(struct rcu_data, rcu_preempt_data);
static struct rcu_state *rcu_state = &rcu_preempt_state; static struct rcu_state *rcu_state = &rcu_preempt_state;
static void rcu_read_unlock_special(struct task_struct *t);
static int rcu_preempted_readers_exp(struct rcu_node *rnp); static int rcu_preempted_readers_exp(struct rcu_node *rnp);
/* /*
...@@ -153,7 +157,7 @@ static void rcu_preempt_qs(int cpu) ...@@ -153,7 +157,7 @@ static void rcu_preempt_qs(int cpu)
* *
* Caller must disable preemption. * Caller must disable preemption.
*/ */
void rcu_preempt_note_context_switch(void) static void rcu_preempt_note_context_switch(int cpu)
{ {
struct task_struct *t = current; struct task_struct *t = current;
unsigned long flags; unsigned long flags;
...@@ -164,7 +168,7 @@ void rcu_preempt_note_context_switch(void) ...@@ -164,7 +168,7 @@ void rcu_preempt_note_context_switch(void)
(t->rcu_read_unlock_special & RCU_READ_UNLOCK_BLOCKED) == 0) { (t->rcu_read_unlock_special & RCU_READ_UNLOCK_BLOCKED) == 0) {
/* Possibly blocking in an RCU read-side critical section. */ /* Possibly blocking in an RCU read-side critical section. */
rdp = __this_cpu_ptr(rcu_preempt_state.rda); rdp = per_cpu_ptr(rcu_preempt_state.rda, cpu);
rnp = rdp->mynode; rnp = rdp->mynode;
raw_spin_lock_irqsave(&rnp->lock, flags); raw_spin_lock_irqsave(&rnp->lock, flags);
t->rcu_read_unlock_special |= RCU_READ_UNLOCK_BLOCKED; t->rcu_read_unlock_special |= RCU_READ_UNLOCK_BLOCKED;
...@@ -228,22 +232,10 @@ void rcu_preempt_note_context_switch(void) ...@@ -228,22 +232,10 @@ void rcu_preempt_note_context_switch(void)
* means that we continue to block the current grace period. * means that we continue to block the current grace period.
*/ */
local_irq_save(flags); local_irq_save(flags);
rcu_preempt_qs(smp_processor_id()); rcu_preempt_qs(cpu);
local_irq_restore(flags); local_irq_restore(flags);
} }
/*
* Tree-preemptible RCU implementation for rcu_read_lock().
* Just increment ->rcu_read_lock_nesting, shared state will be updated
* if we block.
*/
void __rcu_read_lock(void)
{
current->rcu_read_lock_nesting++;
barrier(); /* needed if we ever invoke rcu_read_lock in rcutree.c */
}
EXPORT_SYMBOL_GPL(__rcu_read_lock);
/* /*
* Check for preempted RCU readers blocking the current grace period * Check for preempted RCU readers blocking the current grace period
* for the specified rcu_node structure. If the caller needs a reliable * for the specified rcu_node structure. If the caller needs a reliable
...@@ -310,7 +302,7 @@ static struct list_head *rcu_next_node_entry(struct task_struct *t, ...@@ -310,7 +302,7 @@ static struct list_head *rcu_next_node_entry(struct task_struct *t,
* notify RCU core processing or task having blocked during the RCU * notify RCU core processing or task having blocked during the RCU
* read-side critical section. * read-side critical section.
*/ */
static noinline void rcu_read_unlock_special(struct task_struct *t) void rcu_read_unlock_special(struct task_struct *t)
{ {
int empty; int empty;
int empty_exp; int empty_exp;
...@@ -398,8 +390,9 @@ static noinline void rcu_read_unlock_special(struct task_struct *t) ...@@ -398,8 +390,9 @@ static noinline void rcu_read_unlock_special(struct task_struct *t)
rnp->grphi, rnp->grphi,
!!rnp->gp_tasks); !!rnp->gp_tasks);
rcu_report_unblock_qs_rnp(rnp, flags); rcu_report_unblock_qs_rnp(rnp, flags);
} else } else {
raw_spin_unlock_irqrestore(&rnp->lock, flags); raw_spin_unlock_irqrestore(&rnp->lock, flags);
}
#ifdef CONFIG_RCU_BOOST #ifdef CONFIG_RCU_BOOST
/* Unboost if we were boosted. */ /* Unboost if we were boosted. */
...@@ -418,38 +411,6 @@ static noinline void rcu_read_unlock_special(struct task_struct *t) ...@@ -418,38 +411,6 @@ static noinline void rcu_read_unlock_special(struct task_struct *t)
} }
} }
/*
* Tree-preemptible RCU implementation for rcu_read_unlock().
* Decrement ->rcu_read_lock_nesting. If the result is zero (outermost
* rcu_read_unlock()) and ->rcu_read_unlock_special is non-zero, then
* invoke rcu_read_unlock_special() to clean up after a context switch
* in an RCU read-side critical section and other special cases.
*/
void __rcu_read_unlock(void)
{
struct task_struct *t = current;
if (t->rcu_read_lock_nesting != 1)
--t->rcu_read_lock_nesting;
else {
barrier(); /* critical section before exit code. */
t->rcu_read_lock_nesting = INT_MIN;
barrier(); /* assign before ->rcu_read_unlock_special load */
if (unlikely(ACCESS_ONCE(t->rcu_read_unlock_special)))
rcu_read_unlock_special(t);
barrier(); /* ->rcu_read_unlock_special load before assign */
t->rcu_read_lock_nesting = 0;
}
#ifdef CONFIG_PROVE_LOCKING
{
int rrln = ACCESS_ONCE(t->rcu_read_lock_nesting);
WARN_ON_ONCE(rrln < 0 && rrln > INT_MIN / 2);
}
#endif /* #ifdef CONFIG_PROVE_LOCKING */
}
EXPORT_SYMBOL_GPL(__rcu_read_unlock);
#ifdef CONFIG_RCU_CPU_STALL_VERBOSE #ifdef CONFIG_RCU_CPU_STALL_VERBOSE
/* /*
...@@ -539,16 +500,6 @@ static int rcu_print_task_stall(struct rcu_node *rnp) ...@@ -539,16 +500,6 @@ static int rcu_print_task_stall(struct rcu_node *rnp)
return ndetected; return ndetected;
} }
/*
* Suppress preemptible RCU's CPU stall warnings by pushing the
* time of the next stall-warning message comfortably far into the
* future.
*/
static void rcu_preempt_stall_reset(void)
{
rcu_preempt_state.jiffies_stall = jiffies + ULONG_MAX / 2;
}
/* /*
* Check that the list of blocked tasks for the newly completed grace * Check that the list of blocked tasks for the newly completed grace
* period is in fact empty. It is a serious bug to complete a grace * period is in fact empty. It is a serious bug to complete a grace
...@@ -649,14 +600,6 @@ static int rcu_preempt_offline_tasks(struct rcu_state *rsp, ...@@ -649,14 +600,6 @@ static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
#endif /* #ifdef CONFIG_HOTPLUG_CPU */ #endif /* #ifdef CONFIG_HOTPLUG_CPU */
/*
* Do CPU-offline processing for preemptible RCU.
*/
static void rcu_preempt_cleanup_dead_cpu(int cpu)
{
rcu_cleanup_dead_cpu(cpu, &rcu_preempt_state);
}
/* /*
* Check for a quiescent state from the current CPU. When a task blocks, * Check for a quiescent state from the current CPU. When a task blocks,
* the task is recorded in the corresponding CPU's rcu_node structure, * the task is recorded in the corresponding CPU's rcu_node structure,
...@@ -677,15 +620,6 @@ static void rcu_preempt_check_callbacks(int cpu) ...@@ -677,15 +620,6 @@ static void rcu_preempt_check_callbacks(int cpu)
t->rcu_read_unlock_special |= RCU_READ_UNLOCK_NEED_QS; t->rcu_read_unlock_special |= RCU_READ_UNLOCK_NEED_QS;
} }
/*
* Process callbacks for preemptible RCU.
*/
static void rcu_preempt_process_callbacks(void)
{
__rcu_process_callbacks(&rcu_preempt_state,
&__get_cpu_var(rcu_preempt_data));
}
#ifdef CONFIG_RCU_BOOST #ifdef CONFIG_RCU_BOOST
static void rcu_preempt_do_callbacks(void) static void rcu_preempt_do_callbacks(void)
...@@ -824,9 +758,9 @@ sync_rcu_preempt_exp_init(struct rcu_state *rsp, struct rcu_node *rnp) ...@@ -824,9 +758,9 @@ sync_rcu_preempt_exp_init(struct rcu_state *rsp, struct rcu_node *rnp)
int must_wait = 0; int must_wait = 0;
raw_spin_lock_irqsave(&rnp->lock, flags); raw_spin_lock_irqsave(&rnp->lock, flags);
if (list_empty(&rnp->blkd_tasks)) if (list_empty(&rnp->blkd_tasks)) {
raw_spin_unlock_irqrestore(&rnp->lock, flags); raw_spin_unlock_irqrestore(&rnp->lock, flags);
else { } else {
rnp->exp_tasks = rnp->blkd_tasks.next; rnp->exp_tasks = rnp->blkd_tasks.next;
rcu_initiate_boost(rnp, flags); /* releases rnp->lock */ rcu_initiate_boost(rnp, flags); /* releases rnp->lock */
must_wait = 1; must_wait = 1;
...@@ -870,9 +804,9 @@ void synchronize_rcu_expedited(void) ...@@ -870,9 +804,9 @@ void synchronize_rcu_expedited(void)
* expedited grace period for us, just leave. * expedited grace period for us, just leave.
*/ */
while (!mutex_trylock(&sync_rcu_preempt_exp_mutex)) { while (!mutex_trylock(&sync_rcu_preempt_exp_mutex)) {
if (trycount++ < 10) if (trycount++ < 10) {
udelay(trycount * num_online_cpus()); udelay(trycount * num_online_cpus());
else { } else {
synchronize_rcu(); synchronize_rcu();
return; return;
} }
...@@ -917,50 +851,15 @@ void synchronize_rcu_expedited(void) ...@@ -917,50 +851,15 @@ void synchronize_rcu_expedited(void)
} }
EXPORT_SYMBOL_GPL(synchronize_rcu_expedited); EXPORT_SYMBOL_GPL(synchronize_rcu_expedited);
/*
* Check to see if there is any immediate preemptible-RCU-related work
* to be done.
*/
static int rcu_preempt_pending(int cpu)
{
return __rcu_pending(&rcu_preempt_state,
&per_cpu(rcu_preempt_data, cpu));
}
/*
* Does preemptible RCU have callbacks on this CPU?
*/
static int rcu_preempt_cpu_has_callbacks(int cpu)
{
return !!per_cpu(rcu_preempt_data, cpu).nxtlist;
}
/** /**
* rcu_barrier - Wait until all in-flight call_rcu() callbacks complete. * rcu_barrier - Wait until all in-flight call_rcu() callbacks complete.
*/ */
void rcu_barrier(void) void rcu_barrier(void)
{ {
_rcu_barrier(&rcu_preempt_state, call_rcu); _rcu_barrier(&rcu_preempt_state);
} }
EXPORT_SYMBOL_GPL(rcu_barrier); EXPORT_SYMBOL_GPL(rcu_barrier);
/*
* Initialize preemptible RCU's per-CPU data.
*/
static void __cpuinit rcu_preempt_init_percpu_data(int cpu)
{
rcu_init_percpu_data(cpu, &rcu_preempt_state, 1);
}
/*
* Move preemptible RCU's callbacks from dying CPU to other online CPU
* and record a quiescent state.
*/
static void rcu_preempt_cleanup_dying_cpu(void)
{
rcu_cleanup_dying_cpu(&rcu_preempt_state);
}
/* /*
* Initialize preemptible RCU's state structures. * Initialize preemptible RCU's state structures.
*/ */
...@@ -1001,6 +900,14 @@ void rcu_force_quiescent_state(void) ...@@ -1001,6 +900,14 @@ void rcu_force_quiescent_state(void)
} }
EXPORT_SYMBOL_GPL(rcu_force_quiescent_state); EXPORT_SYMBOL_GPL(rcu_force_quiescent_state);
/*
* Because preemptible RCU does not exist, we never have to check for
* CPUs being in quiescent states.
*/
static void rcu_preempt_note_context_switch(int cpu)
{
}
/* /*
* Because preemptible RCU does not exist, there are never any preempted * Because preemptible RCU does not exist, there are never any preempted
* RCU readers. * RCU readers.
...@@ -1037,14 +944,6 @@ static int rcu_print_task_stall(struct rcu_node *rnp) ...@@ -1037,14 +944,6 @@ static int rcu_print_task_stall(struct rcu_node *rnp)
return 0; return 0;
} }
/*
* Because preemptible RCU does not exist, there is no need to suppress
* its CPU stall warnings.
*/
static void rcu_preempt_stall_reset(void)
{
}
/* /*
* Because there is no preemptible RCU, there can be no readers blocked, * Because there is no preemptible RCU, there can be no readers blocked,
* so there is no need to check for blocked tasks. So check only for * so there is no need to check for blocked tasks. So check only for
...@@ -1072,14 +971,6 @@ static int rcu_preempt_offline_tasks(struct rcu_state *rsp, ...@@ -1072,14 +971,6 @@ static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
#endif /* #ifdef CONFIG_HOTPLUG_CPU */ #endif /* #ifdef CONFIG_HOTPLUG_CPU */
/*
* Because preemptible RCU does not exist, it never needs CPU-offline
* processing.
*/
static void rcu_preempt_cleanup_dead_cpu(int cpu)
{
}
/* /*
* Because preemptible RCU does not exist, it never has any callbacks * Because preemptible RCU does not exist, it never has any callbacks
* to check. * to check.
...@@ -1088,14 +979,6 @@ static void rcu_preempt_check_callbacks(int cpu) ...@@ -1088,14 +979,6 @@ static void rcu_preempt_check_callbacks(int cpu)
{ {
} }
/*
* Because preemptible RCU does not exist, it never has any callbacks
* to process.
*/
static void rcu_preempt_process_callbacks(void)
{
}
/* /*
* Queue an RCU callback for lazy invocation after a grace period. * Queue an RCU callback for lazy invocation after a grace period.
* This will likely be later named something like "call_rcu_lazy()", * This will likely be later named something like "call_rcu_lazy()",
...@@ -1136,22 +1019,6 @@ static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp, ...@@ -1136,22 +1019,6 @@ static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp,
#endif /* #ifdef CONFIG_HOTPLUG_CPU */ #endif /* #ifdef CONFIG_HOTPLUG_CPU */
/*
* Because preemptible RCU does not exist, it never has any work to do.
*/
static int rcu_preempt_pending(int cpu)
{
return 0;
}
/*
* Because preemptible RCU does not exist, it never has callbacks
*/
static int rcu_preempt_cpu_has_callbacks(int cpu)
{
return 0;
}
/* /*
* Because preemptible RCU does not exist, rcu_barrier() is just * Because preemptible RCU does not exist, rcu_barrier() is just
* another name for rcu_barrier_sched(). * another name for rcu_barrier_sched().
...@@ -1162,21 +1029,6 @@ void rcu_barrier(void) ...@@ -1162,21 +1029,6 @@ void rcu_barrier(void)
} }
EXPORT_SYMBOL_GPL(rcu_barrier); EXPORT_SYMBOL_GPL(rcu_barrier);
/*
* Because preemptible RCU does not exist, there is no per-CPU
* data to initialize.
*/
static void __cpuinit rcu_preempt_init_percpu_data(int cpu)
{
}
/*
* Because there is no preemptible RCU, there is no cleanup to do.
*/
static void rcu_preempt_cleanup_dying_cpu(void)
{
}
/* /*
* Because preemptible RCU does not exist, it need not be initialized. * Because preemptible RCU does not exist, it need not be initialized.
*/ */
...@@ -1960,9 +1812,11 @@ static void rcu_idle_count_callbacks_posted(void) ...@@ -1960,9 +1812,11 @@ static void rcu_idle_count_callbacks_posted(void)
*/ */
#define RCU_IDLE_FLUSHES 5 /* Number of dyntick-idle tries. */ #define RCU_IDLE_FLUSHES 5 /* Number of dyntick-idle tries. */
#define RCU_IDLE_OPT_FLUSHES 3 /* Optional dyntick-idle tries. */ #define RCU_IDLE_OPT_FLUSHES 3 /* Optional dyntick-idle tries. */
#define RCU_IDLE_GP_DELAY 6 /* Roughly one grace period. */ #define RCU_IDLE_GP_DELAY 4 /* Roughly one grace period. */
#define RCU_IDLE_LAZY_GP_DELAY (6 * HZ) /* Roughly six seconds. */ #define RCU_IDLE_LAZY_GP_DELAY (6 * HZ) /* Roughly six seconds. */
extern int tick_nohz_enabled;
/* /*
* Does the specified flavor of RCU have non-lazy callbacks pending on * Does the specified flavor of RCU have non-lazy callbacks pending on
* the specified CPU? Both RCU flavor and CPU are specified by the * the specified CPU? Both RCU flavor and CPU are specified by the
...@@ -2039,10 +1893,13 @@ int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies) ...@@ -2039,10 +1893,13 @@ int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies)
return 1; return 1;
} }
/* Set up for the possibility that RCU will post a timer. */ /* Set up for the possibility that RCU will post a timer. */
if (rcu_cpu_has_nonlazy_callbacks(cpu)) if (rcu_cpu_has_nonlazy_callbacks(cpu)) {
*delta_jiffies = RCU_IDLE_GP_DELAY; *delta_jiffies = round_up(RCU_IDLE_GP_DELAY + jiffies,
else RCU_IDLE_GP_DELAY) - jiffies;
*delta_jiffies = RCU_IDLE_LAZY_GP_DELAY; } else {
*delta_jiffies = jiffies + RCU_IDLE_LAZY_GP_DELAY;
*delta_jiffies = round_jiffies(*delta_jiffies) - jiffies;
}
return 0; return 0;
} }
...@@ -2101,6 +1958,7 @@ static void rcu_cleanup_after_idle(int cpu) ...@@ -2101,6 +1958,7 @@ static void rcu_cleanup_after_idle(int cpu)
del_timer(&rdtp->idle_gp_timer); del_timer(&rdtp->idle_gp_timer);
trace_rcu_prep_idle("Cleanup after idle"); trace_rcu_prep_idle("Cleanup after idle");
rdtp->tick_nohz_enabled_snap = ACCESS_ONCE(tick_nohz_enabled);
} }
/* /*
...@@ -2126,6 +1984,18 @@ static void rcu_prepare_for_idle(int cpu) ...@@ -2126,6 +1984,18 @@ static void rcu_prepare_for_idle(int cpu)
{ {
struct timer_list *tp; struct timer_list *tp;
struct rcu_dynticks *rdtp = &per_cpu(rcu_dynticks, cpu); struct rcu_dynticks *rdtp = &per_cpu(rcu_dynticks, cpu);
int tne;
/* Handle nohz enablement switches conservatively. */
tne = ACCESS_ONCE(tick_nohz_enabled);
if (tne != rdtp->tick_nohz_enabled_snap) {
if (rcu_cpu_has_callbacks(cpu))
invoke_rcu_core(); /* force nohz to see update. */
rdtp->tick_nohz_enabled_snap = tne;
return;
}
if (!tne)
return;
/* /*
* If this is an idle re-entry, for example, due to use of * If this is an idle re-entry, for example, due to use of
...@@ -2179,10 +2049,11 @@ static void rcu_prepare_for_idle(int cpu) ...@@ -2179,10 +2049,11 @@ static void rcu_prepare_for_idle(int cpu)
if (rcu_cpu_has_nonlazy_callbacks(cpu)) { if (rcu_cpu_has_nonlazy_callbacks(cpu)) {
trace_rcu_prep_idle("Dyntick with callbacks"); trace_rcu_prep_idle("Dyntick with callbacks");
rdtp->idle_gp_timer_expires = rdtp->idle_gp_timer_expires =
jiffies + RCU_IDLE_GP_DELAY; round_up(jiffies + RCU_IDLE_GP_DELAY,
RCU_IDLE_GP_DELAY);
} else { } else {
rdtp->idle_gp_timer_expires = rdtp->idle_gp_timer_expires =
jiffies + RCU_IDLE_LAZY_GP_DELAY; round_jiffies(jiffies + RCU_IDLE_LAZY_GP_DELAY);
trace_rcu_prep_idle("Dyntick with lazy callbacks"); trace_rcu_prep_idle("Dyntick with lazy callbacks");
} }
tp = &rdtp->idle_gp_timer; tp = &rdtp->idle_gp_timer;
...@@ -2223,8 +2094,9 @@ static void rcu_prepare_for_idle(int cpu) ...@@ -2223,8 +2094,9 @@ static void rcu_prepare_for_idle(int cpu)
if (rcu_cpu_has_callbacks(cpu)) { if (rcu_cpu_has_callbacks(cpu)) {
trace_rcu_prep_idle("More callbacks"); trace_rcu_prep_idle("More callbacks");
invoke_rcu_core(); invoke_rcu_core();
} else } else {
trace_rcu_prep_idle("Callbacks drained"); trace_rcu_prep_idle("Callbacks drained");
}
} }
/* /*
...@@ -2261,6 +2133,7 @@ static void print_cpu_stall_fast_no_hz(char *cp, int cpu) ...@@ -2261,6 +2133,7 @@ static void print_cpu_stall_fast_no_hz(char *cp, int cpu)
static void print_cpu_stall_fast_no_hz(char *cp, int cpu) static void print_cpu_stall_fast_no_hz(char *cp, int cpu)
{ {
*cp = '\0';
} }
#endif /* #else #ifdef CONFIG_RCU_FAST_NO_HZ */ #endif /* #else #ifdef CONFIG_RCU_FAST_NO_HZ */
......
...@@ -46,6 +46,31 @@ ...@@ -46,6 +46,31 @@
#define RCU_TREE_NONCORE #define RCU_TREE_NONCORE
#include "rcutree.h" #include "rcutree.h"
static int show_rcubarrier(struct seq_file *m, void *unused)
{
struct rcu_state *rsp;
for_each_rcu_flavor(rsp)
seq_printf(m, "%s: %c bcc: %d nbd: %lu\n",
rsp->name, rsp->rcu_barrier_in_progress ? 'B' : '.',
atomic_read(&rsp->barrier_cpu_count),
rsp->n_barrier_done);
return 0;
}
static int rcubarrier_open(struct inode *inode, struct file *file)
{
return single_open(file, show_rcubarrier, NULL);
}
static const struct file_operations rcubarrier_fops = {
.owner = THIS_MODULE,
.open = rcubarrier_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#ifdef CONFIG_RCU_BOOST #ifdef CONFIG_RCU_BOOST
static char convert_kthread_status(unsigned int kthread_status) static char convert_kthread_status(unsigned int kthread_status)
...@@ -95,24 +120,16 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp) ...@@ -95,24 +120,16 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
rdp->n_cbs_invoked, rdp->n_cbs_orphaned, rdp->n_cbs_adopted); rdp->n_cbs_invoked, rdp->n_cbs_orphaned, rdp->n_cbs_adopted);
} }
#define PRINT_RCU_DATA(name, func, m) \
do { \
int _p_r_d_i; \
\
for_each_possible_cpu(_p_r_d_i) \
func(m, &per_cpu(name, _p_r_d_i)); \
} while (0)
static int show_rcudata(struct seq_file *m, void *unused) static int show_rcudata(struct seq_file *m, void *unused)
{ {
#ifdef CONFIG_TREE_PREEMPT_RCU int cpu;
seq_puts(m, "rcu_preempt:\n"); struct rcu_state *rsp;
PRINT_RCU_DATA(rcu_preempt_data, print_one_rcu_data, m);
#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */ for_each_rcu_flavor(rsp) {
seq_puts(m, "rcu_sched:\n"); seq_printf(m, "%s:\n", rsp->name);
PRINT_RCU_DATA(rcu_sched_data, print_one_rcu_data, m); for_each_possible_cpu(cpu)
seq_puts(m, "rcu_bh:\n"); print_one_rcu_data(m, per_cpu_ptr(rsp->rda, cpu));
PRINT_RCU_DATA(rcu_bh_data, print_one_rcu_data, m); }
return 0; return 0;
} }
...@@ -166,6 +183,9 @@ static void print_one_rcu_data_csv(struct seq_file *m, struct rcu_data *rdp) ...@@ -166,6 +183,9 @@ static void print_one_rcu_data_csv(struct seq_file *m, struct rcu_data *rdp)
static int show_rcudata_csv(struct seq_file *m, void *unused) static int show_rcudata_csv(struct seq_file *m, void *unused)
{ {
int cpu;
struct rcu_state *rsp;
seq_puts(m, "\"CPU\",\"Online?\",\"c\",\"g\",\"pq\",\"pgp\",\"pq\","); seq_puts(m, "\"CPU\",\"Online?\",\"c\",\"g\",\"pq\",\"pgp\",\"pq\",");
seq_puts(m, "\"dt\",\"dt nesting\",\"dt NMI nesting\",\"df\","); seq_puts(m, "\"dt\",\"dt nesting\",\"dt NMI nesting\",\"df\",");
seq_puts(m, "\"of\",\"qll\",\"ql\",\"qs\""); seq_puts(m, "\"of\",\"qll\",\"ql\",\"qs\"");
...@@ -173,14 +193,11 @@ static int show_rcudata_csv(struct seq_file *m, void *unused) ...@@ -173,14 +193,11 @@ static int show_rcudata_csv(struct seq_file *m, void *unused)
seq_puts(m, "\"kt\",\"ktl\""); seq_puts(m, "\"kt\",\"ktl\"");
#endif /* #ifdef CONFIG_RCU_BOOST */ #endif /* #ifdef CONFIG_RCU_BOOST */
seq_puts(m, ",\"b\",\"ci\",\"co\",\"ca\"\n"); seq_puts(m, ",\"b\",\"ci\",\"co\",\"ca\"\n");
#ifdef CONFIG_TREE_PREEMPT_RCU for_each_rcu_flavor(rsp) {
seq_puts(m, "\"rcu_preempt:\"\n"); seq_printf(m, "\"%s:\"\n", rsp->name);
PRINT_RCU_DATA(rcu_preempt_data, print_one_rcu_data_csv, m); for_each_possible_cpu(cpu)
#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */ print_one_rcu_data_csv(m, per_cpu_ptr(rsp->rda, cpu));
seq_puts(m, "\"rcu_sched:\"\n"); }
PRINT_RCU_DATA(rcu_sched_data, print_one_rcu_data_csv, m);
seq_puts(m, "\"rcu_bh:\"\n");
PRINT_RCU_DATA(rcu_bh_data, print_one_rcu_data_csv, m);
return 0; return 0;
} }
...@@ -201,8 +218,7 @@ static const struct file_operations rcudata_csv_fops = { ...@@ -201,8 +218,7 @@ static const struct file_operations rcudata_csv_fops = {
static void print_one_rcu_node_boost(struct seq_file *m, struct rcu_node *rnp) static void print_one_rcu_node_boost(struct seq_file *m, struct rcu_node *rnp)
{ {
seq_printf(m, "%d:%d tasks=%c%c%c%c kt=%c ntb=%lu neb=%lu nnb=%lu " seq_printf(m, "%d:%d tasks=%c%c%c%c kt=%c ntb=%lu neb=%lu nnb=%lu ",
"j=%04x bt=%04x\n",
rnp->grplo, rnp->grphi, rnp->grplo, rnp->grphi,
"T."[list_empty(&rnp->blkd_tasks)], "T."[list_empty(&rnp->blkd_tasks)],
"N."[!rnp->gp_tasks], "N."[!rnp->gp_tasks],
...@@ -210,11 +226,11 @@ static void print_one_rcu_node_boost(struct seq_file *m, struct rcu_node *rnp) ...@@ -210,11 +226,11 @@ static void print_one_rcu_node_boost(struct seq_file *m, struct rcu_node *rnp)
"B."[!rnp->boost_tasks], "B."[!rnp->boost_tasks],
convert_kthread_status(rnp->boost_kthread_status), convert_kthread_status(rnp->boost_kthread_status),
rnp->n_tasks_boosted, rnp->n_exp_boosts, rnp->n_tasks_boosted, rnp->n_exp_boosts,
rnp->n_normal_boosts, rnp->n_normal_boosts);
seq_printf(m, "j=%04x bt=%04x\n",
(int)(jiffies & 0xffff), (int)(jiffies & 0xffff),
(int)(rnp->boost_time & 0xffff)); (int)(rnp->boost_time & 0xffff));
seq_printf(m, "%s: nt=%lu egt=%lu bt=%lu nb=%lu ny=%lu nos=%lu\n", seq_printf(m, " balk: nt=%lu egt=%lu bt=%lu nb=%lu ny=%lu nos=%lu\n",
" balk",
rnp->n_balk_blkd_tasks, rnp->n_balk_blkd_tasks,
rnp->n_balk_exp_gp_tasks, rnp->n_balk_exp_gp_tasks,
rnp->n_balk_boost_tasks, rnp->n_balk_boost_tasks,
...@@ -270,15 +286,15 @@ static void print_one_rcu_state(struct seq_file *m, struct rcu_state *rsp) ...@@ -270,15 +286,15 @@ static void print_one_rcu_state(struct seq_file *m, struct rcu_state *rsp)
struct rcu_node *rnp; struct rcu_node *rnp;
gpnum = rsp->gpnum; gpnum = rsp->gpnum;
seq_printf(m, "c=%lu g=%lu s=%d jfq=%ld j=%x " seq_printf(m, "%s: c=%lu g=%lu s=%d jfq=%ld j=%x ",
"nfqs=%lu/nfqsng=%lu(%lu) fqlh=%lu oqlen=%ld/%ld\n", rsp->name, rsp->completed, gpnum, rsp->fqs_state,
rsp->completed, gpnum, rsp->fqs_state,
(long)(rsp->jiffies_force_qs - jiffies), (long)(rsp->jiffies_force_qs - jiffies),
(int)(jiffies & 0xffff), (int)(jiffies & 0xffff));
seq_printf(m, "nfqs=%lu/nfqsng=%lu(%lu) fqlh=%lu oqlen=%ld/%ld\n",
rsp->n_force_qs, rsp->n_force_qs_ngp, rsp->n_force_qs, rsp->n_force_qs_ngp,
rsp->n_force_qs - rsp->n_force_qs_ngp, rsp->n_force_qs - rsp->n_force_qs_ngp,
rsp->n_force_qs_lh, rsp->qlen_lazy, rsp->qlen); rsp->n_force_qs_lh, rsp->qlen_lazy, rsp->qlen);
for (rnp = &rsp->node[0]; rnp - &rsp->node[0] < NUM_RCU_NODES; rnp++) { for (rnp = &rsp->node[0]; rnp - &rsp->node[0] < rcu_num_nodes; rnp++) {
if (rnp->level != level) { if (rnp->level != level) {
seq_puts(m, "\n"); seq_puts(m, "\n");
level = rnp->level; level = rnp->level;
...@@ -295,14 +311,10 @@ static void print_one_rcu_state(struct seq_file *m, struct rcu_state *rsp) ...@@ -295,14 +311,10 @@ static void print_one_rcu_state(struct seq_file *m, struct rcu_state *rsp)
static int show_rcuhier(struct seq_file *m, void *unused) static int show_rcuhier(struct seq_file *m, void *unused)
{ {
#ifdef CONFIG_TREE_PREEMPT_RCU struct rcu_state *rsp;
seq_puts(m, "rcu_preempt:\n");
print_one_rcu_state(m, &rcu_preempt_state); for_each_rcu_flavor(rsp)
#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */ print_one_rcu_state(m, rsp);
seq_puts(m, "rcu_sched:\n");
print_one_rcu_state(m, &rcu_sched_state);
seq_puts(m, "rcu_bh:\n");
print_one_rcu_state(m, &rcu_bh_state);
return 0; return 0;
} }
...@@ -343,11 +355,10 @@ static void show_one_rcugp(struct seq_file *m, struct rcu_state *rsp) ...@@ -343,11 +355,10 @@ static void show_one_rcugp(struct seq_file *m, struct rcu_state *rsp)
static int show_rcugp(struct seq_file *m, void *unused) static int show_rcugp(struct seq_file *m, void *unused)
{ {
#ifdef CONFIG_TREE_PREEMPT_RCU struct rcu_state *rsp;
show_one_rcugp(m, &rcu_preempt_state);
#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */ for_each_rcu_flavor(rsp)
show_one_rcugp(m, &rcu_sched_state); show_one_rcugp(m, rsp);
show_one_rcugp(m, &rcu_bh_state);
return 0; return 0;
} }
...@@ -366,44 +377,36 @@ static const struct file_operations rcugp_fops = { ...@@ -366,44 +377,36 @@ static const struct file_operations rcugp_fops = {
static void print_one_rcu_pending(struct seq_file *m, struct rcu_data *rdp) static void print_one_rcu_pending(struct seq_file *m, struct rcu_data *rdp)
{ {
seq_printf(m, "%3d%cnp=%ld " seq_printf(m, "%3d%cnp=%ld ",
"qsp=%ld rpq=%ld cbr=%ld cng=%ld "
"gpc=%ld gps=%ld nf=%ld nn=%ld\n",
rdp->cpu, rdp->cpu,
cpu_is_offline(rdp->cpu) ? '!' : ' ', cpu_is_offline(rdp->cpu) ? '!' : ' ',
rdp->n_rcu_pending, rdp->n_rcu_pending);
seq_printf(m, "qsp=%ld rpq=%ld cbr=%ld cng=%ld ",
rdp->n_rp_qs_pending, rdp->n_rp_qs_pending,
rdp->n_rp_report_qs, rdp->n_rp_report_qs,
rdp->n_rp_cb_ready, rdp->n_rp_cb_ready,
rdp->n_rp_cpu_needs_gp, rdp->n_rp_cpu_needs_gp);
seq_printf(m, "gpc=%ld gps=%ld nf=%ld nn=%ld\n",
rdp->n_rp_gp_completed, rdp->n_rp_gp_completed,
rdp->n_rp_gp_started, rdp->n_rp_gp_started,
rdp->n_rp_need_fqs, rdp->n_rp_need_fqs,
rdp->n_rp_need_nothing); rdp->n_rp_need_nothing);
} }
static void print_rcu_pendings(struct seq_file *m, struct rcu_state *rsp) static int show_rcu_pending(struct seq_file *m, void *unused)
{ {
int cpu; int cpu;
struct rcu_data *rdp; struct rcu_data *rdp;
struct rcu_state *rsp;
for_each_rcu_flavor(rsp) {
seq_printf(m, "%s:\n", rsp->name);
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
rdp = per_cpu_ptr(rsp->rda, cpu); rdp = per_cpu_ptr(rsp->rda, cpu);
if (rdp->beenonline) if (rdp->beenonline)
print_one_rcu_pending(m, rdp); print_one_rcu_pending(m, rdp);
} }
} }
static int show_rcu_pending(struct seq_file *m, void *unused)
{
#ifdef CONFIG_TREE_PREEMPT_RCU
seq_puts(m, "rcu_preempt:\n");
print_rcu_pendings(m, &rcu_preempt_state);
#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */
seq_puts(m, "rcu_sched:\n");
print_rcu_pendings(m, &rcu_sched_state);
seq_puts(m, "rcu_bh:\n");
print_rcu_pendings(m, &rcu_bh_state);
return 0; return 0;
} }
...@@ -453,6 +456,11 @@ static int __init rcutree_trace_init(void) ...@@ -453,6 +456,11 @@ static int __init rcutree_trace_init(void)
if (!rcudir) if (!rcudir)
goto free_out; goto free_out;
retval = debugfs_create_file("rcubarrier", 0444, rcudir,
NULL, &rcubarrier_fops);
if (!retval)
goto free_out;
retval = debugfs_create_file("rcudata", 0444, rcudir, retval = debugfs_create_file("rcudata", 0444, rcudir,
NULL, &rcudata_fops); NULL, &rcudata_fops);
if (!retval) if (!retval)
......
...@@ -2081,7 +2081,6 @@ context_switch(struct rq *rq, struct task_struct *prev, ...@@ -2081,7 +2081,6 @@ context_switch(struct rq *rq, struct task_struct *prev,
#endif #endif
/* Here we just switch the register state and the stack. */ /* Here we just switch the register state and the stack. */
rcu_switch_from(prev);
switch_to(prev, next, prev); switch_to(prev, next, prev);
barrier(); barrier();
......
...@@ -105,7 +105,7 @@ static ktime_t tick_init_jiffy_update(void) ...@@ -105,7 +105,7 @@ static ktime_t tick_init_jiffy_update(void)
/* /*
* NO HZ enabled ? * NO HZ enabled ?
*/ */
static int tick_nohz_enabled __read_mostly = 1; int tick_nohz_enabled __read_mostly = 1;
/* /*
* Enable / Disable tickless mode * Enable / Disable tickless mode
......
...@@ -87,12 +87,10 @@ void __list_add_rcu(struct list_head *new, ...@@ -87,12 +87,10 @@ void __list_add_rcu(struct list_head *new,
struct list_head *prev, struct list_head *next) struct list_head *prev, struct list_head *next)
{ {
WARN(next->prev != prev, WARN(next->prev != prev,
"list_add_rcu corruption. next->prev should be " "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
"prev (%p), but was %p. (next=%p).\n",
prev, next->prev, next); prev, next->prev, next);
WARN(prev->next != next, WARN(prev->next != next,
"list_add_rcu corruption. prev->next should be " "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
"next (%p), but was %p. (prev=%p).\n",
next, prev->next, prev); next, prev->next, prev);
new->next = next; new->next = next;
new->prev = prev; new->prev = prev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment