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: <20250821200701.1329277-10-david@redhat.com>
Date: Thu, 21 Aug 2025 22:06:35 +0200
From: David Hildenbrand <david@...hat.com>
To: linux-kernel@...r.kernel.org
Cc: David Hildenbrand <david@...hat.com>,
	Alexander Potapenko <glider@...gle.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Brendan Jackman <jackmanb@...gle.com>,
	Christoph Lameter <cl@...two.org>,
	Dennis Zhou <dennis@...nel.org>,
	Dmitry Vyukov <dvyukov@...gle.com>,
	dri-devel@...ts.freedesktop.org,
	intel-gfx@...ts.freedesktop.org,
	iommu@...ts.linux.dev,
	io-uring@...r.kernel.org,
	Jason Gunthorpe <jgg@...dia.com>,
	Jens Axboe <axboe@...nel.dk>,
	Johannes Weiner <hannes@...xchg.org>,
	John Hubbard <jhubbard@...dia.com>,
	kasan-dev@...glegroups.com,
	kvm@...r.kernel.org,
	"Liam R. Howlett" <Liam.Howlett@...cle.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	linux-arm-kernel@...s.com,
	linux-arm-kernel@...ts.infradead.org,
	linux-crypto@...r.kernel.org,
	linux-ide@...r.kernel.org,
	linux-kselftest@...r.kernel.org,
	linux-mips@...r.kernel.org,
	linux-mmc@...r.kernel.org,
	linux-mm@...ck.org,
	linux-riscv@...ts.infradead.org,
	linux-s390@...r.kernel.org,
	linux-scsi@...r.kernel.org,
	Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
	Marco Elver <elver@...gle.com>,
	Marek Szyprowski <m.szyprowski@...sung.com>,
	Michal Hocko <mhocko@...e.com>,
	Mike Rapoport <rppt@...nel.org>,
	Muchun Song <muchun.song@...ux.dev>,
	netdev@...r.kernel.org,
	Oscar Salvador <osalvador@...e.de>,
	Peter Xu <peterx@...hat.com>,
	Robin Murphy <robin.murphy@....com>,
	Suren Baghdasaryan <surenb@...gle.com>,
	Tejun Heo <tj@...nel.org>,
	virtualization@...ts.linux.dev,
	Vlastimil Babka <vbabka@...e.cz>,
	wireguard@...ts.zx2c4.com,
	x86@...nel.org,
	Zi Yan <ziy@...dia.com>
Subject: [PATCH RFC 09/35] mm/mm_init: make memmap_init_compound() look more like prep_compound_page()

Grepping for "prep_compound_page" leaves on clueless how devdax gets its
compound pages initialized.

Let's add a comment that might help finding this open-coded
prep_compound_page() initialization more easily.

Further, let's be less smart about the ordering of initialization and just
perform the prep_compound_head() call after all tail pages were
initialized: just like prep_compound_page() does.

No need for a lengthy comment then: again, just like prep_compound_page().

Note that prep_compound_head() already does initialize stuff in page[2]
through prep_compound_head() that successive tail page initialization
will overwrite: _deferred_list, and on 32bit _entire_mapcount and
_pincount. Very likely 32bit does not apply, and likely nobody ever ends
up testing whether the _deferred_list is empty.

So it shouldn't be a fix at this point, but certainly something to clean
up.

Signed-off-by: David Hildenbrand <david@...hat.com>
---
 mm/mm_init.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 5c21b3af216b2..708466c5b2cc9 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1091,6 +1091,10 @@ static void __ref memmap_init_compound(struct page *head,
 	unsigned long pfn, end_pfn = head_pfn + nr_pages;
 	unsigned int order = pgmap->vmemmap_shift;
 
+	/*
+	 * This is an open-coded prep_compound_page() whereby we avoid
+	 * walking pages twice by initializing them in the same go.
+	 */
 	__SetPageHead(head);
 	for (pfn = head_pfn + 1; pfn < end_pfn; pfn++) {
 		struct page *page = pfn_to_page(pfn);
@@ -1098,15 +1102,8 @@ static void __ref memmap_init_compound(struct page *head,
 		__init_zone_device_page(page, pfn, zone_idx, nid, pgmap);
 		prep_compound_tail(head, pfn - head_pfn);
 		set_page_count(page, 0);
-
-		/*
-		 * The first tail page stores important compound page info.
-		 * Call prep_compound_head() after the first tail page has
-		 * been initialized, to not have the data overwritten.
-		 */
-		if (pfn == head_pfn + 1)
-			prep_compound_head(head, order);
 	}
+	prep_compound_head(head, order);
 }
 
 void __ref memmap_init_zone_device(struct zone *zone,
-- 
2.50.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ