* [PATCH -mm 1/2] proc_sched_show_task: use get_nr_threads()
@ 2010-03-23 14:48 Oleg Nesterov
2010-03-23 15:09 ` Oleg Nesterov
2010-03-24 8:40 ` David Howells
0 siblings, 2 replies; 4+ messages in thread
From: Oleg Nesterov @ 2010-03-23 14:48 UTC (permalink / raw)
To: Andrew Morton; +Cc: David Howells, Peter Zijlstra, Roland McGrath, linux-kernel
Trivial, use get_nr_threads() helper to read signal->count which
we are going to change.
Like other callers, proc_sched_show_task() doesn't need the exactly
precise nr_threads.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/sched_debug.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
--- 34-rc1/kernel/sched_debug.c~MISC_1_PROC_SCHED_SHOW_TASK 2009-12-18 19:05:38.000000000 +0100
+++ 34-rc1/kernel/sched_debug.c 2010-03-23 14:52:42.000000000 +0100
@@ -384,15 +384,9 @@ __initcall(init_sched_debug_procfs);
void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
{
unsigned long nr_switches;
- unsigned long flags;
- int num_threads = 1;
-
- if (lock_task_sighand(p, &flags)) {
- num_threads = atomic_read(&p->signal->count);
- unlock_task_sighand(p, &flags);
- }
- 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,
+ get_nr_threads(p));
SEQ_printf(m,
"---------------------------------------------------------\n");
#define __P(F) \
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -mm 1/2] proc_sched_show_task: use get_nr_threads()
2010-03-23 14:48 [PATCH -mm 1/2] proc_sched_show_task: use get_nr_threads() Oleg Nesterov
@ 2010-03-23 15:09 ` Oleg Nesterov
2010-04-09 19:54 ` Roland McGrath
2010-03-24 8:40 ` David Howells
1 sibling, 1 reply; 4+ messages in thread
From: Oleg Nesterov @ 2010-03-23 15:09 UTC (permalink / raw)
To: Andrew Morton; +Cc: David Howells, Peter Zijlstra, Roland McGrath, linux-kernel
On 03/23, Oleg Nesterov wrote:
>
> Trivial, use get_nr_threads() helper to read signal->count which
> we are going to change.
>
> Like other callers, proc_sched_show_task() doesn't need the exactly
> precise nr_threads.
I don't think this can make any problem, but let me clarify just in
case to avoid the possible confusion...
This change is not equivalent. Before this patch, num_threads == 1
if p has already exited (no matter how many other threads we have).
After this patch, we always report the correct number of live threads
in this thread group, this also means we can report zero in unlikely
case.
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> ---
>
> kernel/sched_debug.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> --- 34-rc1/kernel/sched_debug.c~MISC_1_PROC_SCHED_SHOW_TASK 2009-12-18 19:05:38.000000000 +0100
> +++ 34-rc1/kernel/sched_debug.c 2010-03-23 14:52:42.000000000 +0100
> @@ -384,15 +384,9 @@ __initcall(init_sched_debug_procfs);
> void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
> {
> unsigned long nr_switches;
> - unsigned long flags;
> - int num_threads = 1;
> -
> - if (lock_task_sighand(p, &flags)) {
> - num_threads = atomic_read(&p->signal->count);
> - unlock_task_sighand(p, &flags);
> - }
>
> - 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,
> + get_nr_threads(p));
> SEQ_printf(m,
> "---------------------------------------------------------\n");
> #define __P(F) \
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -mm 1/2] proc_sched_show_task: use get_nr_threads()
2010-03-23 14:48 [PATCH -mm 1/2] proc_sched_show_task: use get_nr_threads() Oleg Nesterov
2010-03-23 15:09 ` Oleg Nesterov
@ 2010-03-24 8:40 ` David Howells
1 sibling, 0 replies; 4+ messages in thread
From: David Howells @ 2010-03-24 8:40 UTC (permalink / raw)
To: Oleg Nesterov
Cc: dhowells, Andrew Morton, Peter Zijlstra, Roland McGrath,
linux-kernel
Oleg Nesterov <oleg@redhat.com> wrote:
> Trivial, use get_nr_threads() helper to read signal->count which
> we are going to change.
>
> Like other callers, proc_sched_show_task() doesn't need the exactly
> precise nr_threads.
Note that get_nr_threads() isn't completely equivalent (it can return 0 where
proc_sched_show_task() will display a 1). But I don't think this should be a
problem.
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: David Howells <dhowells@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -mm 1/2] proc_sched_show_task: use get_nr_threads()
2010-03-23 15:09 ` Oleg Nesterov
@ 2010-04-09 19:54 ` Roland McGrath
0 siblings, 0 replies; 4+ messages in thread
From: Roland McGrath @ 2010-04-09 19:54 UTC (permalink / raw)
To: Oleg Nesterov; +Cc: Andrew Morton, David Howells, Peter Zijlstra, linux-kernel
Acked-by: Roland McGrath <roland@redhat.com>
Thanks,
Roland
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-04-09 19:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-23 14:48 [PATCH -mm 1/2] proc_sched_show_task: use get_nr_threads() Oleg Nesterov
2010-03-23 15:09 ` Oleg Nesterov
2010-04-09 19:54 ` Roland McGrath
2010-03-24 8:40 ` David Howells
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox