mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* ​ [PATCH linux-next] mm: huge_memory: remove is_transparent_hugepage()
@ 2024-06-05  8:37 xu.xin16
  2024-06-05  8:56 ` David Hildenbrand
  0 siblings, 1 reply; 2+ messages in thread
From: xu.xin16 @ 2024-06-05  8:37 UTC (permalink / raw)
  To: willy, ziy, akpm
  Cc: ran.xiaokai, xu.xin16, yang.yang29, mhocko, david, linux-mm,
	linux-kernel

From: Ran Xiaokai <ran.xiaokai@zte.com.cn>

is_transparent_hugepage() was first introduced to ensure the page is
2M THP page. After commit de53c05f2ae3 ("mm: add large_rmappable
page flag") and commit fc4d182316bd ("mm: huge_memory: enable debugfs
to split huge pages to any order"), any large folio of mTHP suitable order
can be split, not only 2M THP page.
so the check in split_huge_pages_pid() is not needed here, instead
a folio_test_large() check is sufficient. To ensure a 2M THP folio,
we should use "folio_order(folio) == HPAGE_PMD_ORDER" for now.

As split_huge_pages_pid() is the only user of is_transparent_hugepage(),
we can remove this helper.

Signed-off-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
---
 mm/huge_memory.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 317de2afd371..f1a992945007 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -839,15 +839,6 @@ struct deferred_split *get_deferred_split_queue(struct folio *folio)
 }
 #endif

-static inline bool is_transparent_hugepage(const struct folio *folio)
-{
-	if (!folio_test_large(folio))
-		return false;
-
-	return is_huge_zero_folio(folio) ||
-		folio_test_large_rmappable(folio);
-}
-
 static unsigned long __thp_get_unmapped_area(struct file *filp,
 		unsigned long addr, unsigned long len,
 		loff_t off, unsigned long flags, unsigned long size,
@@ -3439,7 +3430,7 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start,
 			continue;

 		folio = page_folio(page);
-		if (!is_transparent_hugepage(folio))
+		if (!folio_test_large(folio))
 			goto next;

 		if (new_order >= folio_order(folio))
-- 
2.15.2

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH linux-next] mm: huge_memory: remove is_transparent_hugepage()
  2024-06-05  8:37 ​ [PATCH linux-next] mm: huge_memory: remove is_transparent_hugepage() xu.xin16
@ 2024-06-05  8:56 ` David Hildenbrand
  0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2024-06-05  8:56 UTC (permalink / raw)
  To: xu.xin16, willy, ziy, akpm
  Cc: ran.xiaokai, yang.yang29, mhocko, linux-mm, linux-kernel

On 05.06.24 10:37, xu.xin16@zte.com.cn wrote:
> From: Ran Xiaokai <ran.xiaokai@zte.com.cn>
> 
> is_transparent_hugepage() was first introduced to ensure the page is
> 2M THP page. After commit de53c05f2ae3 ("mm: add large_rmappable
> page flag") and commit fc4d182316bd ("mm: huge_memory: enable debugfs
> to split huge pages to any order"), any large folio of mTHP suitable order
> can be split, not only 2M THP page.

Yes.

> so the check in split_huge_pages_pid() is not needed here, instead
> a folio_test_large() check is sufficient. To ensure a 2M THP folio,
> we should use "folio_order(folio) == HPAGE_PMD_ORDER" for now.

What about some kernel-allocated large folio that got mapped using 
vm_insert_pages() and friends? Are we sure these pages (that are not 
large_rmappable and not splittable) are properly handled?

-- 
Cheers,

David / dhildenb


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-05  8:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-05  8:37 ​ [PATCH linux-next] mm: huge_memory: remove is_transparent_hugepage() xu.xin16
2024-06-05  8:56 ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®