linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vishal Moola <vishal.moola@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	 akpm@linux-foundation.org, muchun.song@linux.dev,
	 Cyril Hrubis <chrubis@suse.cz>,
	Jan Stancek <jstancek@redhat.com>, Petr Vorel <pvorel@suse.cz>,
	 ltp@lists.linux.it
Subject: Re: [PATCH v2 5/5] hugetlb: Allow faults to be handled under the VMA lock
Date: Thu, 22 Feb 2024 09:27:00 -0800	[thread overview]
Message-ID: <CAOzc2pyt=3UwRt6a8L-wJGAcQFJr_ZNeFEwiGapx9KktuYC+BQ@mail.gmail.com> (raw)
In-Reply-To: <ZdbFyC6HPr6oKrM-@casper.infradead.org>

On Wed, Feb 21, 2024 at 7:55 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Wed, Feb 21, 2024 at 03:47:32PM -0800, Vishal Moola (Oracle) wrote:
> > Hugetlb can now safely handle faults under the VMA lock, so allow it to
> > do so.
> >
> > This patch may cause ltp hugemmap10 to "fail". Hugemmap10 tests hugetlb
> > counters, and expects the counters to remain unchanged on failure to
> > handle a fault.
> >
> > In hugetlb_no_page(), vmf_anon_prepare() may bailout with no anon_vma
> > under the VMA lock after allocating a folio for the hugepage. In
> > free_huge_folio(), this folio is completely freed on bailout iff there
> > is a surplus of hugetlb pages. This will remove a folio off the freelist
> > and decrement the number of hugepages while ltp expects these counters
> > to remain unchanged on failure.
> >
> > Originally this could only happen due to OOM failures, but now it may
> > also occur after we allocate a hugetlb folio without a suitable anon_vma
> > under the VMA lock. This should only happen for the first freshly
> > allocated hugepage in this vma.
>
> Hmm, so it's a bug in LTP.  Have you talked to the LTP people about it
> (cc's added)?
>
> Also, did you try moving the anon_vma check befor the folio allocation
> so that you can bail out without disturbing the counters?

Moving the check before folio allocation occurs keeps the folios on the
freelist so the counters remain static as expected.

If we are looking at a shareable vma, hugetlb_no_page() does not need
this check at all, so I left the check where it is. We could definitely place
the anon_vma check above allocation, it would just make the code
slightly more complicated - needing another variable (or reassigning
ret in various places) as well as adding another potentially unnecessary
vma flag check.

> > Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
>
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>


      reply	other threads:[~2024-02-22 17:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 23:47 [PATCH v2 0/5] Handle hugetlb faults " Vishal Moola (Oracle)
2024-02-21 23:47 ` [PATCH v2 1/5] mm/memory: Change vmf_anon_prepare() to be non-static Vishal Moola (Oracle)
2024-02-22  3:31   ` Matthew Wilcox
2024-02-21 23:47 ` [PATCH v2 2/5] hugetlb: Move vm_struct declaration to the top of hugetlb_fault() Vishal Moola (Oracle)
2024-02-22  3:35   ` Matthew Wilcox
2024-02-21 23:47 ` [PATCH v2 3/5] hugetlb: Pass struct vm_fault through to hugetlb_handle_userfault() Vishal Moola (Oracle)
2024-02-22  3:41   ` Matthew Wilcox
2024-02-22 16:13     ` Vishal Moola
2024-02-21 23:47 ` [PATCH v2 4/5] hugetlb: Use vmf_anon_prepare() instead of anon_vma_prepare() Vishal Moola (Oracle)
2024-02-22  3:51   ` Matthew Wilcox
2024-02-21 23:47 ` [PATCH v2 5/5] hugetlb: Allow faults to be handled under the VMA lock Vishal Moola (Oracle)
2024-02-22  3:55   ` Matthew Wilcox
2024-02-22 17:27     ` Vishal Moola [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='CAOzc2pyt=3UwRt6a8L-wJGAcQFJr_ZNeFEwiGapx9KktuYC+BQ@mail.gmail.com' \
    --to=vishal.moola@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chrubis@suse.cz \
    --cc=jstancek@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ltp@lists.linux.it \
    --cc=muchun.song@linux.dev \
    --cc=pvorel@suse.cz \
    --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