* [PATCH 1/2] mm/huge_memory: check new folio order when split a folio
@ 2024-03-07 18:18 Zi Yan
2024-03-07 18:18 ` [PATCH 2/2] mm/huge_memory: skip invalid debugfs new_order input for folio split Zi Yan
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Zi Yan @ 2024-03-07 18:18 UTC (permalink / raw)
To: Andrew Morton, linux-mm
Cc: Zi Yan, Dan Carpenter, Pankaj Raghav (Samsung),
Matthew Wilcox (Oracle),
David Hildenbrand, Yang Shi, Yu Zhao, Kirill A . Shutemov,
Ryan Roberts, linux-kernel
From: Zi Yan <ziy@nvidia.com>
A folio can only be split into lower orders. Check new_order to make sure
it is smaller than input folio order.
Link: https://lore.kernel.org/linux-mm/7dda9283-b437-4cf8-ab0d-83c330deb9c0@moroto.mountain/
Fixes: c010d47f107f ("mm: thp: split huge page to any lower order pages")
Signed-off-by: Zi Yan <ziy@nvidia.com>
---
mm/huge_memory.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index a81a09236c16..57fca7bffd20 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3052,6 +3052,9 @@ int split_huge_page_to_list_to_order(struct page *page, struct list_head *list,
VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
VM_BUG_ON_FOLIO(!folio_test_large(folio), folio);
+ if (new_order >= folio_order(folio))
+ return -EINVAL;
+
/* Cannot split anonymous THP to order-1 */
if (new_order == 1 && folio_test_anon(folio)) {
VM_WARN_ONCE(1, "Cannot split to order-1 folio");
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 2/2] mm/huge_memory: skip invalid debugfs new_order input for folio split
2024-03-07 18:18 [PATCH 1/2] mm/huge_memory: check new folio order when split a folio Zi Yan
@ 2024-03-07 18:18 ` Zi Yan
2024-03-07 20:02 ` [PATCH 1/2] mm/huge_memory: check new folio order when split a folio Andrew Morton
2024-03-07 20:03 ` Andrew Morton
2 siblings, 0 replies; 5+ messages in thread
From: Zi Yan @ 2024-03-07 18:18 UTC (permalink / raw)
To: Andrew Morton, linux-mm
Cc: Zi Yan, Dan Carpenter, Pankaj Raghav (Samsung),
Matthew Wilcox (Oracle),
David Hildenbrand, Yang Shi, Yu Zhao, Kirill A . Shutemov,
Ryan Roberts, linux-kernel
From: Zi Yan <ziy@nvidia.com>
User can put arbitrary new_order via debugfs for folio split test. Although
new_order check is added to split_huge_page_to_list_order() in the prior
commit, these two additional checks can avoid unnecessary folio locking
and split_folio_to_order() calls.
Link: https://lore.kernel.org/linux-mm/7dda9283-b437-4cf8-ab0d-83c330deb9c0@moroto.mountain/
Signed-off-by: Zi Yan <ziy@nvidia.com>
---
mm/huge_memory.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 57fca7bffd20..9859aa4f7553 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3486,6 +3486,9 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start,
if (!is_transparent_hugepage(folio))
goto next;
+ if (new_order >= folio_order(folio))
+ goto next;
+
total++;
/*
* For folios with private, split_huge_page_to_list_to_order()
@@ -3553,6 +3556,9 @@ static int split_huge_pages_in_file(const char *file_path, pgoff_t off_start,
total++;
nr_pages = folio_nr_pages(folio);
+ if (new_order >= folio_order(folio))
+ goto next;
+
if (!folio_trylock(folio))
goto next;
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mm/huge_memory: check new folio order when split a folio
2024-03-07 18:18 [PATCH 1/2] mm/huge_memory: check new folio order when split a folio Zi Yan
2024-03-07 18:18 ` [PATCH 2/2] mm/huge_memory: skip invalid debugfs new_order input for folio split Zi Yan
@ 2024-03-07 20:02 ` Andrew Morton
2024-03-07 20:09 ` Zi Yan
2024-03-07 20:03 ` Andrew Morton
2 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2024-03-07 20:02 UTC (permalink / raw)
To: Zi Yan
Cc: Zi Yan, linux-mm, Dan Carpenter, Pankaj Raghav (Samsung),
Matthew Wilcox (Oracle),
David Hildenbrand, Yang Shi, Yu Zhao, Kirill A . Shutemov,
Ryan Roberts, linux-kernel
On Thu, 7 Mar 2024 13:18:53 -0500 Zi Yan <zi.yan@sent.com> wrote:
> From: Zi Yan <ziy@nvidia.com>
>
> A folio can only be split into lower orders. Check new_order to make sure
> it is smaller than input folio order.
It isn't clear what's being fixed here. Presumably something is
passing in such folios, but what and where and why and what are the
effects?
Might it be that these folios are being caused by the debugfs
interface? Or something else?
So I'll add it, but I do think more information and context would
improve the patch, please. Suitable Reported-by:, Closes: and Link:
tags, perhaps.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mm/huge_memory: check new folio order when split a folio
2024-03-07 20:02 ` [PATCH 1/2] mm/huge_memory: check new folio order when split a folio Andrew Morton
@ 2024-03-07 20:09 ` Zi Yan
0 siblings, 0 replies; 5+ messages in thread
From: Zi Yan @ 2024-03-07 20:09 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-mm, Dan Carpenter, "Pankaj Raghav (Samsung)",
"Matthew Wilcox (Oracle)",
David Hildenbrand, Yang Shi, Yu Zhao,
"Kirill A . Shutemov",
Ryan Roberts, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 940 bytes --]
On 7 Mar 2024, at 15:02, Andrew Morton wrote:
> On Thu, 7 Mar 2024 13:18:53 -0500 Zi Yan <zi.yan@sent.com> wrote:
>
>> From: Zi Yan <ziy@nvidia.com>
>>
>> A folio can only be split into lower orders. Check new_order to make sure
>> it is smaller than input folio order.
>
> It isn't clear what's being fixed here. Presumably something is
> passing in such folios, but what and where and why and what are the
> effects?
>
> Might it be that these folios are being caused by the debugfs
> interface? Or something else?
Since there is no new_order checks in debugfs before, any
new_order can be passed via debugfs into
split_huge_page_to_list_to_order().
I did not explicitly mention it here as the debugfs is added in
the commit after the Fixes one.
>
> So I'll add it, but I do think more information and context would
> improve the patch, please. Suitable Reported-by:, Closes: and Link:
> tags, perhaps.
--
Best Regards,
Yan, Zi
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 854 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mm/huge_memory: check new folio order when split a folio
2024-03-07 18:18 [PATCH 1/2] mm/huge_memory: check new folio order when split a folio Zi Yan
2024-03-07 18:18 ` [PATCH 2/2] mm/huge_memory: skip invalid debugfs new_order input for folio split Zi Yan
2024-03-07 20:02 ` [PATCH 1/2] mm/huge_memory: check new folio order when split a folio Andrew Morton
@ 2024-03-07 20:03 ` Andrew Morton
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2024-03-07 20:03 UTC (permalink / raw)
To: Zi Yan
Cc: Zi Yan, linux-mm, Dan Carpenter, Pankaj Raghav (Samsung),
Matthew Wilcox (Oracle),
David Hildenbrand, Yang Shi, Yu Zhao, Kirill A . Shutemov,
Ryan Roberts, linux-kernel
On Thu, 7 Mar 2024 13:18:53 -0500 Zi Yan <zi.yan@sent.com> wrote:
> Link: https://lore.kernel.org/linux-mm/7dda9283-b437-4cf8-ab0d-83c330deb9c0@moroto.mountain/
Oh, there it is.
I'll change this to Reported-by: and Closes:, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-03-07 20:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-07 18:18 [PATCH 1/2] mm/huge_memory: check new folio order when split a folio Zi Yan
2024-03-07 18:18 ` [PATCH 2/2] mm/huge_memory: skip invalid debugfs new_order input for folio split Zi Yan
2024-03-07 20:02 ` [PATCH 1/2] mm/huge_memory: check new folio order when split a folio Andrew Morton
2024-03-07 20:09 ` Zi Yan
2024-03-07 20:03 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox