linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: huge_memory: don't force huge page alignment on 32 bit
@ 2024-01-18 13:35 Yang Shi
  2024-01-18 18:05 ` Yang Shi
                   ` (5 more replies)
  0 siblings, 6 replies; 22+ messages in thread
From: Yang Shi @ 2024-01-18 13:35 UTC (permalink / raw)
  To: jirislaby, surenb, riel, willy, cl, akpm; +Cc: yang, linux-mm, linux-kernel

From: Yang Shi <yang@os.amperecomputing.com>

The commit efa7df3e3bb5 ("mm: align larger anonymous mappings on THP
boundaries") caused two issues [1] [2] reported on 32 bit system or compat
userspace.

It doesn't make too much sense to force huge page alignment on 32 bit
system due to the constrained virtual address space.

[1] https://lore.kernel.org/linux-mm/CAHbLzkqa1SCBA10yjWTtA2mKCsoK5+M1BthSDL8ROvUq2XxZMw@mail.gmail.com/T/#mf211643a0427f8d6495b5b53f8132f453d60ab95
[2] https://lore.kernel.org/linux-mm/CAHbLzkqa1SCBA10yjWTtA2mKCsoK5+M1BthSDL8ROvUq2XxZMw@mail.gmail.com/T/#me93dff2ccbd9902c3e395e1c022fb454e48ecb1d

Fixes: efa7df3e3bb5 ("mm: align larger anonymous mappings on THP boundaries")
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Reported-by: Suren Baghdasaryan <surenb@google.com>
Tested-by: Jiri Slaby <jirislaby@kernel.org>
Tested-by: Suren Baghdasaryan <surenb@google.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Christopher Lameter <cl@linux.com>
Signed-off-by: Yang Shi <yang@os.amperecomputing.com>
---
 mm/huge_memory.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 94ef5c02b459..e9fbaccbe0c0 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -37,6 +37,7 @@
 #include <linux/page_owner.h>
 #include <linux/sched/sysctl.h>
 #include <linux/memory-tiers.h>
+#include <linux/compat.h>
 
 #include <asm/tlb.h>
 #include <asm/pgalloc.h>
@@ -811,6 +812,14 @@ static unsigned long __thp_get_unmapped_area(struct file *filp,
 	loff_t off_align = round_up(off, size);
 	unsigned long len_pad, ret;
 
+	/*
+	 * It doesn't make too much sense to froce huge page alignment on
+	 * 32 bit system or compat userspace due to the contrained virtual
+	 * address space and address entropy.
+	 */
+	if (IS_ENABLED(CONFIG_32BIT) || in_compat_syscall())
+		return 0;
+
 	if (off_end <= off_align || (off_end - off_align) < size)
 		return 0;
 
-- 
2.41.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-07-12 15:31 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-18 13:35 [PATCH] mm: huge_memory: don't force huge page alignment on 32 bit Yang Shi
2024-01-18 18:05 ` Yang Shi
2024-01-19  0:16   ` Matthew Wilcox
2024-01-18 20:14 ` Matthew Wilcox
2024-01-18 20:39   ` Yang Shi
2024-01-19 17:16 ` Rik van Riel
2024-01-25  8:53 ` Michal Hocko
2024-01-26  9:36   ` Jiri Slaby
2024-01-26  9:41     ` Jiri Slaby
2024-01-26 10:51       ` Michal Hocko
2024-02-03  9:24 ` Thorsten Leemhuis
2024-02-05 17:07   ` Yang Shi
2024-02-05 17:53     ` Linux regression tracking (Thorsten Leemhuis)
2024-02-12 13:45       ` Thorsten Leemhuis
2024-02-18  9:26         ` Greg KH
2024-07-11 20:10 ` Yves-Alexis Perez
2024-07-11 20:47   ` Yang Shi
2024-07-11 20:50     ` Matthew Wilcox
2024-07-11 20:53       ` Yang Shi
2024-07-12 14:41         ` Yves-Alexis Perez
2024-07-12 15:31           ` Yang Shi
2024-07-11 20:52   ` Ben Hutchings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox