Message ID | 20220215144241.3812052-59-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 4434DC433EF for <linux-mm@archiver.kernel.org>; Tue, 15 Feb 2022 16:00:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FB276B0078; Tue, 15 Feb 2022 11:00:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9844E6B007B; Tue, 15 Feb 2022 11:00:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 760B36B007D; Tue, 15 Feb 2022 11:00:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0019.hostedemail.com [216.40.44.19]) by kanga.kvack.org (Postfix) with ESMTP id 60E2D6B0078 for <linux-mm@kvack.org>; Tue, 15 Feb 2022 11:00:48 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1FED694FBC for <linux-mm@kvack.org>; Tue, 15 Feb 2022 16:00:48 +0000 (UTC) X-FDA: 79145477376.21.3D52E96 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf31.hostedemail.com (Postfix) with ESMTP id CA33C20013 for <linux-mm@kvack.org>; Tue, 15 Feb 2022 16:00:46 +0000 (UTC) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21FEhxcm006513; Tue, 15 Feb 2022 14:44:08 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=tmGIdJkibtbU1A2f/iYrQfNi/bAe/Pn/qRenGK9KFF0=; b=LxD1Q2TVqzYoUzyowg2J3k2VjS/lZL0/XP9M6khyD6yhUI4WDRl1ebrvMB46WMPAe+98 sM68kJotoJkrqUk9160dNtnlUgwxVxKJvPuzBlUa5jUf+dgJJen1/MQz8n5dUwwJMJgJ CtDN21lN32j6SqZhTM6ljcFKzoZmUVDHCRrVFLgs9FZVEq376EFkCJJ/xyRPKPG1rHJH +tmh+f2gFYFkYQ2wMCeDYvzlRplzDGKsQwiut1ZsflQq49YwEAvzDLTHBlLzvPOrBian xeH/aIDxISWFMVJq9w11bakGlE6+3D51SroyBScUBvBeN55YaYsVa0w1PgSilP6RKjZu jg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3e86n0hge3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Feb 2022 14:44:07 +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 21FEf8ls016243; Tue, 15 Feb 2022 14:44:06 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2176.outbound.protection.outlook.com [104.47.58.176]) by userp3030.oracle.com with ESMTP id 3e620x7vn0-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Feb 2022 14:44:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EXvmeaOHgHr2xTTg/Nx0BruWwsDeMZ7EY93ueTY2e9lZzDlqgDuu2581QnAVDqcgAYPYe7/K6V13t4du4fQ7TU2cxtdjIbTsxNNNqZrL84k1kPaE+t8vUhQCOuEaCIA+GWaMbqVOzy+vndyQj+9OTAgwCKwe7bnBuOuYmKjOpw4874cq/EBFhy7CxLsx2Dfgm2Jy1E3rYqN60z0BO/kvIX8OhgilFS/C1skTqXD+Wzim3BUBDf5SQnXWmYcMmTzjMwwA0JzTQ/OwGleW0k2P/PFnSuoyMzNh/HawUbdtkHpu7/GBJAZvvave99IsGJBNHmqAwJPu8DJHMiYnrbHaLg== 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=tmGIdJkibtbU1A2f/iYrQfNi/bAe/Pn/qRenGK9KFF0=; b=Gxzj7lEmh0CkOhmpHg4sEVov7SGVm1Yffq9bnBCnWDHXbjlyh+p1WN1+EsAMG6nKQFKuDLxyWUC48lSbfglg5FMqihGMzpJnbBEB7am8PuN+MdCv8aUtRSczEyUtiwgftkdAL0gQ7QmEaKxfReJwk6ZMgOgFYRGych4MfkqrjVrv3DfI/Txwc91Dpr2PczEot8kCg3xCxAj27cHwIWWLPJRbO6MzkXnaLW9DC3Lxic9HqdkimDHLEyNHsD7rZpPeBWJkcA/RPrsG9RlEO/moCB2qzQgo98XqHOlMXYKEpkae9BU7IsfCVGsFEjfOQsuyKFzLRtXb4CH0lltlxn0HVg== 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=tmGIdJkibtbU1A2f/iYrQfNi/bAe/Pn/qRenGK9KFF0=; b=ft5SHbxYQwKsuQPZ6u1mMgaEVpswaCKFQAgVZd3gcN3Nq9g1mCtnHFU5dtaaeELRQJthw3s4qQi1s01yNU7zIdScCA8OKWGT24L8Olge5BAkZnPRNN+HY9WMmUxCDZxCnDNNZhz4SkHLZNUc5/wXvMoVz/IdHbns9Yn6KBul8b4= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by CY4PR10MB1863.namprd10.prod.outlook.com (2603:10b6:903:11e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Tue, 15 Feb 2022 14:44:02 +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:44:02 +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> Subject: [PATCH v6 59/71] mm/mlock: Use vma iterator and instead of vma linked list Thread-Topic: [PATCH v6 59/71] mm/mlock: Use vma iterator and instead of vma linked list Thread-Index: AQHYInpjR0vSFFjma0i1OBiMgB+3sw== Date: Tue, 15 Feb 2022 14:43:25 +0000 Message-ID: <20220215144241.3812052-59-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: f27e9851-8a5c-43c9-fea4-08d9f0919bb4 x-ms-traffictypediagnostic: CY4PR10MB1863:EE_ x-microsoft-antispam-prvs: <CY4PR10MB1863704926B42C177AE8DD45FD349@CY4PR10MB1863.namprd10.prod.outlook.com> x-ms-oob-tlc-oobclassifiers: OLM:1417; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Nc03MnqI7UcfzgLoakME9laWDXQ1bftU58z0gfjPKK8v7TCQRiUaF77XegSh2qCa8hlRI7d2scpNgCCIyJ4TmbOuQUtmQIVpr8nnnXNTTfImoJTP2gCM2yHI1qJcUqvSqRn/kmM00xFczvMGD6NCED7fS4qvuV+C8iLwQDZPRefNJSC0UHJl0hiDGu+5zLHx5T5OlHNzvV5DjU1b5DtGR/DbES2Rd0udPvC2+VZ/oOf6DpoablLFJ3gex9NvtSwp5eBN0jT5d1S05Jsk9BXjcePJPEDiPNVrv/Eo6f3Eosss0/jxtkVIKA5VLDIEFgB0FIpPEyX+nS6WRJ4PHM1zsSc7XbpNRJZGhnJfwGa7t4au/TSnMTTYyZZSeOV9FUhZt0n9flOg2hXk5hEEKseLMi3hYHfLWCyC/BkRzSuKKcAjoq+3+sGfIgeOWgy98nznv/T0GoVXTqXA4dhq4nsBb18CfxcESiWwI9+0CF8tCwF8zx+9QJqaK//kO6iHlUs5d8/sTYEqF+DMnY78kSc3GXs8Q59lug4qfC8wu6Fn2LutzPfIhkdDxDmmdkwLFu2SuYnnPcIvtfW0umwzMvtGUlxTQLlEMIu8cqR2Y5f42WrC0j48/TdB0X8vsvSvfvzUj1sdWGGZYtri2xXzcpM8Y37/FQO12Fa9xEqTGwNtWM4DOcvgLMziCPwRVMPaHcEIZvCLY/6Azf3fCyQfQlGDNw== 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)(66446008)(86362001)(66556008)(8676002)(64756008)(316002)(2906002)(44832011)(122000001)(66946007)(66476007)(110136005)(38100700002)(76116006)(91956017)(6486002)(83380400001)(1076003)(5660300002)(8936002)(186003)(2616005)(38070700005)(36756003)(71200400001)(26005)(6506007)(508600001)(6512007)(6666004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?O8bR3QJKBpJftLPsuSkZAjd?= =?iso-8859-1?q?H8xgKfCrE69pJ5swt5Fv+yrRgRzRDS/R1GibJSMN2xHpOnvZKp/OfHI8nQAc?= =?iso-8859-1?q?cJsBw5mr7ZYrtwTqo+KELgEJkBDxJDgZVli4gQeU8t9YtcpaVPckw+MXz+XH?= =?iso-8859-1?q?DPIsObghIQhkRKSJpfMVwpVXRdsgx+kNpM0pg+g+SsjUsusD3gC1YQWWmMki?= =?iso-8859-1?q?Qb4mu5WM+8V+pq42VwSS3I6uJtmHnh7NCqakHSlIjB0HjQix/kdYbhjC2Pc4?= =?iso-8859-1?q?oprLJRKTW6TQow6me7wm3Y4LuJ0lhLJPu6tlk3REa2vuLTfqlNp0Qcs6DzTV?= =?iso-8859-1?q?2Cyn7mNhhxFK9HOqyhYDPO5QhcqxaRAfopUJFpt42iOzYJDcDlzGdRtS7g3M?= =?iso-8859-1?q?Y9R2ZsQgbMZeknrKXjR6dXpu/VOCrMyABM/7QPP4MJySj1+yEgX0PPeUpU60?= =?iso-8859-1?q?p9zT7brKoULUOLGa9vomQ8o2pcia4RoKro20w8hXhLMClBi+Mj4d4ICiB/w2?= =?iso-8859-1?q?MlksYc9VTsJ5KRVg2lhg33upBEumf1m105RqkHg9ZkPfRwsNiuIVzQy9NI6w?= =?iso-8859-1?q?1nyDEVW38L35kN1noYExCZTsU0930FrDfKDwm+UU+zSqyAKow02/VRSYRFmb?= =?iso-8859-1?q?l6AR6w/qhLFFjuM+SiUik/0BzZwBzLSUCTUwcu1/KSETcboslFCIs5EKgepm?= =?iso-8859-1?q?glOobmo3Meq9W9ATfSeCCEe4RzPgIxbMxgEgOjxq3hhCtzzTJEsmRNTKVx5S?= =?iso-8859-1?q?UdgNb/Unz7eGLethfEBnZeyKNGT7iE/ElmISb7+8hkDMFVulF/TC1HnK1qBv?= =?iso-8859-1?q?L1HHdPmE8AGLUDGrmDzZSYY2TmHTcBW7Zjqk2fn922fFZ8TWJKvHpDQJbDPv?= =?iso-8859-1?q?Mxm6XNVBKZKk9Kmv/fVjUS45Unba9SbXRNazgMRl7nhkhECsTtsLQXWtaqBe?= =?iso-8859-1?q?h7EX9fYKXw1QNnknMgs59Sn8+Mxi4bnWHtUGxOiKh9rqyoI9zjau6d1H4/79?= =?iso-8859-1?q?UYynLQyvxll2W60Yew7rErKyisLzZ/bDfKGA4fqnhZ0tAqJFayY8PE3Hsl8p?= =?iso-8859-1?q?1ZcF/ORAhUaSLIyW/In3y7Ef2WEb5YUcn9mqXlayxKezHqzq2eQcn045U9hy?= =?iso-8859-1?q?aVuiX8Jg1FV9wo/u8VUvYeAjujNS2cpUBqhlPXg4unFlsNded9HP9is8HgC6?= =?iso-8859-1?q?ZV03y9lEw2+kCGdlOz2KLibdQXBATR+hMhzlLR9n43hgGzL/CdKimAQX+a/4?= =?iso-8859-1?q?DuRx0yb440E40BJKxWWlT9U7AyFOMvNEB8VsiJ4KjbGZSZGz7zn9K8rJ6YvQ?= =?iso-8859-1?q?KtjFCS7vKsoCY7lEDO7wqpJGz5bXp5gP8UEO7qVXfDql2WOGOEbIBFqFbN1y?= =?iso-8859-1?q?taIKnRgyr15dVWRElwq3EGOdgKxrYhidTY28Tfr7rkUVRGPIzDCaa4lOdPeE?= =?iso-8859-1?q?s+wpPiMJg2ZYlZhF49t0odbWPsPCOzQhiXuUODRhplRbSRG69eYNSVOUaTuP?= =?iso-8859-1?q?RmkDe+d2PeAdxgpySPNtulb+4jZMhmm/039fosuArYlPbbhES/HICPniGAY5?= =?iso-8859-1?q?r8gg3ghnQnDViH/GovI3MVqNub17DnRStrtuMPkNHsdB2XIFTQYMuMzxOoPG?= =?iso-8859-1?q?PEDmROAAB4w88ADflLDJNryfB3vj6dgL88d8nx/u2KhiEoffGAsmyAdoDG7Q?= =?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: f27e9851-8a5c-43c9-fea4-08d9f0919bb4 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Feb 2022 14:43:25.1509 (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: Vz5FnkCxodEv1MgThb80n67gbJx7q/wqaEtRrk2LOxUAjsxdPyErxeWjvapImn0P8BhXJjUxvRbCFumAI8eUFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1863 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10258 signatures=673431 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202150085 X-Proofpoint-ORIG-GUID: g7Ur0NOtgiNmf0CuvTqyk-cOiA_UE1bk X-Proofpoint-GUID: g7Ur0NOtgiNmf0CuvTqyk-cOiA_UE1bk X-Rspamd-Queue-Id: CA33C20013 X-Rspam-User: Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=LxD1Q2TV; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ft5SHbxY; spf=none (imf31.hostedemail.com: domain of liam.howlett@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-Stat-Signature: ashd76y8nm84zipbf76te53qr34ta6cm X-Rspamd-Server: rspam03 X-HE-Tag: 1644940846-296441 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/mlock.c b/mm/mlock.c index 8f584eddd305..8d54f355080f 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -563,6 +563,7 @@ static int apply_vma_lock_flags(unsigned long start, size_t len, unsigned long nstart, end, tmp; struct vm_area_struct *vma, *prev; int error; + MA_STATE(mas, ¤t->mm->mm_mt, start, start); VM_BUG_ON(offset_in_page(start)); VM_BUG_ON(len != PAGE_ALIGN(len)); @@ -571,13 +572,14 @@ static int apply_vma_lock_flags(unsigned long start, size_t len, return -EINVAL; if (end == start) return 0; - vma = find_vma(current->mm, start); - if (!vma || vma->vm_start > start) + vma = mas_walk(&mas); + if (!vma) return -ENOMEM; - prev = vma->vm_prev; if (start > vma->vm_start) prev = vma; + else + prev = mas_prev(&mas, 0); for (nstart = start ; ; ) { vm_flags_t newflags = vma->vm_flags & VM_LOCKED_CLEAR_MASK; @@ -597,7 +599,7 @@ static int apply_vma_lock_flags(unsigned long start, size_t len, if (nstart >= end) break; - vma = prev->vm_next; + vma = find_vma(prev->vm_mm, prev->vm_end); if (!vma || vma->vm_start != nstart) { error = -ENOMEM; break; @@ -618,24 +620,23 @@ static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm, { struct vm_area_struct *vma; unsigned long count = 0; + unsigned long end; + VMA_ITERATOR(vmi, mm, start); if (mm == NULL) mm = current->mm; - vma = find_vma(mm, start); - if (vma == NULL) - return 0; - - for (; vma ; vma = vma->vm_next) { - if (start >= vma->vm_end) - continue; - if (start + len <= vma->vm_start) - break; + /* Don't overflow past ULONG_MAX */ + if (unlikely(ULONG_MAX - len < start)) + end = ULONG_MAX; + else + end = start + len; + for_each_vma_range(vmi, vma, end) { if (vma->vm_flags & VM_LOCKED) { if (start > vma->vm_start) count -= (start - vma->vm_start); - if (start + len < vma->vm_end) { - count += start + len - vma->vm_start; + if (end < vma->vm_end) { + count += end - vma->vm_start; break; } count += vma->vm_end - vma->vm_start; @@ -739,6 +740,7 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len) */ static int apply_mlockall_flags(int flags) { + VMA_ITERATOR(vmi, current->mm, 0); struct vm_area_struct *vma, *prev = NULL; vm_flags_t to_add = 0; @@ -759,7 +761,7 @@ static int apply_mlockall_flags(int flags) to_add |= VM_LOCKONFAULT; } - for (vma = current->mm->mmap; vma ; vma = prev->vm_next) { + for_each_vma(vmi, vma) { vm_flags_t newflags; newflags = vma->vm_flags & VM_LOCKED_CLEAR_MASK;