linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Matthew Wilcox <willy@infradead.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	David Hildenbrand <david@redhat.com>,
	Sidhartha Kumar <sidhartha.kumar@oracle.com>,
	<linux-mm@kvack.org>, Kefeng Wang <wangkefeng.wang@huawei.com>
Subject: [PATCH 4/5] mm: khugepaged: pass a folio for set_huge_pmd()
Date: Sat, 17 Aug 2024 17:51:21 +0800	[thread overview]
Message-ID: <20240817095122.2460977-5-wangkefeng.wang@huawei.com> (raw)
In-Reply-To: <20240817095122.2460977-1-wangkefeng.wang@huawei.com>

Save one compound_head() and remove last PageTransHuge() in set_huge_pmd().

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/khugepaged.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 02e1463e1a79..ae796219f8a0 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1455,7 +1455,7 @@ static void collect_mm_slot(struct khugepaged_mm_slot *mm_slot)
 #ifdef CONFIG_SHMEM
 /* hpage must be locked, and mmap_lock must be held */
 static int set_huge_pmd(struct vm_area_struct *vma, unsigned long addr,
-			pmd_t *pmdp, struct page *hpage)
+			pmd_t *pmdp, struct folio *folio)
 {
 	struct vm_fault vmf = {
 		.vma = vma,
@@ -1464,13 +1464,12 @@ static int set_huge_pmd(struct vm_area_struct *vma, unsigned long addr,
 		.pmd = pmdp,
 	};
 
-	VM_BUG_ON(!PageTransHuge(hpage));
 	mmap_assert_locked(vma->vm_mm);
 
-	if (do_set_pmd(&vmf, hpage))
+	if (do_set_pmd(&vmf, &folio->page))
 		return SCAN_FAIL;
 
-	get_page(hpage);
+	folio_get(folio);
 	return SCAN_SUCCEED;
 }
 
@@ -1670,8 +1669,7 @@ int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr,
 maybe_install_pmd:
 	/* step 5: install pmd entry */
 	result = install_pmd
-			? set_huge_pmd(vma, haddr, pmd, &folio->page)
-			: SCAN_SUCCEED;
+			? set_huge_pmd(vma, haddr, pmd, folio) : SCAN_SUCCEED;
 	goto drop_folio;
 abort:
 	if (nr_ptes) {
-- 
2.27.0



  parent reply	other threads:[~2024-08-17  9:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-17  9:51 [PATCH 0/5] mm: finish three more folio conversion Kefeng Wang
2024-08-17  9:51 ` [PATCH 1/5] mm: remove find_subpage() Kefeng Wang
2024-08-19 11:02   ` Kefeng Wang
2024-08-19 13:27     ` David Hildenbrand
2024-08-20  8:22       ` Kefeng Wang
2024-08-20  8:23         ` David Hildenbrand
2024-08-20  8:34           ` Kefeng Wang
2024-08-17  9:51 ` [PATCH 2/5] pagemap: use a folio in __readahead_batch() Kefeng Wang
2024-08-17  9:51 ` [PATCH 3/5] mm: remove thp_nr_pages() Kefeng Wang
2024-08-17  9:51 ` Kefeng Wang [this message]
2024-08-17  9:51 ` [PATCH 5/5] mm: remove PageTransHuge() Kefeng Wang
2024-08-18 20:33 ` [PATCH 0/5] mm: finish three more folio conversion Matthew Wilcox
2024-08-19  9:59   ` David Hildenbrand
2024-08-19 11:13     ` Kefeng Wang
2024-08-19 13:20       ` Matthew Wilcox
2024-08-20  8:41         ` Kefeng Wang

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=20240817095122.2460977-5-wangkefeng.wang@huawei.com \
    --to=wangkefeng.wang@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=sidhartha.kumar@oracle.com \
    --cc=viro@zeniv.linux.org.uk \
    --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