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-next>] [day] [month] [year] [list]
Date: Sun, 24 Mar 2024 21:55:19 -0700
From: John Hubbard <jhubbard@...dia.com>
To: Andrew Morton <akpm@...ux-foundation.org>
CC: LKML <linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>, John Hubbard
	<jhubbard@...dia.com>, David Hildenbrand <david@...hat.com>, Matthew Wilcox
	<willy@...radead.org>, Mike Rapoport <rppt@...nel.org>, Theodore Ts'o
	<tytso@....edu>, Vishal Moola <vishal.moola@...il.com>, Peter Collingbourne
	<pcc@...gle.com>
Subject: [RFC] mm: page-flags.h: remove the bias against tail pages

commit 1d798ca3f1643 ("mm: make compound_head() robust") added
page->compound_head and the associated "unlikely" check for a tail page
in compound_head():

	if (unlikely(head & 1))
		return (struct page *) (head - 1);
	return page;

That worked nicely in 2015. However, in the 8.5 years since then, things
have changed: folios and huge pages are heavily used, with more uses
coming. See for example the various THP enhancements being proposed. And
hugetlbfs remains alive and well. And large folios are being plumbed
into everything.

With that in mind, remove the "unlikely" attribute when checking for a
tail page in compound_head(), and let normal CPU branch prediction do
what it may.

Cc: David Hildenbrand <david@...hat.com>
Cc: Matthew Wilcox <willy@...radead.org>
Cc: Mike Rapoport (IBM) <rppt@...nel.org>
Cc: Theodore Ts'o <tytso@....edu>
Cc: Vishal Moola (Oracle) <vishal.moola@...il.com>
Cc: Peter Collingbourne <pcc@...gle.com>
Signed-off-by: John Hubbard <jhubbard@...dia.com>
---

Hi,

Is this reasonable? I haven't gone out and gathered test data, because
the original patch to create this just assumed that compound pages were
uncommon, and so now it's time to stop making that assumption. I think
that's sufficient reasoning here to leave out the compiler hint, right?

thanks,
John Hubbard
NVIDIA

 include/linux/page-flags.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 652d77805e99..ae9509c6736c 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -246,7 +246,7 @@ static inline unsigned long _compound_head(const struct page *page)
 {
 	unsigned long head = READ_ONCE(page->compound_head);
 
-	if (unlikely(head & 1))
+	if (head & 1)
 		return head - 1;
 	return (unsigned long)page_fixed_fake_head(page);
 }
-- 
2.44.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ