From: Oleg Nesterov <oleg@tv-sign.ru>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] simplify/fix first_tid()
Date: Mon, 20 Mar 2006 21:30:47 +0300 [thread overview]
Message-ID: <441EF4D7.AEC1AE8C@tv-sign.ru> (raw)
In-Reply-To: <m1fyldvvvo.fsf@ebiederm.dsl.xmission.com>
"Eric W. Biederman" wrote:
>
> Oleg Nesterov <oleg@tv-sign.ru> writes:
>
> > first_tid:
> >
> > /* If nr exceeds the number of threads there is nothing todo */
> > if (nr) {
> > if (nr >= get_nr_threads(leader))
> > goto done;
> > }
> >
> > This is not reliable: sub-threads can exit after this check, so the
> > 'for' loop below can overlap and proc_task_readdir() can return an
> > already filldir'ed dirents.
> >
> > for (; pos && pid_alive(pos); pos = next_thread(pos)) {
> > if (--nr > 0)
> > continue;
> >
> > Off-by-one error, will return 'leader' when nr == 1.
> >
> > This patch tries to fix these problems and simplify the code.
>
> This is better however if I read this code correctly. It modifies
> the code so the last time user space goes trough this loop
> with nr > nr_threads. Then we will walk the entire threads
> list to achieve nothing.
This can happen only if the thread we stopped at has exited, and
some other threads have exited too, so that nr >= ->signal->count.
I think it's not worth optimizing this rare and anyway slow path.
However, you are the code author, I'll send a trivial patch which
restores this optimization if you don't change you mind.
> So we really still need the nr_threads test in there so we don't
> traverse the list twice everytime through readdir.
How so? We don't do it twice?
Oleg.
next prev parent reply other threads:[~2006-03-20 18:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-19 19:25 Oleg Nesterov
2006-03-20 18:00 ` Eric W. Biederman
2006-03-20 18:30 ` Oleg Nesterov [this message]
2006-03-20 18:56 ` Eric W. Biederman
2006-03-20 19:32 ` 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=441EF4D7.AEC1AE8C@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@osdl.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
/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
Powered by JetHome