From patchwork Thu Jul 18 10:58:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13736390 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 E5535C3DA49 for ; Thu, 18 Jul 2024 10:59:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 201246B0096; Thu, 18 Jul 2024 06:59:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B0B16B0098; Thu, 18 Jul 2024 06:59:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02A696B0099; Thu, 18 Jul 2024 06:59:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D227E6B0096 for ; Thu, 18 Jul 2024 06:59:22 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9298D1A1AE4 for ; Thu, 18 Jul 2024 10:59:22 +0000 (UTC) X-FDA: 82352576964.15.D1C8C96 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf19.hostedemail.com (Postfix) with ESMTP id 5F74E1A0025 for ; Thu, 18 Jul 2024 10:59:20 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=d+qT7m4R; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=RfoQg8un; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=d+qT7m4R; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=RfoQg8un; spf=pass (imf19.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=1721300340; 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:dkim-signature; bh=4aP7LJidVwaEiyg2vEhcsAqZZw1DICdTCoxEateoTEY=; b=hZh5aoiceQyAWYDBybNaHpgAQxfK9WhW2gk+fDxbQqCLQHGOGCXlwU1C2xH9nYqaNnW1Gv 9AryP5N0yy2pRRmgHHqpqLApvJ75i38ROQ5b5gR1ZYqTfYXBWgs+kDQBb29ULaatqeVgBB IZrz6OB5PcNsP2i9fldQ4pS/fhuz2eY= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=d+qT7m4R; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=RfoQg8un; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=d+qT7m4R; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=RfoQg8un; spf=pass (imf19.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=1721300340; a=rsa-sha256; cv=none; b=pkWG/kL7PPA3sfdeulNyzrj2kiw4dLh7hHPhvLI2EDAM+0gqSkIwzEx+BEHdHDZZmcdX/Y qEsS300LPOLDYpuSwNIQ5oIsrO0rYhldC+dCKpeGoZMYnyQ9sLvVpb6wnctrnYVQ13LvMU /duMKksxKgAd9Jmv9P+zn9rFCJYC4bo= 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 11B8E1FBB9; Thu, 18 Jul 2024 10:59:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721300359; 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: in-reply-to:in-reply-to:references:references; bh=4aP7LJidVwaEiyg2vEhcsAqZZw1DICdTCoxEateoTEY=; b=d+qT7m4RpuC6EVZ9Nq36ak8RH1R06p1MZpQhX6/5OnJrFM+TMzDEbOlYJOnnMf53JQ18gA 6UO8ijGQ+RQrVs6wlAdXj/I+G+awA3+FT+wBSvbQpEUb1Hiao8qP1zqiFXlZMlXyc5NW6K Pqi+YricO9OYQ9/hVMHCN1yOZemWs8s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721300359; 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: in-reply-to:in-reply-to:references:references; bh=4aP7LJidVwaEiyg2vEhcsAqZZw1DICdTCoxEateoTEY=; b=RfoQg8un5zhYCA7bHCAPVoc/BT3n427oAmpgk3WAUkd672G0mnyM+WWXJUO/6+8Ksk08Cc f4O3wWrTNuyEuUAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721300359; 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: in-reply-to:in-reply-to:references:references; bh=4aP7LJidVwaEiyg2vEhcsAqZZw1DICdTCoxEateoTEY=; b=d+qT7m4RpuC6EVZ9Nq36ak8RH1R06p1MZpQhX6/5OnJrFM+TMzDEbOlYJOnnMf53JQ18gA 6UO8ijGQ+RQrVs6wlAdXj/I+G+awA3+FT+wBSvbQpEUb1Hiao8qP1zqiFXlZMlXyc5NW6K Pqi+YricO9OYQ9/hVMHCN1yOZemWs8s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721300359; 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: in-reply-to:in-reply-to:references:references; bh=4aP7LJidVwaEiyg2vEhcsAqZZw1DICdTCoxEateoTEY=; b=RfoQg8un5zhYCA7bHCAPVoc/BT3n427oAmpgk3WAUkd672G0mnyM+WWXJUO/6+8Ksk08Cc f4O3wWrTNuyEuUAg== 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 07B60136F7; Thu, 18 Jul 2024 10:59:17 +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 kCFWOYX1mGbnVAAAD6G6ig (envelope-from ); Thu, 18 Jul 2024 10:59:17 +0000 From: Oscar Salvador To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Peter Xu , Muchun Song , Michal Hocko , Donet Tom , "Kirill A . Shutemov" , Matthew Wilcox , Vlastimil Babka , Oscar Salvador Subject: [PATCH 5/9] arch/powerpc: Teach book3s64 arch_get_unmapped_area{_topdown} to handle hugetlb mappings Date: Thu, 18 Jul 2024 12:58:59 +0200 Message-ID: <20240718105903.19617-6-osalvador@suse.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240718105903.19617-1-osalvador@suse.de> References: <20240718105903.19617-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspamd-Action: no action X-Spamd-Bar: / X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 5F74E1A0025 X-Stat-Signature: p7n9xm9wmep6nmhrzgyqixr3c8ogwkm8 X-HE-Tag: 1721300360-775611 X-HE-Meta: U2FsdGVkX1948kh6V8lrhtqo9vKoioRxxGc2XwKlO5DvX7IADfHa82ZyFMcBgMFpVzNxEvwoSNqoGQz5aGSWXkazoh47vcv2KpQf+U0SbEhspGt7hJeYzvFTL01QRB+L38eP9MFQCpfjSRbGUYT4Q0FYLUOCocbmNTA3r1NMvExQRS+SPzocGVPZDpslQNZjO+VRfEXOKqqQ1bIzVm78iqJ66/sf7G/eZo32vwJzGGyKY0RZDBMWil8+NC2ops1wJVA6EzzvFNLTINb2PQ2oyxBGkMjosHSq3GqEl9OrjAu61sGXpa78lNM9e+aSF2ZEpg1DJNEb+S5oc784Zu/irADtK05jm/QyGmd5aNOA6uzsAsa90jSCtmUV2/EvHhvEGpfa9zUi8dtsfJrMTd8Nwd3teztJ19fQh8nOoT0HwRE9yxhRkVvYM9wsbUzP/qk9VSxACQf85Erfijo9fUaBiRAPxHmxDHLHrk0AQdVoNt+01VblIDppiVFYkR8iX2z5qrYH7vLsAXThvX1pBzOyFO4P+LRPrcaYQuyku2sqssWoAG4J9+qbNM034GxMAwLYDQH6JiSqaKKXkauRzY89/Py92RT9cZgIvVEC7Gmr9ygu5JwfqvdODIt04Ylvmksy+nYQHt08zmuJ8CARs713ZA7DPNiwi4FEkrE672QXbK2PpdMAyErr+xGakKz+KFqYS3muh/bn8WzQ36eKWIr/+LPARy87uD9/ox4lP4so2UcXDS9Y4aKX4BLllG8ZLHPqXK3j79khC8U7/Ci52kcYWhr9nbZE693vvvikn5e7O5Kun2vDXhmzVSYE9vXnFKyspmo9BrvbyMz+UpuFe/hJs87UbIniB80LVt/jsrsdcV1LKoy1lUAJKFibYXLmTGGdTri9nh8kXyNcP5onagaEvpkSMWvm6urh4CcBycFbNHECwIDSkfG/KS3PuA9KBxebOzw+kHyGOsXFuKHcBNS 3xOy1H3K cXF+aUWHIMOX0pDWMqHd3+sOd+QvAYIgQBtpWdMJ3SeeSBSdeC9BztTMUjUbzFNL7qQLe4UKBUHYOKuSmuTAqwUJ5ipjh/ClgxvAb00SSRcbLGdKSUadaiYin5vPgTY3QYlxXGEVha7hipVIwziWtGm7liT4kDPwDZU1Rp5VKw9XXbutIPiTsyBeAUTa4wApHN8KukrVECODKX7AwlHfkI/SLEqqZgPjecNk6b+H/iCvfDs2nIMKdNIVFhVkfx3VBrJJfEJTzHq9qVL5CTHPaX5V7vkf085DWIC/j 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)