From: Zi Yan <ziy@nvidia.com>
To: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
Hugh Dickins <hughd@google.com>,
David Hildenbrand <david@redhat.com>,
Yang Shi <yang@os.amperecomputing.com>,
Miaohe Lin <linmiaohe@huawei.com>,
Kefeng Wang <wangkefeng.wang@huawei.com>,
Yu Zhao <yuzhao@google.com>, John Hubbard <jhubbard@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Zi Yan <ziy@nvidia.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Subject: Re: [PATCH v7 2/8] mm/huge_memory: add two new (not yet used) functions for folio_split()
Date: Fri, 14 Feb 2025 20:52:34 -0500 [thread overview]
Message-ID: <E2B8D781-01EE-4832-8587-4C5FF57F91B3@nvidia.com> (raw)
In-Reply-To: <20250211155034.268962-3-ziy@nvidia.com>
On 11 Feb 2025, at 10:50, Zi Yan wrote:
> This is a preparation patch, both added functions are not used yet.
>
> The added __split_unmapped_folio() is able to split a folio with
> its mapping removed in two manners: 1) uniform split (the existing way),
> and 2) buddy allocator like split.
>
> The added __split_folio_to_order() can split a folio into any lower order.
> For uniform split, __split_unmapped_folio() calls it once to split
> the given folio to the new order. For buddy allocator split,
> __split_unmapped_folio() calls it (folio_order - new_order) times
> and each time splits the folio containing the given page to one lower
> order.
>
> Signed-off-by: Zi Yan <ziy@nvidia.com>
> ---
> mm/huge_memory.c | 349 ++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 348 insertions(+), 1 deletion(-)
>
Hi Andrew,
Can you fold the patch below into this one? It addresses the error
reported by syzbot at: https://lore.kernel.org/all/67af65cb.050a0220.21dd3.004a.GAE@google.com/ and the concern raised
by David Hildenbrand at: https://lore.kernel.org/linux-mm/db77d017-4a1e-4a47-9064-e335cb0313af@redhat.com/.
Let me know if you prefer a new version of the whole series.
Thanks.
From a6bd83dfbb1143f1614ede4817cccb1e8cc6290d Mon Sep 17 00:00:00 2001
From: Zi Yan <ziy@nvidia.com>
Date: Fri, 14 Feb 2025 16:18:24 -0500
Subject: [PATCH] mm/huge_memory: do not drop the original folio during
truncate.
The caller expects to handle the original folio itself.
also make __split_unmapped_folio() never fail, per discussion with David
Hildenbrand.
Signed-off-by: Zi Yan <ziy@nvidia.com>
---
mm/huge_memory.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 2eda2a9ec8fc..87cb62c81bf3 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3292,16 +3292,12 @@ bool can_split_folio(struct folio *folio, int caller_pins, int *pextra_pins)
* It splits @folio into @new_order folios and copies the @folio metadata to
* all the resulting folios.
*/
-static int __split_folio_to_order(struct folio *folio, int new_order)
+static void __split_folio_to_order(struct folio *folio, int new_order)
{
- int curr_order = folio_order(folio);
long nr_pages = folio_nr_pages(folio);
long new_nr_pages = 1 << new_order;
long index;
- if (curr_order <= new_order)
- return -EINVAL;
-
/*
* Skip the first new_nr_pages, since the new folio from them have all
* the flags from the original folio.
@@ -3396,8 +3392,6 @@ static int __split_folio_to_order(struct folio *folio, int new_order)
if (!new_order)
ClearPageCompound(&folio->page);
-
- return 0;
}
/*
@@ -3491,7 +3485,6 @@ static int __split_unmapped_folio(struct folio *folio, int new_order,
int old_order = folio_order(folio);
struct folio *release;
struct folio *end_folio = folio_next(folio);
- int status;
/* order-1 anonymous folio is not supported */
if (folio_test_anon(folio) && split_order == 1)
@@ -3524,12 +3517,7 @@ static int __split_unmapped_folio(struct folio *folio, int new_order,
split_page_owner(&folio->page, old_order, split_order);
pgalloc_tag_split(folio, old_order, split_order);
- status = __split_folio_to_order(folio, split_order);
-
- if (status < 0) {
- stop_split = true;
- ret = -EINVAL;
- }
+ __split_folio_to_order(folio, split_order);
after_split:
/*
@@ -3567,8 +3555,10 @@ static int __split_unmapped_folio(struct folio *folio, int new_order,
folio_test_swapcache(origin_folio)) ?
folio_nr_pages(release) : 0));
- if (release != origin_folio)
- lru_add_page_tail(origin_folio, &release->page,
+ if (release == origin_folio)
+ continue;
+
+ lru_add_page_tail(origin_folio, &release->page,
lruvec, list);
/* Some pages can be beyond EOF: drop them from page cache */
--
2.47.2
Best Regards,
Yan, Zi
next prev parent reply other threads:[~2025-02-15 1:52 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-11 15:50 [PATCH v7 0/8] Buddy allocator like (or non-uniform) folio split Zi Yan
2025-02-11 15:50 ` [PATCH v7 1/8] xarray: add xas_try_split() to split a multi-index entry Zi Yan
2025-02-12 0:57 ` Zi Yan
2025-02-12 1:51 ` Zi Yan
2025-02-17 21:44 ` David Hildenbrand
2025-02-17 22:05 ` Zi Yan
2025-02-18 15:44 ` David Hildenbrand
2025-02-18 16:04 ` Zi Yan
2025-02-18 16:12 ` David Hildenbrand
2025-02-11 15:50 ` [PATCH v7 2/8] mm/huge_memory: add two new (not yet used) functions for folio_split() Zi Yan
2025-02-14 21:59 ` David Hildenbrand
2025-02-14 22:03 ` Zi Yan
2025-02-14 22:06 ` David Hildenbrand
2025-02-14 22:18 ` Zi Yan
2025-02-15 1:52 ` Zi Yan [this message]
2025-02-11 15:50 ` [PATCH v7 3/8] mm/huge_memory: move folio split common code to __folio_split() Zi Yan
2025-02-11 15:50 ` [PATCH v7 4/8] mm/huge_memory: add buddy allocator like (non-uniform) folio_split() Zi Yan
2025-02-16 10:32 ` David Hildenbrand
2025-02-16 14:17 ` Zi Yan
2025-02-17 15:22 ` Zi Yan
2025-02-18 4:12 ` Andrew Morton
2025-02-18 15:23 ` Zi Yan
2025-02-11 15:50 ` [PATCH v7 5/8] mm/huge_memory: remove the old, unused __split_huge_page() Zi Yan
2025-02-11 15:50 ` [PATCH v7 6/8] mm/huge_memory: add folio_split() to debugfs testing interface Zi Yan
2025-02-11 15:50 ` [PATCH v7 7/8] mm/truncate: use buddy allocator like folio split for truncate operation Zi Yan
2025-02-11 15:50 ` [PATCH v7 8/8] selftests/mm: add tests for folio_split(), buddy allocator like split Zi Yan
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=E2B8D781-01EE-4832-8587-4C5FF57F91B3@nvidia.com \
--to=ziy@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=jhubbard@nvidia.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ryan.roberts@arm.com \
--cc=wangkefeng.wang@huawei.com \
--cc=willy@infradead.org \
--cc=yang@os.amperecomputing.com \
--cc=yuzhao@google.com \
/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