public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kent Overstreet <kmo@daterainc.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Benjamin LaHaise <bcrl@kvack.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-aio@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/1] aio: change exit_aio() to load mm->ioctx_table once and avoid rcu_read_lock()
Date: Tue, 29 Apr 2014 16:36:22 -0700	[thread overview]
Message-ID: <20140429233622.GA7480@kmo-pixel> (raw)
In-Reply-To: <20140429183930.GA32521@redhat.com>

On Tue, Apr 29, 2014 at 08:39:30PM +0200, Oleg Nesterov wrote:
> 1. We can read ->ioctx_table only once and we do not read rcu_read_lock()
>    or even rcu_dereference().
> 
>    This mm has no users, nobody else can play with ->ioctx_table. Otherwise
>    the code is buggy anyway, if we need rcu_read_lock() in a loop because
>    ->ioctx_table can be updated then kfree(table) is obviously wrong.
> 
> 2. Update the comment. "exit_mmap(mm) is coming" is the good reason to avoid
>    munmap(), but another reason is that we simply can't do vm_munmap() unless
>    current->mm == mm and this is not true in general, the caller is mmput().

I'm pretty sure you're analysis is all correct. IIRC there's other things in the
shutdown path we still have to be carefull with synchronization wise, but unless
I've forgotten something you're right about ioctx_table.

If I wrote that code (I'd have to check git blame), I'd say I just wrote it that
way because I prefer to be consistent about how things like RCU protected
pointers are accessed, even if it's not strictly necessary. Feels less tricky to
me. But I don't have a strong preference one way or the other.

w.r.t. ioctx->dead, yes, no need for it to be atomic. a regular int and xchg()
is probably more correct anyways since xchg() implies memory barriers and
atomic_xchg() does not.

  reply	other threads:[~2014-04-29 23:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-29 18:39 [PATCH 0/1] aio: change exit_aio() to load mm->ioctx_table once and avoid rcu_read_lock() Oleg Nesterov
2014-04-29 18:39 ` Oleg Nesterov
2014-04-29 23:36   ` Kent Overstreet [this message]
2014-04-29 18:40 ` [PATCH 1/1] " Oleg Nesterov
2014-04-29 20:42   ` Benjamin LaHaise
2014-04-29 21:22     ` Benjamin LaHaise
2014-04-29 23:04       ` Mateusz Guzik
2014-04-30 12:13         ` Oleg Nesterov
2014-04-30 14:15       ` [PATCH v2 0/2] aio: ioctx_table/rcu_read_lock cleanups Oleg Nesterov
2014-04-30 14:16         ` [PATCH v2 1/2] aio: change exit_aio() to load mm->ioctx_table once and avoid rcu_read_lock() Oleg Nesterov
2014-04-30 15:23           ` Benjamin LaHaise
2014-04-30 17:02             ` [PATCH v3 " Oleg Nesterov
2014-04-30 14:16         ` [PATCH v2 2/2] aio: kill the misleading rcu read locks in ioctx_add_table() and kill_ioctx() Oleg Nesterov
2014-04-29 19:33 ` [PATCH 0/1] aio: change exit_aio() to load mm->ioctx_table once and avoid rcu_read_lock() Benjamin LaHaise
2014-04-29 19:49   ` 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=20140429233622.GA7480@kmo-pixel \
    --to=kmo@daterainc.com \
    --cc=akpm@linux-foundation.org \
    --cc=bcrl@kvack.org \
    --cc=linux-aio@kvack.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox