linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Vishal Moola (Oracle)" <vishal.moola@gmail.com>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	muchun.song@linux.dev, willy@infradead.org,
	"Vishal Moola (Oracle)" <vishal.moola@gmail.com>
Subject: [PATCH v2 0/5] Handle hugetlb faults under the VMA lock
Date: Wed, 21 Feb 2024 15:47:27 -0800	[thread overview]
Message-ID: <20240221234732.187629-1-vishal.moola@gmail.com> (raw)

It is generally safe to handle hugetlb faults under the VMA lock. The
only time this is unsafe is when no anon_vma has been allocated to this
vma yet, so we can use vmf_anon_prepare() instead of anon_vma_prepare()
to bailout if necessary. This should only happen for the first hugetlb
page in the vma.

Additionally, this patchset begins to use struct vm_fault within
hugetlb_fault(). This works towards cleaning up hugetlb code, and should
significantly reduce the number of arguments passed to functions.

-----
The last patch in this series may cause ltp hugemmap10 to "fail". This
is because 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. The rest of the ltp testcases pass.

v2:
  - Removed unnecessary variables and indentations
  - Declare struct vm_fault in hugetlb_fault and pass it down as an
  argument instead of defining it in each called function.
  - Moved vmf_anon_prepare() declaration to mm/internal.h from
  include/linux/hugetlb.h


Vishal Moola (Oracle) (5):
  mm/memory: Change vmf_anon_prepare() to be non-static
  hugetlb: Move vm_struct declaration to the top of hugetlb_fault()
  hugetlb: Pass struct vm_fault through to hugetlb_handle_userfault()
  hugetlb: Use vmf_anon_prepare() instead of anon_vma_prepare()
  hugetlb: Allow faults to be handled under the VMA lock

 mm/hugetlb.c  | 88 ++++++++++++++++++++-------------------------------
 mm/internal.h |  1 +
 mm/memory.c   |  2 +-
 3 files changed, 36 insertions(+), 55 deletions(-)

-- 
2.43.0



             reply	other threads:[~2024-02-21 23:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 23:47 Vishal Moola (Oracle) [this message]
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

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=20240221234732.187629-1-vishal.moola@gmail.com \
    --to=vishal.moola@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --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