[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150316163521.GA9306@redhat.com>
Date: Mon, 16 Mar 2015 17:35:21 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
Cc: linux-mm@...ck.org, Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, Davidlohr Bueso <dbueso@...e.de>,
Al Viro <viro@...iv.linux.org.uk>
Subject: Re: [PATCH] mm: rcu-protected get_mm_exe_file()
On 03/16, Konstantin Khlebnikov wrote:
>
> On 16.03.2015 17:07, Oleg Nesterov wrote:
>> I mean, I think we can do another cleanup on top of this change.
>>
>> 1. set_mm_exe_file() should be called by exit/exec only, so
>> it should use
>>
>> rcu_dereference_protected(mm->exe_file,
>> atomic_read(&mm->mm_users) <= 1);
>>
>> 2. prctl() should not use it, it can do
>>
>> get_file(new_exe);
>> old_exe = xchg(&mm->exe_file);
>> if (old_exe)
>> fput(old_exe);
>
> I think smp_mb() is required before xchg() or
> probably this stuff should be hidden inside yet another magic RCU macro
> ( with two screens of comments =)
Not really, xchg() implies mb's on both sides. As any other atomic operation
which returns the result.
(And in fact we do not even need rcu_assign_pointer() in set_mm_exe_file(),
get_mm_exe_file() could do READ_ONCE() + inc_not_zero(). But this is off-
topic, and of course rcu_* helpers look better)
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists