From patchwork Fri May 5 17:42:00 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: 13232914 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 73B1BC77B7F for ; Fri, 5 May 2023 17:45:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEA0E6B0099; Fri, 5 May 2023 13:45:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B72556B00A4; Fri, 5 May 2023 13:45:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 950516B009F; Fri, 5 May 2023 13:45:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by kanga.kvack.org (Postfix) with ESMTP id 628E36B0099 for ; Fri, 5 May 2023 13:45:01 -0400 (EDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 345Hh61u027900; Fri, 5 May 2023 17:45:01 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=DLizGfG6RsPpK6kYK/8TgPTR+rIq7alrCR/2NcjSElk=; b=JJ7eDEXjw+6rfsSL1OHz4/epsCLYQugMVI8UWNYNP38D+YZQ9NxfFs9ov3i/Swxx0dBT vGFB2ussI8AnEfcOSA+G3k94xQGeXjjRXfc0BIzQuzdKTHRgnFD4f4LOemy6RMePbpbn iCz0j09mh9jbuvSXDq7uYrhuYcfjJ3HzEkesFwLjvMtbVBZI3mqjCJR0h3Gwa5ej+pMD 4V2d2gvNSI5dqp3ky25nfyQjdTz0/7dbtMbNfBr83zxxqdKSB2AR5+iKQ8T3xQzLxNgs fkJ9wELwf4X7P5f0e0jzq6CKW19nhlIrinTcqpp/pi+Uf6i6tKh/F7l19nDGCaiBQv/j uQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q8t5fwf4s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 May 2023 17:45:00 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 345G4EtF027652; Fri, 5 May 2023 17:44:59 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3q8spgetws-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 May 2023 17:44:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bw1k3p/tv/llIQl8kZvEVLB/+hndea968yXQ/Ys8iN0CsKQmpc0mnP48UP8C523boU01Qaozcd2iacZW/bRyHj+C14yI2uIIqN4DDP1h513eADicHFCe92VMUNFeLDyvurO1LhsAjTSqfVg3m+xD+RFtinFlm7liSTP9Dk0+Ex9pUDuE3c6c+KgUyd4eRwz7SHD1tJwoX8ViU33iGmJJW+cLE9QKWuXAV2z6Ggavp2o8IBaNOGIVX7g77CyXJUXTJBIxuvfUJW4lN+lA99TsH3KTn47umXKl6BdOFwkfmKYD08Kf3kS09wZ+tmehJFsPWOyLtBe/u8B9Z6Ycv2W63Q== 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=DLizGfG6RsPpK6kYK/8TgPTR+rIq7alrCR/2NcjSElk=; b=XyfzxuCeOYT3DU0ERF0GwdqVeYK4yVwlvJDxf0fqSmQcSGiBC+OJla/6hLgPaQkrv5c4/pXCMNQZZ7wlHIRy5dCH5GNicFic4CERolxQXXlZVC2lhsTRErVZhgeVE4JD82RRS3kP69ECnHf4EMBQaiYoaRHOZWHcpXzY9MiLSd89LXZTSRRtCim2yz7nEMoSDCfkKf4p8+E2UF0mk1jzghFvkiKuGS7j53dEn7jvUGHFGhi8YqewvpA+G77nXFzpPvK+Z9OVyY6EBoQL3SMSMe8dUDxirqbO7www+2C2haSomnnLfjw3mhqequonGab+l2V2Xcx93zLtjWTmUeoRKg== 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=DLizGfG6RsPpK6kYK/8TgPTR+rIq7alrCR/2NcjSElk=; b=jwCCgu8LhglGmr+r9fDbY5VLPKanUNWtGuB+KoRwnoFx+Ss3q/C1xyhTb722sh4gTwbxc2Pc9qU3JiqMvIC2a8mfI1U/9abQhnVyarKhkn2TAbxPYUjzZ2JGM5t1VwaPg5/lzs6OMj3gGGxuXA3egK3383UeVq+KwQocmB3ZhtU= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by DS0PR10MB6895.namprd10.prod.outlook.com (2603:10b6:8:134::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.27; Fri, 5 May 2023 17:44:57 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8bb9:2bb7:3930:b5da]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8bb9:2bb7:3930:b5da%7]) with mapi id 15.20.6363.022; Fri, 5 May 2023 17:44:57 +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 v2 32/36] maple_tree: Clear up index and last setting in single entry tree Date: Fri, 5 May 2023 13:42:00 -0400 Message-Id: <20230505174204.2665599-33-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230505174204.2665599-1-Liam.Howlett@oracle.com> References: <20230505174204.2665599-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0251.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10f::19) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|DS0PR10MB6895:EE_ X-MS-Office365-Filtering-Correlation-Id: 7bd5c748-5c0d-4b33-d9a0-08db4d907140 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V7U1IRfBfvxzh5zAFl7bwlWU/oL6xbbgP5/lGIVQd5USGjcRaAQjGSuWIE9E9mVoeVqdh+G1eidk77K5EI/ZTqjZYkve3lvapQydWyUV4aJWAFNf9EBpYmh/jYOna+8yNG6g0TBCWkzZJe4ZwCkMl+ZseckmGpCJtC6hYSzWxaWQaVKWb4YPsX7VJ3SJnTw2j3JfpWcRb2nOoQWLUT6FA+iETqTmmJV8B8E5gqtiA0/IJRRlAEzIimz8p8DpweHy9h7TBt8OkeFBuVmTYZ6w6Hbf+2RBQfkkjyFDjiWarFTNOjUr6gPjd/IL19DRg//hu+Y71Erl7TS8lRSwo/dfbYjwrUWCqEHarhCBCqDNPypa685HbtADAeZfXxrj0VdGrXNacyXtN1KPFmsD8gPwYuQX1YbN+yRFlu2AU19t6t6wrdbWhyF1reUNAKJG/ySkwlxfFq6IaDW/fYv2pNojV4WfjwOz07nltxX3pI9FtwrE18JewVJNZrUAo+OJpQW8BReBODYaVKIkqsu7RH+jYHsER4vs7cVVSLP/HK91k2qLxz4pVdY3o9yq3JRXDWJW 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)(136003)(376002)(346002)(396003)(39860400002)(366004)(451199021)(4326008)(6916009)(66946007)(66476007)(66556008)(41300700001)(8936002)(5660300002)(8676002)(6512007)(26005)(6506007)(1076003)(316002)(478600001)(6666004)(6486002)(107886003)(2906002)(186003)(2616005)(83380400001)(86362001)(36756003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: D7dBLONcqYLjARsooyVd65lOPLZ03jlYoVPhnhHHb3G7OnPj9mKFbx5CrEXyBiNvb/ScWgxRlnK0xgpV/j9WtgW8wk0hRjPgggicpIyeZjrNG7bCdKvKVIlza+pyS0Gga7a6cU80yvwbAQ/sI//h/fe9utJSAuID0LEOidexLgKk2AoSSamQcjl9CItq2AoCugrJJhWIlF5W2O/lcLO+goz/u2NXbKDiy6SomDqLVZYr8ByuW0vpsiEew2RVAxDkjaBc9gtzg++TxMLjyMW4IkdrD8SOXQdyuVuJdZK1IaCTIBgHIJO0FkuQOCkm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Jd6cuqRiSNX6rYk2NmS3S/mEkRuWf+CduVNvSWnp+SztlCouQFSdnHkVSeE3sCwxvQmNfCBwTKjtw7quSQ8Nx7lkDC33X1u7byzk6YpnbCjCrdfO9msWO8rlXi+bVJ5bkGA3S2GgsILS7fhPY335UZb5o/Y7yFkjsM7ZKGxLl2SJt3unKVQV35WioWkhY6CtwNKsxSNynu7ND1RKQftuE0Vsyui7Vg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: MoC6P2vwQKtePk+mWPcGlHe8T5QGhozThSs0gA5j1cq8hsW2THkfeDvDYUhxnmMcghe8Fmx02FpUKm+99wLXf60epT524qIRI5uroQgky98AEhaB1NFXEmqipBBn4LUk6952PJ7P0hXfKzkG0WUhgvb5sPFN/3aQ6uVZUrJio6HuDEqh02WWjtHSLevgB5/q3i/xAzYIb9Qvu5bCuQF+8b/G6cyJyrQOYslUFhEj4D7t8+NtrcrULaKRrE0BIhogfkX5kHqvjPOYtiNPUMqV032xHQAUmtu8wd45300w7L3EH8mLLTOtroQPiTGM0OVKOz/zkA++UQjXHp1/SsXo5lxIO4CZzOUTUzZnSDTVAua4tNVXuM9jx2ANQIav56rWsn1cPfESc8S/T2/PsC3RUxF/gVxUl1Dxx3j+j0o1mL/xGfLOUKBHKHz49bNjNv1ajwJquDTumUBMsjMDDULsRlOs8n82RVR3rhDVNY1XlQNQjJV/BOtZrUF3bzAfGnzN6/3GbBZS1cNoYSRqjiRCwc9H++PRhpB9LfaW1PijEpOIZo3uwKKlWv7rJSdhBBs6SkauMnziJ5ij7pIVVHWv4Oqo7HTjBoowD80YwS74ivp04GJvL4AlFVr67BPjMEPShPunCFEJ2DpfIRkJJVU/vuWDEePj9tILwMy52Ro2QMRXxfXeNhKlB4OkkbB1YiUG/mrIK3kmR82W6Uc12oURSuLmE00byXdmS49x4b0hgJGjyqzKMLnyoQFN+hSYBXdwcaatHV9gemDohkq5TTuXRFoTbzHLl/+8fVn8XDCain4ERQY3ia+19Qr5q9IwbYZnPC0PpqgUOCxsIGhgs6FQPPB5wzvQ6Sv9qSlvYYr3enHKD5EdX1Psnbx18pYNVq5E4TuPMX7SjEmcIV/mdg6kfA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7bd5c748-5c0d-4b33-d9a0-08db4d907140 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2023 17:44:57.4888 (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: Pu6caMv+N1IXiYGAmcOi/fKGrx8BxenzDhgIMvcGGfWVisdREw1hjmQJW2mRr6MGWD/DPF7iAtDs5Lf7NvUj+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6895 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-05_24,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2305050146 X-Proofpoint-GUID: IWiT81jmCRPMkQ_TitPZY2Uewq18osnx X-Proofpoint-ORIG-GUID: IWiT81jmCRPMkQ_TitPZY2Uewq18osnx X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When there is a single entry tree (range of 0-0 pointing to an entry), then ensure the limit is either 0-0 or 1-oo, depending on where the user walks. Ensure the correct node setting as well; either MAS_ROOT or MAS_NONE. Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index f060c71965c0d..914399519cf54 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5022,24 +5022,25 @@ void *mas_walk(struct ma_state *mas) { void *entry; + if (mas_is_none(mas) || mas_is_paused(mas)) + mas->node = MAS_START; retry: entry = mas_state_walk(mas); - if (mas_is_start(mas)) + if (mas_is_start(mas)) { goto retry; - - if (mas_is_ptr(mas)) { + } else if (mas_is_none(mas)) { + mas->index = 0; + mas->last = ULONG_MAX; + } else if (mas_is_ptr(mas)) { if (!mas->index) { mas->last = 0; - } else { - mas->index = 1; - mas->last = ULONG_MAX; + return entry; } - return entry; - } - if (mas_is_none(mas)) { - mas->index = 0; + mas->index = 1; mas->last = ULONG_MAX; + mas->node = MAS_NONE; + return NULL; } return entry;