From patchwork Wed Dec 1 14:30:15 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: 12650047 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 1F023C433EF for ; Wed, 1 Dec 2021 14:41:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24E0F6B0098; Wed, 1 Dec 2021 09:31:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FACC6B0099; Wed, 1 Dec 2021 09:31:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F41B26B009A; Wed, 1 Dec 2021 09:31:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0045.hostedemail.com [216.40.44.45]) by kanga.kvack.org (Postfix) with ESMTP id E3F2D6B0098 for ; Wed, 1 Dec 2021 09:31:39 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id AD9C385D50 for ; Wed, 1 Dec 2021 14:31:29 +0000 (UTC) X-FDA: 78869463498.04.267C410 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf20.hostedemail.com (Postfix) with ESMTP id 16177D008C4A for ; Wed, 1 Dec 2021 14:31:21 +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 1B1ECcRn002533; Wed, 1 Dec 2021 14:31:13 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=Ze5mFgSyZ+ZQTsYRn4+a4f3TvD/4+clcpL1kpRmwbag=; b=b5poALOfOiOsU8YFOAwYEwCVOT+Vg+oQYsEo3v3T+qWp5lo1faPaTPez1n3nKf9Ximgw i5oL2uuCP9fQAurriKFScyA9UbA7XmyvO+Xs5f1KQSHopeican50Ze3STmODB6eUHw0V Ap82faF+wck9ov/e+Kj1snXSDuZCr5YDs9c5XjOb69ii750Pza6NDtjfuBrTpfH9DMYO LtIGW54Cn9DDHtLGET/mgjr5D6nS7qydzdUEXry0MXovd5rQcaZHdybh0NRHMBTs7rwJ aJlZUiM236O43RPTNUG/Y39hwGoEu/YmovJ6jxsm0uL/Fe5sGi76r5wocSedX3A1xfAP hg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cmvmx2229-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Dec 2021 14:31:11 +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 1B1EBoq8037533; Wed, 1 Dec 2021 14:30:45 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2046.outbound.protection.outlook.com [104.47.57.46]) by userp3030.oracle.com with ESMTP id 3ck9t1v74d-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Dec 2021 14:30:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kiMwUIcD37AvjrT7/z2fBo1qDI9dAsuDR1Ee35Krn0tQwueAPE4OBiHbRh3yVrqgQqbX3+QmW6zvxA6Oj33OIkK+uHjl30htH36K736RtwVnn0CWuX5bbozL+7RCY165FZPO5+PRqvMPD3DjJDnLrGF5AlstRWQ3F3HLOuWoNTQV5nQNS2nXKIN951AqAYVBaG/XYYAuuOhvemIWoo2pgshtoBpI4F5LpVC3AySEXX9Ec9SW9VVWEpsMF/J7CUscLQ4+JpZXwBLoUgGD0euRgPrQS2gzelbz4lDmgGJlGww/x+d0wL9WNyT9dOrQGw0kp0o8vEJ7wJZzwqbMIbD/DA== 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=Ze5mFgSyZ+ZQTsYRn4+a4f3TvD/4+clcpL1kpRmwbag=; b=RwlQ4KY28WN4LrDFtzfeBGymUviBw566hkQ8Cl4FG4LRNi2oWFUx6WW09iGTGjUmgCWt32t04DBFulaeOfnBZu4/OestvAF1j74+EgDM/SVHluHU7tmfR8pbcTILOMPZN/+tLFqXI6Pyvciltusv6FIVyxCm800YmHV/R//e+mD0NmcGcS3urTDk8exHgQ+5DjQR5uVq++gVeNwnJXO5YdyiWqr5mOUgODTFPZpvCsadjs8R2KGtinmepT0y0fBtqiii1oQT1+4/euyTP98IsCQCzeKN0mIbSKhGqntLZ2AY/nw5PVjl3a8EJTa821RpjR9FcBEZtnOskeIbZYHWGg== 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=Ze5mFgSyZ+ZQTsYRn4+a4f3TvD/4+clcpL1kpRmwbag=; b=SIMHJmqDWG4KUce034ByR9HxViCFVoPhmTbNXNFc9KUB9mKNU9xQFQSgvD6wfuHZDVx2irctQuvfZ4UhXUd6bPS1qlAoEsFLUt4oj4C9DekUyrJjfManDzLTxNeUf7qzjB6oVroDtGe+TQOXdRgT4eqrC0O9EBc9N8HFBimRrWc= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by SN6PR10MB2464.namprd10.prod.outlook.com (2603:10b6:805:4d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Wed, 1 Dec 2021 14:30:41 +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:41 +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 57/66] mm/mprotect: Use maple tree navigation instead of vma linked list Thread-Topic: [PATCH v4 57/66] mm/mprotect: Use maple tree navigation instead of vma linked list Thread-Index: AQHX5r/1/4BXpZ6L10a73qtFjPbdrQ== Date: Wed, 1 Dec 2021 14:30:15 +0000 Message-ID: <20211201142918.921493-58-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: 0baf5c1c-d8ef-4cd7-4453-08d9b4d72736 x-ms-traffictypediagnostic: SN6PR10MB2464: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1303; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Zf1/JKfWx3OZZrWsuXJmm1IHrdWHI47zzn24QM2T0lRQQxWex2y5D38Xt3LLLhveY4VxCPh/Sy4WqlhzmBRvrJjShyZC9KJ2cO+jiu94o1DlRQr0gMDVAke/ZxMyiY5yI0XTOaheFRmLLC6YdvKFhLsI9xjjH5iBLdoftfoHQUUU+0RBQTss5APIr5QXXDtxmWiTv6yD0cxBRI02dfNEe5wMEBh3gV8UE9MQ6MTC7Pwz27FaR+WMMv5GZz2qGMroewbEqxqr8DBsKsEXkm0d/UqeoidG5BifRTtjrAnQ517ANCzAM7xalOZBGS/o7aK8MfJS7Ve9k/2GtAviwUSHEJM2lOgsIrLNNZU8pow9GZ2RJfOl6iR+KO5dX1zCvN+Wszt3i4fKp31btqlppYn1NwwW9UVE+dqrx5+YKwTq9wZ/fxQEqryashuBDIv96HEfig4/gvvkyGFp2haHdl4l/KxzlhQz8SnjUg5Y6/yR1QcEe/H3khkBgPkfEFF+inQktcCefqI72Ua9pXPVsBw0x1v7+tBxH4mrDkysrybhN/waWI4maXniXefZhFB8lh1SHprtQKywv6yfO3YbKtk2K6lS8XPYp6cg+SPdiVxfzqEkn7hxAXRMnb0qBhkajBvIncIvB5ZJYBPMKx69sgP+8t3qz6jh0jJ1Gyq3Dcbm8VABJIGhDrSRCayPUkuzt/OjXvzptAovhDjnH6Fc/Joykg== 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)(91956017)(6512007)(2906002)(1076003)(5660300002)(76116006)(83380400001)(186003)(6666004)(4326008)(26005)(38070700005)(36756003)(8676002)(7416002)(54906003)(107886003)(2616005)(316002)(86362001)(122000001)(44832011)(508600001)(8936002)(64756008)(66446008)(110136005)(38100700002)(66946007)(71200400001)(66556008)(6486002)(66476007)(6506007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?8bJ9KGw2e+KgC5zRh0T1vgR?= =?iso-8859-1?q?5Uwx2vj75gXlAUtm1usWCXZwja0LmobZmBI3Py1QvZdClJSrvMuQdrR0EDB3?= =?iso-8859-1?q?6px2hWZ74MmBmVsEjxUrgJTKiaKCZbqcL/FNJAa1kVuw80ie+W6H9/m2lLRJ?= =?iso-8859-1?q?MwDaokmhHN8Yx63RcG/oVgReQKJB8D8iulYbi546npnRRYJtqGHDmxtMoBS0?= =?iso-8859-1?q?PPQsxcTc2LP0pFa1J5Xjjmjue3OQB6SFpRD+MxdjOD4bOCTOFtCWQY/nELyn?= =?iso-8859-1?q?jeNDbDovBRRfNCzylA36weMb0XRT+Bc5mtaoc04WtngX1xArHnqfhtVI0k4B?= =?iso-8859-1?q?ki1X6J55pvZdI/ottPnXy4BOJ3fsuaIbEEKcQkNjfbxEniTBrvmA3I3kf+AO?= =?iso-8859-1?q?GH9/LuWV5Ifg2zeMl60Fs09mclNbfFqji3aH61kTHl1VZfjGtRrZglzWaZ0q?= =?iso-8859-1?q?XbWNRH7DEjB0aBdGwHLJZkQO3hT2JW8+q/DTrw4Fx35/X5lv6bND+EO84B9B?= =?iso-8859-1?q?UGEp4UeBo3i58VhCPKVpsUz0orT0vgCRCGrhn+9zeQkSaTje6zuy2HYg6E9x?= =?iso-8859-1?q?zkthd0s/jOFsbcUcOqDd6mrx5pZHk+A746QPMMsTU2SJNBvBTcGGt1jUyEkl?= =?iso-8859-1?q?prTKiYlRcO4Hf7PFAqNG49zdwLQVbTBWwBr7QcZ7gnpaQpDX8nOtC1xaoVhK?= =?iso-8859-1?q?Hfng4+4jE1qD+/LKschAgPxAkdDWc1DRMuSKJDNQ3yoeL5w9bKzeuycvB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MJk0qEDhQP+v43m/TTapElsPJ+IobavaZnNiskVzY7EuwMqYw6/buCZ/eLGs?= =?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: 0baf5c1c-d8ef-4cd7-4453-08d9b4d72736 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Dec 2021 14:30:15.6931 (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: YmBwb0uuovgkiSktpMDfIox6Q3fObugIqo9LVwbmNCFKq+quyE6XahRXvUPGqLVcxC9UCxfYke10gbSt+k2XLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2464 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: iqTX6meYlt8Qva54bcXHZkXi94ArY7Go X-Proofpoint-GUID: iqTX6meYlt8Qva54bcXHZkXi94ArY7Go X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 16177D008C4A Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=b5poALOf; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=SIMHJmqD; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf20.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-Stat-Signature: d9f4914dpprrcad5njtqcqkyza8mpwsw X-HE-Tag: 1638369081-452308 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" Signed-off-by: Liam R. Howlett Acked-by: Vlastimil Babka --- mm/mprotect.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/mprotect.c b/mm/mprotect.c index e552f5e0ccbd..7af58fd467c6 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -528,6 +528,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, const int grows = prot & (PROT_GROWSDOWN|PROT_GROWSUP); const bool rier = (current->personality & READ_IMPLIES_EXEC) && (prot & PROT_READ); + MA_STATE(mas, ¤t->mm->mm_mt, start, start); start = untagged_addr(start); @@ -559,7 +560,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, if ((pkey != -1) && !mm_pkey_is_allocated(current->mm, pkey)) goto out; - vma = find_vma(current->mm, start); + vma = mas_find(&mas, ULONG_MAX); error = -ENOMEM; if (!vma) goto out; @@ -585,7 +586,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, if (start > vma->vm_start) prev = vma; else - prev = vma->vm_prev; + prev = mas_prev(&mas, 0); for (nstart = start ; ; ) { unsigned long mask_off_old_flags; @@ -647,7 +648,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, if (nstart >= end) goto out; - vma = prev->vm_next; + vma = find_vma(current->mm, prev->vm_end); if (!vma || vma->vm_start != nstart) { error = -ENOMEM; goto out;