From: ebiederm@xmission.com (Eric W. Biederman)
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Pavel Emelyanov <xemul@openvz.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] task_pid_nr_ns() breaks proc_pid_readdir()
Date: Mon, 19 Nov 2007 11:15:03 -0700 [thread overview]
Message-ID: <m1tzniumoo.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <20071118142047.GA360@tv-sign.ru> (Oleg Nesterov's message of "Sun, 18 Nov 2007 17:20:47 +0300")
Oleg Nesterov <oleg@tv-sign.ru> writes:
> On 11/17, Eric W. Biederman wrote:
>>
>> Oleg Nesterov <oleg@tv-sign.ru> writes:
>>
>> > Make sure that task_pid_nr_ns() returns !0 before updating tgid. Note that
>> > next_tgid(tgid + 1) can find the same "struct pid" again, but we shouldn't
>> > go into the endless loop because pid_task(PIDTYPE_PID) must return NULL in
>> > this case, so next_tgid() can't return the same task.
>> >
>> Oleg I think I would rather update next_tgid to return the tgid (which
>> removes the need to call task_pid_nr_ns). This keeps all of the task
>> iteration logic together in next_tgid.
>
> Yes sure, I think your patch is also correct, please use it.
>
> <offtopic>
>
> Personally, I hate the functions which use pointers to return another value.
> (yes, yes, I know, my taste is perverted). Why don't we return structure in
> this case? We can even make a common helper struct, say,
>
> Of course, another option is to rewrite the kernle in perl, in that case
> proc_pid_readdir() can just do
>
> (task, tgid) = next_tgid();
I wish that last syntax worked in C. That would make returning
structures so much easier. From a compiler optimization standpoint
returning structures is ever so much nicer. Seeing through pointers
or references to optimize things is tricky.
> </offtopic>
>
>> Although looking at this in more detail, I'm half wondering if
>> proc_pid_make_inode() should take a struct pid instead of a task.
>
> Yes, I also thought about this. Needs more changes, and still not perfect.
>
> I am starting to think we need a more generic change. How about the patch
> below? With this change the stable task_struct implies we have the stable
> pids, this allows us to do a lot of cleanups.
I don't see the huge pile of opportunities to clean up. But otherwise
I am in favor of it. In the normal case it should only delay freeing
of struct pid (and the corresponding namespace) by an rcu interval so it
isn't a big deal.
I suspect it will be a help with killing things like the global pids
in task_struct.
Regardless I'm going to pass on the keeping struct pid on the task
struct until we free it and reference counting it there for the
immediate present as I think we can solve the immediate issues cleanly
without it, and we are pretty much in bug fixing territory now.
Eric
next prev parent reply other threads:[~2007-11-19 18:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-17 18:15 Oleg Nesterov
2007-11-17 20:35 ` Eric W. Biederman
2007-11-18 14:20 ` Oleg Nesterov
2007-11-19 18:15 ` Eric W. Biederman [this message]
2007-11-19 18:29 ` Oleg Nesterov
2007-11-19 18:50 ` Eric W. Biederman
2007-11-19 21:44 ` [PATCH] proc: Remove races from proc_id_readdir() Eric W. Biederman
2007-11-20 16:34 ` [PATCH] proc-remove-races-from-proc_id_readdir-factor-out-tgid-increment Oleg Nesterov
2007-11-20 20:45 ` Eric W. Biederman
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=m1tzniumoo.fsf@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
--cc=xemul@openvz.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
all inboxes | Powered by JetHome®