From patchwork Mon Jul 29 09:10:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13744629 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 483ADC3DA7F for ; Mon, 29 Jul 2024 09:10:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 119306B0093; Mon, 29 Jul 2024 05:10:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 07BDD6B0095; Mon, 29 Jul 2024 05:10:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC2CA6B0096; Mon, 29 Jul 2024 05:10:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B515D6B0093 for ; Mon, 29 Jul 2024 05:10:43 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 46DA4401D9 for ; Mon, 29 Jul 2024 09:10:43 +0000 (UTC) X-FDA: 82392219966.23.FA123A4 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf07.hostedemail.com (Postfix) with ESMTP id 278C840005 for ; Mon, 29 Jul 2024 09:10:40 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722244170; 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=4aP7LJidVwaEiyg2vEhcsAqZZw1DICdTCoxEateoTEY=; b=IOm68sWpRmPyfoOmgGECh6ghDrz13XtSl90F4FkKADWkwHj7Bux3cQOBN9Vgeug45B/EBD QNugLXl15KCcqBNbv+w1ZxJP2YlMkjNuv2W0Onfgbb/uTkWqPD484bnoy5Y+h1GQ9NgIe2 vbunvdk8JO4qCjuf0nV9M4yUKLnFKKA= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722244170; a=rsa-sha256; cv=none; b=L1ckIliN/IXbgASduJbWbLCU1zqadpIvD6GiVGUwGqAzGNBZHKhxyjuXRHa1MKOIhHYzS2 Vnk+eF/mP2mRegIVi2YRdX1/ZYw1knRXwXfrGipEhjBsukl5Okv2B5ZDCidD7KT0XIfqxp fpokHwCu8hHdFfvflhTnCxV69G02Kqg= 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 DE10A1F78C; Mon, 29 Jul 2024 09:10:39 +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 9D0651368A; Mon, 29 Jul 2024 09:10:38 +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 mLXnH45cp2Z4BgAAD6G6ig (envelope-from ); Mon, 29 Jul 2024 09:10:38 +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 , Matthew Wilcox , Vlastimil Babka , Michal Hocko , Oscar Salvador Subject: [PATCH v2 5/9] arch/powerpc: Teach book3s64 arch_get_unmapped_area{_topdown} to handle hugetlb mappings Date: Mon, 29 Jul 2024 11:10:14 +0200 Message-ID: <20240729091018.2152-6-osalvador@suse.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240729091018.2152-1-osalvador@suse.de> References: <20240729091018.2152-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: rspam06 X-Rspamd-Queue-Id: 278C840005 X-Stat-Signature: ceq9fzsi55srtsoemiprtn6psrhxmqfe X-Rspam-User: X-HE-Tag: 1722244240-554904 X-HE-Meta: U2FsdGVkX19vZGkHX1YcgOnqb/XFdcMpU++TP60H/zz8itgw1TuYE7VplwJx9xS4gZvoa0NJ7Cuq/fDs3Vl3538+sRWbqhPeR5Y+T4tmTgVVYENq8i00vnwPbZ4EazWINjUkmGSpNqaB0uuBXSajICjsU8orcC6+cR6Y0sllWlaI927u/u5RpGyooN6adsP0yRftB9Hr7mmFKss0bip1O/iO1R85wUCCgt0XFo7vRSLrWXeESzPye621Z3SNzLxUO9FCBAw7pgzli289deCVmaKWdS1e3DcGXavaKmDSvHK87A9/7VTTXu2silmVb8euDkDYAHAAzpUaPC0y8v+gPowjEkNNdCK7YXY9UfoZRWUllZq+IizWPYUWb7FIar0TOedZzOfyQH1mk5u6ABU97mvoSB6z2r4qkRm/H496ZkRP0gizLcaAG4WO1cuVuZWfwS/0+McAL7JnJ743W7B7jSEtiHOQfYfaUshy6D4Ad9A56XJZPKldg6/URsMMmCARfQa24BZ516VMFpFtIsH4Zwu8fwmulBNIytbiHKK/iIeoOQd9zSaksDTNe7flzeFXeo5+k5pkiOWNJzKXrAbxT6C+h85M8MTthBBoFhoekqWFJ79LJvW6GeTPdI96m+YGAQoLtF+gYbV8Kl841Cff9QBkgAoNBC4sI4cmJSCqRDTvfatH0axC33kBJtkxv7H8bBJVWE7mYpLnmCf3BWlh6vJDn08gFYOTpPl0ooIUzUHxMKRVttD28tIfCv16anE6BwSooQrA8snYNRUu0AmuQusu02x9/ZWi0At6lb9otsEjwq/Aqr4lhdOUuf/ZYYny5IokNQyUSEaysC6dIVn5keWmj4jGmmNroG5QCGUecPIadX25HGzBY4ifewmZ+arUnBRKN770KCV7ksFtf86y2wLAeWCvm9GNskfpxExD5aiu0uKjpiczAPCxz6GBRsrO04sjIHIlg0xLNnN5uP9 CswdcmzO L/zof10pc2hVjWyf1Hrhk+2pU0rVyIYKsy3jLQvTihHDeygN90Gho6sWdKdljaunLaO0KvIOy62wor25ozPZFvklwQKSWXrT0QsYpNQYBYc+uIN/P2EHOOrKofiMuhoSY+thlR6+NzgMjVsBcgmXxHFGXgSi9JEBe49EjAZpGIK4hZU0= 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. Reshuffle file_to_psize() definition so arch_get_unmapped_area{_topdown} can make use of it. Signed-off-by: Oscar Salvador --- arch/powerpc/mm/book3s64/slice.c | 39 ++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/mm/book3s64/slice.c b/arch/powerpc/mm/book3s64/slice.c index ef3ce37f1bb3..6914b8de627c 100644 --- a/arch/powerpc/mm/book3s64/slice.c +++ b/arch/powerpc/mm/book3s64/slice.c @@ -633,17 +633,36 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, } EXPORT_SYMBOL_GPL(slice_get_unmapped_area); +#ifdef CONFIG_HUGETLB_PAGE +static int file_to_psize(struct file *file) +{ + struct hstate *hstate = hstate_file(file); + return shift_to_mmu_psize(huge_page_shift(hstate)); +} +#else +static int file_to_psize(struct file *file) +{ + return 0; +} +#endif + unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { + unsigned int psize; + if (radix_enabled()) return generic_get_unmapped_area(filp, addr, len, pgoff, flags); - return slice_get_unmapped_area(addr, len, flags, - mm_ctx_user_psize(¤t->mm->context), 0); + if (filp && is_file_hugepages(filp)) + psize = file_to_psize(filp); + else + psize = mm_ctx_user_psize(¤t->mm->context); + + return slice_get_unmapped_area(addr, len, flags, psize, 0); } unsigned long arch_get_unmapped_area_topdown(struct file *filp, @@ -652,11 +671,17 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, const unsigned long pgoff, const unsigned long flags) { + unsigned int psize; + if (radix_enabled()) return generic_get_unmapped_area_topdown(filp, addr0, len, pgoff, flags); - return slice_get_unmapped_area(addr0, len, flags, - mm_ctx_user_psize(¤t->mm->context), 1); + if (filp && is_file_hugepages(filp)) + psize = file_to_psize(filp); + else + psize = mm_ctx_user_psize(¤t->mm->context); + + return slice_get_unmapped_area(addr0, len, flags, psize, 1); } unsigned int notrace get_slice_psize(struct mm_struct *mm, unsigned long addr) @@ -787,12 +812,6 @@ unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) return 1UL << mmu_psize_to_shift(get_slice_psize(vma->vm_mm, vma->vm_start)); } -static int file_to_psize(struct file *file) -{ - struct hstate *hstate = hstate_file(file); - return shift_to_mmu_psize(huge_page_shift(hstate)); -} - unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)