From patchwork Fri Dec 17 10:28:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12696619 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2EE5C433EF for ; Fri, 17 Dec 2021 10:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hgQODQb0l5uThD1p19D4aWVwZWs+2LULoH6K2fuzhko=; b=jlwGrEoc9fik0I KDY4UiKHG2tZLz3W5bltki8J8PHBAwK9httAvK+YO/5zqSHW0c4kBoTE74QygtnhgqkY0An9+0Uyv c4XQcTvx+9Z7OU6VNQLdDdwXFin61m7EHlpN69/8PiWZ8Iz1m0zc4D4o2VknzDk4TshV6JgUHKmBC hJ01AdWCEQ0aZvTyB11k+G/fzy97DVczm8H2FcuIRpOzaPNje5i08EEaZ2Z5nyTRcfqkZHdGxv4Ed ZEXg2/cg39Rc/UUn4RNEAM3TUTSYqzApiOvLNMdnukYS60nYh+qp1P7SvZMv6VX+Rk4n3z3o6EAT4 gm93JEL3aIC0bKnVVb+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1myAY0-009WVf-La; Fri, 17 Dec 2021 10:33:13 +0000 Received: from mail-pr2fra01on0601.outbound.protection.outlook.com ([2a01:111:f400:7e18::601] helo=FRA01-PR2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1myATD-009UR8-QJ for linux-arm-kernel@lists.infradead.org; Fri, 17 Dec 2021 10:28:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oj4WaMHDie+k/jFA6cDTuNQceOOHHcPIsvVlATUAdVnzTLzvuyJb07Vq3+tdNHuP68lI4Dw+ni4jlq0A3u6nIaTMRumtlvxlTlYLk75+Cpz+8Cz9lqQaTSaAfOb0G9svklUaXKpwebpEbj8IAhPS0oOqneR2O2Z1g+6G6dlOZrJxzT2aKICVyK6OsNX1m05KSjfcpPB6uyTRd0ticof4QzILT0KgPTasPRnQ6XEOCo0Z+6GkYX26OD5RnXxdmQWi68kmkjGFkW5bBhZ2RGLJaTgiLW7NE1TAxCs/X58tXwYjTEvvzowFnh8Y85AP3LbU0jYyaBQgwg97eaTCkJUYMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FdCjHKP9l9OBJ5gDlZQo8deltmcwCmBmFWj0cSPtgCE=; b=WoEtlLTnChvKOx6ah3mb57cqAgqRSEMeli7CTHJcQfpv5txgf1deaCYDCqzKsUpvpk8aLUQwXtDGm41RKgYtO0n3LJKZ7RxWb/xElC+8NaNlGr3FvaEuZYqUnDwczmvKfWt6qZO/0XUo5Ab0i0oUZAe6eDLI7GzvwfLPlMjTg5vhocM7K8m5X4j8ri06sPilt45FsjBAzUGUJcTzn9hKgyCcyjjthPpJEHLepLuCZPiHiH14E09ei1pA953Kli3DRsK6G+uPPWbvBmqF4zPFclCICvPJOXEMP90xdg3xApl7mXWy8oD2yRe1GkIfT4+52ewJGP9UE+dn4CRZh8hi6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=csgroup.eu; dmarc=pass action=none header.from=csgroup.eu; dkim=pass header.d=csgroup.eu; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by MR2P264MB0146.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14; Fri, 17 Dec 2021 10:28:07 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::f0ef:856d:b0de:e85d]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::f0ef:856d:b0de:e85d%5]) with mapi id 15.20.4801.016; Fri, 17 Dec 2021 10:28:07 +0000 From: Christophe Leroy To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , "alex@ghiti.fr" CC: Christophe Leroy , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-mm@kvack.org" , "akpm@linux-foundation.org" , "catalin.marinas@arm.com" , "will@kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: [PATCH v6 11/14] powerpc/mm: Move get_unmapped_area functions to slice.c Thread-Topic: [PATCH v6 11/14] powerpc/mm: Move get_unmapped_area functions to slice.c Thread-Index: AQHX8zDI/14Dl8nBOk2wrm2wRtwUxQ== Date: Fri, 17 Dec 2021 10:28:07 +0000 Message-ID: References: In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=csgroup.eu; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0edcadce-fd1f-48ad-bad5-08d9c147eaf8 x-ms-traffictypediagnostic: MR2P264MB0146:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6108; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: q7B1mFfCyWA2Nt/7Y6C8T+wSmRm6dKy9c500w7/NgJO5zO8owcIBW+WKu3C62V6p5a4rD557pvyXbfzzdtQDSwLuRNmTPf/f5DD6VoNa+KsJOz7mnbtLkKtDrT32TclC/W5GRyKGK20EBd+iewmo5ZLBsVvwAt3T87MCehL6gfl0WPAmpZzC2AUeb//jA498BxL2/YZZybUbTuDhsrMN6uoRcAKRjS24byg+kGAfxt9Ch/PHZJiKs8ORWxpzReuSPVRbQCDx1PzsuBku3BvccjLNm+mPsppQD76hpLA2vjODwqn8sSdNPhEruB16Rv7pXwH+B0Vej09DVUPg9d+La7jSwgOtrX5numdj6aWsLd55z/0Bn6E+wqWZX0YmSAj2s2o/g3KHj8i7TU7o7rBIgAbdvp+anmUkvbGPH9VCeWniX+6BewELt//Pf1dCzM3OQpn/5CKxcyVI1VF3F/SHYUzFaNxzbP9svHmIBTEHlMCYvXgic/70rs2GCLjTogTpM4NFl0KKHt1I++CzUftvM/ux2wUfd0yHNFD8M6t6Y6AFxpvlUCML96yigUBG74sCm+aKx/QA/LgGQH9K2WHjxi3fFL9gKmM35mtP4AogrosHGjz2XcY5at/nJINg0dloSfLAreTXjw63VXaGHt7pnXsBKPWvWgfvXRXM7t9sWAEnzE2l0HviNPF+WBjeen/BMxMXGP3fvmle04cDrOnhjw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(4636009)(366004)(186003)(91956017)(71200400001)(86362001)(83380400001)(66476007)(66556008)(66446008)(2906002)(64756008)(38070700005)(7416002)(44832011)(6506007)(76116006)(4326008)(36756003)(26005)(2616005)(5660300002)(122000001)(8936002)(38100700002)(508600001)(6486002)(54906003)(110136005)(66946007)(8676002)(316002)(6512007); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?AwH+UwICfGArYmEv4UQYEHs?= =?iso-8859-1?q?gXiFTtJpQILGSuc1m5Je1aZroqoqJ7CBt6o1HoV3ArgcCm2h1/CK6gJDff17?= =?iso-8859-1?q?QGHaj7ypKej96NtcmUk5t0jNxaGyEbF3Ua9+7KcBM+raG8QACgFOykZUB/K5?= =?iso-8859-1?q?6NC3dQCG+UH71ti3XZ5YTBRkk3Wd6fwwNzHIc0NWZSsPVLVDQ3i1icONDhJ5?= =?iso-8859-1?q?8IIHk/2sWXL4qmBm5Y6QvTH7U3RA5Hu/2HeO04LscuwQdApxf4LzslYxQO4O?= =?iso-8859-1?q?2twzOk/wily4f4TH30IFkYH2NyBC54k9OZKeAWXT0Nq5BkZI8HYV4fmV4s4w?= =?iso-8859-1?q?i5DZnyz/FUAFKfGRjkxCr2hlXtP9VV9mP1Guplfn4lNheNIBR7aMcoZISKxK?= =?iso-8859-1?q?0/siih5bBpBHfGGCgoklUkwsdsiSlXesfyWbKKuHB1K2Hnt4hY1M1/KT/5WQ?= =?iso-8859-1?q?IfTGYgdNDxrXlUbx2CjP9wQk3FezZTNxvmkrqa83Aafn0Vogmg2ocHIBveia?= =?iso-8859-1?q?bmLV4DrSsQyaZ6zTVR4Z4XI3uJrUnI3Lgds+jNSJ313LzPJP9yY3IDNPFXjw?= =?iso-8859-1?q?zFsPJ0DPLwJD6AfsUQYmkrksmv4uZppEr+nzqQhTIOWiU50z/CezD9iZBRiF?= =?iso-8859-1?q?6s51q09vyntIHopsD6fNuxvabmSHlwCUz2aDniNZAX2qmeEodJMIt+XdMVzD?= =?iso-8859-1?q?IksN7l3GYXi58+LGeIvK0tykcaa/+evar9S74J29yQPZwIHOFTAMDSBL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mBC59/99CZ/00j1fj7JxgHwZl7N1a8D7d4AALpL2mf+ngOtML0HP?= =?iso-8859-1?q?8cffxrhHDCfqjYWC1Jon6LjPX5A4k+1QLyPoR8fSFHAK1jyhehiGGNVgKFY1?= =?iso-8859-1?q?dAzM=3D?= MIME-Version: 1.0 X-OriginatorOrg: csgroup.eu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 0edcadce-fd1f-48ad-bad5-08d9c147eaf8 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2021 10:28:07.7862 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9914def7-b676-4fda-8815-5d49fb3b45c8 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: cGDDHUEs/9mMLX5YWldlzB13M0N9E9LimFds2EioJsxNWcUiI+W/Toboiaj+HX2GT4jhFGqF5zv+d4NKhUgwoNV79MhOOaYf+/Q7PpFAChg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MR2P264MB0146 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211217_022811_933337_D016AF4A X-CRM114-Status: GOOD ( 13.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org hugetlb_get_unmapped_area() is now identical to the generic version if only RADIX is enabled, so move it to slice.c and let it fallback on the generic one when HASH MMU is not compiled in. Do the same with arch_get_unmapped_area() and arch_get_unmapped_area_topdown(). Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/book3s/64/mmu.h | 6 ---- arch/powerpc/include/asm/book3s/64/slice.h | 6 ++++ arch/powerpc/mm/book3s64/slice.c | 42 ++++++++++++++++++++++ arch/powerpc/mm/hugetlbpage.c | 21 ----------- arch/powerpc/mm/mmap.c | 36 ------------------- 5 files changed, 48 insertions(+), 63 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h index 7fee46e50377..310ca3597d58 100644 --- a/arch/powerpc/include/asm/book3s/64/mmu.h +++ b/arch/powerpc/include/asm/book3s/64/mmu.h @@ -4,12 +4,6 @@ #include -#ifdef CONFIG_HUGETLB_PAGE -#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA -#endif -#define HAVE_ARCH_UNMAPPED_AREA -#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN - #ifndef __ASSEMBLY__ /* * Page size definition diff --git a/arch/powerpc/include/asm/book3s/64/slice.h b/arch/powerpc/include/asm/book3s/64/slice.h index 5b0f7105bc8b..b8eb4ad271b9 100644 --- a/arch/powerpc/include/asm/book3s/64/slice.h +++ b/arch/powerpc/include/asm/book3s/64/slice.h @@ -4,6 +4,12 @@ #ifndef __ASSEMBLY__ +#ifdef CONFIG_HUGETLB_PAGE +#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA +#endif +#define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN + #define SLICE_LOW_SHIFT 28 #define SLICE_LOW_TOP (0x100000000ul) #define SLICE_NUM_LOW (SLICE_LOW_TOP >> SLICE_LOW_SHIFT) diff --git a/arch/powerpc/mm/book3s64/slice.c b/arch/powerpc/mm/book3s64/slice.c index e4382713746d..03681042b807 100644 --- a/arch/powerpc/mm/book3s64/slice.c +++ b/arch/powerpc/mm/book3s64/slice.c @@ -639,6 +639,32 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, } EXPORT_SYMBOL_GPL(slice_get_unmapped_area); +unsigned long arch_get_unmapped_area(struct file *filp, + unsigned long addr, + unsigned long len, + unsigned long pgoff, + unsigned long flags) +{ + 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); +} + +unsigned long arch_get_unmapped_area_topdown(struct file *filp, + const unsigned long addr0, + const unsigned long len, + const unsigned long pgoff, + const unsigned long flags) +{ + 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); +} + unsigned int notrace get_slice_psize(struct mm_struct *mm, unsigned long addr) { unsigned char *psizes; @@ -766,4 +792,20 @@ 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) +{ + if (radix_enabled()) + return generic_hugetlb_get_unmapped_area(file, addr, len, pgoff, flags); + + return slice_get_unmapped_area(addr, len, flags, file_to_psize(file), 1); +} #endif diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index bfd7f4af1e58..eb9de09e49a3 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -542,27 +542,6 @@ struct page *follow_huge_pd(struct vm_area_struct *vma, return page; } -#ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA -static inline 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) -{ - if (radix_enabled()) - return generic_hugetlb_get_unmapped_area(file, addr, len, - pgoff, flags); -#ifdef CONFIG_PPC_64S_HASH_MMU - return slice_get_unmapped_area(addr, len, flags, file_to_psize(file), 1); -#endif - BUG(); -} -#endif - bool __init arch_hugetlb_valid_size(unsigned long size) { int shift = __ffs(size); diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c index 46781d0103d1..5972d619d274 100644 --- a/arch/powerpc/mm/mmap.c +++ b/arch/powerpc/mm/mmap.c @@ -80,42 +80,6 @@ static inline unsigned long mmap_base(unsigned long rnd, return PAGE_ALIGN(DEFAULT_MAP_WINDOW - gap - rnd); } -#ifdef HAVE_ARCH_UNMAPPED_AREA -unsigned long arch_get_unmapped_area(struct file *filp, - unsigned long addr, - unsigned long len, - unsigned long pgoff, - unsigned long flags) -{ - if (radix_enabled()) - return generic_get_unmapped_area(filp, addr, len, pgoff, flags); - -#ifdef CONFIG_PPC_64S_HASH_MMU - return slice_get_unmapped_area(addr, len, flags, - mm_ctx_user_psize(¤t->mm->context), 0); -#else - BUG(); -#endif -} - -unsigned long arch_get_unmapped_area_topdown(struct file *filp, - const unsigned long addr0, - const unsigned long len, - const unsigned long pgoff, - const unsigned long flags) -{ - if (radix_enabled()) - return generic_get_unmapped_area_topdown(filp, addr0, len, pgoff, flags); - -#ifdef CONFIG_PPC_64S_HASH_MMU - return slice_get_unmapped_area(addr0, len, flags, - mm_ctx_user_psize(¤t->mm->context), 1); -#else - BUG(); -#endif -} -#endif /* HAVE_ARCH_UNMAPPED_AREA */ - /* * This function, called very early during the creation of a new * process VM image, sets up which VM layout function to use: