From patchwork Fri Jan 21 08:42:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719507 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 9850AC433EF for ; Fri, 21 Jan 2022 08:42:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35AF96B009F; Fri, 21 Jan 2022 03:42:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 30B466B00A0; Fri, 21 Jan 2022 03:42:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AC976B00A1; Fri, 21 Jan 2022 03:42:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0022.hostedemail.com [216.40.44.22]) by kanga.kvack.org (Postfix) with ESMTP id 0A09C6B009F for ; Fri, 21 Jan 2022 03:42:43 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C156C181D75B4 for ; Fri, 21 Jan 2022 08:42:42 +0000 (UTC) X-FDA: 79053653364.28.0364A1B Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120057.outbound.protection.outlook.com [40.107.12.57]) by imf06.hostedemail.com (Postfix) with ESMTP id 3C50C18000E for ; Fri, 21 Jan 2022 08:42:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gpNTen02C54xig4Yw04LcbDg0a3G5H8CUmOalUT8BkQlga4uER3XSXO7ycLV3SrbNtHdg4TXYUdfxBLKYpqYRVxeiqVXTGZ33AMHM14auWV85FzuGqjIh0DODLsOpQXYyvq9bwafxl6dS9ZJD6WnPSi9kbP1JMbxo0L1Nl7aeOMnlq9pdWcoY6YtR9oe4wg4y/2PewPHypDoy4L39s03b5rWVJgGDCHqwqf7b3jdaW4sM9EvN1upOvC2E6xml5OT1pLa1Vfr8tH/OgIQqXdPeEZ/ZQVpQ8myZ0mPlgg5pL2CUkg5fTXFL6OiQ6knd557j9NWfZShXUv4jSGNELqkxg== 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=IGU4kvfJG4xkpoIdoZMTgYSWFbe4RKU94sIZkxd75As=; b=HPTIrA8LW0mNH3XbJy5iTPBI82ap2fI0diTw/uzwYMD78TxMWIIPKHiXRT894YUiXTCL5JP9lsRE6DU+QI3E9DvMu+d3P6kOWeHj9QVOQrUJtrXJwBK6rCTYQkQ8ByOPFdvlLP0UZ/8Dw1PNGE2WvLkIX4+F7M2vS3BTGSbvRnpd9SWxaJEMk+uHRuq+BsIXM6x6mwIRaav68fUee3sf3qfNb8ritC/3HWtGQFXRJa2gRCFnyANdo+s3g3+d1O6YDbXQJxMDL4rlAYmLBwS3KBWtmAZX2JAuxjg3mEfx5DByYgedYDIHvfniOKIBxfPR2HuzKyCQPo0RBI1kAHYV+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB0201.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Fri, 21 Jan 2022 08:42:40 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:40 +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 v7 11/14] powerpc/mm: Move get_unmapped_area functions to slice.c Thread-Topic: [PATCH v7 11/14] powerpc/mm: Move get_unmapped_area functions to slice.c Thread-Index: AQHYDqLZ1ugDhI6z+E+ZOoMcYyydgQ== Date: Fri, 21 Jan 2022 08:42:40 +0000 Message-ID: <1c083902be8813752bff297f2fb760bdc089339a.1642752946.git.christophe.leroy@csgroup.eu> References: In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 45710015-d061-4663-39fd-08d9dcb9fbc7 x-ms-traffictypediagnostic: PR0P264MB0201: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: pL5tnNjoW41rXCod5XamzHMQWNqpe4TcumrT/InYh/VSkn7vP8WtbDjXYy1NSxMaxFQ+DoIEvfgVo224vG9Dvh6DnM7PV+HKXH+qZmtWH+107Z9lVvsUHJmSMk5Ar+swsjIMImQP84qEtpDi2JqghVnClue9i8KMW/bSNRDXVXDX4+xEqNHFpAHB3vHpQZP8s56KemY1EmxmTP7QkpIfP5yXge5tH2ehEXjg7q1C0x1bI4kM5ONochS0Xy3TM6Tst+YdaiDWefGBOL38hxCuQxp07DpCfwWPZqoqasLnHH1/hpBXxYLO4TbSI5QvHnWv/Kr5MxKvLBgZDPsFCYJWkBaJ2WHdzIn7MfNZIKQL8PFiNSu/pYXtRjb+ASGbfu2MKylGokrl0Daw+A791hcCyyjSUgzzxXanVY5R+uWfCTpiDv/jyX6AxLRYgBRrlUmsV4bIUh41zSN/guqI+eDdIxSoBdv9y9Dts+r0Fscmv1zA3qAfFF+36uyXX6biQ4r7Whf5y2fbWDy3ovofJ9+yG34ktSuufIln2AC7RunEhU/Fi1wCo5a8Oep80xbt558rByGtX9K2moVpgTO7gIFs1njwAY4lQHv3Ax//m9AJeUXVSW++xCPuC9ECPG7ETaMOWSwWRH5uBNINSZaS7dbh0I1OHVE4Cpq5rTrfQqTS1wU+ZFt76NiBhV6lEl61GdJCdR6QZd0NWcJkVdgwQ4P1Iw== 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)(76116006)(91956017)(36756003)(66476007)(2906002)(5660300002)(66946007)(8676002)(6512007)(122000001)(71200400001)(8936002)(83380400001)(66446008)(64756008)(4326008)(66556008)(86362001)(26005)(508600001)(6486002)(54906003)(2616005)(44832011)(38070700005)(6506007)(186003)(38100700002)(7416002)(110136005)(316002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?4QpF/JTplOmNv2GF+OVg9B1?= =?iso-8859-1?q?cB1DASAY8fgKRlk9HnuNqqfaFpdkgycB0M8qEXq0A3Iqiz37/WQwWISk0Xuc?= =?iso-8859-1?q?Z+sQhzxsPrtsYTwZaLmw0uGgXzRlyNzMBL8Y9ydUnAC9h2kOTgtXfbgZ/Y14?= =?iso-8859-1?q?PvWIEePlUs7UBGJBHxMQPcBgmOpo1J9TV1bWUWr9nZRe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?q?IKy7uyu0PBte8yMfBtQiVz75pAdIiK9gjmMR8AacAUMItrRZeq1y+Csn54Ho?= =?iso-8859-1?q?GHaxEbR+beOCfvJ2+xGTpGvgJ3gC6GuZyADLPB6vXgpSseKfCdNoK8MBphGT?= =?iso-8859-1?q?c/ED6Vnqc+nfP1duUb2Yu91dV4xmqbJp5wg/tjBe1kwlsddrt/UHLnnFptna?= =?iso-8859-1?q?Bcu0UwDVZDoGf9qxwPUFQ9wTC6DUn8aPt7MnEIO0AnZUn4YFbhk9bFccha6E?= =?iso-8859-1?q?doAwr0kR/hGIvxqOJqZc1kVR8JOHH1xjDbe10YjH8KSmjp8SoZ4woVdZR+9n?= =?iso-8859-1?q?49btLfdL7kesZ3E0ouHqSpFPiPSI/IP740dPYZkKsPSlaCoyO0Q6l02WT/g4?= =?iso-8859-1?q?RyHZqROOGzadzcgLJZnFXMwfleIpvUgVlBCIqGccMDgSmZcMIg5TeFwxNh4p?= =?iso-8859-1?q?a5k5Q5SnMPLuqD4cZabcE7Bnd2kXwE6G9GOlvzBBJzB4+c6ITXx23IH8XmW3?= =?iso-8859-1?q?8515UNkA9By4ZOtqeuHUAoFyHkFt0rDxysYS2cbh/MJBKFGtPTqOsCWY2lQ+?= =?iso-8859-1?q?vACCONHwTruLTGh7dwX67E0cXK+z1R1+YRcznr0ABrIU7irfy7JKWgn/jMb3?= =?iso-8859-1?q?LnVBc3v4oT7ShdeaJnbA7VTAgYLsnZtdBv/mqzCYPJlB1UHDCXAYAch1ZzMi?= =?iso-8859-1?q?ZEpo=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: 45710015-d061-4663-39fd-08d9dcb9fbc7 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:40.0052 (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: ed0mTYjtt/MICJq700pSVfham4LHK6Yx9eHtBvKxaXvihyaqvXopkZ8WZgcv0CyySIkPruS0ntwaPSVfsnRLxsfcdjIXSXKV91zcQmKloIk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB0201 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 3C50C18000E X-Stat-Signature: 6gxza5cd4octk6cfqp911ubhusoe955g Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.57 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-HE-Tag: 1642754562-830474 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: 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 ba5b1becf518..db47524fa8ea 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: