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: 12664917 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 86415C433F5 for ; Wed, 8 Dec 2021 17:21:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4401E6B007D; Wed, 8 Dec 2021 12:18:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3EEB36B007E; Wed, 8 Dec 2021 12:18:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 268A16B0080; Wed, 8 Dec 2021 12:18:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 130CE6B007D for ; Wed, 8 Dec 2021 12:18:35 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C3ECD8956A for ; Wed, 8 Dec 2021 17:18:24 +0000 (UTC) X-FDA: 78895285728.17.601D59D 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 29F2840005 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=IXQ07BPQIzctfRriOILSBHTNtccHh7oJJWGsIwELrgdG8VckWzyGdyBDcKIVP9mJ+diAeP0sh8zIcpishBMK+eWmutElTY5ihBsnoyDpV5kNT8v3Hmp3lS6YPgewvLDTQz4viDgefyGa+olvFVLR1VGVRtaO8k56qf1ZBwMan+IUoSA516+LqbQSjzqkf+EHpJZSl/zlXQh/s1KIKNyw9JxMT2CXyPnB8oR4HxWkNqpTTMkQ4az8cYVSZ1gYOVJ3yCa1uKlNTxcxZPm6VyOJilHPUjkYsRw68fb0mcnAe4g1ppZO5NFvP3FpP8n2Ndpm2LOWlgBnt4psWd0BCsC29Q== 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=Ao0J4RtTmJCD5YE4NNN5icIYyoHVg3j5QWKaKWYo9c4=; b=ZxMCDJZDZK+OFK6s/tQmHWQ8daKJjvWv4/7QgTl+yjCMEw9Gi91eSN+o9rHn+u2CUVu6RsuHgd/D/VmyTSjfpFWwHlK/zDkYNVq12MGN3oSIFcBISdIH91ATw8Er6mBaO5vRYuefWiIPxmt9E8VKLWZc1mGob3pvPZKAgSjAJpf+tZnKkic0dbvS7FOwFeIk0S3ffIjquJCk4fgdD3iPYZxMSxgez2+HXyjoMEYWqlkJ1YeR7AJGere30WTK4FIDdJbiQs7ShDPKlD5Zwn+gH7MtjgmajzO+EGeVIP4Gzy52XQpFkUfQxsaOuk9hcOePPfxSwSBxjKkQKHdENn6raA== 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:21 +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:21 +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 07/10] powerpc/mm: Use generic_hugetlb_get_unmapped_area() Thread-Topic: [PATCH v4 07/10] powerpc/mm: Use generic_hugetlb_get_unmapped_area() Thread-Index: AQHX7FeZBU3PIhmcjU6PaLYrRJLsxw== 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: ff5e2005-5a3c-42ce-b49c-08d9ba6ebc14 x-ms-traffictypediagnostic: MRXP264MB0823:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:246; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ExWAxiY53R56YevK/yj6EVxnp+QEMSy4RxyRNfqmyx41kIRbiqtnFs9x3k/W1Y9yYGR82v3qHfrZagHPY0m1dMo3HNhfN7jjjWIb7834EOTFbBbhGUZY4EGsknqodsXjUiw2U1LE/UH9ajQJ2F3XPBtO1RrXh/9w3NhbGBK/jlH5XZczDtruDR+miWWX+jcLw5wij+jOKUldPEMVDKHFEspb/LVtLolgWYATl39IOxgScditxLp2PqtDCB8NZTuPDnD37bzk24DhJHF6RSH/He46iy4X3Pqe6bNh61L74WbbFFqPSUS3lPtL6pw+3pO22RuG6Qg91L62DnBrBj9NpYJB2mQgNjix6Ztt670SPYwvkHxCL3PgavoRBEG/eR25/rHajE/6kYZauTOEvw5xEMKuKZFrZiEjKvqvr1Nu7Q8t8X7dmJ1ZRhY1H5HRk96ISbHn9fc+qTfC/z3+DJB2mc/ex1BlWerJY8curKspSF1nitdCdTadVsi4XacGxeNGsyDjwST98qa0z6SDBQgL8ok6ywdQJ/kOWzywmw9vQKnByRzAdW1AhBwwRqAXTmrJlXTzKzjD1RA6VVXXIfM9/FwHkitXMyNWfDLO+HSme8EAY3qWzF/cxRozaWbKHYQVd3ax4DDFFgkQ1ieEXNW8vzAnNUS8zQs1mevFObyRjT4an1asRFoWEBzVIqQCv6aSzmjGDDTPYtvVx5BczqiWh/SCEjPhS99ei5VuStU5/f4= 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)(41533002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?GsWeB5eHVHtNsvtUU1nfvOv?= =?iso-8859-1?q?cZ3nmAsXU4bqxKOufQmPNQU2Ojnig+okt8aJ+oDvw1gO7u8q0FlR+mYnMpcu?= =?iso-8859-1?q?6pOG5tndglA0enV+YuwYQi8cQxO4W18kHFsmMLwhnymuHbYAdauxq+hV63L+?= =?iso-8859-1?q?/triT4wGP1JTOhtmvYZJZB/zAV/IMu6gNTIrMxb771EFmL+QcS7GvLdryrGG?= =?iso-8859-1?q?fkKyEScBnh7RUoFWfth0xQ+ITwF9m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?= =?iso-8859-1?q?tujVeuNemi7vDl9I+TbWdwBsb+f+8UudNqFP2Y+isWmdPp4+QTE9C2+jGRGq?= =?iso-8859-1?q?A5pRRIt7gpbEoLVodo2JAySNopO3V0t/gsouZWajjGhyEgIQqXViDEoqCEEX?= =?iso-8859-1?q?Ez4nYXTbYZeKyq757nbnNcsAQszZ8yMDlnx0yiBMPv/AhD1ougGdRIUR3l74?= =?iso-8859-1?q?P/fbWV33I/4P8TsVMFUFIG77RUyqler3VQi8u0JJOjavWpjd+anLjTiZHpMb?= =?iso-8859-1?q?osfV2wQu42+Sd9GdZNkp3Pi0hauAgcQ2F1LKHKij2nSV16FvAEq+Ykr2r+b+?= =?iso-8859-1?q?NyeuuK4XDaNV1xMebrs+eSBzLEXmsUzfvL8AelMCn3RmioR/tElXvmphUT/z?= =?iso-8859-1?q?JoFwyKQ/p4o7PsfBZ9O2sAi0rVeUQGy6xdG3WAuaXSmbIz70dCyhuWdJ1ALH?= =?iso-8859-1?q?NqRrEo3ebbCmf5YanKDNQKb1LeCjbqvWFy52dKEGBcryuwOEQCSHHyKp+SUa?= =?iso-8859-1?q?AIuh+awsLj4NY3m5TeZ/e2mf7O1PkoDL4nGgHd0nhpFEwgjgq+CuyksVS8EV?= =?iso-8859-1?q?1Yo6/98+Vj6KuYBTInoN9eM9TcYMxRE0C3hoUOTOTouQR36ZCmgCO9CIcLSI?= =?iso-8859-1?q?1RR0=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: ff5e2005-5a3c-42ce-b49c-08d9ba6ebc14 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Dec 2021 17:18:21.3621 (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: hl8L5xWVcyA90pSVLxWuQAxMzFUVIlh52aZ07+ZOmmbamyJylFl5J9EI3/qLtvy0MMrZ/CuEMwURzcybiyJ1ufU+G8Y1k/FngaydwX5iWag= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRXP264MB0823 X-Stat-Signature: khtpsg1ouqnheb7bso3m5sh5cx3diaza 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: 29F2840005 X-HE-Tag: 1638983904-761389 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: Use the generic version of arch_hugetlb_get_unmapped_area() which is now available at all time. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/book3s/64/hugetlb.h | 4 -- arch/powerpc/mm/book3s64/radix_hugetlbpage.c | 55 -------------------- arch/powerpc/mm/hugetlbpage.c | 4 +- 3 files changed, 1 insertion(+), 62 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/hugetlb.h b/arch/powerpc/include/asm/book3s/64/hugetlb.h index 12e150e615b7..b37a28f62cf6 100644 --- a/arch/powerpc/include/asm/book3s/64/hugetlb.h +++ b/arch/powerpc/include/asm/book3s/64/hugetlb.h @@ -8,10 +8,6 @@ */ void radix__flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr); void radix__local_flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr); -extern unsigned long -radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags); extern void radix__huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, diff --git a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c index 23d3e08911d3..d2fb776febb4 100644 --- a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c +++ b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c @@ -41,61 +41,6 @@ void radix__flush_hugetlb_tlb_range(struct vm_area_struct *vma, unsigned long st radix__flush_tlb_range_psize(vma->vm_mm, start, end, psize); } -/* - * A vairant of hugetlb_get_unmapped_area doing topdown search - * FIXME!! should we do as x86 does or non hugetlb area does ? - * ie, use topdown or not based on mmap_is_legacy check ? - */ -unsigned long -radix__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; - struct hstate *h = hstate_file(file); - int fixed = (flags & MAP_FIXED); - unsigned long high_limit; - struct vm_unmapped_area_info info; - - high_limit = DEFAULT_MAP_WINDOW; - if (addr >= high_limit || (fixed && (addr + len > high_limit))) - high_limit = TASK_SIZE; - - if (len & ~huge_page_mask(h)) - return -EINVAL; - if (len > high_limit) - return -ENOMEM; - - if (fixed) { - if (addr > high_limit - len) - return -ENOMEM; - if (prepare_hugepage_range(file, addr, len)) - return -EINVAL; - return addr; - } - - if (addr) { - addr = ALIGN(addr, huge_page_size(h)); - vma = find_vma(mm, addr); - if (high_limit - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } - /* - * We are always doing an topdown search here. Slice code - * does that too. - */ - info.flags = VM_UNMAPPED_AREA_TOPDOWN; - info.length = len; - info.low_limit = max(PAGE_SIZE, mmap_min_addr); - info.high_limit = mm->mmap_base + (high_limit - DEFAULT_MAP_WINDOW); - info.align_mask = PAGE_MASK & ~huge_page_mask(h); - info.align_offset = 0; - - return vm_unmapped_area(&info); -} - void radix__huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t old_pte, pte_t pte) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index f18b3a1d18f0..bfd7f4af1e58 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -553,11 +553,9 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { -#ifdef CONFIG_PPC_RADIX_MMU if (radix_enabled()) - return radix__hugetlb_get_unmapped_area(file, addr, len, + return generic_hugetlb_get_unmapped_area(file, addr, len, pgoff, flags); -#endif #ifdef CONFIG_PPC_64S_HASH_MMU return slice_get_unmapped_area(addr, len, flags, file_to_psize(file), 1); #endif