From: Matthew Wilcox <willy@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-xfs@vger.kernel.org, linux-afs@lists.infradead.org,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH v2 3/3] mm: Hold the RCU read lock over calls to ->map_pages
Date: Tue, 28 Mar 2023 16:45:54 +0100 [thread overview]
Message-ID: <ZCMLsm7Cfd6FqXgn@casper.infradead.org> (raw)
In-Reply-To: <20230327230206.GB3223426@dread.disaster.area>
On Tue, Mar 28, 2023 at 10:02:06AM +1100, Dave Chinner wrote:
> On Mon, Mar 27, 2023 at 06:45:15PM +0100, Matthew Wilcox (Oracle) wrote:
> > Prevent filesystems from doing things which sleep in their map_pages
> > method. This is in preparation for a pagefault path protected only
> > by RCU.
> > + rcu_read_lock();
> > + ret = vmf->vma->vm_ops->map_pages(vmf,
> > + vmf->pgoff + from_pte - pte_off,
> > + vmf->pgoff + to_pte - pte_off);
> > + rcu_read_unlock();
> > +
> > + return ret;
>
> Doesn't this mean that the rcu_read_lock/unlock can be removed from
> filemap_map_pages()? i.e. all callers are now already under
> rcu_read_lock(). Maybe WARN_ON_ONCE(!rcu_read_lock_held()) could
> be put in filemap_map_pages() if you are worried about callers not
> holding it...
Yes, it could now be removed. I wasn't too bothered because it's so
cheap (either a noop, or an inc/dec of a CPU-local variable). I don't
think we need the WARN becaause there's one embedded in the XArray
code (must be holding the spinlock or the RCU read lock to iterate
the XArray).
prev parent reply other threads:[~2023-03-28 15:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 17:45 [PATCH v2 0/3] Prevent ->map_pages from sleeping Matthew Wilcox (Oracle)
2023-03-27 17:45 ` [PATCH v2 1/3] xfs: Remove xfs_filemap_map_pages() wrapper Matthew Wilcox (Oracle)
2023-03-27 22:57 ` Dave Chinner
2023-03-27 17:45 ` [PATCH v2 2/3] afs: Split afs_pagecache_valid() out of afs_validate() Matthew Wilcox (Oracle)
2023-03-27 17:45 ` [PATCH v2 3/3] mm: Hold the RCU read lock over calls to ->map_pages Matthew Wilcox (Oracle)
2023-03-27 23:02 ` Dave Chinner
2023-03-28 15:45 ` Matthew Wilcox [this message]
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=ZCMLsm7Cfd6FqXgn@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=david@fromorbit.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).