linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Suren Baghdasaryan <surenb@google.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>,
	akpm@linux-foundation.org, rientjes@google.com,
	 hannes@cmpxchg.org, guro@fb.com, riel@surriel.com,
	minchan@kernel.org,  kirill@shutemov.name, aarcange@redhat.com,
	christian@brauner.io,  hch@infradead.org, oleg@redhat.com,
	david@redhat.com, jannh@google.com,  shakeelb@google.com,
	luto@kernel.org, christian.brauner@ubuntu.com,
	 fweimer@redhat.com, jengelh@inai.de, timmurray@google.com,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	kernel-team@android.com
Subject: Re: [PATCH v3 1/2] mm: protect free_pgtables with mmap_lock write lock in exit_mmap
Date: Wed, 8 Dec 2021 11:13:42 -0800	[thread overview]
Message-ID: <CAJuCfpF0HHXGotVF7Sjo-b4raQcf8a4ckBto8-EE18n1ovmtXQ@mail.gmail.com> (raw)
In-Reply-To: <CAJuCfpFbF4C8q=40aXcbverm3QFoPzuLgfSU0eT2e7imgp2YfQ@mail.gmail.com>

On Wed, Dec 8, 2021 at 8:50 AM Suren Baghdasaryan <surenb@google.com> wrote:
>
> On Wed, Dec 8, 2021 at 8:05 AM Matthew Wilcox <willy@infradead.org> wrote:
> >
> > On Wed, Dec 08, 2021 at 04:51:58PM +0100, Michal Hocko wrote:
> > > On Wed 08-12-21 15:01:24, Matthew Wilcox wrote:
> > > > On Tue, Dec 07, 2021 at 03:08:19PM -0800, Suren Baghdasaryan wrote:
> > > > > > >         /**
> > > > > > >          * @close: Called when the VMA is being removed from the MM.
> > > > > > >          * Context: Caller holds mmap_lock.
> > > > >
> > > > > BTW, is the caller always required to hold mmap_lock for write or it
> > > > > *might* hold it?
> > > >
> > > > __do_munmap() might hold it for read, thanks to:
> > > >
> > > >         if (downgrade)
> > > >                 mmap_write_downgrade(mm);
> > > >
> > > > Should probably say:
> > > >
> > > >     * Context: User context.  May sleep.  Caller holds mmap_lock.
> > > >
> > > > I don't think we should burden the implementor of the vm_ops with the
> > > > knowledge that the VM chooses to not hold the mmap_lock under certain
> > > > circumstances when it doesn't matter whether it's holding the mmap_lock
> > > > or not.
> > >
> > > If we document it like that some code might depend on that lock to be
> > > held. I think we only want to document that the holder itself is not
> > > allowed to take mmap sem or a depending lock.
> >
> > The only place where we're not currently holding the mmap_lock is at
> > task exit, where the mmap_lock is effectively held because nobody else
> > can modify the task's mm.  Besides, Suren is changing that in this patch
> > series anyway, so it will be always true.
>
> Ok, I'll make it a separate patch after the patch that changes
> exit_mmap and this statement will become always true. Sounds
> reasonable?

Actually, while today vma_ops->close is called with mmap_lock held, I
believe we want this comment to reflect the restrictions on the
callback itself, not on the user. IOW, we want to say that the
callback should not take mmap_lock while the caller might or might not
hold it. If so, I think *might* would make more sense here, like this:

* Context: User context.  May sleep.  Caller might hold mmap_lock.

WDYT?


  reply	other threads:[~2021-12-08 19:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-07 21:50 Suren Baghdasaryan
2021-12-07 21:50 ` [PATCH v3 2/2] mm/oom_kill: allow process_mrelease to run under mmap_lock protection Suren Baghdasaryan
2021-12-07 22:07 ` [PATCH v3 1/2] mm: protect free_pgtables with mmap_lock write lock in exit_mmap Matthew Wilcox
2021-12-07 22:47   ` Suren Baghdasaryan
2021-12-07 23:08     ` Suren Baghdasaryan
2021-12-08  8:56       ` Michal Hocko
2021-12-08 15:01       ` Matthew Wilcox
2021-12-08 15:51         ` Michal Hocko
2021-12-08 16:05           ` Matthew Wilcox
2021-12-08 16:50             ` Suren Baghdasaryan
2021-12-08 19:13               ` Suren Baghdasaryan [this message]
2021-12-08 19:22                 ` Matthew Wilcox
2021-12-08 21:24                   ` Suren Baghdasaryan

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=CAJuCfpF0HHXGotVF7Sjo-b4raQcf8a4ckBto8-EE18n1ovmtXQ@mail.gmail.com \
    --to=surenb@google.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=christian.brauner@ubuntu.com \
    --cc=christian@brauner.io \
    --cc=david@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=guro@fb.com \
    --cc=hannes@cmpxchg.org \
    --cc=hch@infradead.org \
    --cc=jannh@google.com \
    --cc=jengelh@inai.de \
    --cc=kernel-team@android.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mhocko@suse.com \
    --cc=minchan@kernel.org \
    --cc=oleg@redhat.com \
    --cc=riel@surriel.com \
    --cc=rientjes@google.com \
    --cc=shakeelb@google.com \
    --cc=timmurray@google.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