diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2008-10-04 16:51:15 -0400 |
---|---|---|
committer | Alexey Dobriyan <adobriyan@gmail.com> | 2008-10-09 20:18:57 -0400 |
commit | a6bebbc87a8c16eabb6bd5c6fd2d994be0236fba (patch) | |
tree | 3e617ca49063f3a12c982da5d6c687882a1b4070 /fs/proc | |
parent | 53167a3ef23df561d898dee636f3393e9fba937c (diff) |
[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>
Diffstat (limited to 'fs/proc')
-rw-r--r-- | fs/proc/array.c | 2 | ||||
-rw-r--r-- | fs/proc/base.c | 9 |
2 files changed, 1 insertions, 10 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c index 71c9be59c9c2..1c8d7b5d7a14 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -261,7 +261,6 @@ static inline void task_sig(struct seq_file *m, struct task_struct *p) | |||
261 | sigemptyset(&ignored); | 261 | sigemptyset(&ignored); |
262 | sigemptyset(&caught); | 262 | sigemptyset(&caught); |
263 | 263 | ||
264 | rcu_read_lock(); | ||
265 | if (lock_task_sighand(p, &flags)) { | 264 | if (lock_task_sighand(p, &flags)) { |
266 | pending = p->pending.signal; | 265 | pending = p->pending.signal; |
267 | shpending = p->signal->shared_pending.signal; | 266 | shpending = p->signal->shared_pending.signal; |
@@ -272,7 +271,6 @@ static inline void task_sig(struct seq_file *m, struct task_struct *p) | |||
272 | qlim = p->signal->rlim[RLIMIT_SIGPENDING].rlim_cur; | 271 | qlim = p->signal->rlim[RLIMIT_SIGPENDING].rlim_cur; |
273 | unlock_task_sighand(p, &flags); | 272 | unlock_task_sighand(p, &flags); |
274 | } | 273 | } |
275 | rcu_read_unlock(); | ||
276 | 274 | ||
277 | seq_printf(m, "Threads:\t%d\n", num_threads); | 275 | seq_printf(m, "Threads:\t%d\n", num_threads); |
278 | seq_printf(m, "SigQ:\t%lu/%lu\n", qsize, qlim); | 276 | seq_printf(m, "SigQ:\t%lu/%lu\n", qsize, qlim); |
diff --git a/fs/proc/base.c b/fs/proc/base.c index a28840b11b89..bb63fa1d34a2 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -164,7 +164,6 @@ static struct fs_struct *get_fs_struct(struct task_struct *task) | |||
164 | 164 | ||
165 | static int get_nr_threads(struct task_struct *tsk) | 165 | static int get_nr_threads(struct task_struct *tsk) |
166 | { | 166 | { |
167 | /* Must be called with the rcu_read_lock held */ | ||
168 | unsigned long flags; | 167 | unsigned long flags; |
169 | int count = 0; | 168 | int count = 0; |
170 | 169 | ||
@@ -471,14 +470,10 @@ static int proc_pid_limits(struct task_struct *task, char *buffer) | |||
471 | 470 | ||
472 | struct rlimit rlim[RLIM_NLIMITS]; | 471 | struct rlimit rlim[RLIM_NLIMITS]; |
473 | 472 | ||
474 | rcu_read_lock(); | 473 | if (!lock_task_sighand(task, &flags)) |
475 | if (!lock_task_sighand(task,&flags)) { | ||
476 | rcu_read_unlock(); | ||
477 | return 0; | 474 | return 0; |
478 | } | ||
479 | memcpy(rlim, task->signal->rlim, sizeof(struct rlimit) * RLIM_NLIMITS); | 475 | memcpy(rlim, task->signal->rlim, sizeof(struct rlimit) * RLIM_NLIMITS); |
480 | unlock_task_sighand(task, &flags); | 476 | unlock_task_sighand(task, &flags); |
481 | rcu_read_unlock(); | ||
482 | 477 | ||
483 | /* | 478 | /* |
484 | * print the file header | 479 | * print the file header |
@@ -3088,9 +3083,7 @@ static int proc_task_getattr(struct vfsmount *mnt, struct dentry *dentry, struct | |||
3088 | generic_fillattr(inode, stat); | 3083 | generic_fillattr(inode, stat); |
3089 | 3084 | ||
3090 | if (p) { | 3085 | if (p) { |
3091 | rcu_read_lock(); | ||
3092 | stat->nlink += get_nr_threads(p); | 3086 | stat->nlink += get_nr_threads(p); |
3093 | rcu_read_unlock(); | ||
3094 | put_task_struct(p); | 3087 | put_task_struct(p); |
3095 | } | 3088 | } |
3096 | 3089 | ||