aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Shi <[email protected]>2024-01-18 10:05:05 -0800
committerAndrew Morton <[email protected]>2024-01-25 23:52:21 -0800
commit4ef9ad19e17676b9ef071309bc62020e2373705d (patch)
treec5fde4b74225e57287ea66ed25dbc88b6cc33b68
parent67695f18d55924b2013534ef3bdc363bc9e14605 (diff)
mm: huge_memory: don't force huge page alignment on 32 bit
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/[email protected]/ [2] https://lore.kernel.org/linux-mm/CAJuCfpHXLdQy1a2B6xN2d7quTYwg2OoZseYPZTRpU0eHHKD-sQ@mail.gmail.com/ Link: https://lkml.kernel.org/r/[email protected] Fixes: efa7df3e3bb5 ("mm: align larger anonymous mappings on THP boundaries") Signed-off-by: Yang Shi <[email protected]> Reported-by: Jiri Slaby <[email protected]> Reported-by: Suren Baghdasaryan <[email protected]> Tested-by: Jiri Slaby <[email protected]> Tested-by: Suren Baghdasaryan <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Christopher Lameter <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
-rw-r--r--mm/huge_memory.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 5f31e51f2235..172b85208276 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,9 @@ static unsigned long __thp_get_unmapped_area(struct file *filp,
loff_t off_align = round_up(off, size);
unsigned long len_pad, ret;
+ if (IS_ENABLED(CONFIG_32BIT) || in_compat_syscall())
+ return 0;
+
if (off_end <= off_align || (off_end - off_align) < size)
return 0;