Commit 7e49827cc937a742ae02078b483e3eb78f791a2a

Authored by Oleg Nesterov
Committed by Linus Torvalds
1 parent 6e1be45aa6

proc: get_nr_threads() doesn't need ->siglock any longer

Now that task->signal can't go away get_nr_threads() doesn't need
->siglock to read signal->count.

Also, make it inline, move into sched.h, and convert 2 other proc users of
signal->count to use this (now trivial) helper.

Henceforth get_nr_threads() is the only valid user of signal->count, we
are ready to turn it into "int nr_threads" or, perhaps, kill it.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 3 changed files with 7 additions and 14 deletions Side-by-side Diff

... ... @@ -267,7 +267,7 @@
267 267 shpending = p->signal->shared_pending.signal;
268 268 blocked = p->blocked;
269 269 collect_sigign_sigcatch(p, &ignored, &caught);
270   - num_threads = atomic_read(&p->signal->count);
  270 + num_threads = get_nr_threads(p);
271 271 rcu_read_lock(); /* FIXME: is this correct? */
272 272 qsize = atomic_read(&__task_cred(p)->user->sigpending);
273 273 rcu_read_unlock();
... ... @@ -410,7 +410,7 @@
410 410 tty_nr = new_encode_dev(tty_devnum(sig->tty));
411 411 }
412 412  
413   - num_threads = atomic_read(&sig->count);
  413 + num_threads = get_nr_threads(task);
414 414 collect_sigign_sigcatch(task, &sigign, &sigcatch);
415 415  
416 416 cmin_flt = sig->cmin_flt;
... ... @@ -166,18 +166,6 @@
166 166 return result;
167 167 }
168 168  
169   -static int get_nr_threads(struct task_struct *tsk)
170   -{
171   - unsigned long flags;
172   - int count = 0;
173   -
174   - if (lock_task_sighand(tsk, &flags)) {
175   - count = atomic_read(&tsk->signal->count);
176   - unlock_task_sighand(tsk, &flags);
177   - }
178   - return count;
179   -}
180   -
181 169 static int proc_cwd_link(struct inode *inode, struct path *path)
182 170 {
183 171 struct task_struct *task = get_proc_task(inode);
include/linux/sched.h
... ... @@ -2147,6 +2147,11 @@
2147 2147 #define while_each_thread(g, t) \
2148 2148 while ((t = next_thread(t)) != g)
2149 2149  
  2150 +static inline int get_nr_threads(struct task_struct *tsk)
  2151 +{
  2152 + return atomic_read(&tsk->signal->count);
  2153 +}
  2154 +
2150 2155 /* de_thread depends on thread_group_leader not being a pid based check */
2151 2156 #define thread_group_leader(p) (p == p->group_leader)
2152 2157