From: ebiederm@xmission.com (Eric W. Biederman)
To: Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Alexey Dobriyan <adobriyan@gmail.com>,
Roland McGrath <roland@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH -mm 0/3] proc: task->signal can't be NULL
Date: Mon, 22 Mar 2010 19:18:38 -0700 [thread overview]
Message-ID: <m1ocifvkzl.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <20100322184127.GA3952@redhat.com> (Oleg Nesterov's message of "Mon\, 22 Mar 2010 19\:41\:27 +0100")
Oleg Nesterov <oleg@redhat.com> writes:
> With the recent changes in -mm it is always safe to dereference
> task->signal. It can't be NULL and it is pinned to task_struct.
>
> fs/proc becomes the only valid user of signal->count which should
> either die or become "int nr_threads".
>
>
> Alexey, Eric.
>
> Can't we kill this counter? Afaics, get_nr_threads() doesn't need to
> be "precise", we probably can estimate the number of threads using
> signal->live (yes sure, we can't use ->live as nr_threads).
>
> Except: first_tid() uses get_nr_threads() for optimization. Is this
> optimization really important? Afaics, it only helps in the unlikely
> case, probably in that case the extra lockless while_each_thread()
> doesn't hurt.
>
> IOW, how about
>
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -3071,11 +3071,6 @@ static struct task_struct *first_tid(str
> goto found;
> }
>
> - /* If nr exceeds the number of threads there is nothing todo */
> - pos = NULL;
> - if (nr && nr >= get_nr_threads(leader))
> - goto out;
> -
> /* If we haven't found our starting place yet start
> * with the leader and walk nr threads forward.
> */
>
> ?
>
> Not that I think it is terribly important to kill this counter, and
> probably signal->nr_threads can make sense anyway, so far I am just
> curious.
I think that was just a sanity check since it was easy. I want to say
it prevents a DOS attack with user space passing unreasonably large
file position but that DOS attack is handled by ensuring we don't walk
through the list if threads more than once.
However:
proc_task_getattr uses get_nr_threads to get it's nlink count correct.
Not walking the thread list to get the number of threads seems like an
important cpu time saving measure.
Eric
next prev parent reply other threads:[~2010-03-23 2:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-22 18:41 [PATCH -mm 0/3] proc: task->signal can't be NULL Oleg Nesterov
2010-03-23 2:18 ` Eric W. Biederman [this message]
2010-03-23 18:31 ` Oleg Nesterov
2010-03-23 20:53 ` Eric W. Biederman
2010-03-24 17:49 ` Oleg Nesterov
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=m1ocifvkzl.fsf@fess.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--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