linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-mm@kvack.org, "Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Laurent Dufour <ldufour@linux.ibm.com>,
	Paul McKenney <paulmckrcu@fb.com>
Subject: Re: synchronize_rcu in munmap?
Date: Tue, 9 Feb 2021 13:08:25 -0400	[thread overview]
Message-ID: <20210209170825.GG4718@ziepe.ca> (raw)
In-Reply-To: <20210208132643.GP308988@casper.infradead.org>

On Mon, Feb 08, 2021 at 01:26:43PM +0000, Matthew Wilcox wrote:
> TLDR: I think we're going to need to call synchronize_rcu() in munmap(),
> and I know this can be quite expensive.  Is this a reasonable price to
> pay for avoiding taking the mmap_sem for page faults?

In my experience we have been ripping out synchronize_rcu() in places
that intersect with userspace, it can be very slow and if something
does more than one iteration things get bad.

Based on that mmunmap seems like a poor place to put synchronize_rcu()

> Next problem: /proc/$pid/smaps calls walk_page_vma() which starts out by
> saying:
>         mmap_assert_locked(walk.mm);
> which made me realise that smaps is also going to walk the page
> tables.

Aren't the presense/absence of the page table levels themselves
managed under the page table locks? I thought that unused levels were
wiped in some lazy fasion after the TLB flush based on being empty? 

There is a state graph of allowed page entry transitions under the
read side of the mmap sem, and allocated -> freed table is not
allowed (freed -> allocated is OK though, IIRC).

I think this has nothing to do with the mmap_sem acting as a VMA lock,
it feels like some extra behavior.

Jason


      parent reply	other threads:[~2021-02-09 17:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08 13:26 synchronize_rcu in munmap? Matthew Wilcox
2021-02-09 14:29 ` Matthew Wilcox
2021-02-09 17:19   ` Laurent Dufour
2021-02-09 17:38     ` Jason Gunthorpe
2021-02-09 19:58       ` Matthew Wilcox
2021-02-10 16:42         ` Jason Gunthorpe
2021-02-09 17:08 ` Jason Gunthorpe [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=20210209170825.GG4718@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=Liam.Howlett@oracle.com \
    --cc=ldufour@linux.ibm.com \
    --cc=linux-mm@kvack.org \
    --cc=paulmckrcu@fb.com \
    --cc=willy@infradead.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).