From patchwork Fri Dec 17 10:27:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12684203 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 E00A3C433EF for ; Fri, 17 Dec 2021 10:28:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 51C0B6B0073; Fri, 17 Dec 2021 05:27:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CB2D6B0075; Fri, 17 Dec 2021 05:27:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 344F96B0078; Fri, 17 Dec 2021 05:27:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0051.hostedemail.com [216.40.44.51]) by kanga.kvack.org (Postfix) with ESMTP id 26ADA6B0073 for ; Fri, 17 Dec 2021 05:27:33 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E485B83E82 for ; Fri, 17 Dec 2021 10:27:22 +0000 (UTC) X-FDA: 78926909124.29.39AB95D Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120073.outbound.protection.outlook.com [40.107.12.73]) by imf09.hostedemail.com (Postfix) with ESMTP id A7BAA140015 for ; Fri, 17 Dec 2021 10:27:18 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jc0o0rlZBnEh4OldiuB3/oaQMFZSrXbG0Z4A+7WszpAgagKCyxWMJXmaE2ybFprAcmihjowWmgFz3OTgzJuuUUW6Ka+/QUu3oY9e6uBEaGEiTuOp9KgNZgvfT4dMwGyTYGluMu4F8YCZ6luYNhg2TZKsxAhCaaOI5rSWAI2tpWlHmue0oyIVgD6oUFe+q0uSuFg8Bcy2NR3uGzpVB9ra14CwQwn2LtBu5A1vSdsgysOWTVpI0NUoqRIju8pn/0LXH7Rlh2RXf20jmNn/IxLAL7odlIb8zDEaElvF+om2Fa00bda5JEysmB+nA29tzRW9ytTECTfQnARG2TfFrWATWA== 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=KuKZ8Pp5OoKCaatHC4wZ7EyUM5TYF66Dvkuh8U4yTxw=; b=CjgyxoZzCVVda1+ATmsdDDbfBY/WNZabqirdxkFby7NGCabd3SjBUMaXGDcksE8y33eGsEoYE0xww0HWXHo92Yh5OEkl2KDVDQs7KUAEDSQBfbrOGalLrAGll5FMTRi3GSTncyw3PnPBmISFXijIaOwouO2SF6gyTWim5GGkm/UzrT4ve1997KFigzJOMG+081IkDRYUv4Z3FyaT667eO/Br6nj3aELudbmV9RTyoTggvpAs2QcejefPyjfi5fPkW3N+HE3Z31PsctabbJLjtDbJ4s+yQ58P14cZA5oWDLXhc5vDq9LnXD/qbUU2QVOLvRcQ8YL8rt8ao9of+P5M9Q== 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 MR1P264MB1650.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:4::11) 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:27:20 +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:27:19 +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" , Nicholas Piggin Subject: [PATCH v6 02/14] mm, hugetlbfs: Allow an arch to always use generic versions of get_unmapped_area functions Thread-Topic: [PATCH v6 02/14] mm, hugetlbfs: Allow an arch to always use generic versions of get_unmapped_area functions Thread-Index: AQHX8zCrhoAF34Ujr0eqThlZaaakHg== Date: Fri, 17 Dec 2021 10:27:19 +0000 Message-ID: <50d176dcf3942894a8dcbc42b7b767b065df9af0.1639736449.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: f5cfc7cf-13bb-4047-43db-08d9c147ce32 x-ms-traffictypediagnostic: MR1P264MB1650:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: eEo1TeUDHpAIwUtuH8cwgQuR2Rtk0Q6UbsXFm8deBpD4b2LvUSjxZ38ZlmeocwZwci9rZZ9Fjz9U4gRAmt8mAk6A2ZYvD/lqUDwoDsOCUmBEalRZXtyh1BGg67391WiQy1RehqWntwKIXMD8KOkWc+03BnlCBVEDt430Vxq4G1OtDdjh4qSPOBF6+6pRQ0ZfFsf07I/UVIAwOhQQlM7b1rGLNjaPeW7VZHRWAxDds/vB8fkJFXot6T/aaa2f1UzOpB4fYJL5Oyvf7496b2OXnDZNxOum9g2MEPTnC4JFrpBQ8Oj8cbvCY2+ZCo2hPizvZZcEHhf0SZwBtDNhvsbUchHIfkZBcvIWhlWe6SQmwziGLe26JrR5ugsZhPNkOLgpOHNOo1sTE8Od9OGGP/VMNc3Frg8PgRloMENcog28tbIf+lm5wuXCBTg+kz1qsGLlFyWibE3Tj43eDu55DHci5mRlCTSzUnOdumMKXXljMzbsfptFzouSrLwCtIWpzMmoFP9fLtOL9O0u9Y3HuYu7LUadRvS9EphmhXIiq1SYnAIQ7m8GoEeEM5iDPRcbJCQlsB/vBpsGB20sRfEPNNfby1Xa7yjVdgq5RJCCWU+b9/JnUxhIvjbKt4HiPctXssn7N1XwS8qfdiXnMhFgEjvsqTKC2DlmTu0QzAzxpnkNjqptdUsIbK39p2E6p/5RZpiRzW1W1KR9EMOE/vfjiw7f6J+0hGuBG2/bqKdashtfJUI= 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)(8936002)(2906002)(6486002)(6512007)(8676002)(83380400001)(122000001)(36756003)(6506007)(186003)(86362001)(26005)(38070700005)(44832011)(76116006)(66476007)(64756008)(66556008)(5660300002)(38100700002)(66446008)(2616005)(91956017)(66946007)(4326008)(508600001)(316002)(71200400001)(54906003)(7416002)(110136005)(41533002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?Teh8ijjSw3AO7mYFAP+TYs2?= =?iso-8859-1?q?rt2zpOns0WKL7/quKLiU+U/FwwuZCMdYgLQJumr+vAlZrOlInROQSS1RAT5C?= =?iso-8859-1?q?jYGrXZxA4WufVos3qyVvnsSMwcTJeo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KpO2U4AL?= =?iso-8859-1?q?Um7OJ+y4ArzSl/fbfY04np9uL0jBX0t9R2+hLpE7Lzryv00mMonyBOU1ZkQq?= =?iso-8859-1?q?90dSlMj13etIH8ayz3mMP6+gVA+kvvxQYUbfOZK0xpT3e/8xO8AjQAD7I67d?= =?iso-8859-1?q?KudBH9EitLeWhXYsmz/i6BBTQRFEDVPdkQ7GhlP2GF/L8Pk7az/p8Lx3d0fx?= =?iso-8859-1?q?6/NQpIeemf2SeOsBBMPbktxvEeyd7nYb8Bk0cjBOo2Wm7CgCv5AiXAdVqaYl?= =?iso-8859-1?q?D7/U0WSnuXPlUhEWr4vDibkqLHyrN3PlT1bRsODKDYmcKvM7WKOnXAlBxaZW?= =?iso-8859-1?q?cn1/btXYKtu0KP7kgFx7cuiDxn8j+TE5TMHEql/4gkZ+GzgPvbzc3k/p59im?= =?iso-8859-1?q?PGWSnmT/I+r1HDwR/NYDN+2QFC1XCvxgez9XBN8+rfmywjSRAkEqfcU82C1y?= =?iso-8859-1?q?/BZV2AK8d44MKV//mQcbOrZo29UwXlwd9Q8uYqb5qmlx9pt5ZatiItnK9Sbt?= =?iso-8859-1?q?Vs8iJlYW233b0u9Sy3yV594Zn+iLgHfqeqceh7ZzsVC3GJXoSOnWMaZlEtr8?= =?iso-8859-1?q?nOrjbihN056Eu2eL3cjnFCBghRwKVOhNZHSUXc1Yal9dtjhrRGcE9tYZkDtY?= =?iso-8859-1?q?yJZI7m3lbxVsZrBxObe2byqyrVXQYP/IO4tzjp5A7cVZ83T+05TXNnJJRUx2?= =?iso-8859-1?q?4TJiQHQnY+8CZt4m1oCpl20JKTjCsRkTBf7o2r5MoAvuwTm7FvJ3HvBY5/qO?= =?iso-8859-1?q?hZqc=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: f5cfc7cf-13bb-4047-43db-08d9c147ce32 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2021 10:27:19.4481 (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: /fi2vfcEAMS3PzO0LMFBm5eH6xx3kn/RMwJItDqWqVo7osGRcTSc/tWcStb7iI+3wPlxmqJGghalBmFdbLKn4h5lw4chGXIjbEC5Yf8Yo9Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MR1P264MB1650 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A7BAA140015 X-Stat-Signature: edzmzgf8xxbwd5rkqwtcd311r615h8dt Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf09.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.73 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-HE-Tag: 1639736838-102622 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: Unlike most architectures, powerpc can only define at runtime if it is going to use the generic arch_get_unmapped_area() or not. Today, powerpc has a copy of the generic arch_get_unmapped_area() because when selection HAVE_ARCH_UNMAPPED_AREA the generic arch_get_unmapped_area() is not available. Rename it generic_get_unmapped_area() and make it independent of HAVE_ARCH_UNMAPPED_AREA. Do the same for arch_get_unmapped_area_topdown() versus HAVE_ARCH_UNMAPPED_AREA_TOPDOWN. Do the same for hugetlb_get_unmapped_area() versus HAVE_ARCH_HUGETLB_UNMAPPED_AREA. Signed-off-by: Christophe Leroy Reviewed-by: Nicholas Piggin --- fs/hugetlbfs/inode.c | 17 +++++++++++++---- include/linux/hugetlb.h | 5 +++++ include/linux/sched/mm.h | 9 +++++++++ mm/mmap.c | 31 ++++++++++++++++++++++++------- 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 49d2e686be74..c7cde4e5924d 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -195,7 +195,6 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) * Called under mmap_write_lock(mm). */ -#ifndef HAVE_ARCH_HUGETLB_UNMAPPED_AREA static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) @@ -244,9 +243,10 @@ hugetlb_get_unmapped_area_topdown(struct file *file, unsigned long addr, return addr; } -static unsigned long -hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, unsigned long flags) +unsigned long +generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) { struct mm_struct *mm = current->mm; struct vm_area_struct *vma; @@ -282,6 +282,15 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr, return hugetlb_get_unmapped_area_bottomup(file, addr, len, pgoff, flags); } + +#ifndef HAVE_ARCH_HUGETLB_UNMAPPED_AREA +static unsigned long +hugetlb_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + return generic_hugetlb_get_unmapped_area(file, addr, len, pgoff, flags); +} #endif static size_t diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 00351ccb49a3..df899d1937ff 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -513,6 +513,11 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, unsigned long flags); #endif /* HAVE_ARCH_HUGETLB_UNMAPPED_AREA */ +unsigned long +generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags); + /* * huegtlb page specific state flags. These flags are located in page.private * of the hugetlb head page. Functions created via the below macros should be diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index aca874d33fe6..2584f7c13f69 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -144,6 +144,15 @@ extern unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); + +unsigned long +generic_get_unmapped_area(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags); +unsigned long +generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags); #else static inline void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) {} diff --git a/mm/mmap.c b/mm/mmap.c index bfb0ea164a90..7ac6a07ff382 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2131,10 +2131,10 @@ unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info) * * This function "knows" that -ENOMEM has the bits set. */ -#ifndef 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) +generic_get_unmapped_area(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) { struct mm_struct *mm = current->mm; struct vm_area_struct *vma, *prev; @@ -2164,17 +2164,25 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, info.align_offset = 0; return vm_unmapped_area(&info); } + +#ifndef 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) +{ + return generic_get_unmapped_area(filp, addr, len, pgoff, flags); +} #endif /* * This mmap-allocator allocates new areas top-down from below the * stack's low limit (the base): */ -#ifndef HAVE_ARCH_UNMAPPED_AREA_TOPDOWN unsigned long -arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags) +generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) { struct vm_area_struct *vma, *prev; struct mm_struct *mm = current->mm; @@ -2222,6 +2230,15 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, return addr; } + +#ifndef HAVE_ARCH_UNMAPPED_AREA_TOPDOWN +unsigned long +arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + return generic_get_unmapped_area_topdown(filp, addr, len, pgoff, flags); +} #endif unsigned long