diff options
| author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2010-03-03 10:46:56 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2010-03-04 05:46:14 -0500 |
| commit | db1466b3e1bd1727375cdbfcbea4bcce2f860f61 (patch) | |
| tree | e56e8d7b82f8851e570d95f531ec62e4d107967a | |
| parent | 0e064caf6402d1d67db4233d26beec88ca212919 (diff) | |
rcu: Use wrapper function instead of exporting tasklist_lock
Lockdep-RCU commit d11c563d exported tasklist_lock, which is not
a good thing. This patch instead exports a function that uses
lockdep to check whether tasklist_lock is held.
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: laijs@cn.fujitsu.com
Cc: dipankar@in.ibm.com
Cc: mathieu.desnoyers@polymtl.ca
Cc: josh@joshtriplett.org
Cc: dvhltc@us.ibm.com
Cc: niv@us.ibm.com
Cc: peterz@infradead.org
Cc: rostedt@goodmis.org
Cc: Valdis.Kletnieks@vt.edu
Cc: dhowells@redhat.com
Cc: Christoph Hellwig <hch@lst.de>
LKML-Reference: <1267631219-8713-1-git-send-email-paulmck@linux.vnet.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
| -rw-r--r-- | include/linux/cred.h | 2 | ||||
| -rw-r--r-- | include/linux/sched.h | 4 | ||||
| -rw-r--r-- | kernel/exit.c | 2 | ||||
| -rw-r--r-- | kernel/fork.c | 9 | ||||
| -rw-r--r-- | kernel/pid.c | 4 |
5 files changed, 17 insertions, 4 deletions
diff --git a/include/linux/cred.h b/include/linux/cred.h index 4db09f89b637..52507c3e1387 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h | |||
| @@ -280,7 +280,7 @@ static inline void put_cred(const struct cred *_cred) | |||
| 280 | * task or by holding tasklist_lock to prevent it from being unlinked. | 280 | * task or by holding tasklist_lock to prevent it from being unlinked. |
| 281 | */ | 281 | */ |
| 282 | #define __task_cred(task) \ | 282 | #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()))) |
| 284 | 284 | ||
| 285 | /** | 285 | /** |
| 286 | * get_task_cred - Get another task's objective credentials | 286 | * get_task_cred - Get another task's objective credentials |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 0eef87b58ea5..a47af2064dcc 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -258,6 +258,10 @@ extern spinlock_t mmlist_lock; | |||
| 258 | 258 | ||
| 259 | struct task_struct; | 259 | struct task_struct; |
| 260 | 260 | ||
| 261 | #ifdef CONFIG_PROVE_RCU | ||
| 262 | extern int lockdep_tasklist_lock_is_held(void); | ||
| 263 | #endif /* #ifdef CONFIG_PROVE_RCU */ | ||
| 264 | |||
| 261 | extern void sched_init(void); | 265 | extern void sched_init(void); |
| 262 | extern void sched_init_smp(void); | 266 | extern void sched_init_smp(void); |
| 263 | extern asmlinkage void schedule_tail(struct task_struct *prev); | 267 | extern asmlinkage void schedule_tail(struct task_struct *prev); |
diff --git a/kernel/exit.c b/kernel/exit.c index 45ed043b8bf5..fed3a4db6f04 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
| @@ -87,7 +87,7 @@ static void __exit_signal(struct task_struct *tsk) | |||
| 87 | 87 | ||
| 88 | sighand = rcu_dereference_check(tsk->sighand, | 88 | sighand = rcu_dereference_check(tsk->sighand, |
| 89 | rcu_read_lock_held() || | 89 | rcu_read_lock_held() || |
| 90 | lockdep_is_held(&tasklist_lock)); | 90 | lockdep_tasklist_lock_is_held()); |
| 91 | spin_lock(&sighand->siglock); | 91 | spin_lock(&sighand->siglock); |
| 92 | 92 | ||
| 93 | posix_cpu_timers_exit(tsk); | 93 | posix_cpu_timers_exit(tsk); |
diff --git a/kernel/fork.c b/kernel/fork.c index 17bbf093356d..8691c540a470 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
| @@ -86,7 +86,14 @@ int max_threads; /* tunable limit on nr_threads */ | |||
| 86 | DEFINE_PER_CPU(unsigned long, process_counts) = 0; | 86 | DEFINE_PER_CPU(unsigned long, process_counts) = 0; |
| 87 | 87 | ||
| 88 | __cacheline_aligned DEFINE_RWLOCK(tasklist_lock); /* outer */ | 88 | __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 */ | ||
| 90 | 97 | ||
| 91 | int nr_processes(void) | 98 | int nr_processes(void) |
| 92 | { | 99 | { |
diff --git a/kernel/pid.c b/kernel/pid.c index b08e697cd83f..b6064405f367 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
| @@ -367,7 +367,9 @@ struct task_struct *pid_task(struct pid *pid, enum pid_type type) | |||
| 367 | struct task_struct *result = NULL; | 367 | struct task_struct *result = NULL; |
| 368 | if (pid) { | 368 | if (pid) { |
| 369 | struct hlist_node *first; | 369 | struct hlist_node *first; |
| 370 | first = rcu_dereference_check(pid->tasks[type].first, rcu_read_lock_held() || lockdep_is_held(&tasklist_lock)); | 370 | first = rcu_dereference_check(pid->tasks[type].first, |
| 371 | rcu_read_lock_held() || | ||
| 372 | lockdep_tasklist_lock_is_held()); | ||
| 371 | if (first) | 373 | if (first) |
| 372 | result = hlist_entry(first, struct task_struct, pids[(type)].node); | 374 | result = hlist_entry(first, struct task_struct, pids[(type)].node); |
| 373 | } | 375 | } |
