Skip to content

Commit a6bebbc

Browse files
Lai JiangshanAlexey Dobriyan
authored andcommitted
[PATCH] signal, procfs: some lock_task_sighand() users do not need rcu_read_lock()
lock_task_sighand() make sure task->sighand is being protected, so we do not need rcu_read_lock(). [ exec() will get task->sighand->siglock before change task->sighand! ] But code using rcu_read_lock() _just_ to protect lock_task_sighand() only appear in procfs. (and some code in procfs use lock_task_sighand() without such redundant protection.) Other subsystem may put lock_task_sighand() into rcu_read_lock() critical region, but these rcu_read_lock() are used for protecting "for_each_process()", "find_task_by_vpid()" etc. , not for protecting lock_task_sighand(). Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> [ok from Oleg] Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
1 parent 53167a3 commit a6bebbc

3 files changed

Lines changed: 1 addition & 12 deletions

File tree

‎fs/proc/array.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ static inline void task_sig(struct seq_file *m, struct task_struct *p)
261261
sigemptyset(&ignored);
262262
sigemptyset(&caught);
263263

264-
rcu_read_lock();
265264
if (lock_task_sighand(p, &flags)) {
266265
pending = p->pending.signal;
267266
shpending = p->signal->shared_pending.signal;
@@ -272,7 +271,6 @@ static inline void task_sig(struct seq_file *m, struct task_struct *p)
272271
qlim = p->signal->rlim[RLIMIT_SIGPENDING].rlim_cur;
273272
unlock_task_sighand(p, &flags);
274273
}
275-
rcu_read_unlock();
276274

277275
seq_printf(m, "Threads:\t%d\n", num_threads);
278276
seq_printf(m, "SigQ:\t%lu/%lu\n", qsize, qlim);

‎fs/proc/base.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ static struct fs_struct *get_fs_struct(struct task_struct *task)
164164

165165
static int get_nr_threads(struct task_struct *tsk)
166166
{
167-
/* Must be called with the rcu_read_lock held */
168167
unsigned long flags;
169168
int count = 0;
170169

@@ -471,14 +470,10 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
471470

472471
struct rlimit rlim[RLIM_NLIMITS];
473472

474-
rcu_read_lock();
475-
if (!lock_task_sighand(task,&flags)) {
476-
rcu_read_unlock();
473+
if (!lock_task_sighand(task, &flags))
477474
return 0;
478-
}
479475
memcpy(rlim, task->signal->rlim, sizeof(struct rlimit) * RLIM_NLIMITS);
480476
unlock_task_sighand(task, &flags);
481-
rcu_read_unlock();
482477

483478
/*
484479
* print the file header
@@ -3088,9 +3083,7 @@ static int proc_task_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
30883083
generic_fillattr(inode, stat);
30893084

30903085
if (p) {
3091-
rcu_read_lock();
30923086
stat->nlink += get_nr_threads(p);
3093-
rcu_read_unlock();
30943087
put_task_struct(p);
30953088
}
30963089

‎kernel/sched_debug.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,10 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
333333
unsigned long flags;
334334
int num_threads = 1;
335335

336-
rcu_read_lock();
337336
if (lock_task_sighand(p, &flags)) {
338337
num_threads = atomic_read(&p->signal->count);
339338
unlock_task_sighand(p, &flags);
340339
}
341-
rcu_read_unlock();
342340

343341
SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, p->pid, num_threads);
344342
SEQ_printf(m,

0 commit comments

Comments
 (0)