mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oscar Salvador <osalvador@suse.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
	Karsten Desler <kdesler@soohrt.org>,
	Muchun Song <muchun.song@linux.dev>,
	David Hildenbrand <david@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	"Liam R . Howlett" <liam@infradead.org>,
	Andreas Larsson <andreas@gaisler.com>,
	"David S . Miller" <davem@davemloft.net>,
	Huacai Chen <chenhuacai@kernel.org>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Oscar Salvador <osalvador@suse.de>
Subject: [PATCH 3/8] arch/x86: Stop special-casing hugetlb mappings in arch_get_unmapped_area
Date: Sat,  6 Jun 2026 05:49:58 +0200	[thread overview]
Message-ID: <20260606035003.529685-4-osalvador@suse.de> (raw)
In-Reply-To: <20260606035003.529685-1-osalvador@suse.de>

arch_get_unmapped_area* sets info.align_mask to make room for extra alignment,
so that is added on top of the length we request in unmapped_area{_topdown}.
hugetlb_get_unmapped_area() already adds this extra padding in the 'len'
parameter, and it also masks off the address it gets to properly align it to
the huge_page_size we are using.

So, stop special-casing hugetlb in arch_get_unmapped_area* functions.

Also, there is no need to worry about align_offset and start_gap because
the former will be masked off back in hugetlb_get_unmapped_area() and
the latter only applies to mappings created via vm_mmap_shadow_stack() which
do not involve hugetlb.

Signed-off-by: Oscar Salvador <osalvador@suse.de>
---
 arch/x86/kernel/sys_x86_64.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index 776ae6fa7f2d..1cf2dafd223b 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -18,7 +18,6 @@
 #include <linux/random.h>
 #include <linux/uaccess.h>
 #include <linux/elf.h>
-#include <linux/hugetlb.h>
 
 #include <asm/elf.h>
 #include <asm/ia32.h>
@@ -28,8 +27,6 @@
  */
 static unsigned long get_align_mask(struct file *filp)
 {
-	if (filp && is_file_hugepages(filp))
-		return huge_page_mask_align(filp);
 	/* handle 32- and 64-bit case with a single conditional */
 	if (va_align.flags < 0 || !(va_align.flags & (2 - mmap_is_ia32())))
 		return 0;
@@ -151,10 +148,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len,
 	info.length = len;
 	info.low_limit = begin;
 	info.high_limit = end;
-	if (!(filp && is_file_hugepages(filp))) {
-		info.align_offset = pgoff << PAGE_SHIFT;
-		info.start_gap = stack_guard_placement(vm_flags);
-	}
+	info.align_offset = pgoff << PAGE_SHIFT;
+	info.start_gap = stack_guard_placement(vm_flags);
 	if (filp) {
 		info.align_mask = get_align_mask(filp);
 		info.align_offset += get_align_bits();
@@ -205,10 +200,8 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr0,
 		info.low_limit = PAGE_SIZE;
 
 	info.high_limit = get_mmap_base(0);
-	if (!(filp && is_file_hugepages(filp))) {
-		info.start_gap = stack_guard_placement(vm_flags);
-		info.align_offset = pgoff << PAGE_SHIFT;
-	}
+	info.start_gap = stack_guard_placement(vm_flags);
+	info.align_offset = pgoff << PAGE_SHIFT;
 
 	/*
 	 * If hint address is above DEFAULT_MAP_WINDOW, look for unmapped area
-- 
2.35.3


  parent reply	other threads:[~2026-06-06  3:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-06  3:49 [PATCH 0/8] Stop special-casing hugetlb mappings in get_unmapped_area Oscar Salvador
2026-06-06  3:49 ` [PATCH 1/8] mm,hugetlb: Encode extra padding for aligning directly in hugetlb_get_unmapped_area Oscar Salvador
2026-06-06  3:49 ` [PATCH 2/8] mm/mmap: Stop special-casing hugetlb in generic_get_unmapped_area path Oscar Salvador
2026-06-06  3:49 ` Oscar Salvador [this message]
2026-06-06  3:49 ` [PATCH 4/8] arch/s390: Stop special-casing hugetlb mappings in arch_get_unmapped_area Oscar Salvador
2026-06-30 17:10   ` Gerald Schaefer
2026-06-06  3:50 ` [PATCH 5/8] arch/loongarch: Stop special-casing hugetlb in arch_get_unmapped_area_common Oscar Salvador
2026-06-06  3:50 ` [PATCH 6/8] arch/sparc64: Stop special-casing hugetlb mappings in arch_get_unmapped_area Oscar Salvador
2026-06-06  3:50 ` [PATCH 7/8] arch/sparc32: Rip out hugetlb from sys_sparc_32.c Oscar Salvador
2026-06-06  3:50 ` [PATCH 8/8] mm,hugetlb: Kill huge_page_mask_align Oscar Salvador
2026-06-28  6:55 ` [PATCH 0/8] Stop special-casing hugetlb mappings in get_unmapped_area Andrew Morton
2026-06-29 10:21   ` Lorenzo Stoakes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260606035003.529685-4-osalvador@suse.de \
    --to=osalvador@suse.de \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreas@gaisler.com \
    --cc=chenhuacai@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=david@kernel.org \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=kdesler@soohrt.org \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=vbabka@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®