From: Rik van Riel <riel@surriel.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Josef Bacik <josef@toxicpanda.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
Matthew Wilcox <willy@infradead.org>, Chris Mason <clm@fb.com>
Subject: Re: [PATCH] mm: fix page leak with multiple threads mapping the same page
Date: Wed, 06 Jul 2022 20:42:56 -0400 [thread overview]
Message-ID: <cf744705857d80ac9c8c06cb08a334f43e51d0a9.camel@surriel.com> (raw)
In-Reply-To: <20220706224657.3xbhbkflernezlxy@black.fi.intel.com>
[-- Attachment #1: Type: text/plain, Size: 1602 bytes --]
On Thu, 2022-07-07 at 01:46 +0300, Kirill A. Shutemov wrote:
> On Tue, Jul 05, 2022 at 04:00:36PM -0400, Josef Bacik wrote:
> >
> > Fix this by returning VM_FAULT_NOPAGE in the
> > pmd_devmap_trans_unstable()
> > case, this makes us drop the ref on the page properly, and now my
> > reproducer no longer leaks the huge pages.
> >
> > Fixes: f9ce0be71d1f ("mm: Cleanup faultaround and finish_fault()
> > codepaths")
> > Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
> > Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> > Signed-off-by: Rik van Riel <riel@surriel.com>
> > Signed-off-by: Chris Mason <clm@fb.com>
>
> Cc: stable@
Yes, it should. How do we send a patch to stable@
after the start of the thread?
> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -4371,7 +4371,7 @@ vm_fault_t finish_fault(struct vm_fault *vmf)
> >
> > /* See comment in handle_pte_fault() */
> > if (pmd_devmap_trans_unstable(vmf->pmd))
> > - return 0;
> > + return VM_FAULT_NOPAGE;
>
> Comment update would be nice.
>
> Other instances of pmd_devmap_trans_unstable() return 0 in the fault
> path.
> Explanation would be helpful.
>
The explanation is that by the time we get to
finish_fault, we already have a reference on a
page, and we need to ensure that reference
gets released by the caller.
VM_FAULT_NOPAGE is one of the ways to indicate
that the page should be freed.
--
All Rights Reversed.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2022-07-07 0:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-05 20:00 Josef Bacik
2022-07-06 22:46 ` Kirill A. Shutemov
2022-07-07 0:42 ` Rik van Riel [this message]
2022-07-08 0:58 ` Andrew Morton
2022-07-15 15:21 ` Rik van Riel
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=cf744705857d80ac9c8c06cb08a334f43e51d0a9.camel@surriel.com \
--to=riel@surriel.com \
--cc=akpm@linux-foundation.org \
--cc=clm@fb.com \
--cc=josef@toxicpanda.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-mm@kvack.org \
--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