Skip to content

Commit db1466b

Browse files
paulmckIngo Molnar
authored andcommitted
rcu: Use wrapper function instead of exporting tasklist_lock
Lockdep-RCU commit d11c563 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>
1 parent 0e064ca commit db1466b

5 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎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/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);

‎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
{

‎kernel/pid.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,9 @@ struct task_struct *pid_task(struct pid *pid, enum pid_type type)
367367
struct task_struct *result = NULL;
368368
if (pid) {
369369
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());
371373
if (first)
372374
result = hlist_entry(first, struct task_struct, pids[(type)].node);
373375
}

0 commit comments

Comments
 (0)