lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <D94BB56F-4BA0-4376-B5C4-7E38D2D92624@nvidia.com>
Date: Mon, 10 Mar 2025 12:42:06 -0400
From: Zi Yan <ziy@...dia.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: <linux-mm@...ck.org>, Andrew Morton <akpm@...ux-foundation.org>,
 Hugh Dickins <hughd@...gle.com>, Ryan Roberts <ryan.roberts@....com>,
 "Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
 David Hildenbrand <david@...hat.com>, Yang Shi <yang@...amperecomputing.com>,
 Miaohe Lin <linmiaohe@...wei.com>, Kefeng Wang <wangkefeng.wang@...wei.com>,
 Yu Zhao <yuzhao@...gle.com>, John Hubbard <jhubbard@...dia.com>,
 Baolin Wang <baolin.wang@...ux.alibaba.com>,
 <linux-kselftest@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
 Kairui Song <kasong@...cent.com>
Subject: Re: [PATCH v10 2/8] mm/huge_memory: add two new (not yet used)
 functions for folio_split()

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ