public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Howells <dhowells@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Roland McGrath <roland@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH -mm 1/2] proc_sched_show_task: use get_nr_threads()
Date: Tue, 23 Mar 2010 16:09:38 +0100	[thread overview]
Message-ID: <20100323150938.GA11056@redhat.com> (raw)
In-Reply-To: <20100323144839.GA10424@redhat.com>

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) \


  reply	other threads:[~2010-03-23 15:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2010-04-09 19:54   ` Roland McGrath
2010-03-24  8:40 ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100323150938.GA11056@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=roland@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox