Skip to content

Commit 4e3eadd

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: locking: Make sparse work with inline spinlocks and rwlocks x86/mce: Fix RCU lockdep splats rcu: Increase RCU CPU stall timeouts if PROVE_RCU ftrace: Replace read_barrier_depends() with rcu_dereference_raw() rcu: Suppress RCU lockdep warnings during early boot rcu, ftrace: Fix RCU lockdep splat in ftrace_perf_buf_prepare() rcu: Suppress __mpol_dup() false positive from RCU lockdep rcu: Make rcu_read_lock_sched_held() handle !PREEMPT rcu: Add control variables to lockdep_rcu_dereference() diagnostics rcu, cgroup: Relax the check in task_subsys_state() as early boot is now handled by lockdep-RCU rcu: Use wrapper function instead of exporting tasklist_lock sched, rcu: Fix rcu_dereference() for RCU-lockdep rcu: Make task_subsys_state() RCU-lockdep checks handle boot-time use rcu: Fix holdoff for accelerated GPs for last non-dynticked CPU x86/gart: Unexport gart_iommu_aperture Fix trivial conflicts in kernel/trace/ftrace.c
2 parents 8655e7e + b97c4bc commit 4e3eadd

18 files changed

Lines changed: 120 additions & 55 deletions

File tree

‎arch/x86/kernel/aperture_64.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <asm/x86_init.h>
3232

3333
int gart_iommu_aperture;
34-
EXPORT_SYMBOL_GPL(gart_iommu_aperture);
3534
int gart_iommu_aperture_disabled __initdata;
3635
int gart_iommu_aperture_allowed __initdata;
3736

‎arch/x86/kernel/cpu/mcheck/mce.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646

4747
#include "mce-internal.h"
4848

49+
#define rcu_dereference_check_mce(p) \
50+
rcu_dereference_check((p), \
51+
rcu_read_lock_sched_held() || \
52+
lockdep_is_held(&mce_read_mutex))
53+
4954
#define CREATE_TRACE_POINTS
5055
#include <trace/events/mce.h>
5156

@@ -158,7 +163,7 @@ void mce_log(struct mce *mce)
158163
mce->finished = 0;
159164
wmb();
160165
for (;;) {
161-
entry = rcu_dereference(mcelog.next);
166+
entry = rcu_dereference_check_mce(mcelog.next);
162167
for (;;) {
163168
/*
164169
* When the buffer fills up discard new entries.
@@ -1500,7 +1505,7 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
15001505
return -ENOMEM;
15011506

15021507
mutex_lock(&mce_read_mutex);
1503-
next = rcu_dereference(mcelog.next);
1508+
next = rcu_dereference_check_mce(mcelog.next);
15041509

15051510
/* Only supports full reads right now */
15061511
if (*off != 0 || usize < MCE_LOG_LEN*sizeof(struct mce)) {
@@ -1565,7 +1570,7 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
15651570
static unsigned int mce_poll(struct file *file, poll_table *wait)
15661571
{
15671572
poll_wait(file, &mce_wait, wait);
1568-
if (rcu_dereference(mcelog.next))
1573+
if (rcu_dereference_check_mce(mcelog.next))
15691574
return POLLIN | POLLRDNORM;
15701575
return 0;
15711576
}

‎include/linux/cred.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static inline void put_cred(const struct cred *_cred)
280280
* task or by holding tasklist_lock to prevent it from being unlinked.
281281
*/
282282
#define __task_cred(task) \
283-
((const struct cred *)(rcu_dereference_check((task)->real_cred, rcu_read_lock_held() || lockdep_is_held(&tasklist_lock))))
283+
((const struct cred *)(rcu_dereference_check((task)->real_cred, rcu_read_lock_held() || lockdep_tasklist_lock_is_held())))
284284

285285
/**
286286
* get_task_cred - Get another task's objective credentials

‎include/linux/rcupdate.h‎

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,26 @@ extern struct lockdep_map rcu_sched_lock_map;
101101
# define rcu_read_release_sched() \
102102
lock_release(&rcu_sched_lock_map, 1, _THIS_IP_)
103103

104+
static inline int debug_lockdep_rcu_enabled(void)
105+
{
106+
return likely(rcu_scheduler_active && debug_locks);
107+
}
108+
104109
/**
105110
* rcu_read_lock_held - might we be in RCU read-side critical section?
106111
*
107112
* If CONFIG_PROVE_LOCKING is selected and enabled, returns nonzero iff in
108113
* an RCU read-side critical section. In absence of CONFIG_PROVE_LOCKING,
109114
* this assumes we are in an RCU read-side critical section unless it can
110115
* prove otherwise.
116+
*
117+
* Check rcu_scheduler_active to prevent false positives during boot.
111118
*/
112119
static inline int rcu_read_lock_held(void)
113120
{
114-
if (debug_locks)
115-
return lock_is_held(&rcu_lock_map);
116-
return 1;
121+
if (!debug_lockdep_rcu_enabled())
122+
return 1;
123+
return lock_is_held(&rcu_lock_map);
117124
}
118125

119126
/**
@@ -123,12 +130,14 @@ static inline int rcu_read_lock_held(void)
123130
* an RCU-bh read-side critical section. In absence of CONFIG_PROVE_LOCKING,
124131
* this assumes we are in an RCU-bh read-side critical section unless it can
125132
* prove otherwise.
133+
*
134+
* Check rcu_scheduler_active to prevent false positives during boot.
126135
*/
127136
static inline int rcu_read_lock_bh_held(void)
128137
{
129-
if (debug_locks)
130-
return lock_is_held(&rcu_bh_lock_map);
131-
return 1;
138+
if (!debug_lockdep_rcu_enabled())
139+
return 1;
140+
return lock_is_held(&rcu_bh_lock_map);
132141
}
133142

134143
/**
@@ -139,15 +148,26 @@ static inline int rcu_read_lock_bh_held(void)
139148
* this assumes we are in an RCU-sched read-side critical section unless it
140149
* can prove otherwise. Note that disabling of preemption (including
141150
* disabling irqs) counts as an RCU-sched read-side critical section.
151+
*
152+
* Check rcu_scheduler_active to prevent false positives during boot.
142153
*/
154+
#ifdef CONFIG_PREEMPT
143155
static inline int rcu_read_lock_sched_held(void)
144156
{
145157
int lockdep_opinion = 0;
146158

159+
if (!debug_lockdep_rcu_enabled())
160+
return 1;
147161
if (debug_locks)
148162
lockdep_opinion = lock_is_held(&rcu_sched_lock_map);
149-
return lockdep_opinion || preempt_count() != 0 || !rcu_scheduler_active;
163+
return lockdep_opinion || preempt_count() != 0;
164+
}
165+
#else /* #ifdef CONFIG_PREEMPT */
166+
static inline int rcu_read_lock_sched_held(void)
167+
{
168+
return 1;
150169
}
170+
#endif /* #else #ifdef CONFIG_PREEMPT */
151171

152172
#else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
153173

@@ -168,10 +188,17 @@ static inline int rcu_read_lock_bh_held(void)
168188
return 1;
169189
}
170190

191+
#ifdef CONFIG_PREEMPT
171192
static inline int rcu_read_lock_sched_held(void)
172193
{
173-
return preempt_count() != 0 || !rcu_scheduler_active;
194+
return !rcu_scheduler_active || preempt_count() != 0;
195+
}
196+
#else /* #ifdef CONFIG_PREEMPT */
197+
static inline int rcu_read_lock_sched_held(void)
198+
{
199+
return 1;
174200
}
201+
#endif /* #else #ifdef CONFIG_PREEMPT */
175202

176203
#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
177204

@@ -188,7 +215,7 @@ static inline int rcu_read_lock_sched_held(void)
188215
*/
189216
#define rcu_dereference_check(p, c) \
190217
({ \
191-
if (debug_locks && !(c)) \
218+
if (debug_lockdep_rcu_enabled() && !(c)) \
192219
lockdep_rcu_dereference(__FILE__, __LINE__); \
193220
rcu_dereference_raw(p); \
194221
})

‎include/linux/rwlock.h‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ do { \
2929
#endif
3030

3131
#ifdef CONFIG_DEBUG_SPINLOCK
32-
extern void do_raw_read_lock(rwlock_t *lock);
32+
extern void do_raw_read_lock(rwlock_t *lock) __acquires(lock);
3333
#define do_raw_read_lock_flags(lock, flags) do_raw_read_lock(lock)
3434
extern int do_raw_read_trylock(rwlock_t *lock);
35-
extern void do_raw_read_unlock(rwlock_t *lock);
36-
extern void do_raw_write_lock(rwlock_t *lock);
35+
extern void do_raw_read_unlock(rwlock_t *lock) __releases(lock);
36+
extern void do_raw_write_lock(rwlock_t *lock) __acquires(lock);
3737
#define do_raw_write_lock_flags(lock, flags) do_raw_write_lock(lock)
3838
extern int do_raw_write_trylock(rwlock_t *lock);
39-
extern void do_raw_write_unlock(rwlock_t *lock);
39+
extern void do_raw_write_unlock(rwlock_t *lock) __releases(lock);
4040
#else
41-
# define do_raw_read_lock(rwlock) arch_read_lock(&(rwlock)->raw_lock)
41+
# define do_raw_read_lock(rwlock) do {__acquire(lock); arch_read_lock(&(rwlock)->raw_lock); } while (0)
4242
# define do_raw_read_lock_flags(lock, flags) \
43-
arch_read_lock_flags(&(lock)->raw_lock, *(flags))
43+
do {__acquire(lock); arch_read_lock_flags(&(lock)->raw_lock, *(flags)); } while (0)
4444
# define do_raw_read_trylock(rwlock) arch_read_trylock(&(rwlock)->raw_lock)
45-
# define do_raw_read_unlock(rwlock) arch_read_unlock(&(rwlock)->raw_lock)
46-
# define do_raw_write_lock(rwlock) arch_write_lock(&(rwlock)->raw_lock)
45+
# define do_raw_read_unlock(rwlock) do {arch_read_unlock(&(rwlock)->raw_lock); __release(lock); } while (0)
46+
# define do_raw_write_lock(rwlock) do {__acquire(lock); arch_write_lock(&(rwlock)->raw_lock); } while (0)
4747
# define do_raw_write_lock_flags(lock, flags) \
48-
arch_write_lock_flags(&(lock)->raw_lock, *(flags))
48+
do {__acquire(lock); arch_write_lock_flags(&(lock)->raw_lock, *(flags)); } while (0)
4949
# define do_raw_write_trylock(rwlock) arch_write_trylock(&(rwlock)->raw_lock)
50-
# define do_raw_write_unlock(rwlock) arch_write_unlock(&(rwlock)->raw_lock)
50+
# define do_raw_write_unlock(rwlock) do {arch_write_unlock(&(rwlock)->raw_lock); __release(lock); } while (0)
5151
#endif
5252

5353
#define read_can_lock(rwlock) arch_read_can_lock(&(rwlock)->raw_lock)

‎include/linux/sched.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ extern spinlock_t mmlist_lock;
258258

259259
struct task_struct;
260260

261+
#ifdef CONFIG_PROVE_RCU
262+
extern int lockdep_tasklist_lock_is_held(void);
263+
#endif /* #ifdef CONFIG_PROVE_RCU */
264+
261265
extern void sched_init(void);
262266
extern void sched_init_smp(void);
263267
extern asmlinkage void schedule_tail(struct task_struct *prev);

‎include/linux/spinlock.h‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,21 @@ static inline void smp_mb__after_lock(void) { smp_mb(); }
128128
#define raw_spin_unlock_wait(lock) arch_spin_unlock_wait(&(lock)->raw_lock)
129129

130130
#ifdef CONFIG_DEBUG_SPINLOCK
131-
extern void do_raw_spin_lock(raw_spinlock_t *lock);
131+
extern void do_raw_spin_lock(raw_spinlock_t *lock) __acquires(lock);
132132
#define do_raw_spin_lock_flags(lock, flags) do_raw_spin_lock(lock)
133133
extern int do_raw_spin_trylock(raw_spinlock_t *lock);
134-
extern void do_raw_spin_unlock(raw_spinlock_t *lock);
134+
extern void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock);
135135
#else
136-
static inline void do_raw_spin_lock(raw_spinlock_t *lock)
136+
static inline void do_raw_spin_lock(raw_spinlock_t *lock) __acquires(lock)
137137
{
138+
__acquire(lock);
138139
arch_spin_lock(&lock->raw_lock);
139140
}
140141

141142
static inline void
142-
do_raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long *flags)
143+
do_raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long *flags) __acquires(lock)
143144
{
145+
__acquire(lock);
144146
arch_spin_lock_flags(&lock->raw_lock, *flags);
145147
}
146148

@@ -149,9 +151,10 @@ static inline int do_raw_spin_trylock(raw_spinlock_t *lock)
149151
return arch_spin_trylock(&(lock)->raw_lock);
150152
}
151153

152-
static inline void do_raw_spin_unlock(raw_spinlock_t *lock)
154+
static inline void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock)
153155
{
154156
arch_spin_unlock(&lock->raw_lock);
157+
__release(lock);
155158
}
156159
#endif
157160

‎include/trace/ftrace.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,9 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
699699
* __cpu = smp_processor_id();
700700
*
701701
* if (in_nmi())
702-
* trace_buf = rcu_dereference(perf_trace_buf_nmi);
702+
* trace_buf = rcu_dereference_sched(perf_trace_buf_nmi);
703703
* else
704-
* trace_buf = rcu_dereference(perf_trace_buf);
704+
* trace_buf = rcu_dereference_sched(perf_trace_buf);
705705
*
706706
* if (!trace_buf)
707707
* goto end;

‎kernel/exit.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static void __exit_signal(struct task_struct *tsk)
8787

8888
sighand = rcu_dereference_check(tsk->sighand,
8989
rcu_read_lock_held() ||
90-
lockdep_is_held(&tasklist_lock));
90+
lockdep_tasklist_lock_is_held());
9191
spin_lock(&sighand->siglock);
9292

9393
posix_cpu_timers_exit(tsk);

‎kernel/fork.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ int max_threads; /* tunable limit on nr_threads */
8686
DEFINE_PER_CPU(unsigned long, process_counts) = 0;
8787

8888
__cacheline_aligned DEFINE_RWLOCK(tasklist_lock); /* outer */
89-
EXPORT_SYMBOL_GPL(tasklist_lock);
89+
90+
#ifdef CONFIG_PROVE_RCU
91+
int lockdep_tasklist_lock_is_held(void)
92+
{
93+
return lockdep_is_held(&tasklist_lock);
94+
}
95+
EXPORT_SYMBOL_GPL(lockdep_tasklist_lock_is_held);
96+
#endif /* #ifdef CONFIG_PROVE_RCU */
9097

9198
int nr_processes(void)
9299
{

0 commit comments

Comments
 (0)