From patchwork Wed Dec 15 06:45:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12677573 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 66E99C433F5 for ; Wed, 15 Dec 2021 06:48:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D43D6B007B; Wed, 15 Dec 2021 01:45:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 06C4C6B0080; Wed, 15 Dec 2021 01:45:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA0506B007D; Wed, 15 Dec 2021 01:45:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay037.a.hostedemail.com [64.99.140.37]) by kanga.kvack.org (Postfix) with ESMTP id B06FD6B007B for ; Wed, 15 Dec 2021 01:45:28 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 39B8F22077 for ; Wed, 15 Dec 2021 06:45:18 +0000 (UTC) X-FDA: 78919091916.02.1789FF6 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120051.outbound.protection.outlook.com [40.107.12.51]) by imf24.hostedemail.com (Postfix) with ESMTP id 1573418000E for ; Wed, 15 Dec 2021 06:45:14 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qdh1OFQ/hFEVvIs7Pbz3bsXCk4DHECsZ9puS+lymWDgCMjhvem3rKHy9MAhbWsccM8HeONg9DXmbt7x0grYxYPBQkUGb2bZ9nhfAyJPCqChlukAmO8sPiB0J+7G0kd15nxiPu39oeZ2VCxdDTJs8Roh50009ukH8oNModDhcZzpLqWeQ6LGxOtc3mSXTBx3PGU+mGsiK+hRg6hJeAA/BcrQw3iDivG6Z9zHwzZiTjHOsRVRM1n5j2vBdiCDoX7wMLG7eGPVRIhcz6PPXp4CFWWIEr+woibBFr8N8D1zuYf3B2x1+rASa9USyvcI6Szl75WeSzGkmnVnoELeKPeIGkw== 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=cJDKGo+c42Z348GOCVWVuQ4zCHV33E04EN2Sm94CbyOiG6Oz83FHyj+0+5kkLYnytZwCx9OQU/kKEOSMB/slJ7I82Q1wNe2qoztDR2hqA78aJ+HX/sDSD5TM02a7bqYQporOfgtr4LP5GmQZKdcTtj+P8X7trzCl991Am0yID1WCyDRZnth9TObiLTPqiED+nH0TJmXsEgWrvywd1N269QEOT80JRAPzxlY3htZ8FPOffRjDNffnxZKdyY7Y+Tsppf+E/0AMaYAsTcOY3gOwwZvBkJ+ZPbYLiVbxyf7SiKjNEhhXdWZwZ2yjHTCkxsJhXumHvTOXxwWW3048jnNopw== 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 MRXP264MB0311.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:22::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14; Wed, 15 Dec 2021 06:45:13 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::fc67:d895:7965:663f]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::fc67:d895:7965:663f%2]) with mapi id 15.20.4778.018; Wed, 15 Dec 2021 06:45:13 +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 v5 09/11] powerpc/mm: Move get_unmapped_area functions to slice.c Thread-Topic: [PATCH v5 09/11] powerpc/mm: Move get_unmapped_area functions to slice.c Thread-Index: AQHX8X9PfJMd8arIBE+k0k9TTXOCMg== Date: Wed, 15 Dec 2021 06:45:13 +0000 Message-ID: <510046d11cc0d5da800d9bdbd9d4ac3bc0a605a8.1639550392.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: 7723a19b-edec-41ab-2773-08d9bf967277 x-ms-traffictypediagnostic: MRXP264MB0311: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: FE7A4ulTpvjfTq9lmcnyjtJzaGw76Yx6pZkfIav7678rRCyJlnmylhRwtHekoSak9JcnRhYwTNWE5+ElWnPnTOTcK73/qVAwMe4r2rOWkT9PecsO+Rty+azuzJy62U1x924yfojqzJ85y/XzvE+szGYLa0S4lTK7vNBxFeSI0y6vlLM7LgkusdifR7A1PRBpZZizri2kAV8wfgFy7qCZPj04e2RgaXDWBGJpqx03Xouz1jnxPXawuu1OuN/wpQqjR9zCh50kwmoeqhkjCtkJpzpOm/oMHYCcc7PqCf4TlfQzxdLcJWgBSXXR5OJtICag5Z5zsAZpripCyZE956tDr+KH0SF8ssi5YQtt2NLG6nKrZyeGMCAqBtAs4vulgX3XUxNpSoNzmR23dEK7ACmcS05PLj7uJtl+kF9amRWUB8lWtiChhNnh0OfMQUqlN9E0PyFZYaP6jqEeZfw48YMAvK4R2P9tV5rr0PZkZzHm4HNrDBL6+uBPr0bU8vhKh9KIGRQGrtFQNg9uL06qf2Q3MVSefL1URqG6XBBAwIiZxeTWO/vfkIBlSXhPLpaZaKtha2h43lHheQGg6xDHDx1wIE+9RERpuwy6ZlVyiOMXKiHSE800sudWEKhVTiMuy98m+TdSR5p+0CMyf9o9TwvyiMi/keE5saPHC90Sx0fR8uC3mdmHzssg/euwqFwXZ3F9WW5JqSyyxHNNF44hzdZpjw== 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)(54906003)(36756003)(86362001)(6512007)(83380400001)(2616005)(26005)(76116006)(8936002)(71200400001)(66556008)(66476007)(66946007)(64756008)(66446008)(38070700005)(186003)(110136005)(122000001)(38100700002)(316002)(8676002)(6506007)(7416002)(5660300002)(91956017)(508600001)(2906002)(6486002)(4326008)(44832011);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?yqTnmyqVRZbbRekppizezaN?= =?iso-8859-1?q?1e96udt7mWRpmR+bNpl8ZpG3lN/x17lJdpFDK4N6bKgV7pugiuHQ/P+/KbBm?= =?iso-8859-1?q?UhbA/wPPvvcgQiOwrAjAIvqlwPdrhCfe0WBsThBnrR8bViAPC/1vN/NBojI8?= =?iso-8859-1?q?fBmdFZrLKDHkyrm8i98kBtaGRgeVj7qQPLdbtoBPFbhXwihbeFHU9JQwLKc+?= =?iso-8859-1?q?iGwJNiav6DUOtjIGnNfj0XE98aceUd4r9QlTw1P5pvzE0CVo6uGwRaNuwY39?= =?iso-8859-1?q?v8492xh4gWE62cEtY1aRa5Uhg/Elp0HsQc1ba7alzeNvnde+9kL8bW8ITM+L?= =?iso-8859-1?q?kPp/AHwpfcM1inG/5Ae6nywBXmc56Saf/TmC9lyd/dJHP7AsKJJ8d9loMk15?= =?iso-8859-1?q?gYDBLegbbHlmiTEQ8kwDvCZUNlMmjm7g3+9vsZ794t5mVFWz99ULOggqWwWg?= =?iso-8859-1?q?12E6Y9F0LpQ/oWQ77sZCKWlikltiUVDtkWH5fPI9ex0MtqPy7iTvLFiAa9yE?= =?iso-8859-1?q?dscBzhdWpx8eLZZeYzcu7Cy3jp0HXz5+peSgZXem7H1Spls3LzfFNwMklRNa?= =?iso-8859-1?q?uwJioWWzFHkMWd56wGkboZq22EtTO420QJWu8CDFAV1B3E0APMqvLBzG5GHk?= =?iso-8859-1?q?mCxGeFOYKhyO5+hHCzs6bYghtIdkIUe1zd1l266iRV7uhwxiARbs2G/v2FN0?= =?iso-8859-1?q?P5JInI9rLTqRXFwqN0dMj5t6XL8GamvOvCJdW5s0tHbAPURhPEzF4OQoHflD?= =?iso-8859-1?q?iYI4LW4UhMECaczXrOcS+wqLKZZHv6UNbktwdvotCCl64aCPJa4IAmM3HD+P?= =?iso-8859-1?q?KHiwz3lxJWQH58X6FGRB7vtbZsdADkclynSHWRf5lu55gwTC8a6RNny07mgc?= =?iso-8859-1?q?11GUdEB++p8qKJN9iJq7hrfPS1syzOPOsPiwd0BbzCmshBLn/5I+ynuQ89Iw?= =?iso-8859-1?q?W8ltEchQS2iHKSkP8TLeTXc6jzzAcrkz9jCA4rJxHxHm0Z7MO7T/p2+igoH2?= =?iso-8859-1?q?uiKHvBRwnU6Gp9Q1mDVSCDHv6bSw/TPLBlbgqZ9aIXnUtUxC74Tnrw50WEKL?= =?iso-8859-1?q?g1qh+MhiEesVmicRr/iq4WYQaaZJhmjjKnlzbGo6wJUVLzc8F18pFIeaTrlH?= =?iso-8859-1?q?Mg8d1VYdRgrIYeh6he2aRUrYlu2oOoJFyG9sOOfGc5Us0SNQWxUGB4Zy1OpP?= =?iso-8859-1?q?DwZi/yb6UZ2AgTdwBYoXY5YdWfBetGOHo5OSHI7K+pqP7aTXCpxRbE7bXGY+?= =?iso-8859-1?q?hp6P2cGf2xL1tow535+9Kmw3wceAUkC7qGdnAJnuqvNlUYb0h5kxSnZtnVPn?= =?iso-8859-1?q?/MyfaOYjK3Q4JHZncYUM/xK/gs4iQ/MGeEqBWBlvRDyYmDDxVmffNS5f+VNC?= =?iso-8859-1?q?N8q9enwmeJg/iSQ4agPb+2AVVFBP2bKW4nzrkh19yva+F/ZjsKuMD6GTq8qf?= =?iso-8859-1?q?bxJRqoQO5SF9hn9opHjoaA8lBg5JKLmMMqAZkK0AN6+iimESKUixYBLHfASQ?= =?iso-8859-1?q?wgEWJBANvA6uAQQbPV9/LXFyZSVFvWbwojAkL6frczpgF6G6X4mpOxhLDY3I?= =?iso-8859-1?q?yhPAHwsj0sjnC1HG/9q/zzAEt4U9xTcix6LZ/TG9LYEVvfXLJFmQOWLglEX7?= =?iso-8859-1?q?UPCzgxxsgw88lYT8/83hrKGD0jrJ9CBJMM3aAlJCj3zOc52fL7QtmkBzVwqR?= =?iso-8859-1?q?eGQZpCdO9BZ/CqKPAPullTdLtINSTiKOzjLFaiNocUmScRsT2fzScpv5/YsD?= =?iso-8859-1?q?Ug70=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: 7723a19b-edec-41ab-2773-08d9bf967277 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Dec 2021 06:45:13.5350 (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: IVbILLp60vu25x7ojZvUNTt4Qmq6401YdRxKOxtZs2gKieBVtZovoM8siJX5oq111HPP+JMFMnEbkB+OdVni2F0dn+euYGppxpRTqzl2siM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRXP264MB0311 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1573418000E X-Stat-Signature: 5zzt8qbs691z4r98p1dsw5b1415myii9 Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.51 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-HE-Tag: 1639550714-309699 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 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: