From patchwork Fri May 12 18:20:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13239628 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 6284CC7EE23 for ; Fri, 12 May 2023 18:21:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE7DE900008; Fri, 12 May 2023 14:21:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D4748900003; Fri, 12 May 2023 14:21:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AAF6F900008; Fri, 12 May 2023 14:21:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 865E1900003 for ; Fri, 12 May 2023 14:21:57 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5447041012 for ; Fri, 12 May 2023 18:21:57 +0000 (UTC) X-FDA: 80782421874.03.B678467 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf27.hostedemail.com (Postfix) with ESMTP id C5EE040002 for ; Fri, 12 May 2023 18:21:53 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=HYnCAy6x; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CwyS2FgB; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf27.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683915714; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3YIlBAFzfGCQ5M2VHn0qgaBT5Vs2S2TInPApujgd1e4=; b=lKaLCdmrK6vOG3kj05xuIu6L1aOOpTjvvHywW3Gs1icxDM02wnqJNCSQ4RbmEScbeCniOs mdUOE89RznpF8Yyp26gxMWr/al2P3KFrvf7bLltIOLKsvpZmRHf4j6Sn5EprAuO9BRggQa CAsIDDGJ+3nA1UpIJRPTxc2LYhbK2TU= ARC-Authentication-Results: i=2; imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=HYnCAy6x; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CwyS2FgB; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf27.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1683915714; a=rsa-sha256; cv=pass; b=xtV2RZlxnWfsdRXe+D4Vgixt96sWZkbYyQ1fES9yhsUWKDGggrR7BGB/FvanSaXGyViWic hbCE55rjoBH9LIFzN3cdH3yghb0mzQm6KDDZw1afEnP62l3XvPVfgXi2i0Iwlzvl5PoQMK PrwazKl2M/GoJgRkDAhTyspHK04WFP0= Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34CF4knv023066; Fri, 12 May 2023 18:21:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=3YIlBAFzfGCQ5M2VHn0qgaBT5Vs2S2TInPApujgd1e4=; b=HYnCAy6xw6XMvlFAc13PDRlmvCVyN5wvF+lASVn25NdL9BbZaDOwqv/MRzb/d2dpTNia Dd6Xie7LJ85uyFLOBNJoDYWmH7EpqXSk19r8DBQFY2iATJWXSsiAv2mrEAghwFUYykRG TWECXrTIMWVx50JTnYk8D2JKoScfGLKuiaKoTE3wEW6h59ci6DgExLMymbDgPWLr8pfx VQblRA1xlpRr7mT+TDg8CpCyEWCszx0uiAeseZmtXQxUykLnDLBUkiqjthGwrKfafx+g Dr6pj7+NdNY+zfIM5M0tsbf8VZzlFsrRn1OTMX67dmFURTPcSnpl/67A70vAzvQ4lUsC yQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qf77gbq39-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 May 2023 18:21:52 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 34CHnCYu011668; Fri, 12 May 2023 18:21:51 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3qf815700r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 May 2023 18:21:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QjNBU4o2XLu6a8L4EBRJ9y6RZCtUz7Wiw59OAh4ldQacYWEH9sC0MXwvWdPAdo+QntXwF9cUfi44L0xtv8P9DyrP1g27zpXtJ1TfXM3TiXfqpGNmOQiCLSSx9XWj+Qb0vh9clm3E5g43VnyLIExwC0Ex9zKv9tP1/JbJQ0ir6DNgOQdFXGHNl23MYpyZUxOHuJKAOS4YVwtBKnQZJqS5QHH6ZajN8RWR/fj9EdHwBs2A1IeXBUqvh/ycq0hFlRsr+Lm2Sv3N7we/zc+SbdwXroAKDELl5AGQrqhffTj22F5x3DdzY3AkFytvF5uOY5CCKVwFg2vpJ4jXCKd/XfVvCQ== 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=3YIlBAFzfGCQ5M2VHn0qgaBT5Vs2S2TInPApujgd1e4=; b=DxBJDQpbbCaz/zFLoOF6tkJCvCdT+OWNGpIS4ZG6axmNN3ImrgpBcu0/yK3ZXFPmuN8T0Tm8osRU2Y4/mYE5Td3+jqhdE6QWVkUsycSMbysiiMfsSG6/SyamYgS0oXMI8tAN5AK0CU280B2xlW279PkD7IFFpMsLH7wZ4CPkrUOrK4umwgCqvUN7aUIRh95k1sSuAzEdq9YrefE9nQp/ITDJC94erve25qmRZizprmGWyJVC0H2v7kDXaveL0zIuao7zLItp8+nhX+6m5IFa8nWQdpu7CTltSoLe+dYvJXBufMZO6j0wevq8IzBBOpEWhrHnwLLWerusZAl9P+jM7g== 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=3YIlBAFzfGCQ5M2VHn0qgaBT5Vs2S2TInPApujgd1e4=; b=CwyS2FgBTYsmDoWA/yy/ZcPd2KGYSc9VeGDTOfAvxb/FH32ZSBfbG1o9JqUYJExIptkDIaWt/+Y6Co//9MbBRAxuTEmYbYWEVtA9R4ysUDqGwvNsoA7MQ9xqh1y6eLK6zzq34sLtdsYkUBnE8WEQHPuM7jUXOOS3HObMTmrrt8U= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by CH0PR10MB5211.namprd10.prod.outlook.com (2603:10b6:610:df::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.18; Fri, 12 May 2023 18:21:49 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::c478:d218:8f15:37c]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::c478:d218:8f15:37c%6]) with mapi id 15.20.6363.032; Fri, 12 May 2023 18:21:49 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Liam R. Howlett" Subject: [PATCH v3 23/35] maple_tree: Try harder to keep active node after mas_next() Date: Fri, 12 May 2023 14:20:24 -0400 Message-Id: <20230512182036.359030-24-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230512182036.359030-1-Liam.Howlett@oracle.com> References: <20230512182036.359030-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT1PR01CA0113.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2c::22) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|CH0PR10MB5211:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ef86968-e9ac-406a-207f-08db5315c094 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nrj7KS5gg6U22Q7F0TNNa/5Rz6sJ9xTmQZbaH4Ha3+H49CQnJMm4mY0acTywaYeO6qi3qrEK+VGMa6tziSo1syNRCf1r7GRQfLs5XASPVn0sNWtDzE/n5jOrC0MTHb2qyhBMMDU/uvPl2iXZfw+9IYaYnbpdMuOT3bUnFdIjp1vGfhvoDSAhxwSN5MfldAThMhvDbdPI4rL28gqzn3gNo7Fs4Z9eIcHNE+9jwlvquB0JwYx7+ehq2zw62aFgAzJ27oIsaGkGj7kjq9QxXzLt2M5iOStgj6p2HWBghTZLmVB9ApSX7N/xcFiZ+cArZSYhDPJIY4FdrjXpgN61jE8TVxVM2ynOvN60Lx1n69kcfqp40ab6mEH8aF2zcHJwAePyCRF6P1E3suV4rNvt1aSTgyqNGaImx15WIiGtwbntDgPi77adfrwy5V7Y0HqcfboZ59745SmHtATQlbTBLn0Xx55TQFNygrD9Kp51L9Ou6FYsD+vSwHMnbJejYiMhO0omu3YfWUo2Uxa0//SSeP92+1soHhzP2hVpCVnyYS8rnDaHFuc/QDB6lGtz6zRHzBS7ZUxQWibiI7jm6rLM2q0nFbZ6tbVfmX6C9E0qvUgY/ouOezTIgH8hkMdvrc+kyTorKKdG2FTp/XK/dZ8Cy1NwTQ== 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:(13230028)(376002)(396003)(346002)(366004)(136003)(39860400002)(451199021)(2616005)(8936002)(8676002)(6506007)(38100700002)(26005)(6512007)(478600001)(1076003)(36756003)(186003)(4326008)(2906002)(66556008)(66476007)(6916009)(66946007)(83380400001)(5660300002)(6486002)(316002)(107886003)(6666004)(86362001)(41300700001)(34023003)(148693002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zceNuZX/tdKXIpwWQXn6Wup9zrYAsUVGPaVCYaEONN/EgFGAMZ1Do0K03sqpnC4eWecG5AFAUqJAbi92XHX72d5nORzhRUcY7agCzAKOq/Ye7vdsSt+R6qJKodukV9BjLlo5t1EeZ9OuidlFiL8d4jPAwOcbaaS4ChnCH6KxcwqeMiKUJGlrUoclgP/bpLyUIMYuKBrlGa2MRELMApNhmrfVZZMLOdXmXdAiDNYxKnm2N/pFanrpwS8tKWZX/bx//rAm7nzVnY/0S+kgfI7gXPJW1dbQfV7PixDfpM4+9uYdOHEaMWsM0Uy6K6EYxWLvVOefvSlD3frDETC6scnp7z6GYN8etCAZDx0FeZHJqJDFr/7NU7XIolDEwIRnlY6tAzVTcLUjRltrZURpvj78qPd9wZ5g77KpDT4AYbYB/1bs70K5kFQf7lil6VPa4xWsHy28MYGU925HJqG2ookyaZPEs10t5zZKzn86uX9/Xt6QlV+Fqzg212K+0AHUnEexkfxEyMH90ag7xuTcjkcVrFy2Mx2CoWig/FzxovX6Pv2roI5gSNblwEIhN/Qy3PMPNNNQ8P8Jx9rlrO8TJkZbt/Qzio9mfNPhHv82rXCAptQgJTjgUTXKdUk7aO2NZcyTD9UiZd7Uuw8eAQItyI9Smck6jjNP+46nsYW3o7rPH6XfsJ3JKplJMzlwUwhfIR+b8C6SRJZfeRaF7R3cydr0zDtBLmaO3UuLqSSUyLkhNr023OqV/bgxbTCg2zR6AgGHsuZbjvvrR/182mS4KRk9dFNujLkZibuw48Ok9cZyXG58ehRKjqL5C23AnaqB8k3lCJ+StFim9VWrMv4x3hM3s98C2lb3jcGsyUWXM8DHBNqigvmy3Y1glgt5P+VUnOrhnkx0nYtqdRA3HMTpCduwCta3M61vt5OelemhqNZtEOEevzvRJuVNMQ9JBYpPgzLZ9EjECfueT99O9ePN0eCM0HLN5HGj7hWBiSEsGfpvh1/3X2ynKfPfDg5grQIpvk7YqhDu56ppi2iCy47PD2CvNigdsJSoThVQ1hYyQHVV/XJkNouGLzemIh5FEptzFFsIg30uPYQu6kWbenRG9CMfTJr5lmyIgLAfAwc2nFz7d4M2YIfDv48c3th4L2DV/m00GcjZO7nVGg4gUZt3PY6SBxKUCmRakGzMhvtx89t7Y08A/lstryTCqiq3CGB3DUS/rB5t9D2LixyZJifj9ZaSGGzYnjJx+9NXjerkLOkpJFrVv3Sw7vPKRUHCADXoXotFP03tfsValXG7QUxRzY39EflwK9sv58fdYg2i79G1+q3GGFgZm6q1pm1LC11GrFME5oQahQJcp+sOweEOWCduS7Zy4r68taNZh+2B1p2o6U7LfWXO4eOFkDrOeErT7RPEixOMhMRRvaoZ532ANDy3dhhOoNOwkz9X3R6kXBCqfZ0/UNJ7xEZG/i/8N9dJ/mwOZalTa9I5565l9KDrPIjRiyqf5ZfwzCzbuoB68tUUQlAAbtMsZBmUghqZWUBkn/WCxKuD+vL0PFWOu3fzrXBRAPrzYlW6J/DPmznup+fQSRySTRRuwvDTzJEU/Ai8r30gOzdP+OXXfKwSEXw9ownDMA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: e4fFV0upExBfoB1ckU73+6rNphfFiTGg56YtzekMmzbjrsDUDTNh6LQ+Xsy6kbkBfn70x4p5PoviflQ8oLZQiX6NjJcK3Em4Ob5fU3eLCs2h2rsTxlRfycoLCgw/300wDS8omG1KdWfCgEenRHh6acMgBpQn3dROkQE4hIhftkWvywIwggClv0NMaaK8Qpv8ZW2USd6WYgwDQQifZmOGb6LhKjM63WZ9Shtz6ktr3LTo8M3pVzJD1B6/xzwHjWynEdrz20Ng7qKIb48FOakBX0e4/F5TEyn1YklpMu/hrchMqeCbnic4kmD6S21o5e4lsVOB8qVGzeGo8aBWPD/MDofWPziWS6tD7tIPOmH/wOCTKUtTjELou2V87xQBqahrkhHuG9UEbgHMveNLbnveYpH6dHj7Yx5/xnnopAnzsf2pCRpr9WLJrMrO9W2CN5mSAauxDJggw0Dov1p8ERcM62LytoyddmuXJwRYwuKbzmxFHYbpxXtCExUpqsIfT6baRL3ubJkt4ABo5guoFEDpUZK9nYFBjrD68Tn0lXCf3g6y05/ZKkmG2Rhknhmvzc/w1mqcVKHgUc0KCDDaLEtKH0YDbrBgMiCl6t5+bu3yJniGjSI1jleKTw78xpjjzyb9AuEiugxw2SjSSxZ/0XLuWbl1qDEfd7HGEl+gK+rCgA4/snx2sli8e0gcyn9z3qJnakYyV+H8glwcS+6nYkhw8b+XlmBXlXt3Xt75KI8Un1mNuqL4PIKJkIS5WtxLfSW+R6CqpHeppRyIZBLnjsJTFIT4+l+myBs2JGxZ/ca97osu7sDVWPNs8tp1eBF1twA/6qZJhvRibaUWZxhyi7EqHgMrSLkaH0xurPtHHMgGo4I+bJd+hk5PSFRoxR0qybG4Flf89RzhBG9r5UH/lF7XrA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ef86968-e9ac-406a-207f-08db5315c094 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 18:21:49.4493 (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: /ejo6fmRijm0fzGVuBWiA8MifLBuiG6nmXr7GXaTSRvQyRS4CdphmFzI9lNGT6gy02IGor8zQw5HWq6Mm7xOig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5211 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-12_11,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 adultscore=0 spamscore=0 suspectscore=0 malwarescore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305120153 X-Proofpoint-GUID: y86mGncaSUL0_gSnKgVtwzje2rfbvAwU X-Proofpoint-ORIG-GUID: y86mGncaSUL0_gSnKgVtwzje2rfbvAwU X-Stat-Signature: i7niufemq589d6pizt3zqnttbyjdfx5q X-Rspam-User: X-Rspamd-Queue-Id: C5EE040002 X-Rspamd-Server: rspam07 X-HE-Tag: 1683915713-49751 X-HE-Meta: U2FsdGVkX18jlP8FCAZlWzonF9JK9s3ROfJIAGOilQAtu519AKKlCHFKKUEokOWYHWoThYLwQqS+eozJQX7pE5SwwAXBIlLy/tN6etvAG9PBcKiUT6OLViD+A/d50Pgt4QKse053bCIDtilyzJNuXqo9SCJMEow2/vjGCOYxcGLd1hr6VOpcxV0wk4NSdJNfjeHtw5ZOQ8hos+cXplJfAU+bl8y5MrzanBrIF9XTA4VpAux/4F8BiPr5FyFFYK19QULXK5UgeZ3Nv7P9IbuHSXs0jZiYUp/kRb/8Dwa4IBlFFURS/oNi3gGiDQ68c1RzZMddZ0dg+98nN4u5A7eBl8/GjuQgzYdB1yCCzLxPh/FItsE7rUIJ2ECrWNMVvgrBh0887SvZjQSVUmoZo8ZViOZ2KbgMsaIJLK78Sbt5jaJ/gHBRQVPueOdnzLhmgw5kbpqvUlnYjR1UTG8BZlaBDZuSojYaerBEjEEwd0HqrYvqsfzb+7xcGrHAmBBECMHB7+QoI1E52YCgEwk6MzCSxRDZappA3D5/LPu9i3wOVGJQ5k72ICmPVOimmBYGa5vC27P4Aau4h9HXeJQoWoY4r9zoFxHrQtP+S2/hOAQ7vPQKL5jYLuoutrVRdVRdk/MfCKu1Ao/xa3sgCSTo28RTE7jEmigMKCMmwz1T2ClAJy7iNvwoOA9jKq3111EUZaTEQsN0iLlE0zEg+WXsRwqO4oUt7CHEOnseI52sZbfOzOTv46NsmA0koRwk7k6iRnJZElQzF69eyAvBR3UDXwtRY/MHpxh6Dx7D7kUyaw5kRwUFrF8+3KLNp24zkXsGtE2DDdLPH8+llLda/7Rsvpxe4YfxZe37SdtAiku0JF+44ZYukyiMcAZtwDnCoxzyO1RGhmtKyQFBQfKIr02ntXz1RM2gLjb03pjjnTTaDabdURm2eWSsqYOlEwBJ7ry3B68K4o5KDWHdqY+FZGaRG6O HFvZoJPD ldk72nXHHZ6WORI1uqQ/rLO4BQy7dl+t6IIWA9F52ay+GmL4xR2Au4PRU7vYhdgpRlgPPF2REqKnA71JNH+ffhDAWvtZKiN3y8TfjsQF1ypouKSNtnyWEMOQvNc18KZCQOZOU5au9f1rYlG6PBHWc0C68jZ7WuGE9ZXBVSKPRhOgiMYoBBePxeNCAfrQ6GPxULhf5ACtQz0TH6tNXnAxXClM/fRJR05DQfkXnAyNKaSOa/BomoQvJQCapIxlpIcHL9GVZn3pqqovWlzG9RgdlAk8Pf3XyGleCMpI7jlSCtLp4jSxendNMkqJ6AehtsVvHI+63zik+bRnTFtAv6n8dvE0xOA4eFK5b98w5sAZFKgeemosrx/eBVgVw7SybBNQ8YSzPOCeDKVxiGm+i+iWX3cJ3UZ69sMTeR1vsn5q58t7ocSs= 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: Clean up the mas_next() call to try and keep a node reference when possible. This will avoid re-walking the tree in most cases. Also clean up the single entry tree handling to ensure index/last are consistent with what one would expect. (returning NULL with limit of 1-oo). Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 89 +++++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index e233f41ed4da2..09142af082148 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4726,33 +4726,25 @@ static inline void *mas_next_nentry(struct ma_state *mas, if (ma_dead_node(node)) return NULL; + mas->last = pivot; if (entry) - goto found; + return entry; if (pivot >= max) return NULL; + if (pivot >= mas->max) + return NULL; + mas->index = pivot + 1; mas->offset++; } - if (mas->index > mas->max) { - mas->index = mas->last; - return NULL; - } - - pivot = mas_safe_pivot(mas, pivots, mas->offset, type); + pivot = mas_logical_pivot(mas, pivots, mas->offset, type); entry = mas_slot(mas, slots, mas->offset); if (ma_dead_node(node)) return NULL; - if (!pivot) - return NULL; - - if (!entry) - return NULL; - -found: mas->last = pivot; return entry; } @@ -4781,21 +4773,15 @@ static inline void mas_rewalk(struct ma_state *mas, unsigned long index) static inline void *mas_next_entry(struct ma_state *mas, unsigned long limit) { void *entry = NULL; - struct maple_enode *prev_node; struct maple_node *node; - unsigned char offset; unsigned long last; enum maple_type mt; - if (mas->index > limit) { - mas->index = mas->last = limit; - mas_pause(mas); + if (mas->last >= limit) return NULL; - } + last = mas->last; retry: - offset = mas->offset; - prev_node = mas->node; node = mas_mn(mas); mt = mte_node_type(mas->node); mas->offset++; @@ -4814,12 +4800,10 @@ static inline void *mas_next_entry(struct ma_state *mas, unsigned long limit) if (likely(entry)) return entry; - if (unlikely((mas->index > limit))) - break; + if (unlikely((mas->last >= limit))) + return NULL; next_node: - prev_node = mas->node; - offset = mas->offset; if (unlikely(mas_next_node(mas, node, limit))) { mas_rewalk(mas, last); goto retry; @@ -4829,9 +4813,6 @@ static inline void *mas_next_entry(struct ma_state *mas, unsigned long limit) mt = mte_node_type(mas->node); } - mas->index = mas->last = limit; - mas->offset = offset; - mas->node = prev_node; return NULL; } @@ -5919,6 +5900,8 @@ EXPORT_SYMBOL_GPL(mas_expected_entries); */ void *mas_next(struct ma_state *mas, unsigned long max) { + bool was_none = mas_is_none(mas); + if (mas_is_none(mas) || mas_is_paused(mas)) mas->node = MAS_START; @@ -5926,16 +5909,16 @@ void *mas_next(struct ma_state *mas, unsigned long max) mas_walk(mas); /* Retries on dead nodes handled by mas_walk */ if (mas_is_ptr(mas)) { - if (!mas->index) { - mas->index = 1; - mas->last = ULONG_MAX; + if (was_none && mas->index == 0) { + mas->index = mas->last = 0; + return mas_root(mas); } + mas->index = 1; + mas->last = ULONG_MAX; + mas->node = MAS_NONE; return NULL; } - if (mas->last == ULONG_MAX) - return NULL; - /* Retries on dead nodes handled by mas_next_entry */ return mas_next_entry(mas, max); } @@ -6059,17 +6042,25 @@ EXPORT_SYMBOL_GPL(mas_pause); */ void *mas_find(struct ma_state *mas, unsigned long max) { + if (unlikely(mas_is_none(mas))) { + if (unlikely(mas->last >= max)) + return NULL; + + mas->index = mas->last; + mas->node = MAS_START; + } + if (unlikely(mas_is_paused(mas))) { - if (unlikely(mas->last == ULONG_MAX)) { - mas->node = MAS_NONE; + if (unlikely(mas->last >= max)) return NULL; - } + mas->node = MAS_START; mas->index = ++mas->last; } - if (unlikely(mas_is_none(mas))) - mas->node = MAS_START; + + if (unlikely(mas_is_ptr(mas))) + goto ptr_out_of_range; if (unlikely(mas_is_start(mas))) { /* First run or continue */ @@ -6081,13 +6072,27 @@ void *mas_find(struct ma_state *mas, unsigned long max) entry = mas_walk(mas); if (entry) return entry; + } - if (unlikely(!mas_searchable(mas))) + if (unlikely(!mas_searchable(mas))) { + if (unlikely(mas_is_ptr(mas))) + goto ptr_out_of_range; + + return NULL; + } + + if (mas->index == max) return NULL; /* Retries on dead nodes handled by mas_next_entry */ return mas_next_entry(mas, max); + +ptr_out_of_range: + mas->node = MAS_NONE; + mas->index = 1; + mas->last = ULONG_MAX; + return NULL; } EXPORT_SYMBOL_GPL(mas_find); @@ -6518,7 +6523,7 @@ void *mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max) if (entry) goto unlock; - while (mas_searchable(&mas) && (mas.index < max)) { + while (mas_searchable(&mas) && (mas.last < max)) { entry = mas_next_entry(&mas, max); if (likely(entry && !xa_is_zero(entry))) break;