Message ID | 20211201142918.921493-14-Liam.Howlett@oracle.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 60846C433EF for <linux-mm@archiver.kernel.org>; Wed, 1 Dec 2021 14:33:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 643D76B007E; Wed, 1 Dec 2021 09:30:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F3046B0080; Wed, 1 Dec 2021 09:30:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F86E6B0081; Wed, 1 Dec 2021 09:30:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0039.hostedemail.com [216.40.44.39]) by kanga.kvack.org (Postfix) with ESMTP id 2E58D6B007E for <linux-mm@kvack.org>; Wed, 1 Dec 2021 09:30:35 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DC8101810865B for <linux-mm@kvack.org>; Wed, 1 Dec 2021 14:30:24 +0000 (UTC) X-FDA: 78869460768.04.5986DC6 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf22.hostedemail.com (Postfix) with ESMTP id 4B20E190A for <linux-mm@kvack.org>; Wed, 1 Dec 2021 14:30:22 +0000 (UTC) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B1EP5FO018239; Wed, 1 Dec 2021 14:30:08 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=0CFRTPqyZIG6PWgVrYCXxKoKg38/V7oG5AY10sIVrDU=; b=nojI65PyUr+fRTG7Xouo6nSZ7pSiwQH8rB3CZoatDiA+1NBrgVbsaa+9iA25L4Bi3x/Q 7aq6XCDydodkAWMkeC/5uvS8BdaqTeGoVdjpg+teu5La4zXYaohokFcLBMO7kUIvLv4Z zyAz8Y+1dmEyhNGMD4vIDBNH+ON+x9k5ldnRILTQBp8anj07nhRU4S3nkb+qQQWDEgiM exoVFgBq0hDAnjQeLhDEYnZBNB3a1JieMn81Fe5cJMQw5CSUWTRs9jb3F3v76nkNneU7 ydXB6CevneDMRfo3QnKgCeYiVGR4ITvlSaRBbF4wWAcW7AY5f0PccZw4rPd9Q3hqzdrw gw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3cpasyg0y9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Dec 2021 14:30:07 +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 1B1EBMFL049269; Wed, 1 Dec 2021 14:29:58 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by aserp3030.oracle.com with ESMTP id 3ckaqgkcte-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Dec 2021 14:29:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dfQdvwTlWv9wVqugbz1wkfGDR6R8yhaskVGL9Fdm/o+THbnn9VNmRbzeRS9q8Oolhrf63HCC2um1TtXST3OLY4q72jkvWDMnGYUAYUs4nOiM3oyTijECQqO7GfyDkTuGQA8vidD2VGSPwEEr06XzWjm3qOtmS8/VkV05D6IOWxJMtrdXib6BofuUTJxzm58MarRMLr4/OGNYwb7DgprnMxQMbha7ov38p3soM52iTu9qts1079EsXq/kiDjFKp4k6C9NKkRVwzcRmo+Vl71o8nXWdk1FuyPKF+e1zQnyhg97nU/k9JTOSehqktVdJqkK8WWH9BB9WuoYpzV6jL5fJw== 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=0CFRTPqyZIG6PWgVrYCXxKoKg38/V7oG5AY10sIVrDU=; b=iYcunDz8QFF9PwWaXAZRkPargG+iVmJcJS36Vf9ZRy9MFDQ4bkDr3OTLoZyxTwV6fKQDEUZ9PPJgAICaw5IwZu7/SerIWCsgLRE/m6ytV20OABIcWIdlYiPsB1XNYGNh1OGhSu3HtfWaaSmtxE0qcBn0/i5EewAVioneDrxzFsnTWzDg/izAoICzzwAewiFJ/BMu07GpLk0NjJwaigGswVjf3DTVwwAVWvUoSlW8rZvdQfU69qiyVwAZZyQlx0M/PFMkSpfu2J4lRJD40Bd5+f3hA/5iBqXFnep7jE0rL7DlfMUCJnqLxGp/xa6snf1121Uj03ygRX8axPabEQ9VmA== 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=0CFRTPqyZIG6PWgVrYCXxKoKg38/V7oG5AY10sIVrDU=; b=kn3NNb/1YpachRapiGxM0ESIDebQBpWyWZtD9G/fd9bcvctyAxMW0/v+vxdx62HBXY+3ytTsADnHGrZY5tDBoO1El9ugONWMK3UrvJpQJbTd4KVIsHQyqJdAgODttKEbI8ahBEH/zg2rDSHIFQE1G2Fzg3JQ+cNyKKqstYKhxsI= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by SN6PR10MB2768.namprd10.prod.outlook.com (2603:10b6:805:4a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Wed, 1 Dec 2021 14:29:55 +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:29:55 +0000 From: Liam Howlett <liam.howlett@oracle.com> To: "maple-tree@lists.infradead.org" <maple-tree@lists.infradead.org>, "linux-mm@kvack.org" <linux-mm@kvack.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Andrew Morton <akpm@linux-foundation.org> CC: Song Liu <songliubraving@fb.com>, Davidlohr Bueso <dave@stgolabs.net>, "Paul E . McKenney" <paulmck@kernel.org>, Matthew Wilcox <willy@infradead.org>, Laurent Dufour <ldufour@linux.ibm.com>, David Rientjes <rientjes@google.com>, Axel Rasmussen <axelrasmussen@google.com>, Suren Baghdasaryan <surenb@google.com>, Vlastimil Babka <vbabka@suse.cz>, Rik van Riel <riel@surriel.com>, Peter Zijlstra <peterz@infradead.org>, Michel Lespinasse <walken.cr@gmail.com>, Jerome Glisse <jglisse@redhat.com>, Minchan Kim <minchan@google.com>, Joel Fernandes <joelaf@google.com>, Rom Lemarchand <romlem@google.com>, Liam Howlett <liam.howlett@oracle.com> Subject: [PATCH v4 13/66] damon: Convert __damon_va_three_regions to use the VMA iterator Thread-Topic: [PATCH v4 13/66] damon: Convert __damon_va_three_regions to use the VMA iterator Thread-Index: AQHX5r/oy5pyTKa4b0ew8xucfh+fuw== Date: Wed, 1 Dec 2021 14:29:55 +0000 Message-ID: <20211201142918.921493-14-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: 70b398c0-345f-4fc3-1a65-08d9b4d70b63 x-ms-traffictypediagnostic: SN6PR10MB2768: x-microsoft-antispam-prvs: <SN6PR10MB2768675D4695314C1A3CA7DAFD689@SN6PR10MB2768.namprd10.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Nmejyd2Qa4xYSaVV1aDr+duPrWkruifKoQjXRQs3tT2ZSEYZHa+9k/cC4LjtdLJQtvlDdZMc2oZd438Avbbtj6O8UjRjAlec+H9jbatD6ldzOOV7BCb53fMcl0T3Em82CljZNWfV1GhalRXNhbihuUNqdkEbfLyNWL8zJG8rusWob18mRIpXcl0qq6WXDr6ADsKM0/rs2oCRLp1UpH74NYYOGcsOpecElfcBWtiXP2Iqbhlld4ONSR7h4cVTODizJQemekOyKUCL5RPixTKyjgQE5TlV6eb0OOhvhdcPdB3DjAeeQiLId7DG/DOWkWVU/GnldaAbz8axoN51qLm3oS9rejFC/+47jz0tv4YtlXHmwKfBn91BPjPczrEAp1+uomQi76prgjeZp6nS3YDP5Xi8fG7sIKZ0Ca6qM6fq6VEhityqwi/Y5s/DPH/0afxpysq/L9YBrFicFnGmMv5Ijd4/1h/COpqf93yhFdPW+GIda5RFtbqYpAK6o4d+Y/AiBEDUvtydiFbbyE3Nhd1S4ni8ssfTl3LLF6vYYZsPW3iGBqV1+GRMzdBxMc1TOz/gf/cy4yADsCZS0eqFBCIcdYuCfN7ZMPpOoNFJ3tD3P3jooDjnCMx2JIwI6dNIDMLSC7YPuwUfjUkdvQuFYqpyEP8hSC68drGe33FbuaxFMU4+5owA3/ErepAvRdUchKYU6eLZftJWe/P1LJpB5SmdBQ== 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)(6512007)(508600001)(66446008)(64756008)(66556008)(66476007)(44832011)(7416002)(66946007)(110136005)(316002)(36756003)(122000001)(6486002)(54906003)(2616005)(4326008)(186003)(91956017)(5660300002)(71200400001)(38070700005)(26005)(8676002)(86362001)(83380400001)(76116006)(2906002)(1076003)(38100700002)(8936002)(6506007)(107886003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?JrsT237S1FrlTA+wI2r1jJG?= =?iso-8859-1?q?IJOjMJnYaCy0hwyqK0AGYxbaH2x5e5eUuofF6oAydC9VlLlBxTuFT/DI6YO5?= =?iso-8859-1?q?qjLf91FwbaN5GGRN+FlftbD+Yvj5A99cYzqbLJLmRX8XFEGK+lH/2bbCRezV?= =?iso-8859-1?q?k/6oFHauitz02UmtxZxV7sqtgb8NaAt646xP4C8sVTRhPqP0TafLbkpggMQB?= =?iso-8859-1?q?Nce4E+2hI3h/SCic7+WQujrw/PvnPDi2pibjaPO2mC5QUtMTr/3hHo0yVLli?= =?iso-8859-1?q?0LHb+pAZX6DyTzZ/ZN9smfes1DD+e5XfTt89cYGUg5mDjUqNnUC4Z3m7Zdqh?= =?iso-8859-1?q?gzmXOGTtbcl4vBSfDDkgXwMpOmlbD7L9o2uxOT1BCG84dVAjKaSKBnOXHW6H?= =?iso-8859-1?q?PGktD8nqYhdZAoVhXBpMMKi4dH+CMG2EIK5NYyIZ1luzPp/CFVBeDjewLCS2?= =?iso-8859-1?q?eB9Ni1c4ZS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B0LAqKB0PZySKtInnj/?= =?iso-8859-1?q?hzoG2LvqHBA0e9QaoIMgWJQE0Z/BC+xAKry4CWqQfF7ZF72X0z9YVKMh0vNr?= =?iso-8859-1?q?wuXyPd4BE5zgeSxfPCOJGUO8mbepUxXKx9EL4ZUMgXEmkOU/SJfpDei5mRJF?= =?iso-8859-1?q?KIbvEVbTP5qeO2tldGAVSlLGHuxy/z25He+88UNXURULkxA6g19JXWpYsaJT?= =?iso-8859-1?q?mYUuCsEtYJjNKtogAXAHedjBPuT7kWuyFw5XwpiAHBggBu6pZd7TDOuthM2b?= =?iso-8859-1?q?Yth81WBieo5wMaTHFL2udQEvf0y3guUeRYqnesmvJsqlUrrgfRReyr2oB4hY?= =?iso-8859-1?q?=3D?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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: 70b398c0-345f-4fc3-1a65-08d9b4d70b63 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Dec 2021 14:29:55.0728 (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: ruMEAtU0DdlCjIyk/fCdHExsdU4bl+YeF74sDLVTA2c+0mfddqTgwYWPDGNfVQW3V9Xxx853+ERFCI7tw6Y1KA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2768 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10184 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 mlxscore=0 suspectscore=0 mlxlogscore=970 spamscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112010081 X-Proofpoint-GUID: 8qdqm2jyZbOVbXyWP0sAHH-NJj_oBidi X-Proofpoint-ORIG-GUID: 8qdqm2jyZbOVbXyWP0sAHH-NJj_oBidi X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4B20E190A X-Stat-Signature: sn3gi36rhkj7modfp8qqgujay5sjw9mp Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=nojI65Py; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="kn3NNb/1"; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf22.hostedemail.com: domain of liam.howlett@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=liam.howlett@oracle.com X-HE-Tag: 1638369022-205639 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: <linux-mm.kvack.org> |
Series |
Introducing the Maple Tree
|
expand
|
diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 35fe49080ee9..906eb8d0c640 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -120,37 +120,38 @@ static void swap_ranges(struct damon_addr_range *r1, * * Returns 0 if success, or negative error code otherwise. */ -static int __damon_va_three_regions(struct vm_area_struct *vma, +static int __damon_va_three_regions(struct mm_struct *mm, struct damon_addr_range regions[3]) { - struct damon_addr_range gap = {0}, first_gap = {0}, second_gap = {0}; - struct vm_area_struct *last_vma = NULL; - unsigned long start = 0; - struct rb_root rbroot; - - /* Find two biggest gaps so that first_gap > second_gap > others */ - for (; vma; vma = vma->vm_next) { - if (!last_vma) { - start = vma->vm_start; - goto next; - } + struct damon_addr_range first_gap = {0}, second_gap = {0}; + VMA_ITERATOR(vmi, mm, 0); + struct vm_area_struct *vma, *prev = NULL; + unsigned long start; - if (vma->rb_subtree_gap <= sz_range(&second_gap)) { - rbroot.rb_node = &vma->vm_rb; - vma = rb_entry(rb_last(&rbroot), - struct vm_area_struct, vm_rb); + /* + * Find the two biggest gaps so that first_gap > second_gap > others. + * If this is too slow, it can be optimised to examine the maple + * tree gaps. + */ + for_each_vma(vmi, vma) { + unsigned long gap; + + if (!prev) { + start = vma->vm_start; goto next; } - - gap.start = last_vma->vm_end; - gap.end = vma->vm_start; - if (sz_range(&gap) > sz_range(&second_gap)) { - swap_ranges(&gap, &second_gap); - if (sz_range(&second_gap) > sz_range(&first_gap)) - swap_ranges(&second_gap, &first_gap); + gap = vma->vm_start - prev->vm_end; + + if (gap > sz_range(&first_gap)) { + second_gap = first_gap; + first_gap.start = prev->vm_end; + first_gap.end = vma->vm_start; + } else if (gap > sz_range(&second_gap)) { + second_gap.start = prev->vm_end; + second_gap.end = vma->vm_start; } next: - last_vma = vma; + prev = vma; } if (!sz_range(&second_gap) || !sz_range(&first_gap)) @@ -166,7 +167,7 @@ static int __damon_va_three_regions(struct vm_area_struct *vma, regions[1].start = ALIGN(first_gap.end, DAMON_MIN_REGION); regions[1].end = ALIGN(second_gap.start, DAMON_MIN_REGION); regions[2].start = ALIGN(second_gap.end, DAMON_MIN_REGION); - regions[2].end = ALIGN(last_vma->vm_end, DAMON_MIN_REGION); + regions[2].end = ALIGN(prev->vm_end, DAMON_MIN_REGION); return 0; } @@ -187,7 +188,7 @@ static int damon_va_three_regions(struct damon_target *t, return -EINVAL; mmap_read_lock(mm); - rc = __damon_va_three_regions(mm->mmap, regions); + rc = __damon_va_three_regions(mm, regions); mmap_read_unlock(mm); mmput(mm);