Skip to content

Commit f579bbc

Browse files
committed
Merge branch 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: futex: fix requeue_pi key imbalance futex: Fix typo in FUTEX_WAIT/WAKE_BITSET_PRIVATE definitions rcu: Place root rcu_node structure in separate lockdep class rcu: Make hot-unplugged CPU relinquish its own RCU callbacks rcu: Move rcu_barrier() to rcutree futex: Move exit_pi_state() call to release_mm() futex: Nullify robust lists after cleanup futex: Fix locking imbalance panic: Fix panic message visibility by calling bust_spinlocks(0) before dying rcu: Replace the rcu_barrier enum with pointer to call_rcu*() function rcu: Clean up code based on review feedback from Josh Triplett, part 4 rcu: Clean up code based on review feedback from Josh Triplett, part 3 rcu: Fix rcu_lock_map build failure on CONFIG_PROVE_LOCKING=y rcu: Clean up code to address Ingo's checkpatch feedback rcu: Clean up code based on review feedback from Josh Triplett, part 2 rcu: Clean up code based on review feedback from Josh Triplett
2 parents e80fb7e + da08568 commit f579bbc

14 files changed

Lines changed: 405 additions & 316 deletions

File tree

‎include/linux/futex.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
#define FUTEX_LOCK_PI_PRIVATE (FUTEX_LOCK_PI | FUTEX_PRIVATE_FLAG)
3434
#define FUTEX_UNLOCK_PI_PRIVATE (FUTEX_UNLOCK_PI | FUTEX_PRIVATE_FLAG)
3535
#define FUTEX_TRYLOCK_PI_PRIVATE (FUTEX_TRYLOCK_PI | FUTEX_PRIVATE_FLAG)
36-
#define FUTEX_WAIT_BITSET_PRIVATE (FUTEX_WAIT_BITS | FUTEX_PRIVATE_FLAG)
37-
#define FUTEX_WAKE_BITSET_PRIVATE (FUTEX_WAKE_BITS | FUTEX_PRIVATE_FLAG)
36+
#define FUTEX_WAIT_BITSET_PRIVATE (FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG)
37+
#define FUTEX_WAKE_BITSET_PRIVATE (FUTEX_WAKE_BITSET | FUTEX_PRIVATE_FLAG)
3838
#define FUTEX_WAIT_REQUEUE_PI_PRIVATE (FUTEX_WAIT_REQUEUE_PI | \
3939
FUTEX_PRIVATE_FLAG)
4040
#define FUTEX_CMP_REQUEUE_PI_PRIVATE (FUTEX_CMP_REQUEUE_PI | \

‎include/linux/rcupdate.h‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ extern int rcu_scheduler_active;
7777
#error "Unknown RCU implementation specified to kernel configuration"
7878
#endif
7979

80-
#define RCU_HEAD_INIT { .next = NULL, .func = NULL }
80+
#define RCU_HEAD_INIT { .next = NULL, .func = NULL }
8181
#define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT
8282
#define INIT_RCU_HEAD(ptr) do { \
8383
(ptr)->next = NULL; (ptr)->func = NULL; \
@@ -129,12 +129,6 @@ static inline void rcu_read_lock(void)
129129
rcu_read_acquire();
130130
}
131131

132-
/**
133-
* rcu_read_unlock - marks the end of an RCU read-side critical section.
134-
*
135-
* See rcu_read_lock() for more information.
136-
*/
137-
138132
/*
139133
* So where is rcu_write_lock()? It does not exist, as there is no
140134
* way for writers to lock out RCU readers. This is a feature, not
@@ -144,6 +138,12 @@ static inline void rcu_read_lock(void)
144138
* used as well. RCU does not care how the writers keep out of each
145139
* others' way, as long as they do so.
146140
*/
141+
142+
/**
143+
* rcu_read_unlock - marks the end of an RCU read-side critical section.
144+
*
145+
* See rcu_read_lock() for more information.
146+
*/
147147
static inline void rcu_read_unlock(void)
148148
{
149149
rcu_read_release();
@@ -196,6 +196,8 @@ static inline void rcu_read_lock_sched(void)
196196
__acquire(RCU_SCHED);
197197
rcu_read_acquire();
198198
}
199+
200+
/* Used by lockdep and tracing: cannot be traced, cannot call lockdep. */
199201
static inline notrace void rcu_read_lock_sched_notrace(void)
200202
{
201203
preempt_disable_notrace();
@@ -213,6 +215,8 @@ static inline void rcu_read_unlock_sched(void)
213215
__release(RCU_SCHED);
214216
preempt_enable();
215217
}
218+
219+
/* Used by lockdep and tracing: cannot be traced, cannot call lockdep. */
216220
static inline notrace void rcu_read_unlock_sched_notrace(void)
217221
{
218222
__release(RCU_SCHED);

‎include/linux/rcutree.h‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@
3030
#ifndef __LINUX_RCUTREE_H
3131
#define __LINUX_RCUTREE_H
3232

33+
struct notifier_block;
34+
3335
extern void rcu_sched_qs(int cpu);
3436
extern void rcu_bh_qs(int cpu);
35-
37+
extern int rcu_cpu_notify(struct notifier_block *self,
38+
unsigned long action, void *hcpu);
3639
extern int rcu_needs_cpu(int cpu);
40+
extern int rcu_expedited_torture_stats(char *page);
3741

3842
#ifdef CONFIG_TREE_PREEMPT_RCU
3943

@@ -85,16 +89,11 @@ static inline void synchronize_rcu_bh_expedited(void)
8589

8690
extern void __rcu_init(void);
8791
extern void rcu_check_callbacks(int cpu, int user);
88-
extern void rcu_restart_cpu(int cpu);
8992

9093
extern long rcu_batches_completed(void);
9194
extern long rcu_batches_completed_bh(void);
9295
extern long rcu_batches_completed_sched(void);
9396

94-
static inline void rcu_init_sched(void)
95-
{
96-
}
97-
9897
#ifdef CONFIG_NO_HZ
9998
void rcu_enter_nohz(void);
10099
void rcu_exit_nohz(void);
@@ -107,7 +106,7 @@ static inline void rcu_exit_nohz(void)
107106
}
108107
#endif /* CONFIG_NO_HZ */
109108

110-
/* A context switch is a grace period for rcutree. */
109+
/* A context switch is a grace period for RCU-sched and RCU-bh. */
111110
static inline int rcu_blocking_is_gp(void)
112111
{
113112
return num_online_cpus() == 1;

‎init/main.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,6 @@ static void __init do_initcalls(void)
778778
*/
779779
static void __init do_basic_setup(void)
780780
{
781-
rcu_init_sched(); /* needed by module_init stage. */
782781
init_workqueues();
783782
cpuset_init_smp();
784783
usermodehelper_init();

‎kernel/exit.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,8 +991,6 @@ NORET_TYPE void do_exit(long code)
991991
tsk->mempolicy = NULL;
992992
#endif
993993
#ifdef CONFIG_FUTEX
994-
if (unlikely(!list_empty(&tsk->pi_state_list)))
995-
exit_pi_state_list(tsk);
996994
if (unlikely(current->pi_state_cache))
997995
kfree(current->pi_state_cache);
998996
#endif

‎kernel/fork.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,18 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
570570

571571
/* Get rid of any futexes when releasing the mm */
572572
#ifdef CONFIG_FUTEX
573-
if (unlikely(tsk->robust_list))
573+
if (unlikely(tsk->robust_list)) {
574574
exit_robust_list(tsk);
575+
tsk->robust_list = NULL;
576+
}
575577
#ifdef CONFIG_COMPAT
576-
if (unlikely(tsk->compat_robust_list))
578+
if (unlikely(tsk->compat_robust_list)) {
577579
compat_exit_robust_list(tsk);
580+
tsk->compat_robust_list = NULL;
581+
}
578582
#endif
583+
if (unlikely(!list_empty(&tsk->pi_state_list)))
584+
exit_pi_state_list(tsk);
579585
#endif
580586

581587
/* Get rid of any cached register state */

‎kernel/futex.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,8 @@ futex_wake_op(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
916916
hb1 = hash_futex(&key1);
917917
hb2 = hash_futex(&key2);
918918

919-
double_lock_hb(hb1, hb2);
920919
retry_private:
920+
double_lock_hb(hb1, hb2);
921921
op_ret = futex_atomic_op_inuser(op, uaddr2);
922922
if (unlikely(op_ret < 0)) {
923923

@@ -2117,7 +2117,6 @@ int handle_early_requeue_pi_wakeup(struct futex_hash_bucket *hb,
21172117
* Unqueue the futex_q and determine which it was.
21182118
*/
21192119
plist_del(&q->list, &q->list.plist);
2120-
drop_futex_key_refs(&q->key);
21212120

21222121
if (timeout && !timeout->task)
21232122
ret = -ETIMEDOUT;

‎kernel/panic.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ NORET_TYPE void panic(const char * fmt, ...)
9090

9191
atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
9292

93+
bust_spinlocks(0);
94+
9395
if (!panic_blink)
9496
panic_blink = no_blink;
9597

@@ -136,7 +138,6 @@ NORET_TYPE void panic(const char * fmt, ...)
136138
mdelay(1);
137139
i++;
138140
}
139-
bust_spinlocks(0);
140141
}
141142

142143
EXPORT_SYMBOL(panic);

‎kernel/rcupdate.c‎

Lines changed: 7 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,15 @@
4646
#include <linux/module.h>
4747
#include <linux/kernel_stat.h>
4848

49-
enum rcu_barrier {
50-
RCU_BARRIER_STD,
51-
RCU_BARRIER_BH,
52-
RCU_BARRIER_SCHED,
53-
};
49+
#ifdef CONFIG_DEBUG_LOCK_ALLOC
50+
static struct lock_class_key rcu_lock_key;
51+
struct lockdep_map rcu_lock_map =
52+
STATIC_LOCKDEP_MAP_INIT("rcu_read_lock", &rcu_lock_key);
53+
EXPORT_SYMBOL_GPL(rcu_lock_map);
54+
#endif
5455

55-
static DEFINE_PER_CPU(struct rcu_head, rcu_barrier_head) = {NULL};
56-
static atomic_t rcu_barrier_cpu_count;
57-
static DEFINE_MUTEX(rcu_barrier_mutex);
58-
static struct completion rcu_barrier_completion;
5956
int rcu_scheduler_active __read_mostly;
6057

61-
static atomic_t rcu_migrate_type_count = ATOMIC_INIT(0);
62-
static struct rcu_head rcu_migrate_head[3];
63-
static DECLARE_WAIT_QUEUE_HEAD(rcu_migrate_wq);
64-
6558
/*
6659
* Awaken the corresponding synchronize_rcu() instance now that a
6760
* grace period has elapsed.
@@ -164,129 +157,10 @@ void synchronize_rcu_bh(void)
164157
}
165158
EXPORT_SYMBOL_GPL(synchronize_rcu_bh);
166159

167-
static void rcu_barrier_callback(struct rcu_head *notused)
168-
{
169-
if (atomic_dec_and_test(&rcu_barrier_cpu_count))
170-
complete(&rcu_barrier_completion);
171-
}
172-
173-
/*
174-
* Called with preemption disabled, and from cross-cpu IRQ context.
175-
*/
176-
static void rcu_barrier_func(void *type)
177-
{
178-
int cpu = smp_processor_id();
179-
struct rcu_head *head = &per_cpu(rcu_barrier_head, cpu);
180-
181-
atomic_inc(&rcu_barrier_cpu_count);
182-
switch ((enum rcu_barrier)type) {
183-
case RCU_BARRIER_STD:
184-
call_rcu(head, rcu_barrier_callback);
185-
break;
186-
case RCU_BARRIER_BH:
187-
call_rcu_bh(head, rcu_barrier_callback);
188-
break;
189-
case RCU_BARRIER_SCHED:
190-
call_rcu_sched(head, rcu_barrier_callback);
191-
break;
192-
}
193-
}
194-
195-
static inline void wait_migrated_callbacks(void)
196-
{
197-
wait_event(rcu_migrate_wq, !atomic_read(&rcu_migrate_type_count));
198-
smp_mb(); /* In case we didn't sleep. */
199-
}
200-
201-
/*
202-
* Orchestrate the specified type of RCU barrier, waiting for all
203-
* RCU callbacks of the specified type to complete.
204-
*/
205-
static void _rcu_barrier(enum rcu_barrier type)
206-
{
207-
BUG_ON(in_interrupt());
208-
/* Take cpucontrol mutex to protect against CPU hotplug */
209-
mutex_lock(&rcu_barrier_mutex);
210-
init_completion(&rcu_barrier_completion);
211-
/*
212-
* Initialize rcu_barrier_cpu_count to 1, then invoke
213-
* rcu_barrier_func() on each CPU, so that each CPU also has
214-
* incremented rcu_barrier_cpu_count. Only then is it safe to
215-
* decrement rcu_barrier_cpu_count -- otherwise the first CPU
216-
* might complete its grace period before all of the other CPUs
217-
* did their increment, causing this function to return too
218-
* early.
219-
*/
220-
atomic_set(&rcu_barrier_cpu_count, 1);
221-
on_each_cpu(rcu_barrier_func, (void *)type, 1);
222-
if (atomic_dec_and_test(&rcu_barrier_cpu_count))
223-
complete(&rcu_barrier_completion);
224-
wait_for_completion(&rcu_barrier_completion);
225-
mutex_unlock(&rcu_barrier_mutex);
226-
wait_migrated_callbacks();
227-
}
228-
229-
/**
230-
* rcu_barrier - Wait until all in-flight call_rcu() callbacks complete.
231-
*/
232-
void rcu_barrier(void)
233-
{
234-
_rcu_barrier(RCU_BARRIER_STD);
235-
}
236-
EXPORT_SYMBOL_GPL(rcu_barrier);
237-
238-
/**
239-
* rcu_barrier_bh - Wait until all in-flight call_rcu_bh() callbacks complete.
240-
*/
241-
void rcu_barrier_bh(void)
242-
{
243-
_rcu_barrier(RCU_BARRIER_BH);
244-
}
245-
EXPORT_SYMBOL_GPL(rcu_barrier_bh);
246-
247-
/**
248-
* rcu_barrier_sched - Wait for in-flight call_rcu_sched() callbacks.
249-
*/
250-
void rcu_barrier_sched(void)
251-
{
252-
_rcu_barrier(RCU_BARRIER_SCHED);
253-
}
254-
EXPORT_SYMBOL_GPL(rcu_barrier_sched);
255-
256-
static void rcu_migrate_callback(struct rcu_head *notused)
257-
{
258-
if (atomic_dec_and_test(&rcu_migrate_type_count))
259-
wake_up(&rcu_migrate_wq);
260-
}
261-
262-
extern int rcu_cpu_notify(struct notifier_block *self,
263-
unsigned long action, void *hcpu);
264-
265160
static int __cpuinit rcu_barrier_cpu_hotplug(struct notifier_block *self,
266161
unsigned long action, void *hcpu)
267162
{
268-
rcu_cpu_notify(self, action, hcpu);
269-
if (action == CPU_DYING) {
270-
/*
271-
* preempt_disable() in on_each_cpu() prevents stop_machine(),
272-
* so when "on_each_cpu(rcu_barrier_func, (void *)type, 1);"
273-
* returns, all online cpus have queued rcu_barrier_func(),
274-
* and the dead cpu(if it exist) queues rcu_migrate_callback()s.
275-
*
276-
* These callbacks ensure _rcu_barrier() waits for all
277-
* RCU callbacks of the specified type to complete.
278-
*/
279-
atomic_set(&rcu_migrate_type_count, 3);
280-
call_rcu_bh(rcu_migrate_head, rcu_migrate_callback);
281-
call_rcu_sched(rcu_migrate_head + 1, rcu_migrate_callback);
282-
call_rcu(rcu_migrate_head + 2, rcu_migrate_callback);
283-
} else if (action == CPU_DOWN_PREPARE) {
284-
/* Don't need to wait until next removal operation. */
285-
/* rcu_migrate_head is protected by cpu_add_remove_lock */
286-
wait_migrated_callbacks();
287-
}
288-
289-
return NOTIFY_OK;
163+
return rcu_cpu_notify(self, action, hcpu);
290164
}
291165

292166
void __init rcu_init(void)

‎kernel/rcutorture.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,6 @@ static struct rcu_torture_ops sched_ops_sync = {
606606
.name = "sched_sync"
607607
};
608608

609-
extern int rcu_expedited_torture_stats(char *page);
610-
611609
static struct rcu_torture_ops sched_expedited_ops = {
612610
.init = rcu_sync_torture_init,
613611
.cleanup = NULL,
@@ -650,7 +648,7 @@ rcu_torture_writer(void *arg)
650648
old_rp = rcu_torture_current;
651649
rp->rtort_mbtest = 1;
652650
rcu_assign_pointer(rcu_torture_current, rp);
653-
smp_wmb();
651+
smp_wmb(); /* Mods to old_rp must follow rcu_assign_pointer() */
654652
if (old_rp) {
655653
i = old_rp->rtort_pipe_count;
656654
if (i > RCU_TORTURE_PIPE_LEN)

0 commit comments

Comments
 (0)