Commit a6bebbc8 authored by Lai Jiangshan's avatar Lai Jiangshan Committed by Alexey Dobriyan

[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: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
[ok from Oleg]
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
parent 53167a3e
...@@ -261,7 +261,6 @@ static inline void task_sig(struct seq_file *m, struct task_struct *p) ...@@ -261,7 +261,6 @@ static inline void task_sig(struct seq_file *m, struct task_struct *p)
sigemptyset(&ignored); sigemptyset(&ignored);
sigemptyset(&caught); sigemptyset(&caught);
rcu_read_lock();
if (lock_task_sighand(p, &flags)) { if (lock_task_sighand(p, &flags)) {
pending = p->pending.signal; pending = p->pending.signal;
shpending = p->signal->shared_pending.signal; shpending = p->signal->shared_pending.signal;
...@@ -272,7 +271,6 @@ static inline void task_sig(struct seq_file *m, struct task_struct *p) ...@@ -272,7 +271,6 @@ static inline void task_sig(struct seq_file *m, struct task_struct *p)
qlim = p->signal->rlim[RLIMIT_SIGPENDING].rlim_cur; qlim = p->signal->rlim[RLIMIT_SIGPENDING].rlim_cur;
unlock_task_sighand(p, &flags); unlock_task_sighand(p, &flags);
} }
rcu_read_unlock();
seq_printf(m, "Threads:\t%d\n", num_threads); seq_printf(m, "Threads:\t%d\n", num_threads);
seq_printf(m, "SigQ:\t%lu/%lu\n", qsize, qlim); seq_printf(m, "SigQ:\t%lu/%lu\n", qsize, qlim);
......
...@@ -164,7 +164,6 @@ static struct fs_struct *get_fs_struct(struct task_struct *task) ...@@ -164,7 +164,6 @@ static struct fs_struct *get_fs_struct(struct task_struct *task)
static int get_nr_threads(struct task_struct *tsk) static int get_nr_threads(struct task_struct *tsk)
{ {
/* Must be called with the rcu_read_lock held */
unsigned long flags; unsigned long flags;
int count = 0; int count = 0;
...@@ -471,14 +470,10 @@ static int proc_pid_limits(struct task_struct *task, char *buffer) ...@@ -471,14 +470,10 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
struct rlimit rlim[RLIM_NLIMITS]; struct rlimit rlim[RLIM_NLIMITS];
rcu_read_lock(); if (!lock_task_sighand(task, &flags))
if (!lock_task_sighand(task,&flags)) {
rcu_read_unlock();
return 0; return 0;
}
memcpy(rlim, task->signal->rlim, sizeof(struct rlimit) * RLIM_NLIMITS); memcpy(rlim, task->signal->rlim, sizeof(struct rlimit) * RLIM_NLIMITS);
unlock_task_sighand(task, &flags); unlock_task_sighand(task, &flags);
rcu_read_unlock();
/* /*
* print the file header * print the file header
...@@ -3088,9 +3083,7 @@ static int proc_task_getattr(struct vfsmount *mnt, struct dentry *dentry, struct ...@@ -3088,9 +3083,7 @@ static int proc_task_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
generic_fillattr(inode, stat); generic_fillattr(inode, stat);
if (p) { if (p) {
rcu_read_lock();
stat->nlink += get_nr_threads(p); stat->nlink += get_nr_threads(p);
rcu_read_unlock();
put_task_struct(p); put_task_struct(p);
} }
......
...@@ -333,12 +333,10 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m) ...@@ -333,12 +333,10 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
unsigned long flags; unsigned long flags;
int num_threads = 1; int num_threads = 1;
rcu_read_lock();
if (lock_task_sighand(p, &flags)) { if (lock_task_sighand(p, &flags)) {
num_threads = atomic_read(&p->signal->count); num_threads = atomic_read(&p->signal->count);
unlock_task_sighand(p, &flags); unlock_task_sighand(p, &flags);
} }
rcu_read_unlock();
SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, p->pid, num_threads); SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, p->pid, num_threads);
SEQ_printf(m, SEQ_printf(m,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment