From patchwork Mon Oct 7 07:50:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13824287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90D48CFB441 for ; Mon, 7 Oct 2024 07:50:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBF516B00F6; Mon, 7 Oct 2024 03:50:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E49956B00F7; Mon, 7 Oct 2024 03:50:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8A5F6B00FA; Mon, 7 Oct 2024 03:50:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 93A546B00F6 for ; Mon, 7 Oct 2024 03:50:56 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2A30641289 for ; Mon, 7 Oct 2024 07:50:56 +0000 (UTC) X-FDA: 82646034912.29.3342F6D Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf03.hostedemail.com (Postfix) with ESMTP id 11A8820005 for ; Mon, 7 Oct 2024 07:50:53 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf03.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728287345; a=rsa-sha256; cv=none; b=gyquhtHnoisbVk+jX+nSvsxcoTycDmwCPYvkV/XDE5sB/9HK8xqIF+rdlREa4kO+HSPQlx ufeLsZotVg4E2GIq6DQAyvMIzw1/1e4nrfidnIitpJXhOrOAJAcGMFMqHyEq6t6rYpmXTH 1Pqxd/uUACGmfKTQqVEleK3BlwWlKXg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf03.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728287345; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hWJGxSt8TXIQHuQog2Pqb6brVhcVjyPAR9HLfk56Q/4=; b=ZZqEV9LzfKxzqUdezBGtoOGXBDB3Ayk5E3dEtSj10f4kSicOf3sAGTOjonthzHNT9kNh8m RQJrYBsPXQS4mWZFQXPD+oyqyny/V0hDgtViP+bVRrumlUuWGSRtoJ3AsNB5OvppMhZIEl kilTcG64k0+ZnY8sBNMLp5dbz7GdQVs= 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-out1.suse.de (Postfix) with ESMTPS id A5FA721BF8; Mon, 7 Oct 2024 07:50:52 +0000 (UTC) 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 065B113A55; Mon, 7 Oct 2024 07:50:51 +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 CN9COtuSA2d6cQAAD6G6ig (envelope-from ); Mon, 07 Oct 2024 07:50:51 +0000 From: Oscar Salvador To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Peter Xu , Muchun Song , David Hildenbrand , Donet Tom , Vlastimil Babka , Michal Hocko , Lorenzo Stoakes , Oscar Salvador Subject: [PATCH v4 2/9] arch/s390: Teach arch_get_unmapped_area{_topdown} to handle hugetlb mappings Date: Mon, 7 Oct 2024 09:50:30 +0200 Message-ID: <20241007075037.267650-3-osalvador@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241007075037.267650-1-osalvador@suse.de> References: <20241007075037.267650-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 11A8820005 X-Stat-Signature: 981mk46qx85k7ek5p4kdu9ixtonpffkq X-Rspam-User: X-HE-Tag: 1728287453-57496 X-HE-Meta: U2FsdGVkX1/Ya50NuhmGvWlVHfSG5ofPmhR0EW2yTpqOLwYSVm/miQjqJx7cSlYvdowdUsqZRJ+f1Xokmz/M2ZFdIiDccWjQeVShrdak/W+ufZr7Y/SXIKLQOTSSqHwfjvX7suM0PgvDJ1yLDdDzkQj1OOY0JtU6NLojJfDpJrierSd71n5W6sq/ErhrygwVaAwX4sfBl5Jfg7+sU5DgJKNj3VyDlXsXFbXTMDfGnaE2y31neNmU88o4MyyAv98w409tT9odRTxeXiHh3LNSgxrePthcZs7xpsz1Lcb2+VvV7DszxDF5IM5AaI7DqNEpBj06KrjuXXNbFSEuBgd2ddySM8kWMQL9lsAmiHT+t7XDzosNxUG+0DhziORL6GLZLMEkKyHoeEcM+YgGg8p73kb8HsOPKqaYU0+6OSrF+5sDKqYo2wR3QWYSs7Ft6kENK8UrcpJSfTnHRF/U8ubXFlimCz+Xl/QarecgTBOCQcCiFqcRp8Q6DMMpCw2hw5qieEXNf+3ZyX7+tEGwdvkxIwqu/+NFihDnsi1bFrYr2AL4Rt4ajP3QQKbEl1PMdGul5CZDQEWrjCPR7ZM/clOVz5OZzwdjgXwxTwY8qGBI89K1aLlDGkiDx2p0vG02eUNoR6kS2VyIFCAFOLkdN8p/8voCSfX3hYFwFNXaPlrJSCZdp4RkaCAl4Cwi7SDtBBLNk/s6lU/O0mzTRWXSSQofnIJc0smmlNlGWcUGq/T3e7gYIEB2JjGDQmYhH5y6Ifvwo9xrY6rFzHqarkBM7tBfAVqkWgZn5bMElt4wE2+zn7fzpH+D6aUIbguDz7tueWL9G62Qf16o5rMzgOoZYg7GfFBsR77TQ/ug9DCEYcMBtcRgty7Vcy8IymTHAQTJ2oaDcgGkAIvhuIBxsszX9mpDbMEc45n1Wopu6jikeHZcFd1bzVCi15QzO9G+wxN2SiLxYY8/Ac86fwL/aIpzhWY cgDFaMIO 8RkwypU8QVDfXuSxou5/RY8KGCae/Q7IklMUIHS8yvFSNry+F8YtX8cjWBUCeba5pd9UPDOrbDUVGQfP0kf17ID1SDUEi0j7LgKxjDI5QeGMFMhyFIirgjZ0UX1B1K06txw1owjlAXaLDPv0nB3xQwwel8VAM5qidybDpxelIm6fmLvg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We want to stop special casing hugetlb mappings and make them go through generic channels, so teach arch_get_unmapped_area{_topdown} to handle those. s390 specific hugetlb function does not set info.align_offset, so do the same here for compatibility. Signed-off-by: Oscar Salvador --- arch/s390/mm/mmap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index 96efa061ce01..33f3504be90b 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -17,6 +17,7 @@ #include #include #include +#include #include static unsigned long stack_maxrandom_size(void) @@ -73,6 +74,8 @@ static inline unsigned long mmap_base(unsigned long rnd, static int get_align_mask(struct file *filp, unsigned long flags) { + if (filp && is_file_hugepages(filp)) + return huge_page_mask_align(filp); if (!(current->flags & PF_RANDOMIZE)) return 0; if (filp || (flags & MAP_SHARED)) @@ -106,7 +109,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, info.low_limit = mm->mmap_base; info.high_limit = TASK_SIZE; info.align_mask = get_align_mask(filp, flags); - info.align_offset = pgoff << PAGE_SHIFT; + if (!(filp && is_file_hugepages(filp))) + info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); if (offset_in_page(addr)) return addr; @@ -144,7 +148,8 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned long ad info.low_limit = PAGE_SIZE; info.high_limit = mm->mmap_base; info.align_mask = get_align_mask(filp, flags); - info.align_offset = pgoff << PAGE_SHIFT; + if (!(filp && is_file_hugepages(filp))) + info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); /*