From patchwork Wed Dec 1 14:30:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 12650109 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 91A5DC433F5 for ; Wed, 1 Dec 2021 14:59:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B64C6B00DD; Wed, 1 Dec 2021 09:58:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1696D6B00DE; Wed, 1 Dec 2021 09:58:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED39E6B00DF; Wed, 1 Dec 2021 09:58:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id D722C6B00DD for ; Wed, 1 Dec 2021 09:58:51 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9B1D382499B9 for ; Wed, 1 Dec 2021 14:58:41 +0000 (UTC) X-FDA: 78869532042.10.EBC3F3A Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf15.hostedemail.com (Postfix) with ESMTP id 0C569D000081 for ; Wed, 1 Dec 2021 14:58:40 +0000 (UTC) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B1DDP4T010062; Wed, 1 Dec 2021 14:30:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2021-07-09; bh=N3cnOAJfDqtpAm5+5UWZLmgos+io/LmGgzQtDeAC+fQ=; b=fSRroTQ7XkT8sKW+l96svGYF4Bzba0jpVjjCBRkK/5sv5zMcqAwWQoDBABkvK5eXAfJO h0tBOxfDZOzEk5eLfI4hVpjs3NX7OZcFmRp5KoksBkTATHlAMaeu8Bu+EGhvNI8VnyEx YvQhV7op+fKAtwRuh7tdIxvb/EzSni/sH0pQqPLJpDpSadkDdgu/mUU6ToNT0TuPrDVS 8t7Wgkr89O1lCzBLfK5LoAdlaEY1g0nRmtTPehhDJZ5K/JkW7V+aL6v9eEfyW8uC8vuD slGpqi9hwmEqtH58F193Jr4UcwLBrMPnX4IsY71hIIIjxhGkajH0T1nELEg84wrL4zJ5 Jw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cp9r50e3g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Dec 2021 14:30:40 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B1EBouv037539; Wed, 1 Dec 2021 14:30:39 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by userp3030.oracle.com with ESMTP id 3ck9t1v6xx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Dec 2021 14:30:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kYQV9U6L1DdxjvSq+pyT5bDQtcrcuxN1C5GInuEUl8ytsHRd3cYzPxK50PGYNIb6Xyg5RPAzWmA2cqdxXjxKOy1lYucsQ3z9sUSbO++LpriFadD9HjjRrC32TyzM5kS7Tf6jeAHDvM/S35WK7A6kHBOXUq4jodNxCDceabSs2S3Vxjh1vL2+7gclWCv4si16V+egI3nbmq49mrHfn586cSpgHD1ka5brv9U/7bBzIo8pt1nvnDFvLEQR0q8bbZ8VF/rNLlYIM+6nWLgabOA5XWNgEl6AlProTErxayLBBJ+yJHRi9MrxUAoN4B2xROUkr9TstGq6qjrHQJQlESeGIA== 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=N3cnOAJfDqtpAm5+5UWZLmgos+io/LmGgzQtDeAC+fQ=; b=N8+6ZpAy9ytlLsxPRS++3DpgTUyiIs34M07okwqLmTi2k0xkmsWtmn3ISIWt8Dm5233LaneTjmX3NVytmVn8/LyMVT2RT5w/o5LKAZyO5zYSByxXYstp126LAyQ4kmD9lQwx6DmUxzxDUPCENN3J0/DNdtz1TGPbjhAiVDP5DnohtX9diSiwEleXG5xwDtJQoqAAIanFLTEgArW2moBTTKN1fc0o/p9yMm6jhqVr4aUtGTkgfugRgHn/09f6DnAGdOlAhfBC2vkWLb169z5qouGj8wW7SwXmPBFQMhRBDzasNzElMWpXJIYq+10TEdrbe4pnaHWCPG9tyXk//rBCJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N3cnOAJfDqtpAm5+5UWZLmgos+io/LmGgzQtDeAC+fQ=; b=KrimMfcsPsIuoGfNcvKTVkEnHOUXOzIHPNICjhDPohpJZnu+dFDdEGbimmOJ6qhVje6G1i72QegpyMVZxQiDAudWzNVwZakwkxLi/eUC0xXlskrDYkQDtGKNUMApzIj5RRx411BiUZMX6B6whmOuvf27nyeoON1qLFgQni7o2Ys= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11; Wed, 1 Dec 2021 14:30:35 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::c4d0:8291:84d:ac66]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::c4d0:8291:84d:ac66%7]) with mapi id 15.20.4734.027; Wed, 1 Dec 2021 14:30:35 +0000 From: Liam Howlett To: "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton CC: Song Liu , Davidlohr Bueso , "Paul E . McKenney" , Matthew Wilcox , Laurent Dufour , David Rientjes , Axel Rasmussen , Suren Baghdasaryan , Vlastimil Babka , Rik van Riel , Peter Zijlstra , Michel Lespinasse , Jerome Glisse , Minchan Kim , Joel Fernandes , Rom Lemarchand , Liam Howlett Subject: [PATCH v4 30/66] powerpc: Remove mmap linked list walks Thread-Topic: [PATCH v4 30/66] powerpc: Remove mmap linked list walks Thread-Index: AQHX5r/ulVD3717XCUCyV2GqJY677Q== Date: Wed, 1 Dec 2021 14:30:05 +0000 Message-ID: <20211201142918.921493-31-Liam.Howlett@oracle.com> References: <20211201142918.921493-1-Liam.Howlett@oracle.com> In-Reply-To: <20211201142918.921493-1-Liam.Howlett@oracle.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.30.2 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 93e5ee45-74a7-4ff6-6d22-08d9b4d72376 x-ms-traffictypediagnostic: SN6PR10MB3021: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: EYJbJij4FZ0FN1KqzW1YhQdnU+frc1TuZa/T9FPuqO+PVJUQWQg2q7n8J0pQQM09CGdiLmdZWYB1x5zuc8SVeVWVCcpfSNiVxIZdHKTUrqOau0L4SbWSKuikMvvfjO0jLIvUsDxXjMUHMxaM3px7ay5VJhcZn3V79Z/zbMevtBQdrfDSlBuPuol5G69pITgV5EeIONDhqXMBA7kNhwz4grXQBlChNEPM062hWTeXMy2DnXQczERwxkXErmfHQ7+v1rT9qWFdwO42Hd+JCjxa0u5eQwAbDdT+yF1QzLDYKpF6uagW8Y7t5cGaybH7r1iWf7yiCSlv/C/5f8GHPgGPXV/L6yaXarxU9LrXKbtw55o3TaUKiv0Zs4o7IzQLJCvSwVRIrhPMBANggk+dLK19pYG6gvFm0WQE+RjPDRHDMV8lj4BXBAJAK2zvOUbeC7NAM504u61QDjAtG/jSQbAv8fPCqOQqIgWVRuG1zJplGQHvVg4Ydxi9RS4GMQztMGuV/gvjKSVonfVkv+RwYhNBV0NzoUHMHjMoKuy39rOZipU3Tn2dNIWJnj3iFLWEa7ijmp7ni1SIbdHx5505xK8+uX0GL8PWiaz7NREOzmw5vZMg4hc82FrK0WxINeuthqjylgrUdPkdsPpFQ2lqWyLnSMV3gKvnSpmaJSEYrK1QWohZr2ZmQ1JGtmfGEgg8+o+mrLkPdfClMhBh6EQeFsP4xw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3022.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(66556008)(7416002)(38100700002)(107886003)(38070700005)(316002)(66446008)(76116006)(64756008)(66476007)(2616005)(122000001)(83380400001)(2906002)(6512007)(91956017)(508600001)(66946007)(71200400001)(8936002)(54906003)(186003)(86362001)(44832011)(4326008)(6486002)(6506007)(5660300002)(6666004)(36756003)(8676002)(110136005)(26005)(1076003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?SPxL4EB35T9bDuc7BOOasVt?= =?iso-8859-1?q?4wzcUHOGzS+HqtsWZ6cBbaaSTCaTGkOLVkZB4Jo9c8oXR+w/nwIhn7jjdx4f?= =?iso-8859-1?q?ZJh45c23aqlXKhlgKtAhd/Nt2epCa0CTTivth1CG0r4Ki+b9+FNOQsy/Mnsl?= =?iso-8859-1?q?rxaw5D5rl5VGC2J6o/PTbqMybupvtjnvcbUr8Ex6Uaz2pm1KGbyFO8Pks742?= =?iso-8859-1?q?m3z+Sy3IR+ELfic4wVSGMGp+Z0vWgkNZVbcR7YH4bPjK7pcNgyv6sIQyqrQF?= =?iso-8859-1?q?+rKUAjicoRBRSxdxLx6iPpqcjJtpqdRPYxTzURv9V3zXn9uL4PeVovJJCPAC?= =?iso-8859-1?q?JyhZ5tlHbqGDvN3VV2D2ffdfXONlRo1bZC15Ii0mPDkRK118LyeIcPSvDTq7?= =?iso-8859-1?q?b1Qf0yCbQDcRRHyXNYBmSa/mcRC9PhBcrD16YTviD2a/jRCa7TIg3YFejjW6?= =?iso-8859-1?q?Q1AULzhUI0KmOyoWi8cWJslT/GP1jlkg3ebl5swJn3HTg4pMVmVuMJNP5WOj?= =?iso-8859-1?q?KwFX081wJ+LqG6L85tdiIcA9mPaMgi7+2m1tnvibqhvmG6g4B/fcpN6mBlC6?= =?iso-8859-1?q?ZfQo2OZ3UyV5mfZ47VWhnXI4GhpcVyQ7JFbUaXCkdvCuszSWU83P3z2sWVLk?= =?iso-8859-1?q?NaQXHezC3dJk5//6B1/MzS7uZld4PpUe3rBzF2gW+WNQLO0ae5V8/e6ouo55?= =?iso-8859-1?q?wQFYARgagQgZ+VIAQ4u001t/S+KXGKeg+qLcl3PribZcjiU8Ob+wigtpOhLT?= =?iso-8859-1?q?yOzqc5Obrz9HaeZya550sNbtaR12THtZIQM99bMQ/slj9f0py113mOQRIrM8?= =?iso-8859-1?q?dXAQCreXd369t7VL3DVvQWKabQ98JVreSU+yi6o76J/skrdK8itUXb3oFhvZ?= =?iso-8859-1?q?IiuS6jwpU38DP6+BSExrUQIDAub0Of5DKPkAck+B5/LNwBSYlHqikmopR3ix?= =?iso-8859-1?q?7KuEE6CcwOLaW9+vqBjRg3ccW19nlcpoJgSPY6JtFtXh+cAZSoKnTnhyalYT?= =?iso-8859-1?q?BOIBMvuDRkzV4BZ1FqlUnYZ7x0/yQlKkzmPmjlQGp9+LiLu6k9AwJFYHACB8?= =?iso-8859-1?q?l/humUmHG92PXoXwB6SZypo7ZrjBUKhwDTc7/bsLPNhxGkKi6iteBtV+JjWH?= =?iso-8859-1?q?VaJ0eNSFhK1iBFlRyLZWi8qi7OOj3c65xucbMQUhrrUtsiqOnydRqnxHfs1H?= =?iso-8859-1?q?cK/19NOQ5C7NZk2EozbrU69dj4Aq9L57m59MSwmMuf3Mllik9cmkDjQdS7GM?= =?iso-8859-1?q?AVZofWdWD3S1xsY8nCbI9U62tRvVlD0HT38YNY6nX8i2KVDnhBLHNGITCD1y?= =?iso-8859-1?q?A2X1SixhBs0Wcehs2xI7dV0GJvzhp9WYMFB6fZc948Y6HxDNp7ZiwDECMi7/?= =?iso-8859-1?q?EfhnMG4/VTBu7kezjORmMf5WuWm9FloyQRzPKQ/k+EYLsiRhiPB56t9AK/Eg?= =?iso-8859-1?q?YxpZ+GtfQAPf+mZ8UvW2MKRm355Ju8ce9wSwaHZ270FpslDULVCAPzM/IED0?= =?iso-8859-1?q?Jgqp386lmDGkjvRfuLJ4mK0PUPExdyUJvB1VzHPc9iHM5MAY9+RuhTbb34Lo?= =?iso-8859-1?q?bw6wHqM2x7p6Yid7R6hCeYGdyFDuWqatXlrvYJzqZYSIHB+JbfmgohutBkVi?= =?iso-8859-1?q?kpFefOiV8IhLVAsiioHrU3RIdeiwZS/kD3vRGiqBTvoyTtqDIRTMkzEc36zA?= =?iso-8859-1?q?=3D?= MIME-Version: 1.0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93e5ee45-74a7-4ff6-6d22-08d9b4d72376 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Dec 2021 14:30:05.0511 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: /7byFUKSP5Lj0rCUhECPaBk5+uKNVTRTor9oO1/gNXdpaGtXJDqbmANdVI1aIJOCdchNsqY9lQUKmqa9w7jSgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB3021 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10184 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112010081 X-Proofpoint-ORIG-GUID: aLK5RJWCy5jAT_kGNbX5XNYJNQ98HLsM X-Proofpoint-GUID: aLK5RJWCy5jAT_kGNbX5XNYJNQ98HLsM X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0C569D000081 X-Stat-Signature: 8ndmy1141agdsotkqtbmcyn1r1d1bu6z Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=fSRroTQ7; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=KrimMfcs; spf=none (imf15.hostedemail.com: domain of liam.howlett@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-HE-Tag: 1638370720-77279 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: From: "Liam R. Howlett" Use the VMA iterator instead. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Liam R. Howlett Reviewed-by: Vlastimil Babka --- arch/powerpc/kernel/vdso.c | 6 +++--- arch/powerpc/mm/book3s32/tlb.c | 11 ++++++----- arch/powerpc/mm/book3s64/subpage_prot.c | 13 ++----------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c index 717f2c9a7573..f70db911e061 100644 --- a/arch/powerpc/kernel/vdso.c +++ b/arch/powerpc/kernel/vdso.c @@ -114,18 +114,18 @@ struct vdso_data *arch_get_vdso_data(void *vvar_page) int vdso_join_timens(struct task_struct *task, struct time_namespace *ns) { struct mm_struct *mm = task->mm; + VMA_ITERATOR(vmi, mm, 0); struct vm_area_struct *vma; mmap_read_lock(mm); - - for (vma = mm->mmap; vma; vma = vma->vm_next) { + for_each_vma(vmi, vma) { unsigned long size = vma->vm_end - vma->vm_start; if (vma_is_special_mapping(vma, &vvar_spec)) zap_page_range(vma, vma->vm_start, size); } - mmap_read_unlock(mm); + return 0; } diff --git a/arch/powerpc/mm/book3s32/tlb.c b/arch/powerpc/mm/book3s32/tlb.c index 19f0ef950d77..9ad6b56bfec9 100644 --- a/arch/powerpc/mm/book3s32/tlb.c +++ b/arch/powerpc/mm/book3s32/tlb.c @@ -81,14 +81,15 @@ EXPORT_SYMBOL(hash__flush_range); void hash__flush_tlb_mm(struct mm_struct *mm) { struct vm_area_struct *mp; + VMA_ITERATOR(vmi, mm, 0); /* - * It is safe to go down the mm's list of vmas when called - * from dup_mmap, holding mmap_lock. It would also be safe from - * unmap_region or exit_mmap, but not from vmtruncate on SMP - - * but it seems dup_mmap is the only SMP case which gets here. + * It is safe to iterate the vmas when called from dup_mmap, + * holding mmap_lock. It would also be safe from unmap_region + * or exit_mmap, but not from vmtruncate on SMP - but it seems + * dup_mmap is the only SMP case which gets here. */ - for (mp = mm->mmap; mp != NULL; mp = mp->vm_next) + for_each_vma(vmi, mp) hash__flush_range(mp->vm_mm, mp->vm_start, mp->vm_end); } EXPORT_SYMBOL(hash__flush_tlb_mm); diff --git a/arch/powerpc/mm/book3s64/subpage_prot.c b/arch/powerpc/mm/book3s64/subpage_prot.c index 60c6ea16a972..d73b3b4176e8 100644 --- a/arch/powerpc/mm/book3s64/subpage_prot.c +++ b/arch/powerpc/mm/book3s64/subpage_prot.c @@ -149,24 +149,15 @@ static void subpage_mark_vma_nohuge(struct mm_struct *mm, unsigned long addr, unsigned long len) { struct vm_area_struct *vma; + VMA_ITERATOR(vmi, mm, addr); /* * We don't try too hard, we just mark all the vma in that range * VM_NOHUGEPAGE and split them. */ - vma = find_vma(mm, addr); - /* - * If the range is in unmapped range, just return - */ - if (vma && ((addr + len) <= vma->vm_start)) - return; - - while (vma) { - if (vma->vm_start >= (addr + len)) - break; + for_each_vma_range(vmi, vma, addr + len) { vma->vm_flags |= VM_NOHUGEPAGE; walk_page_vma(vma, &subpage_walk_ops, NULL); - vma = vma->vm_next; } } #else