From: Zi Yan <ziy@nvidia.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: <linux-mm@kvack.org>, Andrew Morton <akpm@linux-foundation.org>,
Hugh Dickins <hughd@google.com>,
Ryan Roberts <ryan.roberts@arm.com>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.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>,
Kairui Song <kasong@tencent.com>
Subject: Re: [PATCH v10 2/8] mm/huge_memory: add two new (not yet used) functions for folio_split()
Date: Mon, 10 Mar 2025 12:42:06 -0400 [thread overview]
Message-ID: <D94BB56F-4BA0-4376-B5C4-7E38D2D92624@nvidia.com> (raw)
In-Reply-To: <A10312E5-F4CE-4CBA-B7CB-D435DFEA496F@nvidia.com>
On 10 Mar 2025, at 12:39, Zi Yan wrote:
> On 10 Mar 2025, at 12:30, Matthew Wilcox wrote:
>
>> On Fri, Mar 07, 2025 at 12:39:55PM -0500, Zi Yan wrote:
>>> + for (index = new_nr_pages; index < nr_pages; index += new_nr_pages) {
>>> + struct page *head = &folio->page;
>>> + struct page *new_head = head + index;
>>> +
>>> + /*
>>> + * Careful: new_folio is not a "real" folio before we cleared PageTail.
>>> + * Don't pass it around before clear_compound_head().
>>> + */
>>> + struct folio *new_folio = (struct folio *)new_head;
>> [...]
>>> + /* ->mapping in first and second tail page is replaced by other uses */
>>> + VM_BUG_ON_PAGE(new_nr_pages > 2 && new_head->mapping != TAIL_MAPPING,
>>> + new_head);
>>> + new_head->mapping = head->mapping;
>>> + new_head->index = head->index + index;
>>
>> Why are you using new_head->mapping and ->index instead of new_folio?
>
> Because of the “Careful” comment. But new_folio->* should be fine,
> since it is the same as new_head. So I probably can replace all
> new_head with new_folio except those VM_BUG_ON_PAGE checks?
Something like?
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index f06508e4d242..007c927536bb 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3341,8 +3341,8 @@ static void __split_folio_to_order(struct folio *folio, int old_order,
* unreferenced sub-pages of an anonymous THP: we can simply drop
* PG_anon_exclusive (-> PG_mappedtodisk) for these here.
*/
- new_head->flags &= ~PAGE_FLAGS_CHECK_AT_PREP;
- new_head->flags |= (head->flags &
+ new_folio->flags &= ~PAGE_FLAGS_CHECK_AT_PREP;
+ new_folio->flags |= (head->flags &
((1L << PG_referenced) |
(1L << PG_swapbacked) |
(1L << PG_swapcache) |
@@ -3364,8 +3364,8 @@ static void __split_folio_to_order(struct folio *folio, int old_order,
/* ->mapping in first and second tail page is replaced by other uses */
VM_BUG_ON_PAGE(new_nr_pages > 2 && new_head->mapping != TAIL_MAPPING,
new_head);
- new_head->mapping = head->mapping;
- new_head->index = head->index + index;
+ new_folio->mapping = head->mapping;
+ new_folio->index = head->index + index;
/*
* page->private should not be set in tail pages. Fix up and warn once
Best Regards,
Yan, Zi
next prev parent reply other threads:[~2025-03-10 16:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 17:39 [PATCH v10 0/8] Buddy allocator like (or non-uniform) folio split Zi Yan
2025-03-07 17:39 ` [PATCH v10 1/8] xarray: add xas_try_split() to split a multi-index entry Zi Yan
2025-03-07 17:39 ` [PATCH v10 2/8] mm/huge_memory: add two new (not yet used) functions for folio_split() Zi Yan
2025-03-10 16:14 ` Zi Yan
2025-03-10 17:32 ` Zi Yan
2025-03-13 14:08 ` Zi Yan
2025-03-10 16:30 ` Matthew Wilcox
2025-03-10 16:39 ` Zi Yan
2025-03-10 16:42 ` Zi Yan [this message]
2025-03-10 17:00 ` Matthew Wilcox
2025-03-10 17:05 ` Zi Yan
2025-03-07 17:39 ` [PATCH v10 3/8] mm/huge_memory: move folio split common code to __folio_split() Zi Yan
2025-03-07 17:39 ` [PATCH v10 4/8] mm/huge_memory: add buddy allocator like (non-uniform) folio_split() Zi Yan
2025-03-07 17:39 ` [PATCH v10 5/8] mm/huge_memory: remove the old, unused __split_huge_page() Zi Yan
2025-03-07 17:39 ` [PATCH v10 6/8] mm/huge_memory: add folio_split() to debugfs testing interface Zi Yan
2025-03-07 17:40 ` [PATCH v10 7/8] mm/truncate: use folio_split() in truncate operation Zi Yan
2025-03-07 17:40 ` [PATCH v10 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=D94BB56F-4BA0-4376-B5C4-7E38D2D92624@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=kasong@tencent.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