From patchwork Wed Dec 8 17:18:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12664919 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 D3DE4C433EF for ; Wed, 8 Dec 2021 17:22:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41B606B007E; Wed, 8 Dec 2021 12:18:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C7C26B0080; Wed, 8 Dec 2021 12:18:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21B6D6B0081; Wed, 8 Dec 2021 12:18:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0150.hostedemail.com [216.40.44.150]) by kanga.kvack.org (Postfix) with ESMTP id 0E83E6B007E for ; Wed, 8 Dec 2021 12:18:36 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C9400180AA98F for ; Wed, 8 Dec 2021 17:18:25 +0000 (UTC) X-FDA: 78895285770.12.A7F61D9 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120085.outbound.protection.outlook.com [40.107.12.85]) by imf01.hostedemail.com (Postfix) with ESMTP id 2009B40009 for ; Wed, 8 Dec 2021 17:18:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bagqc6I5u3rSF3lMqjMqlVWhOntWMPeXKyfsgWuTDSRbKB8IDZBOpPDo9NpEMF66MtAh5EIMlHV2zPfN4asYTa7GufOhG1D0MnglJp3OljGvIfSBGIwjaWMNZsVO2kfe7+jBYVEwaPRpMTPam/jZexViN81jwJvoB4uPAHe0Bt0uhRujSAm7dXDSKu1dWXcYxc0Zdv61myzYYneCI7GILbw9RdmAGqEZVzWvyqwCfwVYdG5NiFL4ICzouWzQO262ccyE3GPblSqfUDOj/uAgVsjQXKUPFvZo4tY2HKUB4Leg34FdZ9K5pMVGVXEmk53yI3/cX8cVoZVJlbHuXzg5cg== 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=HLKYz883fMmLSc4NFf5M8qRBeEmMYcuDc7mWmHJQE5mdNoFvOcLdSPT8djd1AWhm7rGhHMWa84WpBSwtj+xHZcXjCu7Npwv4f7JvyIuXQtYvHQnb38LGX7Qomi1SSJ0Vqh8/LjZJg81eJ/X/ftpxCZTfx/aYPh87UaOaVaMrQBL55vBzpw/XxX60/5c7N42dMUNW6WyKfgROIDTiU3aUsp82p5Tp4ysJIP6uTowqgEAhqhPjJmHgFrRVQdUWAxYUbiq7GXClBSVUxBEM2z9X/RvMdgxtSD79iga5SmMQJD7AI9yfqOzk9njXznJ7yaWwQPmsmMsezIGNIwrC3H3AJA== 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 MRXP264MB0823.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:16::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11; Wed, 8 Dec 2021 17:18:22 +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.4755.022; Wed, 8 Dec 2021 17:18:22 +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" Subject: [PATCH v4 08/10] powerpc/mm: Move get_unmapped_area functions to slice.c Thread-Topic: [PATCH v4 08/10] powerpc/mm: Move get_unmapped_area functions to slice.c Thread-Index: AQHX7FeZb+/3TX1n7EW9KYtAkSYZWw== Date: Wed, 8 Dec 2021 17:18:21 +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: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b3ae390d-0861-45db-02d3-08d9ba6ebc7c x-ms-traffictypediagnostic: MRXP264MB0823: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: ENUghyS1DmrofjT/CTeoKkLPf8F+whxyMAUn3lGq5qqIyeZgSyT6RmWRlYoVca4jAOEJc0wr/kqjv3ehpCYLPfbiCID8eldnpJpWsvbwtQsRhmkwVKyV6LH+iV+Hgvp87t5mGCR2NTtMbHvHDQ+cLMf/+fhoeq9LjO7lt5Q5XBTROy/QEMz9wynBuef9ZF9le2PSaZ2l6b3y+PLCUrkCZEOUkXz8gTas1R1YFinoDYk4TXcbR2nKUR7pY+j6mYRg1QPO9m1+9SbC0+JfX+g7qby183sAqMsLFL4tL1iGnXebBkPGXM8ykRh5k91g9y7I2ZfwWe17rgagnssIsv2rus69VhRoclYm6YcJWJ0Z5Rs1LRxvziHzWiMg2GYjdSC9vE+m62w//duNFvuJQGzLxGE8tYmfxKgilEImjhFpRB5uFffto7e9sAi+CpJZaPTFxoVcTjF5uCL2mIvkcNZc4p8PGqRdCTFMvtZhLQli4iiiwmdr2Y/EB/8lHyg5FiT631ssnZYb4RqpHeSQykrbqNV+E2GbZv004aJzGyftx36k1CgOJq7nFZQLcalYlqLanAmNVjpEaVGLfQ6sEmQjNP1TJce2LHeIphYyDi9IPTZs2zr6tXMAXtMBgZAxK5fLTTR9f+2Dw+yU9l7tLFqoY68P4iOAoIjAvdx04tIqTehYe3mH2fxrJdiUS1dEkwNdK2NHmc9NH/rP3j43s61pCg== 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)(4326008)(316002)(83380400001)(6486002)(2906002)(36756003)(26005)(110136005)(64756008)(91956017)(66946007)(8676002)(54906003)(86362001)(44832011)(76116006)(6506007)(66476007)(66556008)(6512007)(5660300002)(508600001)(38100700002)(2616005)(66446008)(71200400001)(122000001)(186003)(8936002)(38070700005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?/scOSMs6fldDoeHWFuInGPQ?= =?iso-8859-1?q?Fb8mFx3JumMfg8Zx0MC6d48flYER8dQ0LndrukgiNWvGlP4SJ8ZRyg/ihHpz?= =?iso-8859-1?q?9rZ8qetYREPn8smUlDdEYw/IouogmsJJ8XQB5o7ygN4yj/8ylpTBjdZM62OO?= =?iso-8859-1?q?Ko76Z2rPKc3dalC6b7Jc6zEEEvDuUyfRHc/ElgE5eojYxFHY05vZO6xBdtj4?= =?iso-8859-1?q?MPCHfduzA0dl3cCZbextH1eJ71wHkxWpZRBVroLLhH6ie2hM69SGgaLPImRh?= =?iso-8859-1?q?aldN21cgZWPb/RpIlnfDgnPVraVzmvf+rt255YfbEJH4i0vW1511GMW46v8f?= =?iso-8859-1?q?XWRyitTTc16CoOPSe+UnS86WZCKnuIZkn+wM9xfHTkrMtLBq8GzM6+SwOHo3?= =?iso-8859-1?q?aTV36x49eN/n1zyqFdaxpeJtNI7rLl1H2yUZtf+7bXHS5yMwcM0P9P6RaNmE?= =?iso-8859-1?q?sj6WuQYPPJDt3g0TGPdy8JEvaV3aNI3Px7h/DBy4QnnplpoCihlncrYzc8Ej?= =?iso-8859-1?q?tOfpp/Qc2XiyIlClmuTSIIiK2CLcEjtTyay29c6SuB5PKDuDuxE687p1ACnD?= =?iso-8859-1?q?IcPV8tlxs/+vijIAe543ealbQx8cn7I08YJ3AZXzwowW+G279W+QFBu0VOwZ?= =?iso-8859-1?q?2QNFbQtBivjwazLVOKf+t3DeRxcJSeoUODAW+0Ai3RJ0Y+PiTIH3XGKV4C13?= =?iso-8859-1?q?/ammYx/hRU556WfITV4G+IpokfHo8D53ArbgAwMo9dWlIlaOoD10tVCaUA5b?= =?iso-8859-1?q?gkzI9gW43GH/53hJM6XglKRLMOo7e/M4gvXXh+P8K8Wj+/IZxyzuWPXqJha+?= =?iso-8859-1?q?UxvxCIw723E5MdYu0B/KnnhFSeWFquPrihN9M9VutFfSad9yMFpHvR39mR07?= =?iso-8859-1?q?J+ncYOQAkpob5eGKNnZhqm6H2H1fkqB9Nmk2eD3nGSxy0npsehxkTb5xbpLo?= =?iso-8859-1?q?ftTfRXqpGJ9Wn/2ghV8sg8S7omhMbKBu2y9yR4XZh2jZyK0GEtjzSxP8XdyR?= =?iso-8859-1?q?hFBWA0hXuacUkQTRh6P23BTE8qAp2qSzdtD1ozH12Mt3DXRe7dTXsIU1zY2Y?= =?iso-8859-1?q?ECFXO2SI3R+oei2Wda2s4MjXih/be2V2YDdvt9BJVE24UGchtmSNBN3cSKJB?= =?iso-8859-1?q?sjBOl/TmQZtD3C1AQ5BimiDFUVBbeHxHy4g7lEYXim/XMItrz1INuVGE/MRf?= =?iso-8859-1?q?FQ9y4HQS5dDU0UuIrsDkieyuK1NQl3Kd+kVU5TxZBKroUsnfr3CQcfROpJfw?= =?iso-8859-1?q?HIPDBlcaw96BMTnjlijP1HEWY5FaLf6MBnH9f8+YrPYWdiky3mTPUa132fxT?= =?iso-8859-1?q?VNozKqkoIXdr1gqWG57Lj5AVTB45hJvlY+RxUviUIHMwP4Z0Idj5qYLlgR01?= =?iso-8859-1?q?e+30yhtOn6CdZdTZbe1wUqIqi6NEYAQPzCVyhLE7aKhlsbRhJKFJRQPxclzu?= =?iso-8859-1?q?zJ9hL1KoeTRn6411zoTHMtKQHxBGwAtwtzGDfNhcdt6yEFol8H224IckYKOj?= =?iso-8859-1?q?HjgCZooZYGrnTy88pIe78UE7r6RQZjC6Wa8+cLlStWZxJV7Q1EffsldZ7NRo?= =?iso-8859-1?q?NjerOJDlM0Zt3fgaHz4GazEIdIle5SiDlbwXXiIxpmqK7ACEFBoLvv+bNnTQ?= =?iso-8859-1?q?2G9H/JTEGoOxQpr2kcyie3mX4H6NPWZlvlpdRd38QFCDhQcp4ekNtMsmOb2z?= =?iso-8859-1?q?1m1twfLtxuuzcqcYOqvzqVGjd3lql+3GbiXfugoUas4fLcG723v8Tg1TvTiC?= =?iso-8859-1?q?Rxac=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: b3ae390d-0861-45db-02d3-08d9ba6ebc7c X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Dec 2021 17:18:21.9823 (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: ha/Nl7FLp3/Hr4FN/njRChDUEPjhm3n1UMzMv0atpK3hFiUtVSvVQBDLx4Z6WQ/2cxmBpH2Xrs8nKWc5mB6N3FMHuUfxHQ7nk5KmOz6mMJo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRXP264MB0823 X-Stat-Signature: e8afbqs9gwomhsasnj64w98yfdo9jrhe Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf01.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.85 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 2009B40009 X-HE-Tag: 1638983904-143945 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: