From patchwork Tue Feb 15 14:43:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 12747177 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 4B53DC433F5 for ; Tue, 15 Feb 2022 14:44:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9AB866B00A1; Tue, 15 Feb 2022 09:44:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 91E2C6B00A5; Tue, 15 Feb 2022 09:44:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 62F4B6B00A2; Tue, 15 Feb 2022 09:44:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 4AD716B00A4 for ; Tue, 15 Feb 2022 09:44:03 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 0F49E8A9A5 for ; Tue, 15 Feb 2022 14:44:03 +0000 (UTC) X-FDA: 79145283966.30.E277C25 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf17.hostedemail.com (Postfix) with ESMTP id 4D39B40004 for ; Tue, 15 Feb 2022 14:44:02 +0000 (UTC) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21FEhvWl022181; Tue, 15 Feb 2022 14:44:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2021-07-09; bh=pq8BsbnDfrZqeESMo1PCnflJwYLvDx1XFEkEc4GYrNw=; b=SJz406xU4jQTOj/XzVSPon4AKn857Eack8y10kyVP7CnxIDst/A9JyKL7KIm1hsUWLlz ID4/DXMKyXuPM5cSZumeSgpwpdcXkSqzKh6Jt3eraZL6VPj7+qcRTBumWXvzNp7HtFMM RLGsjso3TM38t6e2haVl/3lVecCyT7rQIDTAZO5icTJJNTKPNMjz9jp1yu3wQcGb7JSt BRmkkSRFjGq6yfBqBx6Y3mOO5H/uTq3cG9nnXuDujZlttKRgkF3i6EEN/XKrt7hKkF7Y zkt1ErN4C+U7rFBRtS8o2NWXiHX8xmo84ud7JZuZJvoTUhU/RS49nXOsUI4pnuAnQVwn jg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3e884r97hd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Feb 2022 14:44:01 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21FEeT4Q145723; Tue, 15 Feb 2022 14:44:00 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2042.outbound.protection.outlook.com [104.47.74.42]) by aserp3030.oracle.com with ESMTP id 3e62xeqfex-15 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Feb 2022 14:44:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ClzaqOkLNsAciBiiqaal+e+D+5TIuhNHH5ulvlbjascBEjlxmQRecRoElATLLB4xxmuYWO6W6O5VqoPt+yn65tGCAptv2Pb1vnwyqPOjJRws/woBVsnUQfaddm/Y7p3uJ+Ny6hLEzjY2ovYRt2ujt1/cdZnSlT7tbpCwN2EK3CtJ9qJkz5IVdg12D3O+ks9EhzPeHf9h8+89M+SsqumpFarayzYUznBW3cOq5l6vLoOQKKga12MDzVJWCA1cA0+SRuHK+uNp8yqq2LoAzE1wMrhx4kzG1wMB3FwdQCU9Rs13BCCvkQmOCuEMzpTAhuXuN/io2e0bqJ0TzwDgJILOGw== 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=pq8BsbnDfrZqeESMo1PCnflJwYLvDx1XFEkEc4GYrNw=; b=FPiFlX4xqn4ZOnWbo2Qca9jyx+UBsGplo+0afL+5xjyt7t+dbRhsGhaIV4j42bGfMa2rVyVqaodwfdI/qoaadWSrgsmo+1TALBmK6DyyaR0OZyGom9to83AfZY5+3rhuTKG4tKTHjEkmsObTrFahvHZmvO/9TfgqId9apBI6egxpz6R4m5Nl9zDtMnfVxgvOWseaN5IoK1F2xaZnNqFbkD00YHfcfteccUxho26ssdnItu/hUV+wo/0sp25n2Byoo4pAgjrxbC2jFCgkKTsaL4MfZoilpqMNLPbqrn2fwM2nG74YbOxSPvyPZf5BIrgP0PIMLw0I6oI31DXUWBhFMw== 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=pq8BsbnDfrZqeESMo1PCnflJwYLvDx1XFEkEc4GYrNw=; b=xi64paBFKJaLtaKqHbsf1NAs4Pf/rG8HOFQx821CMOVZw/orb9pWHSqRHk3govXo7C6i6+OU3eWyY5hLhGV2Qza5gGgkItlveUmRONk1ZeyCkBcI/aVIOegZV93MvD9z+BYcOqQVz9HY9GhBKw9YgVWoR7pAzP7YNjuCjrogct0= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by PH0PR10MB5578.namprd10.prod.outlook.com (2603:10b6:510:f1::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14; Tue, 15 Feb 2022 14:43:57 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::899e:951a:8129:8ef1]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::899e:951a:8129:8ef1%4]) with mapi id 15.20.4975.019; Tue, 15 Feb 2022 14:43:57 +0000 From: Liam Howlett To: "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton Subject: [PATCH v6 49/71] perf: Use VMA iterator Thread-Topic: [PATCH v6 49/71] perf: Use VMA iterator Thread-Index: AQHYInpgicPZbw0hXUOpg04Y3eiotg== Date: Tue, 15 Feb 2022 14:43:21 +0000 Message-ID: <20220215144241.3812052-49-Liam.Howlett@oracle.com> References: <20220215143728.3810954-1-Liam.Howlett@oracle.com> <20220215144241.3812052-1-Liam.Howlett@oracle.com> In-Reply-To: <20220215144241.3812052-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.34.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9105f7d7-47df-46b9-8c41-08d9f091990d x-ms-traffictypediagnostic: PH0PR10MB5578:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4502; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: XvI4Lf++eO7fbAHdmLQkX+S3pWhdxwWUuya8vuaeb+PEFAEWbNErEzvh+BUKq2v5ASsrNPaVTC40z8QTsflqGqi5cX6OwQ1B4uNi4/CjIyjRg5xqs2CyhDkBLd+kaya4qcd+QngGmacV3gY2f85/yTiK+dz1Rbv+ZgzuPMvC+FAHbn4oiJKTritplsDrjeDeA/CuwjrVDhBn3+4T6B8IDnZtAuSVkK7LLpkurF6ljcw/saNLYa14dL1TSQyKGKyrh5W3/vfnbm0UxFItPgpYRscAXofxZQwrKu/4HmPvIYJcYkYhKZg9Zq/Kv/rkkpn2nV5QeF3BLNRZwLAfQWgYRDTArJfpBwhx7WBf1k7IzMzArseaPNyG/o/s0Y8jXDEofXR9A26BL9ABIgk5IetIeLBLZOQGu1BLZEPTQuveHAGv57CLO2QxETc+xHVKVh8XHk8FZ58NqCpABFq4dsR4YcUhottByPEA6gPhiJD/X2VzeKy5k6Xm1XuPQGGwO3cuwuxFysq94C+JmxYxh/xGubHop/t3fL0Eig4rkVZkZ4MS3gtMl0nl0n7WrXjJ94GnPTaRJEawVMTqa+nFhXncBkEGMrqvvrBAQpwNo8HlDCct4nNxYUXGUzAOl10gcgBFY+vTeRK4y9aoJUzTmy4ajSB6G+3cE7g23b/GVtE+gf7I5de6C/gRFwO9QWWa8r8lhJunVYBPotl78ZVfNjJyXA== 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:(13230001)(366004)(316002)(2906002)(6486002)(83380400001)(38100700002)(110136005)(508600001)(91956017)(64756008)(66556008)(66476007)(66446008)(5660300002)(66946007)(76116006)(8676002)(71200400001)(38070700005)(44832011)(86362001)(2616005)(1076003)(122000001)(6506007)(186003)(6666004)(6512007)(26005)(8936002)(36756003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?srwOwkxeEGK+yubYn07oEX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8/5SM5213lO/rZdyWM4JyHVOAcyW6cFa4rG3PTYaeahGqGDfTYx0Ac+L326?= =?iso-8859-1?q?/8bCdLE5kZvJDtpd1+wcPlt3BtJUROfEVyon+OMKI1WQ73ZIfRwJqLBlWDEy?= =?iso-8859-1?q?tJoGaLixKAwril7rFaTJ9M3bYGAxDipX76B504v/U8FH7Dr5rhxJWOz3BKhy?= =?iso-8859-1?q?toOe4aovvlNs4xk9SzwgSEFn2fyGDJS0qmPXS8021ju+YVbfR/zTEtmTsXRA?= =?iso-8859-1?q?0WvV2KJlai06lr/3/LJ4fLVvJVcnAo37OkXQeHEJAAiPUqkpAF2/hcD9b5UU?= =?iso-8859-1?q?SD7ph8qCGXgbLm3cmcH8jZhL4JIB7pPQRVZpb62LhYuH6/T8WTpBjHLt8EN9?= =?iso-8859-1?q?3+w59956tYnFx9wrZEoIhQfgG2N3Ch/BNUDmede5fq2jCzjlx5gjH1qilQlZ?= =?iso-8859-1?q?u0kROdHHrmrYdbfWJcva4B2hVYha51BRGaggANSzwyVOxmLq2q4vCCwYkg8/?= =?iso-8859-1?q?Qv2JfQweysPukPlFvq9RvGjrD5K8vb06/sxJiwt9jqtDPblPW17uf712F2pX?= =?iso-8859-1?q?eZ1D/bqGSwbw2IGsmJPLpjYj8lalc5ZDmS5qm22PevrrSTGNC9390q42KKiV?= =?iso-8859-1?q?o2121d2/tGpIHI164r2YxK+2eQyEbjVfJ8kGz/M+yalahmHsmBFPrl3u0naV?= =?iso-8859-1?q?5Qm4fQ2+dAej1LoGUjqqCUSC3TPTlO8JANuLwHIEiv8OaF8LL6Ys6NNlNG28?= =?iso-8859-1?q?HqYkyRGD6kQxd8jAE7f4TLrShYfchdgcoV1BwHUEoHysZYBFc/sjXc5B9YT8?= =?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: 9105f7d7-47df-46b9-8c41-08d9f091990d X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Feb 2022 14:43:21.5730 (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: pc5kDjYl5/LUXijMbvv6sPA3zbN7Wtfmj3SbOzkNG26S54PXs9CvGXXXfpdIr2Ax9yeGZF2zKopna8mHfNcS0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5578 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10258 signatures=673431 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202150085 X-Proofpoint-GUID: OkSAs9nYU46-5wvSooeBqtAkPy0SXCZw X-Proofpoint-ORIG-GUID: OkSAs9nYU46-5wvSooeBqtAkPy0SXCZw Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=SJz406xU; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=xi64paBF; spf=none (imf17.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-Rspamd-Server: rspam07 X-Rspam-User: X-Rspamd-Queue-Id: 4D39B40004 X-Stat-Signature: 1otecqpaffow96zp5ohsurdh945sbfgi X-HE-Tag: 1644936242-365720 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" The VMA iterator is faster than the linked list and removing the linked list will shrink the vm_area_struct. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Liam R. Howlett Acked-by: Vlastimil Babka --- kernel/events/core.c | 3 ++- kernel/events/uprobes.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 6859229497b1..935e738a5eb6 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -10319,8 +10319,9 @@ static void perf_addr_filter_apply(struct perf_addr_filter *filter, struct perf_addr_filter_range *fr) { struct vm_area_struct *vma; + VMA_ITERATOR(vmi, mm, 0); - for (vma = mm->mmap; vma; vma = vma->vm_next) { + for_each_vma(vmi, vma) { if (!vma->vm_file) continue; diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 6357c3580d07..5dee6c41f36d 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -356,9 +356,10 @@ static bool valid_ref_ctr_vma(struct uprobe *uprobe, static struct vm_area_struct * find_ref_ctr_vma(struct uprobe *uprobe, struct mm_struct *mm) { + VMA_ITERATOR(vmi, mm, 0); struct vm_area_struct *tmp; - for (tmp = mm->mmap; tmp; tmp = tmp->vm_next) + for_each_vma(vmi, tmp) if (valid_ref_ctr_vma(uprobe, tmp)) return tmp; @@ -1237,11 +1238,12 @@ int uprobe_apply(struct inode *inode, loff_t offset, static int unapply_uprobe(struct uprobe *uprobe, struct mm_struct *mm) { + VMA_ITERATOR(vmi, mm, 0); struct vm_area_struct *vma; int err = 0; mmap_read_lock(mm); - for (vma = mm->mmap; vma; vma = vma->vm_next) { + for_each_vma(vmi, vma) { unsigned long vaddr; loff_t offset; @@ -1989,9 +1991,10 @@ bool uprobe_deny_signal(void) static void mmf_recalc_uprobes(struct mm_struct *mm) { + VMA_ITERATOR(vmi, mm, 0); struct vm_area_struct *vma; - for (vma = mm->mmap; vma; vma = vma->vm_next) { + for_each_vma(vmi, vma) { if (!valid_vma(vma, false)) continue; /*