All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, Davidlohr Bueso <dbueso@suse.de>,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] mm: rcu-protected get_mm_exe_file()
Date: Mon, 16 Mar 2015 17:35:21 +0100	[thread overview]
Message-ID: <20150316163521.GA9306@redhat.com> (raw)
In-Reply-To: <550701BE.40100@yandex-team.ru>

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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Oleg Nesterov <oleg@redhat.com>
To: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, Davidlohr Bueso <dbueso@suse.de>,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] mm: rcu-protected get_mm_exe_file()
Date: Mon, 16 Mar 2015 17:35:21 +0100	[thread overview]
Message-ID: <20150316163521.GA9306@redhat.com> (raw)
In-Reply-To: <550701BE.40100@yandex-team.ru>

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.


  reply	other threads:[~2015-03-16 16:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-16 13:12 [PATCH] mm: rcu-protected get_mm_exe_file() Konstantin Khlebnikov
2015-03-16 13:12 ` Konstantin Khlebnikov
2015-03-16 14:07 ` Oleg Nesterov
2015-03-16 14:07   ` Oleg Nesterov
2015-03-16 14:50   ` Davidlohr Bueso
2015-03-16 14:50     ` Davidlohr Bueso
2015-03-16 16:18     ` Konstantin Khlebnikov
2015-03-16 16:18       ` Konstantin Khlebnikov
2015-03-16 17:04       ` Davidlohr Bueso
2015-03-16 17:04         ` Davidlohr Bueso
2015-03-16 16:15   ` Konstantin Khlebnikov
2015-03-16 16:15     ` Konstantin Khlebnikov
2015-03-16 16:35     ` Oleg Nesterov [this message]
2015-03-16 16:35       ` 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=20150316163521.GA9306@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dbueso@suse.de \
    --cc=khlebnikov@yandex-team.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.