LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Oleg Nesterov <oleg@tv-sign.ru>,
mingo@elte.hu, paulmck@linux.vnet.ibm.com, xemul@openvz.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fix tasklist + find_pid() with CONFIG_PREEMPT_RCU
Date: Tue, 29 Jan 2008 19:16:50 -0700 [thread overview]
Message-ID: <m1r6g0gir1.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <20080129150836.7fd994a2.akpm@linux-foundation.org> (Andrew Morton's message of "Tue, 29 Jan 2008 15:08:36 -0800")
Andrew Morton <akpm@linux-foundation.org> writes:
> On Tue, 29 Jan 2008 19:40:19 +0300
> Oleg Nesterov <oleg@tv-sign.ru> wrote:
>
>> With CONFIG_PREEMPT_RCU read_lock(tasklist_lock) doesn't imply
> rcu_read_lock(),
>> but find_pid_ns()->hlist_for_each_entry_rcu() should be safe under tasklist.
>>
>> Usually it is, detach_pid() is always called under write_lock(tasklist_lock),
>> but copy_process() calls free_pid() lockless.
>>
>> "#ifdef CONFIG_PREEMPT_RCU" is added mostly as documentation, perhaps it is
>> too ugly and should be removed.
>>
>> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
>>
>> --- MM/kernel/fork.c~PR_RCU 2008-01-27 17:09:47.000000000 +0300
>> +++ MM/kernel/fork.c 2008-01-29 19:23:44.000000000 +0300
>> @@ -1335,8 +1335,19 @@ static struct task_struct *copy_process(
>> return p;
>>
>> bad_fork_free_pid:
>> - if (pid != &init_struct_pid)
>> + if (pid != &init_struct_pid) {
>> +#ifdef CONFIG_PREEMPT_RCU
>> + /*
>> + * read_lock(tasklist_lock) doesn't imply rcu_read_lock(),
>> + * make sure find_pid() is safe under read_lock(tasklist).
>> + */
>> + write_lock_irq(&tasklist_lock);
>> +#endif
>> free_pid(pid);
>> +#ifdef CONFIG_PREEMPT_RCU
>> + write_unlock_irq(&tasklist_lock);
>> +#endif
>> + }
>> bad_fork_cleanup_namespaces:
>> exit_task_namespaces(p);
>> bad_fork_cleanup_keys:
>
> My attempt to understand this change timed out.
>
> kernel/pid.c is full of global but undocumented functions. What are the
> locking requirements for free_pid()? free_pid_ns()? If it's just
> caller-must-hold-rcu_read_lock() then why not use rcu_read_lock() here?
>
> If the locking is "caller must hold write_lock_irq(tasklist_lock) then the
> sole relevant comment in there (in free_pid()) is wrong.
>
> Guys, more maintainable code please?
Well I took a quick look.
Yeah this looks complex.
Mutation of the hash table is protected by pidmap_lock.
But attachments of tasks to hash entries is protected task_lock.
And it looks like it has been that way since commit 92476d7fc0326a409ab1d3864a04093a6be9aca7
I thought free_pid did not have any requirements that a lock be held when
it was called, taking all of the needed locks.
Now how read_lock doesn't imply rcu_read_lock is another question.
Anyway I have to run. I will see about looking at this in a bit.
Eric
next prev parent reply other threads:[~2008-01-30 2:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-29 16:40 Oleg Nesterov
2008-01-29 23:02 ` Andrew Morton
2008-01-30 14:17 ` Peter Zijlstra
2008-01-31 13:32 ` Ingo Molnar
2008-01-29 23:08 ` Andrew Morton
2008-01-30 2:16 ` Eric W. Biederman [this message]
2008-01-30 4:56 ` Paul E. McKenney
2008-01-30 3:24 ` Eric W. Biederman
2008-01-30 5:00 ` Paul E. McKenney
2008-01-30 9:20 ` Eric W. Biederman
2008-01-30 9:48 ` Oleg Nesterov
2008-01-30 9:30 ` Oleg Nesterov
2008-01-30 18:28 ` Eric W. Biederman
2008-01-31 9:31 ` Oleg Nesterov
2009-12-14 2:15 Tetsuo Handa
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=m1r6g0gir1.fsf@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--cc=paulmck@linux.vnet.ibm.com \
--cc=xemul@openvz.org \
--subject='Re: [PATCH] fix tasklist + find_pid() with CONFIG_PREEMPT_RCU' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).