Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 435CB26A0DD for ; Sat, 6 Jun 2026 03:50:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780717836; cv=none; b=u7giHYez1bql1veCkQTCRcRRs2kF/FbFiQ60GbYaJzdFQge9Svusn+9QN6ZbYTiL6Na8Ksr6oF7td53JX8/WA3wTF0T7vSC2wNyoAIEYRo2ks89LobA5LuZbOA5knfQXY2P5WHDoE5hvgNShFbhLTRNLzLzfMyRU142GI07MLVY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780717836; c=relaxed/simple; bh=230i8eNfhK1yVayGSLFkfXUuPhcRpJdAHhokhhgBtYg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RLNINFPMItxLV96R30HykHfLDCdSgL8ZG4/95/7fM8MKke2PZg8d4O5nPOBDoIFeeNuCqVAf1kg299fVvMmMxgj2VqfcmzClRMnkYubf7ws6o6ooPSm6GbOecXyjLGTqbYAEBD4ppBJAdJrRYTbNZj9JYkNfC0iMwm0Q19f+aPs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=s/SzQXgD; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=17k+KsaE; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=s/SzQXgD; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=17k+KsaE; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="s/SzQXgD"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="17k+KsaE"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="s/SzQXgD"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="17k+KsaE" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4CB3975BDB; Sat, 6 Jun 2026 03:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1780717833; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=/83iEfioFt974ERLFFdypfnzGP9tlZXs6SCesUBJTCM=; b=s/SzQXgDQeynUvzgMXrhzdTlSVabsBN0SMV1zziJI6JaapxIryL92kAWZJvrDnPNYenCEb gBOyFptk+QwIQtwD3YJwCTtnVhbBJKwpB4LQGqkZOC7hrS/HAfYKNEOB4YrDP1iBwIiTJR XGEWfrDxnt9J+3QIEMjvHV0a9zFWIEA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1780717833; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=/83iEfioFt974ERLFFdypfnzGP9tlZXs6SCesUBJTCM=; b=17k+KsaEbkzK8N3myYCe77qbAyQ4bWgEXjDlPC8B1eMhAUjhhgKwihl3FumpDYPLrFCDrm BDFNFfrANXwmezBw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="s/SzQXgD"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=17k+KsaE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1780717833; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=/83iEfioFt974ERLFFdypfnzGP9tlZXs6SCesUBJTCM=; b=s/SzQXgDQeynUvzgMXrhzdTlSVabsBN0SMV1zziJI6JaapxIryL92kAWZJvrDnPNYenCEb gBOyFptk+QwIQtwD3YJwCTtnVhbBJKwpB4LQGqkZOC7hrS/HAfYKNEOB4YrDP1iBwIiTJR XGEWfrDxnt9J+3QIEMjvHV0a9zFWIEA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1780717833; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=/83iEfioFt974ERLFFdypfnzGP9tlZXs6SCesUBJTCM=; b=17k+KsaEbkzK8N3myYCe77qbAyQ4bWgEXjDlPC8B1eMhAUjhhgKwihl3FumpDYPLrFCDrm BDFNFfrANXwmezBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 637E1779A7; Sat, 6 Jun 2026 03:50:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id zDDOFAiZI2poQwAAD6G6ig (envelope-from ); Sat, 06 Jun 2026 03:50:32 +0000 From: Oscar Salvador To: Andrew Morton Cc: Dave Hansen , Karsten Desler , Muchun Song , David Hildenbrand , Lorenzo Stoakes , Vlastimil Babka , "Liam R . Howlett" , Andreas Larsson , "David S . Miller" , Huacai Chen , Alexander Gordeev , Gerald Schaefer , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oscar Salvador Subject: [PATCH 0/8] Stop special-casing hugetlb mappings in get_unmapped_area Date: Sat, 6 Jun 2026 05:49:55 +0200 Message-ID: <20260606035003.529685-1-osalvador@suse.de> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Action: no action X-Rspamd-Queue-Id: 4CB3975BDB X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWELVE(0.00)[16]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org A regression was reported on AMD 15h Family for hugetlb mappings when 'align_va_addr' is set [1]. Historically, for hugetlb mappings we always ignored 'align_offset' in get_unmapped_area functions, but after commit 7bd3f1e1a9ae ("mm: make hugetlb mappings go through mm_get_unmapped_area_vmflags") that was no longer the case for x86. While we could fix that by work it around in x86 code, the truth is that the current functioning of hugetlb mappings with get_unmapped_area functions is a bit clumsy, and we can do better. This patchset aims at two things: 1) Fix regression reported in [1] 2) Stop special-casing hugetlb mappings in get_unmapped_area functions Fixing the regression involve doing what we do for THP mappings, which is encoding the extra padding we need for worst-case-alignment scenarios directly in the 'len' parameter and stop using 'align_mask' for that matter. And then, mask off the address we get from mm_get_unmapped_area_vmflags. After that, since the set up of 'align_mask' for hugetlb mappings disappears, this means we do not have to be hugetlb-aware down the road, and we can stop special casing it. The only thing to note though is that depending on the architecture, we sometimes use 'align_mask' to do coloring for pagecache and to avoid cache aliasing. This was ignored for hugetlb mappings, but after this patchset that is no longer the case, so this means that 'align_mask' will be added on top of the requested length of the mapping, making us to allocate a larger(ish) gap in the mapple tree, but that should be harmless as most of the times that is PAGE_SIZE, and whatever the offset is will be masked off in hugetlb_get_unmapped_area. [NOTE] Patch#1 is v2, since Dave Hansen was kind enough to provide some feedback in [2] while this was still on the works. [1] https://lore.kernel.org/linux-mm/20260527143643.GO31091@soohrt.org/ [2] https://lore.kernel.org/linux-mm/bae37c0c-f9e8-486b-a1a8-53c9dc0af8e0@intel.com/#t Oscar Salvador (8): mm,hugetlb: Encode extra padding for aligning directly in hugetlb_get_unmapped_area mm/mmap: Stop special-casing hugetlb in generic_get_unmapped_area path arch/x86: Stop special-casing hugetlb mappings in arch_get_unmapped_area arch/s390: Stop special-casing hugetlb mappings in arch_get_unmapped_area arch/loongarch: Stop special-casing hugetlb in arch_get_unmapped_area_common arch/sparc64: Stop special-casing hugetlb mappings in arch_get_unmapped_area arch/sparc32: Rip out hugetlb from sys_sparc_32.c mm,hugetlb: Kill huge_page_mask_align arch/loongarch/mm/mmap.c | 6 +----- arch/s390/mm/mmap.c | 9 ++------- arch/sparc/kernel/sys_sparc_32.c | 16 +++------------- arch/sparc/kernel/sys_sparc_64.c | 25 ++++++------------------- arch/x86/kernel/sys_x86_64.c | 15 ++++----------- fs/hugetlbfs/inode.c | 25 ++++++++++++++++++++++++- include/linux/hugetlb.h | 10 ---------- mm/mmap.c | 4 ---- 8 files changed, 40 insertions(+), 70 deletions(-) -- 2.35.3