On Thu 18-01-24 05:35:04, Yang Shi wrote:
From: Yang Shi <yang@xxxxxxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxx/T/#mf211643a0427f8d6495b5b53f8132f453d60ab95
[2] https://lore.kernel.org/linux-mm/CAHbLzkqa1SCBA10yjWTtA2mKCsoK5+M1BthSDL8ROvUq2XxZMw@xxxxxxxxxxxxxx/T/#me93dff2ccbd9902c3e395e1c022fb454e48ecb1d
Fixes: efa7df3e3bb5 ("mm: align larger anonymous mappings on THP boundaries")
Reported-by: Jiri Slaby <jirislaby@xxxxxxxxxx>
Reported-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>
Tested-by: Jiri Slaby <jirislaby@xxxxxxxxxx>
Tested-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>
Cc: Rik van Riel <riel@xxxxxxxxxxx>
Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
Cc: Christopher Lameter <cl@xxxxxxxxx>
Signed-off-by: Yang Shi <yang@xxxxxxxxxxxxxxxxxxxxxx>
Acked-by: Michal Hocko <mhocko@xxxxxxxx>
Thanks!
---
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.
+ */