From patchwork Thu Sep 21 18:12:35 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: 13394242 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 7A38DE7D0A5 for ; Thu, 21 Sep 2023 18:13:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B6636B020B; Thu, 21 Sep 2023 14:13:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1668E6B020C; Thu, 21 Sep 2023 14:13:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EFBCC6B020D; Thu, 21 Sep 2023 14:13:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DF6F56B020B for ; Thu, 21 Sep 2023 14:13:27 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id AA06E140FE4 for ; Thu, 21 Sep 2023 18:13:27 +0000 (UTC) X-FDA: 81261402054.01.6B676FA Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf15.hostedemail.com (Postfix) with ESMTP id 680D8A0046 for ; Thu, 21 Sep 2023 18:13:24 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=gyGWKrA2; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=KL24Vmrv; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf15.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.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=1695320004; 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=ubzRy/J3CaNQKXWbZ+x7hIiS+95zrwHNV/oKW0YUlk8=; b=8a/xNUP+0pzIJ3zQ+oYc0vgT2Kz+4n0PLu6wJzeu+OWBjwFvvl/va9PjmJ0Fz5W3NfTOHz 9c14nlQCDANKoqpjm8oU23hp4BjxJbrEJtlN73vD4IAvhzkVCJdH2xhXmXGFPowg1O8aJQ ncKDcVgLhyyuXG8B4+HezodRr+uNFOU= ARC-Authentication-Results: i=2; imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=gyGWKrA2; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=KL24Vmrv; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf15.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1695320004; a=rsa-sha256; cv=pass; b=GigLt6Jz2Bg7ODwPli7Kql38kAdgzKuts0ZWK+/6fqy1jWiwi1CNteEd9mX9Cj7TBs3Tz5 ZkgFP2OL4W/w6xFVDZlm96NRx9vHo7UFoVSOxcRghTXoecKd8qAZHij/VN7BXHvFltREDp MoCzi+hDjwKu8D3H6EqO4GTMN/BpV78= Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38LI5A6g026386; Thu, 21 Sep 2023 18:13:21 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=ubzRy/J3CaNQKXWbZ+x7hIiS+95zrwHNV/oKW0YUlk8=; b=gyGWKrA2/vyM5fgvdoEqjiNvhg+DetHN2N7nB5ArF3lzxWvZ8hnZrVBfJIvMA2r2d5A6 8wRU2PoJvDwCBpzVPhW4hneyTheEzTtI+6RVoWK8JovbQeVmcxQPNa7kQqspxLIuh/IK KRA8DI1gW4qGl4vCvVexEZYqd1Q47Tjg1cpJ8SuJb4r+xCieNpQhq2NvmgdGINLkRH3w q1gxYOiz7btwhqt99i15FvIh418hBVJUFvJ1yWcBkrwQryG9u7qXEXGJgOSq186/YGmw fYoyfhHSjQpw4jNhcSoAiNDf0RzCJVqLetVRXTVF7bUedcTVDxULoJIa/Xv9uqLdxM2S yA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t8tsvr0fs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Sep 2023 18:13:20 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38LHPC14030875; Thu, 21 Sep 2023 18:13:19 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t52t8yn2k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Sep 2023 18:13:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Su8Gq2j5kPaJeq4p9/d4YLyKlCAIpSKvlDxlWR/ZO9TCVdSZjWmjlYV2VIJVXXv/2O8vbM5hRO89DlOhL6ygIcKqN+mOqCxO/ny31aIMWJamndieoznzgnprjOaLxN/PCiNsCiZVRKg4xJzg5FU9BPzfENgP4ZTjFrCoatCj/bihd5LVQSLnEpTS7HY9+WVFp4V++R6uKuGYIJRWNADQBDKZAqEA2x1f5cCSVpd94k/fyiJJg52ybaEcCc4Nul/Neqp+g1lQ+12xd39LHS3XbSS6gsOHkuNmSKyTFHccsz5hIyUjQjCbmpvLd1EwxpDzg463KepaMd4xHrae/fsIlQ== 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=ubzRy/J3CaNQKXWbZ+x7hIiS+95zrwHNV/oKW0YUlk8=; b=I8MsdwSZTFlyTGGTnUBcGTXeEuMrFLoka9CNQrWXuZS/wf5bPbU6a6lO5Yf8G0Pc9l3Fd74G04TWja2cJKMPnrO9dc66vTou+FRQt21gEonIPu88QXywho99ZU901bawpJUBhjuxwdQhqUWgqXVtiOw5AD18GsHR/Cks0ImYrG9RhopTzVB2/nTBFlX+rHXsalvV+YykrV4SBktXu6h30Xc3XbbaCZpQA0fA3rUZKOMk/B2KcViIKWZiBT0oIdLF9CQzRE4q599xI0gKZ98GxHWs2LXvKto2JbVKtwq9FLjA9rkMkHGYuMchhdSb0+cZRcXNCxzp58MgYjvcs14svg== 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=ubzRy/J3CaNQKXWbZ+x7hIiS+95zrwHNV/oKW0YUlk8=; b=KL24VmrvIFDjsld/3zYPta7nUghNqwzp3G4CK/HvFX9d+yAkirQ6r43uM7gmauUuUEDC0qyLuD5yDznL7duMRDqi1g2YZj5Dnwit6kyLBqUTg7o6LPuFB1pJwF4PgcRgrvtA3gYaNJ3++74aMuERMc8mkVxBoc5qUI0qnJ2ztHU= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by BN0PR10MB5158.namprd10.prod.outlook.com (2603:10b6:408:120::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Thu, 21 Sep 2023 18:12:55 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8979:3e3f:c3e0:8dfa]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8979:3e3f:c3e0:8dfa%4]) with mapi id 15.20.6792.026; Thu, 21 Sep 2023 18:12:55 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pedro.falcato@gmail.com, stable , "Liam R. Howlett" Subject: [PATCH 1/2] maple_tree: Add mas_active() to detect in-tree walks Date: Thu, 21 Sep 2023 14:12:35 -0400 Message-Id: <20230921181236.509072-2-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230921181236.509072-1-Liam.Howlett@oracle.com> References: <20230921181236.509072-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0470.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d6::17) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|BN0PR10MB5158:EE_ X-MS-Office365-Filtering-Correlation-Id: aa9a95ce-acab-435d-aaa0-08dbbace60fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UGJukz2vzpqgfI4Z3P9kKMEoSipUZQ3fx+EGgl15rmYaY1beRaPpS/wtojDquNturz7P34kF3ksLDQKOwYJ0W1NAvcGOVoJ7I3U4Nitkca8391QsxFizu8fNa6Ro9Dx3FiaIbQMBGQgXhfjCcx6BRcjoHwjHcqSyc6abp0p2dsGeL7T1vx30kpNc/N2gCr9hU2eIL7PWGo/InlrZH3SBvdfT74GEU3NQQTcDqmt9320aSwQ9F0Bzm+0lTLK204Y+uM5jUOUpTqS7VeYx4ROGdGkOkUMJK5GnoIDHrbEVXulDweGA/3ZwryrcqSWNkVLRyWYHfC1feclfzpU+6frKVSJ32d2qH37qzyrY9DLDwQzRoHAqZTlRrQEjfdgb3I4bSvBdx/08d1jglNhtqXf1NoHwBtGhKD02P9YHzpe19QxhIvtGiCI3lQHe8y6Wvuwm5lnQY+q+EyknI6N2EQY7TswhGfk55h/Jf8T7Is0IoU7RZJmn6VKp9UdYMGxewiMppmBWzBwit4lYjy3cUwGBzGo+GpkEshSK7ux56Apq9OWXU0HEUa7YLfXDaX63ROT2 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:(13230031)(376002)(366004)(136003)(346002)(39860400002)(396003)(186009)(451199024)(1800799009)(5660300002)(4744005)(2906002)(4326008)(41300700001)(38100700002)(8936002)(8676002)(316002)(66476007)(66556008)(66946007)(6916009)(54906003)(86362001)(36756003)(26005)(6512007)(2616005)(1076003)(107886003)(6486002)(6506007)(478600001)(6666004);DI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iIRaaeoxPtFsx06yWozo6dUex80h1d/XpeyD+hHJwkatje4/1lrFdZt2Hu+wOC0WdbcUIP8XORjQ095q8IBGxLnYze2nFLoQxcFmiB0SGH5zHgi2gKSOS2xgs1RPfGL/RkD/795x2ID1joTc+x06/Mf//FHuag2HEx4cdvv0b/+Zp+8nu0yWEafitUEZZq7p87IQsqeUuVlgIq9rcqYxaiTnj33lHIo4sqoBR9cNUAgnKtALfO97AOhHtQ4i8tMpTpCbNSRAclJTP5VAzuXwVHp6pj44y7JdNesrKlLjvT5sQEh1nGES99kme7EZ0jnywbbHJ55T/XpsmnsMIBtcKinesuWPuAG4+e44f9FWlbabHN9ChHqvzTigpIUYr8L2L6UgfIMLXe0OIfbfTjjUt/DocYW4Vv254Pf54teI1EJDXJm1Wz/nnCitdGbxkGlCsW3+RiigBLqAYUYbiHcNIy1diG7vMrZrUp/jEMPWit8JVuqKy1ZI3qxzZmY6bzDcxW/Vg1XncvEjTww5qjj8oX6LlNGeZa9q6w2per8RozQsKV2unUG3PethN0DmA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa9a95ce-acab-435d-aaa0-08dbbace60fd X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2023 18:12:55.6966 (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: L0mEROA9BaJTiq/VPsXpT7xUXyYOUVgS24LQWHhAnIVLsk/dyXhU6BafemN/N0HJtpvBs5U+2eK2G9gYJeJIjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5158 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-21_16,2023-09-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309210159 X-Proofpoint-GUID: dsaAO_h3ftXn_8rN_OxIy7MNzk5YF3h7 X-Proofpoint-ORIG-GUID: dsaAO_h3ftXn_8rN_OxIy7MNzk5YF3h7 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 680D8A0046 X-Stat-Signature: 88g13dcrh7kmh58we1i7dfp37nkh7xtf X-HE-Tag: 1695320004-377004 X-HE-Meta: U2FsdGVkX18qWTx+J1OPCRnj2fFz38PplA81t96hZLOUJ5LVGgOkHE37Qk6p0fUnxe+akuOT3FOpZBraKRJQr1uUhOouleM0N1oa4TBYFxgN+NHpasN5gzsJN/ymLsDzDA0Y7ymYiaQIcDSunRoW2M3JG+nSJ0rm3nq6AfI+oSK6osXRzGj/5bbArUyrBhZaMALyyzHrCrXGXkHMBNfKIJFQjLjZ52rkNV4u1nsFBRwb+A7KPs/yNQ2CXcn6rXp2wPCJgt/8VqoW/wjXF5ZxGIHVUhApUQLC/QkJ+sPayuYcR/j3n5jigmSs7Z6NgeTznRSCzWyNWlJWsZg6QWzWkXks0PvcTrfJgg7kWtNn5ElpKYcRXbV1iHMGb1qmZnp5duRtt3Bn9I51hhpN7eIKXGO6fpTnRGnq/PIQHWuLPSGIrnW6r+LM6ofUjge1iKiMkO3WBpOX8QroVHEFQMM2q1erLCJjR16Kl3rlrdoAh+5QZRuCeU5NTyQP4dO46IOoffjwBvHx3Ka+5pENDzNiei/zjGvXc77pgw6FCNSMexl5i0Idh/Lr5YuQr5lUW84pTZYGegFHpyLsDQDagzuFZTI8MFhCKCCi70ialBCaN0Zcz0dGEK368kGrT78MdhG8AqkSG+9jjtBUG1M6kbi1FhfADwSSSgvJU784TI8scaE6sFyqYAobDyxLQHU1IePjrP7Khxt1c7ajFmGVeCFQG6WGc4L680MJrXfIUyaINz2hB7AqLgQ6N9FRJNB9o7L/rE6FdVU85KNrI7TzHzQHHRkwsfWQf1JxRU927NIePz1xSNhuRlCYZhTY2dHcJJKgvEpe2ee3Gv4cDkvccdr7HqJxoXmUkqvb32aprwuwRbB3D7mVNVkRpKJFGLUWQRxCXtVvldgkwJaOO+3ID/J2hua8TJIFdT2SJq6F9zj/e94aJpt0mzHFDxCvWRa+yTBZJFQxIkj62SKZgwPMzlk QC/aqtJW GTalwENY33+HnCqyTqEBKo1gM7v9TZyoASl7nchooBj4OVq18V8RNPHQAhC88rLSTWjxGEjt7UelFBmCWxqEWPDSCH/klqhtu7FmH0V+XKP+2bpQBPK+hpnlM509x97RIx7zFCeyRQQpDCRLfX7xMtqSz4S0U2pV3YME+KUQEnn6Hr7l/8Z0RxW9+tGbSFh5fDPvNl2KfqHEdoOJtRaWS5PyKKsSX8IW/4CHebGcON2FtJZ4bx7qpBCShd+SErskVPulp7E2o1Yok9kyCeXfpWgWP0xr0CSdTtj0C2SbkamIuUXrt8+H0j5f/Vr+1AAe3Gk9cfMqKIU5vnv7Ymhi+JG4m7UNOU5vKkTV3esGOsFKFRWINQPWyZYxiLscjIaff+luIAxXOlSluMzyf5uV5ins1Fs6Ke03c/8IFBxK2V0sUkvjunnbkLRVQZmyr9vKsgqD2LvwrN/AcFfNToWVAfor5ostXYxJ5Dt2mve0o/TLq26WIYdFEHvfFnFCUu1z2OxLGOrsPJQdsUX4smJ6rrKX15Y/a5wjVkExkn3ZgaUcmj5C8C3+oCqSo1n/d26NHAX0RcOnp112AJrttLiDxc8dufs+w1TPiSxIATFnoil1HYSUZNp51at+xpurUpcSStcXrZ61IxTGwu+c= 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: Instead of constantly checking each possibility of the maple state, create a fast path that will skip over checking unlikely states. Signed-off-by: Liam R. Howlett --- include/linux/maple_tree.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index e41c70ac7744..f66f5f78f8cf 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -511,6 +511,15 @@ static inline bool mas_is_paused(const struct ma_state *mas) return mas->node == MAS_PAUSE; } +/* Check if the mas is pointing to a node or not */ +static inline bool mas_is_active(struct ma_state *mas) +{ + if ((unsigned long)mas->node >= MAPLE_RESERVED_RANGE) + return true; + + return false; +} + /** * mas_reset() - Reset a Maple Tree operation state. * @mas: Maple Tree operation state. From patchwork Thu Sep 21 18:12:36 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: 13394243 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 A4655E7D0A2 for ; Thu, 21 Sep 2023 18:13:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 364376B020D; Thu, 21 Sep 2023 14:13:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 314106B020F; Thu, 21 Sep 2023 14:13:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F1E86B0246; Thu, 21 Sep 2023 14:13:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EF0C96B020D for ; Thu, 21 Sep 2023 14:13:34 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B4054A0F90 for ; Thu, 21 Sep 2023 18:13:34 +0000 (UTC) X-FDA: 81261402348.24.144F1F6 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf16.hostedemail.com (Postfix) with ESMTP id 542AF18001B for ; Thu, 21 Sep 2023 18:13:31 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=KWLP1lWV; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Nk7IWFaD; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf16.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=1695320011; 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=MSdCmzhVS/I/zLXGiVcgOOj2URLRbWRWQQI6ktXwUqc=; b=mbvedXCec7WOgM0tB29PqOPaKsmLkMrQlZa0RHeyOiFpAfeXA95PqWJTgRrA5dFUn5EMXb YYGK+vSEhbjgz6hlOjiPXXJr7RLLJMFiUuoMeziYbqrp1LCDdjaOsKOsuD4UnRlFBbFJMx pB+GbOFINmzz3hCl3zW3KvIgU4cVKaY= ARC-Authentication-Results: i=2; imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=KWLP1lWV; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Nk7IWFaD; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf16.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=1695320011; a=rsa-sha256; cv=pass; b=SgB0zLfGO2xl6UvmCKttfitatMZwEVsMDh+pDozrt+A16jTLEYJRQyxI/7jncJZxtwOVqe 6rzInyfj7PdDxXGwMUXiWGwuofLSGszTglrpIuTsLNrfsmVLEHMEBomhssw94Lszq6k1RV qeTgFzic90kpCp27SwtAGtL1fLtUcKA= 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 38LI5AY7011191; Thu, 21 Sep 2023 18:13:23 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=MSdCmzhVS/I/zLXGiVcgOOj2URLRbWRWQQI6ktXwUqc=; b=KWLP1lWVS42YjPYeF7/6cIiDdrZoF2QoZYdKHFOtgo/g7YwxSQpY27Wm8m48sSU3X7jj cxHrulV/V53DfbzlYCQNBblM6r4um8a3+1SlXNmlZrLtoN7NYC6cdEPTA/V6cRT2MRkY /FoS0qvfxiqhVafq+z4wzGAldfPe0rGae9YS/DLA9A69DdyHbHoy3D/rsbpMd5RS/l9x NlUzun+UHw+xVcopiHRZU9G6ferPbOGzJ4Qf1iQ/M4HGi0B4rcoKfANYtsZ+0NoDUIcz I7a0UMBzKfnW700N+cX7gL8CCQc/GXsb5RxboFNjmyU+O0kwe7keA/dnNWXD+4mRXSmR /Q== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t8tsxr0jv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Sep 2023 18:13:22 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38LHPC1D030875; Thu, 21 Sep 2023 18:13:22 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t52t8yn2k-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Sep 2023 18:13:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SPF95kHVJ17aCy1mt72a98S6AyDgfAp0AYC2TanZJDh2afyFo/bYhaOuWTH2f6JG57uFc4ZhAdQ3NJiquJCByk/PDy9Q/tx8BWkpQ5oQWNgOuxJMe9WTvhxIPF3giCXQfnO8gjNahRcrcqg+wDTTUExMeukY2cbOqRiYoFy7wwfFzQyB1/Optad+qY9aTWHt07NZdMcMly7zpqJw1qqBWJKMxCzf9ib6cjrmIreY0+weV7hachRd7KT8cBKRh4KupcgCr7vn8ftREeCkXEYn91lp3WnZlUnHkOQSSsV8BqIGsyVmmMXqomBtZpeKf4nddXjAWzvOp2fJeTGPkjMm2Q== 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=MSdCmzhVS/I/zLXGiVcgOOj2URLRbWRWQQI6ktXwUqc=; b=CrI9aAoVHeaZ0ZUNTONr5xZeayJ1om0rgwR3bt2fmDy5lMKUQLmX2pBNhQU3vXv65cO1Xf2mv6UJB0gvs46/x3wID8mZ9ADdAShylFKh+hTuoI1946wgz31nqu2kzPbz/GtTVe2Ur1f8oBQfn3hAbcHOPSmALSEVbjTXeQYqVSNb0VgTj2C96u9CqnYkY750i3bjAa+NqThAKMXtu8q8Lr+hXiGzLQyFEfrUtBFYWkXwlo1cLBp9DhPTiB2o6CIdFozSbmhpZjQpnu8YSW9R2s8G7TW1O/RjG3IlBojyMRIFsLm07awe/OTSMeQ26RD3smKeRvW61wvTFoKxlQH2HA== 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=MSdCmzhVS/I/zLXGiVcgOOj2URLRbWRWQQI6ktXwUqc=; b=Nk7IWFaDC/+78Xz4QQbaf+R5QyIiCwsA5XrHtnWp3d4y8ijOWDeV/6py1UXDFtLyH4+RgpxqWnWTxc/051NtBGTuDkjKi0OL6889qAUd8MzqdPD2f/n1lLRlNt56qxXjyv5shjGYxWrTsgNCnsuXkPYQmExFKxz17llkOR9P16M= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by BN0PR10MB5158.namprd10.prod.outlook.com (2603:10b6:408:120::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Thu, 21 Sep 2023 18:12:58 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8979:3e3f:c3e0:8dfa]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8979:3e3f:c3e0:8dfa%4]) with mapi id 15.20.6792.026; Thu, 21 Sep 2023 18:12:58 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pedro.falcato@gmail.com, stable , "Liam R. Howlett" Subject: [PATCH 2/2] maple_tree: Add MAS_UNDERFLOW and MAS_OVERFLOW states Date: Thu, 21 Sep 2023 14:12:36 -0400 Message-Id: <20230921181236.509072-3-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230921181236.509072-1-Liam.Howlett@oracle.com> References: <20230921181236.509072-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT1PR01CA0056.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::25) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|BN0PR10MB5158:EE_ X-MS-Office365-Filtering-Correlation-Id: bd54530a-175d-4bd2-2ebd-08dbbace628e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZUMruCIqigI42Zl92GiZda2pzTfCvK+EStnCG9MMer2f6HkoaVGQVbKxrgrc/uIOk9AUWOXC+Qz6uaqfMyjso0q4cTZkYBXVbCwh1neFz37SvAhltoInTzGY5VPseBJGtg1QF6nYLTZS9dWRjh4IpucawHvHvbfbLFCC1fr0wdqRFCk3Ouu+hBxiZHkkS+AvBhU47lT0XZrh+Tdhu2XEpbk3RwYa3yONLnoL98EQfLkoY+zjmjoPdH6kTY/R/sc/BEbo2Y0fQdczJEClTyt0zpP2FfLvduYAk+tMTvOxcYmBi8TzIrJBo0ZZ34wMVJHTwLCqbmBm7ICCFrGfAlPHwTXBLsX9Lf7F1kNnCrX+h7Th8BXBDwsyxEs0AACoAE4rDSUUHt55reFHlsFS3CGb9Sbd3hGxL7ehaSupLBLMNypEg47K7r4LLVJdV0GJEK7TSyP6m0DVfX7wg9mYneDZTFJlzapoKUcepP9oy3QkJN0dXs4yezfKd9ekjXVgNygkhQAELIfVy7gEI/0PEYL4UPTIZJMc1IvH/dVfGNkdXbo= 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:(13230031)(376002)(366004)(136003)(346002)(39860400002)(396003)(186009)(451199024)(1800799009)(5660300002)(2906002)(30864003)(4326008)(41300700001)(38100700002)(8936002)(8676002)(316002)(66476007)(66556008)(66946007)(6916009)(54906003)(86362001)(36756003)(26005)(83380400001)(6512007)(2616005)(1076003)(107886003)(6486002)(6506007)(478600001)(6666004)(966005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VN0TrkaYcCR3YKAMFR/f1sDp1TMg6Bn70XGZRy+yjJ0jXdW0iuLU97Dzir/qytVIKR5SYdwY+vAbc21tnctgrcKiI0Qg5tuA3Um5lE00dcb00j3+FyG9GYv2g3LgGSsx2ejedaYKMSEHgHD467ofK28i+STxpF69cKUlfoOtcaSmaGGQi6cex6IzhAI8yrf3BEump1NspGvAJMIZJV8aRzNa/SjScHzqaeZcLDGCQbZPrcBjSdjKFYdkjfL9JjuSzmy0ep8f+aOERervfhjfrnN2m6eKaf7dFaxItS5W30vhd1pjr1ibzrqy8afJmQWNEuclPVJQaY3baUihzPHpQ73wyMzGIorggw/Hp4ca0ASLeT3inPXENegV91nSn2AZQV3CGVjz547Q1YUevm+AnYRre4gy6TzzAJDal3/jJ5w1LFKljemB2rjVQXLWun08m88cj/a0QBMBRtu2kF/bRnOuH8s4UDPve/s+2835kSFk5XBZvstFdxVibtbvj0LlygwOwtNm6Hlsi3h6jiTQVAt5k1Xoir8ISDM8YKft4mmrcOFBb37RkDzxEANLkWLlainEbujE0dtDZPftm/v2Ff1Gop+JdNNoIJvqiqayHYTgHwyN31WYCz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5/z35gV6+YvRslA1joH/aetJIIGH4WyO7DOGfwk8P9XGjKdF0N+BP4+P7G90oQgq8Dlclx2ePrwp4GtiYqRFcvSbCWrsFkZpElWVtbNVae/sB+SXFW4T+hunYsM1NOTo6IuIoZ7O6uo0j0W0aWyOreJ3npbp8D/2MjSdmvn5fg5XfKKxjBOPzjYAiP1SmCH/I98PwR9TPV0v44sRx76xqeMPu/xkgfv6gGOuEoF8q2pYG+nWeSAc8IVXDdf7rEH9U0en1ypboSZX6L/Dfp/pQmE/H2eDfgW/1YK1BQOHLjZm+Ny6b6JQtHs5tCrqNj9fdLXfoER91OT6EY0z193C1fQ1KPCDuSAzhRhfU8j44B6Q7D4P79RR/rtrBVsFYawFLUnzoajahLgASLmFpkThAWUMSEA3ojJKgkvgzlrHOVBK7JR8is+a5YPTV2B1zDKsWael2lPNdwZN4gW6BM0EilvLFq6Q4iDEBSVNDZeTGPhVraVtdbFQOUpCD1M1dEGaIqCakJNHcCywa/4hD4Z4EYIy1oKg8IFSZZdKynxkReu56AdaAcYr4kFxu65vLcQ87NwpPy8DM4U22sITxCczASZijsS2eDJ77DkzMsZVf3H7lzF2JZBSL4xT4wD6penwrLKQ9pOHaWaCj9gfiKpTOpbwXcgAToO5Pm/u7tqOz1+eCF/vyMILPUWGJdcHQ2fstqEwi5jELTcM7aPkK5l068KGgJZ/uoEy/mAwgq+dorrXHxzq7DMtRyLXfu1o13bDfxxB4wDYMOfumLrSK8+286zDS56bToNowuBP4EccTcV0eG867MBT3Y9jSRtzePOfgtgZowq7qkAQbfabwsFU8BO9koW8Z+DNYvWo3Tn2IutGiKQHjSbCMGoazEn4QiB1g3HIS3OTsETX/zDcIqUCCra7sctzch230J8aHvCdNigbI5OvyHjmwjS+EjA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd54530a-175d-4bd2-2ebd-08dbbace628e X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2023 18:12:58.4195 (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: IyEOZ+ZY9KzvS2/8zbrUuaVQWu3hzsHDH2cny3Oo3oYf9fXp0DXgJhy6AUXa1A21Nj35STiJ/y1O4IHV7WqWgQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5158 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-21_16,2023-09-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309210159 X-Proofpoint-ORIG-GUID: UmPb45QrXnD4_1u4JegkvXMQp1aJD73w X-Proofpoint-GUID: UmPb45QrXnD4_1u4JegkvXMQp1aJD73w X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 542AF18001B X-Stat-Signature: fpgkmo7is3zt6tz9ir8jts96knqa5pns X-Rspam-User: X-HE-Tag: 1695320011-933112 X-HE-Meta: U2FsdGVkX1/Hc1TfdDyLzyE3kgqKkhTzueGMo3NTSvg1juGUfTMFrzFY7YN/EVFk1sUDncbg8GIh44A3ZV0hFKlsgumhKPD4lhGEsy93jjdZ4R3si318k6wY7aWBbZ+BN6dU/N277Pb7Sz4XlqeBC5jTMHjnNLnOGMzdXdh6+MGso7AA8zXbgMTuzf48xgRje4AMDntpFfcLJULrfJSiRbR+QLCr7gE9tC/ZjqmqCRBeRXIviVOkxF5X3/UpL8xXMzBP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Ms8cbXZPR+fmud2IchTB5odNsHZ99NANgisBvcpV3wxxRJ9p/1InrDSOrFL8RPjeUJSGTJtvPFm+yeUE8XgHuWRTf+JKIGxg7eB1wZ7hmRhn8aFy5ocXYp6Vqjt4kiQj/85LxnSyOP8E+IwE0eke2xBwBwMEzFyBNw/uD6NgD74dEmGPV8ZNxpUtr9D68r3H4YL5olQmus7caLP/8YzofITDyQPtwP3RcGJCadE4wSRwCCswt6aUNxSdA7YL77BmUwWE/C9ccWFdFgXXIRF9E6q 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: When updating the maple tree iterator to avoid rewalks, an issue was introduced when shifting beyond the limits. This can be seen by trying to go to the previous address of 0, which would set the maple node to MAS_NONE and keep the range as the last entry. Subsequent calls to mas_find() would then search upwards from mas->last and skip the value at mas->index/mas->last. This showed up as a bug in mprotect which skips the actual VMA at the current range after attempting to go to the previous VMA from 0. Since MAS_NONE is used for handling of the maple tree when it's a single entry at 0 (just a pointer), changing the handling of MAS_NONE in mas_find() would make the code more complicated and error prone. Furthermore, there was no way to tell which limit was hit, and thus which action to take (next or the entry at the current range). This solution is to add two states to track what happened with the previous iterator action. This allows for the expected behaviour of the next command to return the correct item (either the item at the range requested, or the next/previous). Tests are also added and updated accordingly. Reported-by: pedro.falcato@gmail.com Link: https://gist.github.com/heatd/85d2971fae1501b55b6ea401fbbe485b Fixes: 39193685d585 ("maple_tree: try harder to keep active node with mas_prev()") Cc: stable Signed-off-by: Liam R. Howlett --- include/linux/maple_tree.h | 2 + lib/maple_tree.c | 221 +++++++++++++++++++++++++++---------- lib/test_maple_tree.c | 87 ++++++++++++--- 3 files changed, 237 insertions(+), 73 deletions(-) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index f66f5f78f8cf..d01e850b570f 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -428,6 +428,8 @@ struct ma_wr_state { #define MAS_ROOT ((struct maple_enode *)5UL) #define MAS_NONE ((struct maple_enode *)9UL) #define MAS_PAUSE ((struct maple_enode *)17UL) +#define MAS_OVERFLOW ((struct maple_enode *)33UL) +#define MAS_UNDERFLOW ((struct maple_enode *)65UL) #define MA_ERROR(err) \ ((struct maple_enode *)(((unsigned long)err << 2) | 2UL)) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index ee1ff0c59fd7..0e00a84e8e8f 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -256,6 +256,22 @@ bool mas_is_err(struct ma_state *mas) return xa_is_err(mas->node); } +static __always_inline bool mas_is_overflow(struct ma_state *mas) +{ + if (unlikely(mas->node == MAS_OVERFLOW)) + return true; + + return false; +} + +static __always_inline bool mas_is_underflow(struct ma_state *mas) +{ + if (unlikely(mas->node == MAS_UNDERFLOW)) + return true; + + return false; +} + static inline bool mas_searchable(struct ma_state *mas) { if (mas_is_none(mas)) @@ -4415,10 +4431,13 @@ static inline int mas_prev_node(struct ma_state *mas, unsigned long min) * * @mas: The maple state * @max: The minimum starting range + * @empty: Can be empty + * @set_underflow: Set the @mas->node to underflow state on limit. * * Return: The entry in the previous slot which is possibly NULL */ -static void *mas_prev_slot(struct ma_state *mas, unsigned long min, bool empty) +static void *mas_prev_slot(struct ma_state *mas, unsigned long min, bool empty, + bool set_underflow) { void *entry; void __rcu **slots; @@ -4435,7 +4454,6 @@ static void *mas_prev_slot(struct ma_state *mas, unsigned long min, bool empty) if (unlikely(mas_rewalk_if_dead(mas, node, save_point))) goto retry; -again: if (mas->min <= min) { pivot = mas_safe_min(mas, pivots, mas->offset); @@ -4443,9 +4461,10 @@ static void *mas_prev_slot(struct ma_state *mas, unsigned long min, bool empty) goto retry; if (pivot <= min) - return NULL; + goto underflow; } +again: if (likely(mas->offset)) { mas->offset--; mas->last = mas->index - 1; @@ -4457,7 +4476,7 @@ static void *mas_prev_slot(struct ma_state *mas, unsigned long min, bool empty) } if (mas_is_none(mas)) - return NULL; + goto underflow; mas->last = mas->max; node = mas_mn(mas); @@ -4474,10 +4493,19 @@ static void *mas_prev_slot(struct ma_state *mas, unsigned long min, bool empty) if (likely(entry)) return entry; - if (!empty) + if (!empty) { + if (mas->index <= min) + goto underflow; + goto again; + } return entry; + +underflow: + if (set_underflow) + mas->node = MAS_UNDERFLOW; + return NULL; } /* @@ -4567,10 +4595,13 @@ static inline int mas_next_node(struct ma_state *mas, struct maple_node *node, * @mas: The maple state * @max: The maximum starting range * @empty: Can be empty + * @set_overflow: Should @mas->node be set to overflow when the limit is + * reached. * * Return: The entry in the next slot which is possibly NULL */ -static void *mas_next_slot(struct ma_state *mas, unsigned long max, bool empty) +static void *mas_next_slot(struct ma_state *mas, unsigned long max, bool empty, + bool set_overflow) { void __rcu **slots; unsigned long *pivots; @@ -4589,22 +4620,22 @@ static void *mas_next_slot(struct ma_state *mas, unsigned long max, bool empty) if (unlikely(mas_rewalk_if_dead(mas, node, save_point))) goto retry; -again: if (mas->max >= max) { if (likely(mas->offset < data_end)) pivot = pivots[mas->offset]; else - return NULL; /* must be mas->max */ + goto overflow; if (unlikely(mas_rewalk_if_dead(mas, node, save_point))) goto retry; if (pivot >= max) - return NULL; + goto overflow; } if (likely(mas->offset < data_end)) { mas->index = pivots[mas->offset] + 1; +again: mas->offset++; if (likely(mas->offset < data_end)) mas->last = pivots[mas->offset]; @@ -4616,8 +4647,11 @@ static void *mas_next_slot(struct ma_state *mas, unsigned long max, bool empty) goto retry; } - if (mas_is_none(mas)) + if (WARN_ON_ONCE(mas_is_none(mas))) { + mas->node = MAS_OVERFLOW; return NULL; + goto overflow; + } mas->offset = 0; mas->index = mas->min; @@ -4636,12 +4670,20 @@ static void *mas_next_slot(struct ma_state *mas, unsigned long max, bool empty) return entry; if (!empty) { - if (!mas->offset) - data_end = 2; + if (mas->last >= max) + goto overflow; + + mas->index = mas->last + 1; + /* Node cannot end on NULL, so it's safe to short-cut here */ goto again; } return entry; + +overflow: + if (set_overflow) + mas->node = MAS_OVERFLOW; + return NULL; } /* @@ -4651,17 +4693,20 @@ static void *mas_next_slot(struct ma_state *mas, unsigned long max, bool empty) * * Set the @mas->node to the next entry and the range_start to * the beginning value for the entry. Does not check beyond @limit. - * Sets @mas->index and @mas->last to the limit if it is hit. + * Sets @mas->index and @mas->last to the range, Does not update @mas->index and + * @mas->last on overflow. * Restarts on dead nodes. * * Return: the next entry or %NULL. */ static inline void *mas_next_entry(struct ma_state *mas, unsigned long limit) { - if (mas->last >= limit) + if (mas->last >= limit) { + mas->node = MAS_OVERFLOW; return NULL; + } - return mas_next_slot(mas, limit, false); + return mas_next_slot(mas, limit, false, true); } /* @@ -4837,7 +4882,7 @@ void *mas_walk(struct ma_state *mas) { void *entry; - if (mas_is_none(mas) || mas_is_paused(mas) || mas_is_ptr(mas)) + if (!mas_is_active(mas) || !mas_is_start(mas)) mas->node = MAS_START; retry: entry = mas_state_walk(mas); @@ -5294,14 +5339,22 @@ static inline void mte_destroy_walk(struct maple_enode *enode, static void mas_wr_store_setup(struct ma_wr_state *wr_mas) { - if (mas_is_start(wr_mas->mas)) - return; + if (!mas_is_active(wr_mas->mas)) { + if (mas_is_start(wr_mas->mas)) + return; - if (unlikely(mas_is_paused(wr_mas->mas))) - goto reset; + if (unlikely(mas_is_paused(wr_mas->mas))) + goto reset; - if (unlikely(mas_is_none(wr_mas->mas))) - goto reset; + if (unlikely(mas_is_none(wr_mas->mas))) + goto reset; + + if (unlikely(mas_is_overflow(wr_mas->mas))) + goto reset; + + if (unlikely(mas_is_underflow(wr_mas->mas))) + goto reset; + } /* * A less strict version of mas_is_span_wr() where we allow spanning @@ -5595,8 +5648,25 @@ static inline bool mas_next_setup(struct ma_state *mas, unsigned long max, { bool was_none = mas_is_none(mas); - if (mas_is_none(mas) || mas_is_paused(mas)) + if (unlikely(mas->last >= max)) { + mas->node = MAS_OVERFLOW; + return true; + } + + if (mas_is_active(mas)) + return false; + + if (mas_is_none(mas) || mas_is_paused(mas)) { + mas->node = MAS_START; + } else if (mas_is_overflow(mas)) { + /* Overflowed before, but the max changed */ mas->node = MAS_START; + } else if (mas_is_underflow(mas)) { + mas->node = MAS_START; + *entry = mas_walk(mas); + if (*entry) + return true; + } if (mas_is_start(mas)) *entry = mas_walk(mas); /* Retries on dead nodes handled by mas_walk */ @@ -5615,6 +5685,7 @@ static inline bool mas_next_setup(struct ma_state *mas, unsigned long max, if (mas_is_none(mas)) return true; + return false; } @@ -5637,7 +5708,7 @@ void *mas_next(struct ma_state *mas, unsigned long max) return entry; /* Retries on dead nodes handled by mas_next_slot */ - return mas_next_slot(mas, max, false); + return mas_next_slot(mas, max, false, true); } EXPORT_SYMBOL_GPL(mas_next); @@ -5660,7 +5731,7 @@ void *mas_next_range(struct ma_state *mas, unsigned long max) return entry; /* Retries on dead nodes handled by mas_next_slot */ - return mas_next_slot(mas, max, true); + return mas_next_slot(mas, max, true, true); } EXPORT_SYMBOL_GPL(mas_next_range); @@ -5691,18 +5762,31 @@ EXPORT_SYMBOL_GPL(mt_next); static inline bool mas_prev_setup(struct ma_state *mas, unsigned long min, void **entry) { - if (mas->index <= min) - goto none; + if (unlikely(mas->index <= min)) { + mas->node = MAS_UNDERFLOW; + return true; + } - if (mas_is_none(mas) || mas_is_paused(mas)) + if (mas_is_active(mas)) + return false; + + if (mas_is_overflow(mas)) { mas->node = MAS_START; + *entry = mas_walk(mas); + if (*entry) + return true; + } - if (mas_is_start(mas)) { - mas_walk(mas); - if (!mas->index) - goto none; + if (mas_is_none(mas) || mas_is_paused(mas)) { + mas->node = MAS_START; + } else if (mas_is_underflow(mas)) { + /* underflowed before but the min changed */ + mas->node = MAS_START; } + if (mas_is_start(mas)) + mas_walk(mas); + if (unlikely(mas_is_ptr(mas))) { if (!mas->index) goto none; @@ -5747,7 +5831,7 @@ void *mas_prev(struct ma_state *mas, unsigned long min) if (mas_prev_setup(mas, min, &entry)) return entry; - return mas_prev_slot(mas, min, false); + return mas_prev_slot(mas, min, false, true); } EXPORT_SYMBOL_GPL(mas_prev); @@ -5770,7 +5854,7 @@ void *mas_prev_range(struct ma_state *mas, unsigned long min) if (mas_prev_setup(mas, min, &entry)) return entry; - return mas_prev_slot(mas, min, true); + return mas_prev_slot(mas, min, true, true); } EXPORT_SYMBOL_GPL(mas_prev_range); @@ -5828,24 +5912,35 @@ EXPORT_SYMBOL_GPL(mas_pause); static inline bool mas_find_setup(struct ma_state *mas, unsigned long max, void **entry) { - *entry = NULL; + if (mas_is_active(mas)) { + if (mas->last < max) + return false; - if (unlikely(mas_is_none(mas))) { + return true; + } + + if (mas_is_paused(mas)) { if (unlikely(mas->last >= max)) return true; - mas->index = mas->last; + mas->index = ++mas->last; mas->node = MAS_START; - } else if (unlikely(mas_is_paused(mas))) { + } else if (mas_is_none(mas)) { if (unlikely(mas->last >= max)) return true; + mas->index = mas->last; mas->node = MAS_START; - mas->index = ++mas->last; - } else if (unlikely(mas_is_ptr(mas))) - goto ptr_out_of_range; + } else if (mas_is_overflow(mas) || mas_is_underflow(mas)) { + if (mas->index > max) { + mas->node = MAS_OVERFLOW; + return true; + } + + mas->node = MAS_START; + } - if (unlikely(mas_is_start(mas))) { + if (mas_is_start(mas)) { /* First run or continue */ if (mas->index > max) return true; @@ -5895,7 +5990,7 @@ void *mas_find(struct ma_state *mas, unsigned long max) return entry; /* Retries on dead nodes handled by mas_next_slot */ - return mas_next_slot(mas, max, false); + return mas_next_slot(mas, max, false, false); } EXPORT_SYMBOL_GPL(mas_find); @@ -5913,13 +6008,13 @@ EXPORT_SYMBOL_GPL(mas_find); */ void *mas_find_range(struct ma_state *mas, unsigned long max) { - void *entry; + void *entry = NULL; if (mas_find_setup(mas, max, &entry)) return entry; /* Retries on dead nodes handled by mas_next_slot */ - return mas_next_slot(mas, max, true); + return mas_next_slot(mas, max, true, false); } EXPORT_SYMBOL_GPL(mas_find_range); @@ -5934,26 +6029,36 @@ EXPORT_SYMBOL_GPL(mas_find_range); static inline bool mas_find_rev_setup(struct ma_state *mas, unsigned long min, void **entry) { - *entry = NULL; - - if (unlikely(mas_is_none(mas))) { - if (mas->index <= min) - goto none; + if (mas_is_active(mas)) { + if (mas->index > min) + return false; - mas->last = mas->index; - mas->node = MAS_START; + return true; } - if (unlikely(mas_is_paused(mas))) { + if (mas_is_paused(mas)) { if (unlikely(mas->index <= min)) { mas->node = MAS_NONE; return true; } mas->node = MAS_START; mas->last = --mas->index; + } else if (mas_is_none(mas)) { + if (mas->index <= min) + goto none; + + mas->last = mas->index; + mas->node = MAS_START; + } else if (mas_is_underflow(mas) || mas_is_overflow(mas)) { + if (mas->last <= min) { + mas->node = MAS_UNDERFLOW; + return true; + } + + mas->node = MAS_START; } - if (unlikely(mas_is_start(mas))) { + if (mas_is_start(mas)) { /* First run or continue */ if (mas->index < min) return true; @@ -6004,13 +6109,13 @@ static inline bool mas_find_rev_setup(struct ma_state *mas, unsigned long min, */ void *mas_find_rev(struct ma_state *mas, unsigned long min) { - void *entry; + void *entry = NULL; if (mas_find_rev_setup(mas, min, &entry)) return entry; /* Retries on dead nodes handled by mas_prev_slot */ - return mas_prev_slot(mas, min, false); + return mas_prev_slot(mas, min, false, false); } EXPORT_SYMBOL_GPL(mas_find_rev); @@ -6030,13 +6135,13 @@ EXPORT_SYMBOL_GPL(mas_find_rev); */ void *mas_find_range_rev(struct ma_state *mas, unsigned long min) { - void *entry; + void *entry = NULL; if (mas_find_rev_setup(mas, min, &entry)) return entry; /* Retries on dead nodes handled by mas_prev_slot */ - return mas_prev_slot(mas, min, true); + return mas_prev_slot(mas, min, true, false); } EXPORT_SYMBOL_GPL(mas_find_range_rev); diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index 0674aebd4423..06959165e2f9 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -2166,7 +2166,7 @@ static noinline void __init next_prev_test(struct maple_tree *mt) MT_BUG_ON(mt, val != NULL); MT_BUG_ON(mt, mas.index != 0); MT_BUG_ON(mt, mas.last != 5); - MT_BUG_ON(mt, mas.node != MAS_NONE); + MT_BUG_ON(mt, mas.node != MAS_UNDERFLOW); mas.index = 0; mas.last = 5; @@ -2917,6 +2917,7 @@ static noinline void __init check_empty_area_fill(struct maple_tree *mt) * exists MAS_NONE active range * exists active active range * DNE active active set to last range + * ERANGE active MAS_OVERFLOW last range * * Function ENTRY Start Result index & last * mas_prev() @@ -2945,6 +2946,7 @@ static noinline void __init check_empty_area_fill(struct maple_tree *mt) * any MAS_ROOT MAS_NONE 0 * exists active active range * DNE active active last range + * ERANGE active MAS_UNDERFLOW last range * * Function ENTRY Start Result index & last * mas_find() @@ -2955,7 +2957,7 @@ static noinline void __init check_empty_area_fill(struct maple_tree *mt) * DNE MAS_START MAS_NONE 0 * DNE MAS_PAUSE MAS_NONE 0 * DNE MAS_ROOT MAS_NONE 0 - * DNE MAS_NONE MAS_NONE 0 + * DNE MAS_NONE MAS_NONE 1 * if index == 0 * exists MAS_START MAS_ROOT 0 * exists MAS_PAUSE MAS_ROOT 0 @@ -2967,7 +2969,7 @@ static noinline void __init check_empty_area_fill(struct maple_tree *mt) * DNE MAS_START active set to max * exists MAS_PAUSE active range * DNE MAS_PAUSE active set to max - * exists MAS_NONE active range + * exists MAS_NONE active range (start at last) * exists active active range * DNE active active last range (max < last) * @@ -2992,7 +2994,7 @@ static noinline void __init check_empty_area_fill(struct maple_tree *mt) * DNE MAS_START active set to min * exists MAS_PAUSE active range * DNE MAS_PAUSE active set to min - * exists MAS_NONE active range + * exists MAS_NONE active range (start at index) * exists active active range * DNE active active last range (min > index) * @@ -3039,10 +3041,10 @@ static noinline void __init check_state_handling(struct maple_tree *mt) mtree_store_range(mt, 0, 0, ptr, GFP_KERNEL); mas_lock(&mas); - /* prev: Start -> none */ + /* prev: Start -> underflow*/ entry = mas_prev(&mas, 0); MT_BUG_ON(mt, entry != NULL); - MT_BUG_ON(mt, mas.node != MAS_NONE); + MT_BUG_ON(mt, mas.node != MAS_UNDERFLOW); /* prev: Start -> root */ mas_set(&mas, 10); @@ -3069,7 +3071,7 @@ static noinline void __init check_state_handling(struct maple_tree *mt) MT_BUG_ON(mt, entry != NULL); MT_BUG_ON(mt, mas.node != MAS_NONE); - /* next: start -> none */ + /* next: start -> none*/ mas_set(&mas, 10); entry = mas_next(&mas, ULONG_MAX); MT_BUG_ON(mt, mas.index != 1); @@ -3268,25 +3270,46 @@ static noinline void __init check_state_handling(struct maple_tree *mt) MT_BUG_ON(mt, mas.last != 0x2500); MT_BUG_ON(mt, !mas_active(mas)); - /* next:active -> active out of range*/ + /* next:active -> active beyond data */ entry = mas_next(&mas, 0x2999); MT_BUG_ON(mt, entry != NULL); MT_BUG_ON(mt, mas.index != 0x2501); MT_BUG_ON(mt, mas.last != 0x2fff); MT_BUG_ON(mt, !mas_active(mas)); - /* Continue after out of range*/ + /* Continue after last range ends after max */ entry = mas_next(&mas, ULONG_MAX); MT_BUG_ON(mt, entry != ptr3); MT_BUG_ON(mt, mas.index != 0x3000); MT_BUG_ON(mt, mas.last != 0x3500); MT_BUG_ON(mt, !mas_active(mas)); - /* next:active -> active out of range*/ + /* next:active -> active continued */ + entry = mas_next(&mas, ULONG_MAX); + MT_BUG_ON(mt, entry != NULL); + MT_BUG_ON(mt, mas.index != 0x3501); + MT_BUG_ON(mt, mas.last != ULONG_MAX); + MT_BUG_ON(mt, !mas_active(mas)); + + /* next:active -> overflow */ entry = mas_next(&mas, ULONG_MAX); MT_BUG_ON(mt, entry != NULL); MT_BUG_ON(mt, mas.index != 0x3501); MT_BUG_ON(mt, mas.last != ULONG_MAX); + MT_BUG_ON(mt, mas.node != MAS_OVERFLOW); + + /* next:overflow -> overflow */ + entry = mas_next(&mas, ULONG_MAX); + MT_BUG_ON(mt, entry != NULL); + MT_BUG_ON(mt, mas.index != 0x3501); + MT_BUG_ON(mt, mas.last != ULONG_MAX); + MT_BUG_ON(mt, mas.node != MAS_OVERFLOW); + + /* prev:overflow -> active */ + entry = mas_prev(&mas, 0); + MT_BUG_ON(mt, entry != ptr3); + MT_BUG_ON(mt, mas.index != 0x3000); + MT_BUG_ON(mt, mas.last != 0x3500); MT_BUG_ON(mt, !mas_active(mas)); /* next: none -> active, skip value at location */ @@ -3307,11 +3330,46 @@ static noinline void __init check_state_handling(struct maple_tree *mt) MT_BUG_ON(mt, mas.last != 0x1500); MT_BUG_ON(mt, !mas_active(mas)); - /* prev:active -> active out of range*/ + /* prev:active -> active spanning end range */ + entry = mas_prev(&mas, 0x0100); + MT_BUG_ON(mt, entry != NULL); + MT_BUG_ON(mt, mas.index != 0); + MT_BUG_ON(mt, mas.last != 0x0FFF); + MT_BUG_ON(mt, !mas_active(mas)); + + /* prev:active -> underflow */ + entry = mas_prev(&mas, 0); + MT_BUG_ON(mt, entry != NULL); + MT_BUG_ON(mt, mas.index != 0); + MT_BUG_ON(mt, mas.last != 0x0FFF); + MT_BUG_ON(mt, mas.node != MAS_UNDERFLOW); + + /* prev:underflow -> underflow */ entry = mas_prev(&mas, 0); MT_BUG_ON(mt, entry != NULL); MT_BUG_ON(mt, mas.index != 0); MT_BUG_ON(mt, mas.last != 0x0FFF); + MT_BUG_ON(mt, mas.node != MAS_UNDERFLOW); + + /* next:underflow -> active */ + entry = mas_next(&mas, ULONG_MAX); + MT_BUG_ON(mt, entry != ptr); + MT_BUG_ON(mt, mas.index != 0x1000); + MT_BUG_ON(mt, mas.last != 0x1500); + MT_BUG_ON(mt, !mas_active(mas)); + + /* prev:first value -> underflow */ + entry = mas_prev(&mas, 0x1000); + MT_BUG_ON(mt, entry != NULL); + MT_BUG_ON(mt, mas.index != 0x1000); + MT_BUG_ON(mt, mas.last != 0x1500); + MT_BUG_ON(mt, mas.node != MAS_UNDERFLOW); + + /* find:underflow -> first value */ + entry = mas_find(&mas, ULONG_MAX); + MT_BUG_ON(mt, entry != ptr); + MT_BUG_ON(mt, mas.index != 0x1000); + MT_BUG_ON(mt, mas.last != 0x1500); MT_BUG_ON(mt, !mas_active(mas)); /* prev: pause ->active */ @@ -3325,14 +3383,14 @@ static noinline void __init check_state_handling(struct maple_tree *mt) MT_BUG_ON(mt, mas.last != 0x2500); MT_BUG_ON(mt, !mas_active(mas)); - /* prev:active -> active out of range*/ + /* prev:active -> active spanning min */ entry = mas_prev(&mas, 0x1600); MT_BUG_ON(mt, entry != NULL); MT_BUG_ON(mt, mas.index != 0x1501); MT_BUG_ON(mt, mas.last != 0x1FFF); MT_BUG_ON(mt, !mas_active(mas)); - /* prev: active ->active, continue*/ + /* prev: active ->active, continue */ entry = mas_prev(&mas, 0); MT_BUG_ON(mt, entry != ptr); MT_BUG_ON(mt, mas.index != 0x1000); @@ -3379,7 +3437,7 @@ static noinline void __init check_state_handling(struct maple_tree *mt) MT_BUG_ON(mt, mas.last != 0x2FFF); MT_BUG_ON(mt, !mas_active(mas)); - /* find: none ->active */ + /* find: overflow ->active */ entry = mas_find(&mas, 0x5000); MT_BUG_ON(mt, entry != ptr3); MT_BUG_ON(mt, mas.index != 0x3000); @@ -3778,7 +3836,6 @@ static int __init maple_tree_seed(void) check_empty_area_fill(&tree); mtree_destroy(&tree); - mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE); check_state_handling(&tree); mtree_destroy(&tree);