From: Vishal Moola <vishal.moola@gmail.com>
To: Muchun Song <muchun.song@linux.dev>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
willy@infradead.org, linux-mm@kvack.org
Subject: Re: [PATCH v2 3/3] hugetlb: Convert hugetlb_wp() to use struct vm_fault
Date: Mon, 8 Apr 2024 10:47:12 -0700 [thread overview]
Message-ID: <ZhQtoFNZBNwBCeXn@fedora> (raw)
In-Reply-To: <7d001108-157d-4139-bfa9-5b4102166f17@linux.dev>
[-- Attachment #1: Type: text/plain, Size: 1206 bytes --]
On Sun, Apr 07, 2024 at 05:12:42PM +0800, Muchun Song wrote:
>
>
> On 2024/4/2 04:26, Vishal Moola (Oracle) wrote:
> > hugetlb_wp() can use the struct vm_fault passed in from hugetlb_fault().
> > This alleviates the stack by consolidating 5 variables into a single
> > struct.
> >
> > Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
> > ---
> > mm/hugetlb.c | 61 ++++++++++++++++++++++++++--------------------------
> > 1 file changed, 30 insertions(+), 31 deletions(-)
> >
> > diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> > index aca2f11b4138..d4f26947173e 100644
> > --- a/mm/hugetlb.c
> > +++ b/mm/hugetlb.c
> > @@ -5918,18 +5918,16 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
> > * Keep the pte_same checks anyway to make transition from the mutex easier.
> > */
> > static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma,
> > - unsigned long address, pte_t *ptep, unsigned int flags,
> > - struct folio *pagecache_folio, spinlock_t *ptl,
> > + struct folio *pagecache_folio,
>
> The same as comment in the previous thread.
And fold the attached patch into here as well please Andrew?
[-- Attachment #2: 0002-hugetlb-Simplyfy-hugetlb_wp-arguments.patch --]
[-- Type: text/plain, Size: 2130 bytes --]
From f4adcf13ecc15a6733af43649756e53457078221 Mon Sep 17 00:00:00 2001
From: "Vishal Moola (Oracle)" <vishal.moola@gmail.com>
Date: Mon, 8 Apr 2024 10:21:44 -0700
Subject: [PATCH 2/2] hugetlb: Simplyfy hugetlb_wp() arguments
To simplify the function arguments, as suggested by Oscar and Muchun.
Suggested-by: Muchun Song <muchun.song@linux.dev>
Suggested-by: Oscar Salvador <osalvador@suse.de>
Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
---
mm/hugetlb.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 05fe610f4699..0d96a41efde8 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5915,10 +5915,11 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
* cannot race with other handlers or page migration.
* Keep the pte_same checks anyway to make transition from the mutex easier.
*/
-static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma,
- struct folio *pagecache_folio,
+static vm_fault_t hugetlb_wp(struct folio *pagecache_folio,
struct vm_fault *vmf)
{
+ struct vm_area_struct *vma = vmf->vma;
+ struct mm_struct *mm = vma->vm_mm;
const bool unshare = vmf->flags & FAULT_FLAG_UNSHARE;
pte_t pte = huge_ptep_get(vmf->pte);
struct hstate *h = hstate_vma(vma);
@@ -6364,7 +6365,7 @@ static vm_fault_t hugetlb_no_page(struct address_space *mapping,
hugetlb_count_add(pages_per_huge_page(h), mm);
if ((vmf->flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
/* Optimization, do the COW without a second fault */
- ret = hugetlb_wp(mm, vma, folio, vmf);
+ ret = hugetlb_wp(folio, vmf);
}
spin_unlock(vmf->ptl);
@@ -6577,7 +6578,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
if (flags & (FAULT_FLAG_WRITE|FAULT_FLAG_UNSHARE)) {
if (!huge_pte_write(vmf.orig_pte)) {
- ret = hugetlb_wp(mm, vma, pagecache_folio, &vmf);
+ ret = hugetlb_wp(pagecache_folio, &vmf);
goto out_put_page;
} else if (likely(flags & FAULT_FLAG_WRITE)) {
vmf.orig_pte = huge_pte_mkdirty(vmf.orig_pte);
--
2.43.0
next prev parent reply other threads:[~2024-04-08 17:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-01 20:26 [PATCH v2 0/3] Hugetlb fault path " Vishal Moola (Oracle)
2024-04-01 20:26 ` [PATCH v2 1/3] hugetlb: Convert hugetlb_fault() " Vishal Moola (Oracle)
2024-04-04 12:27 ` Oscar Salvador
2024-04-04 19:32 ` Vishal Moola
2024-04-07 7:36 ` Muchun Song
2024-04-07 7:18 ` Muchun Song
2024-04-01 20:26 ` [PATCH v2 2/3] hugetlb: Convert hugetlb_no_page() " Vishal Moola (Oracle)
2024-04-04 12:50 ` Oscar Salvador
2024-04-04 19:58 ` Vishal Moola
2024-04-07 8:59 ` Muchun Song
2024-04-08 17:45 ` Vishal Moola
2024-04-05 3:12 ` Oscar Salvador
2024-04-01 20:26 ` [PATCH v2 3/3] hugetlb: Convert hugetlb_wp() " Vishal Moola (Oracle)
2024-04-05 3:23 ` Oscar Salvador
2024-04-07 9:12 ` Muchun Song
2024-04-08 17:47 ` Vishal Moola [this message]
2024-04-08 17:55 ` Matthew Wilcox
2024-04-04 2:07 ` [PATCH v2 0/3] Hugetlb fault path " Andrew Morton
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=ZhQtoFNZBNwBCeXn@fedora \
--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