From patchwork Wed Feb 2 02:42:04 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: 12732530 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 E151AC433EF for ; Wed, 2 Feb 2022 02:42:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6DE98D00AE; Tue, 1 Feb 2022 21:42:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ACC798D00B0; Tue, 1 Feb 2022 21:42:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BBA68D00AE; Tue, 1 Feb 2022 21:42:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0005.hostedemail.com [216.40.44.5]) by kanga.kvack.org (Postfix) with ESMTP id 5D8B68D00A3 for ; Tue, 1 Feb 2022 21:42:12 -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 2B26195AFD for ; Wed, 2 Feb 2022 02:42:12 +0000 (UTC) X-FDA: 79096290504.29.DFD5EDA Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf29.hostedemail.com (Postfix) with ESMTP id 7E3C0120003 for ; Wed, 2 Feb 2022 02:42:11 +0000 (UTC) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2120QIZZ015788; Wed, 2 Feb 2022 02:42:10 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=gm74/0iA/LIx90egKsskfSSmwq94iUjGww9YFu9eATc=; b=rLsa+PsHTRPKOSxex6rf/JIBgKgzs7Q7l3Y5E6HzLSVYJA6BfYKc9xNB0bg70B6aPKf3 vqp2KlmHPFqYT149AmzjTqPqhVTNdh2hAXBtL1jemx/TuGJBa69mGVvGnhT8cp6A3SEJ oP3oVrHtpLltbymyky7o/0uXOwjDW0ShMU7D104Dcqy81kggJbxYye80kq3RHmOxztLx mbpzx4HzZTpCP2JQWOc0XLtRjhBjH71v7HkTha5pkx8yBhdTaSYRCDS3s6MhB33h4I6m 7B8yhAZ7fYlTe6W0TFwaRMxxpvZCL9MFjenFc02LtYsO7iUKhB5QkO7qjoWh6snPxzGA YA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3dxj9wcnvb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 02 Feb 2022 02:42:10 +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 2122ZvkP015152; Wed, 2 Feb 2022 02:42:09 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2047.outbound.protection.outlook.com [104.47.74.47]) by aserp3030.oracle.com with ESMTP id 3dvumggtjf-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 02 Feb 2022 02:42:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fAnFN0E8zayh+qtK5DLyjku2Gg0wQVx1mZmPFrE5OPDRfBDXZY/ExrDm2AYNZZIGgiJY1s2WFCn/wY2fR2oZVNjkcqIrJtYjzJecBQGveGz6XGBclDw8YZcntuphSi1kYusJXL0zFxMMFTgJQzu5LMdDIANnqhz2jT2j3JFFzOHGD51IRNtfwHt6Va4B5Lbg5vEieGbPChiQFDs4YVAsdyj1PIuFiari8C+MgTP5denpZAgQiza3A51hjD6e1tZGNr6aYFSQSVemOdZ1X0Ke8j0qdo+kii8fXyXMoh2pKO43aDK1EEZFe/DHraQjdlM/jgKHbygQa2KzGGfVL6eewg== 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=gm74/0iA/LIx90egKsskfSSmwq94iUjGww9YFu9eATc=; b=AkODs07yImVjKywAmcPawDQpk8pziWYzJm35epO376AXWDHWmgik9AcwmkEdTXLaN3XTaDWnXQdl7Bgu7/d0gpRAiL2PJ6S9aRlbx9BKyKjA01GDIJeSX9PHBgG5UU8RsYgq+VPTqlW/R5SrUKJM48T20HPxDD52347KJpVDe6QnGH5aaFisZJ6/89Mb7XOPasR3sNdHP9zDmGAavY5H9kS4NCdqNlA57KneH5T9kBnHKgNEKkBycPjovQ0C5zu4w+St0gRa/JDXA8Epj/hGq+kfdC+O4alISv4dRbjdqwri81DamnQO49A0UTN42AYHJ0NQJyaUCLDNbPacb3Ve+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=gm74/0iA/LIx90egKsskfSSmwq94iUjGww9YFu9eATc=; b=vOrGy/yZARQs+QvdLASmd6WSkRQ07Ps1vhA+xVxVFGR9KhydZuCQgCXEQ78c7ITp71ja+h4t+ckjZFpJnTSNEK7kgdyEFWvExPAWKGLkW5JL6+lv2ss5UkZZfTMgBdJRZ5pO3DCKXmBhprXZvajIwd60DfQ8FrVhBLijaq/rGjY= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by BY5PR10MB3970.namprd10.prod.outlook.com (2603:10b6:a03:1ff::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 2 Feb 2022 02:42:07 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::3857:3a25:3444:fdd3]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::3857:3a25:3444:fdd3%5]) with mapi id 15.20.4930.022; Wed, 2 Feb 2022 02:42:07 +0000 From: Liam Howlett To: "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton Subject: [PATCH v5 17/70] proc: Remove VMA rbtree use from nommu Thread-Topic: [PATCH v5 17/70] proc: Remove VMA rbtree use from nommu Thread-Index: AQHYF952iyomoc3ocUKtj4dQGcgWYg== Date: Wed, 2 Feb 2022 02:42:04 +0000 Message-ID: <20220202024137.2516438-18-Liam.Howlett@oracle.com> References: <20220202024137.2516438-1-Liam.Howlett@oracle.com> In-Reply-To: <20220202024137.2516438-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: 5217ccff-998c-433b-9d32-08d9e5f59a99 x-ms-traffictypediagnostic: BY5PR10MB3970:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: FN2Byk2sPoCTVnDeZX6eOQxaCe7n8cHllzekGs4KVkGU4tkKCMA7Y7A2bJnF21td61YgqihO+bL+wdhW/vQh2Wfd27r3i6d39Qp5hl3/U+d2OsMdEJFLfqsR+GbC3UyNJwck5z50b+p4LnH2nr45VXbNQu1jatdfiEr8n82eZOkOuPcZ3TWieBPefTGgKjfMwqznRBJFmRLSnXdmJ30lXUjfYxRf8XoR1y1EsokLqZy6L9jZLWAHefuewXI6go51Wzt4NquJvKJjJzbchnP4weHxP0TxjgU1l89QYCXQvBvfSx1f2zsvtYY7uAN3JISEUzjIYYKJU+WJclFe+kgAZ54F8QMcO8ZuqKofuVDBLtca1meN4irFen9+uHqN9J/hrgfB1vX7Or27PdcgxA/VAS6gcvN6saHk59R3gcN3/gA/+yZcNRtuUDHw0Ja1hcZeYfCt3Etr/XjANnnFzSB3/0Fq7oCx8uQeMG0589/8i5SlWLsBFJjN5OP9/5VnHd3FqocOnY0ZPIcS1J0Dny08KGeFMCzFfGz8FnejC5Rgvo6SWLhVSbuCUu7HEPHNy68+FhD/M7tqypjBK80eW5N4BSFszcBA63hIzngNvuBcWHWYtEYOzcDQj15Hsi6uCsM/+8SoV3CT0KzyvuFtvNWV6DXTMLa6A/9QzZeAQfGmB1UK5YBnZo6+Yc7aUmP67rJ8NdlOgB+hyBp/as441QquLQ== 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)(8936002)(316002)(110136005)(44832011)(2906002)(186003)(66446008)(8676002)(91956017)(66476007)(71200400001)(508600001)(76116006)(6486002)(26005)(66946007)(66556008)(6512007)(5660300002)(6666004)(6506007)(64756008)(83380400001)(86362001)(1076003)(38070700005)(2616005)(38100700002)(122000001)(36756003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?tqvzwUYP/yc8AUm1jcEkdF2?= =?iso-8859-1?q?CgMsDi5/35gWst3MmkTPV+DzkxUl+2c0JVAXF5cVPGRlfqvoerZneJCVGqFd?= =?iso-8859-1?q?n6a6ZAmDwdzsPk4ghxnOB2LCUF2wvk1T14ddS2D/ARltRgSy+klx24uplhgC?= =?iso-8859-1?q?SguIs5yPgjLQsJFVWPiuAJS/m0Kvs9NI08d9c9g5bQItS2n9NF6rmJT1ubQ2?= =?iso-8859-1?q?44x/Xvw3nW/WWU1r+jvCFkxEsT0c0GKdXUoMdHpfSudCOZyNf5BXVf2g8M9F?= =?iso-8859-1?q?0F8NnminwqXfGj8ZZ3gAwcP7UqjVGQm2esDvLPmLEu+9mHV+Tbj7SdiIhEQI?= =?iso-8859-1?q?8dx8a+cV1eJegV1EqD7stfJJXxcsCQEHzO8Arl2Rjdo+/vVjiB3XiN5XQDUy?= =?iso-8859-1?q?e9ksadattdJUPbBiRKyKHRN1asGdt7CEw/3eKjS3WQvXExdcDP9VSLNUXrgl?= =?iso-8859-1?q?PPlckGNJ9LZBv2VTREH0gT/CCf2cbpAikf8dLGU0XMqlRTQ/lZWbtQl6FffC?= =?iso-8859-1?q?tZ0ke7dAtGjKNGP8RR8W59hK3z9FAtVv8yY4xvJlONsZHGZejwHIkhVqEwUK?= =?iso-8859-1?q?WjSZWS1K+X+lO62uPATjAXTBsC90Qbzk0mnWs17tbs3ateXn20YICzM02jom?= =?iso-8859-1?q?jTW4q5CqEB7CSxLDBW+yyhS6zpGnt8jQvECgcAD2cBdIn6+4igaORMKvl6EN?= =?iso-8859-1?q?GkriyPu8NMIjsBuuyw7GxS9GtB/tp1wfaD/2IP45JBPdqiIP5/Gdi1ocijBH?= =?iso-8859-1?q?j/YIviXh46g5FfqX5fX4styz5/t6T+vyfatcprCeU4mIeVND2zQq793IhRXe?= =?iso-8859-1?q?JpKLb4mDneLAq2XXrnct5yBFSiToaWuUolWqfc7RrqNsoaPzwingNuFh0n6V?= =?iso-8859-1?q?EMa4UFQ16hFTcxwT0olQqTtzzQYpkH5LdjrnY0nl6IGUr5qDRS8m0UDjrgSr?= =?iso-8859-1?q?CeXkGiNlm2IfLEb45FQzgKq1lQJ7ktH2M1HF8AZkVXCb3fCLq2zbamBop3jp?= =?iso-8859-1?q?oLYBPpnvwEN99Gn66P8B/WsxfWfjw8zioSrnNYXBE9ZH3Q+3lBEgyQwl4DB2?= =?iso-8859-1?q?IfyOMuJSWtit0Cay5GGReumUtxTiRbMyJ9elPf0vxkKQhWUpDkgS1FFcx1sg?= =?iso-8859-1?q?oouD4Jocv6yKwEOZQNGardXZUzrVo02mmN82+Bh9X9/EADN64QPk+RPMqYC4?= =?iso-8859-1?q?FwPeWFYMy+qYVGknzIuwnycJ3oMDrImpoYF+vl+Rz7V84dwdZ+UlBMggCTs+?= =?iso-8859-1?q?j6no3UlENfcj4BX6dknydHj07CciqBthlTDOWSxSvxycXrKU7/vVik9WbkDT?= =?iso-8859-1?q?R5uLId9kGG7jUKArQCnfYT0+1Y/vr4yZVT/kN+hvNj98cuQ6im3BMoBQIN9w?= =?iso-8859-1?q?w2N4JUPpj/4+f0tmaoe7LgDZbuMe26KkYn6X9V7huGPl4m3QUqLyUkDkoiGx?= =?iso-8859-1?q?wvbIe0szSXFuFm4P2r60h3sfOfwS16XZUAukhguuneZPlKs2TJMmFzMT71NA?= =?iso-8859-1?q?0eCLYO3NG01IEo0MicsyoQfO7ptbQPsflK+kZC12VjdjhgX8re5bR3AsmbSO?= =?iso-8859-1?q?w78Pcr6JMVaAKZf73yhVCDxYdL5q4hqLitTdCFQIALLIkaTDXmw+65BaGsuz?= =?iso-8859-1?q?dHG1vVirwfOsbEAKsoDDHinrl5iQUoqnQvvuxcM76Xb3HkE7UvzumZ3SwbUk?= =?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: 5217ccff-998c-433b-9d32-08d9e5f59a99 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2022 02:42:04.1894 (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: tDSHfTFDC60x0o3UEKCoo/K9muW1UbZQUcug13UFNTIdAngQi3ACKCU2moZ3pisCH3OBh13grsxljL2YNSlsww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3970 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10245 signatures=673430 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202020010 X-Proofpoint-ORIG-GUID: qi4_4teUtBO-tW2zdtX_aPYICR4ZVSh_ X-Proofpoint-GUID: qi4_4teUtBO-tW2zdtX_aPYICR4ZVSh_ X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 7E3C0120003 X-Stat-Signature: uzc3yej5dq7s9cyhrryenwomjex4ufcc Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=rLsa+PsH; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="vOrGy/yZ"; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf29.hostedemail.com: domain of liam.howlett@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=liam.howlett@oracle.com X-Rspam-User: nil X-HE-Tag: 1643769731-187436 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: "Matthew Wilcox (Oracle)" These users of the rbtree should probably have been walks of the linked list, but convert them to use walks of the maple tree. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Liam R. Howlett Acked-by: Vlastimil Babka --- fs/proc/task_nommu.c | 45 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index a6d21fc0033c..2fd06f52b6a4 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c @@ -20,15 +20,13 @@ */ void task_mem(struct seq_file *m, struct mm_struct *mm) { + VMA_ITERATOR(vmi, mm, 0); struct vm_area_struct *vma; struct vm_region *region; - struct rb_node *p; unsigned long bytes = 0, sbytes = 0, slack = 0, size; - - mmap_read_lock(mm); - for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) { - vma = rb_entry(p, struct vm_area_struct, vm_rb); + mmap_read_lock(mm); + for_each_vma(vmi, vma) { bytes += kobjsize(vma); region = vma->vm_region; @@ -82,15 +80,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm) unsigned long task_vsize(struct mm_struct *mm) { + VMA_ITERATOR(vmi, mm, 0); struct vm_area_struct *vma; - struct rb_node *p; unsigned long vsize = 0; mmap_read_lock(mm); - for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) { - vma = rb_entry(p, struct vm_area_struct, vm_rb); + for_each_vma(vmi, vma) vsize += vma->vm_end - vma->vm_start; - } mmap_read_unlock(mm); return vsize; } @@ -99,14 +95,13 @@ unsigned long task_statm(struct mm_struct *mm, unsigned long *shared, unsigned long *text, unsigned long *data, unsigned long *resident) { + VMA_ITERATOR(vmi, mm, 0); struct vm_area_struct *vma; struct vm_region *region; - struct rb_node *p; unsigned long size = kobjsize(mm); mmap_read_lock(mm); - for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) { - vma = rb_entry(p, struct vm_area_struct, vm_rb); + for_each_vma(vmi, vma) { size += kobjsize(vma); region = vma->vm_region; if (region) { @@ -190,17 +185,19 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma) */ static int show_map(struct seq_file *m, void *_p) { - struct rb_node *p = _p; - - return nommu_vma_show(m, rb_entry(p, struct vm_area_struct, vm_rb)); + return nommu_vma_show(m, _p); } static void *m_start(struct seq_file *m, loff_t *pos) { struct proc_maps_private *priv = m->private; struct mm_struct *mm; - struct rb_node *p; - loff_t n = *pos; + struct vm_area_struct *vma; + unsigned long addr = *pos; + + /* See m_next(). Zero at the start or after lseek. */ + if (addr == -1UL) + return NULL; /* pin the task and mm whilst we play with them */ priv->task = get_proc_task(priv->inode); @@ -216,10 +213,10 @@ static void *m_start(struct seq_file *m, loff_t *pos) return ERR_PTR(-EINTR); } - /* start from the Nth VMA */ - for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) - if (n-- == 0) - return p; + /* start the next element from addr */ + vma = find_vma(mm, addr); + if (vma) + return vma; mmap_read_unlock(mm); mmput(mm); @@ -242,10 +239,10 @@ static void m_stop(struct seq_file *m, void *_vml) static void *m_next(struct seq_file *m, void *_p, loff_t *pos) { - struct rb_node *p = _p; + struct vm_area_struct *vma = _p; - (*pos)++; - return p ? rb_next(p) : NULL; + *pos = vma->vm_end; + return find_vma(vma->vm_mm, vma->vm_end); } static const struct seq_operations proc_pid_maps_ops = {