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: 142912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5141221vqi; Thu, 21 Sep 2023 14:11:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEkHM2pwk8G2Tio3rdHfjqGLPoePW8+yNoTKjF/som02kEOf+ORH9PEtFOVMZ84Qv+OqM5Q X-Received: by 2002:a05:6870:4799:b0:1d6:cd8a:d99e with SMTP id c25-20020a056870479900b001d6cd8ad99emr7601712oaq.0.1695330670351; Thu, 21 Sep 2023 14:11:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695330670; cv=pass; d=google.com; s=arc-20160816; b=pYlx8rt0A6vzKUvFX1N8GAVNaFnd5aAGGeTJdnAqeoCqv+IKt1vXx8L4vjRTdOd06F bOonWaJNVRFdZJGe8sh9NXLrVWGldV75srio+rJF2S9+WsBng0qCSkJOWxTfkhBG20sz Owco03vJscKsAZVLiDMqCetAuDDvPgMxZCWghDBh2qCEu1ygTPnsyRbY685fuT3L1hN4 fowrlSGJ8ykj+lr2vFZe1ivTu+qBerizIu7N8cv3TocqgxqqFeorlsSD2uMxNRG8bmY+ 50HmNCHbZhzWZoCtfEV5WQVTGIk5whDxhn6o9LEN1H++qhbLpdTc+mZPzyCo2AsU0KJT UHng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=ubzRy/J3CaNQKXWbZ+x7hIiS+95zrwHNV/oKW0YUlk8=; fh=vvTzGQq2kjyMXlnFq0LWLmmDSFcqxM3YcNXUiN4Pqss=; b=ZVv4zl9p3LtNeH06Ctpmxe8dmPbrEqIoLuYcm0Ajry2OjxdOXsIuQw6YWHSR61xk9w W8gtYmj8ET0xnF6YIO0KTcwIROvvDY8YUSEQ1S1LhTvEqTlZeYM8AlFbnQO5U2W4hNsb dGisbIGxiC9EW/hLlgvZWLxgzPO/EHD9SfJ1RLVIsujSzTQ9ab/jFR7zZbFc1Ym1uvSh bGmW8lIdWAwWnFmBkDJ+G9H8Jsc3rZUdNo3PcwJyD1upIq4zy+pS/CBp0+rU3482ekCb ivaCOF+YaIll0UAG+wrNGaF9HAFpPBA8QGEOCG+ZiJT4h062ik4plHPO3K/QFVZtWkY4 yZQQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=gyGWKrA2; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=KL24Vmrv; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bg26-20020a056a02011a00b00563deb65f93si2144353pgb.200.2023.09.21.14.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 14:11:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=gyGWKrA2; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=KL24Vmrv; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5B5B5818C7A5; Thu, 21 Sep 2023 13:58:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232304AbjIUU6p (ORCPT + 29 others); Thu, 21 Sep 2023 16:58:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232203AbjIUU6R (ORCPT ); Thu, 21 Sep 2023 16:58:17 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59825A4A91 for ; Thu, 21 Sep 2023 11:13:57 -0700 (PDT) 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);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yZkQZuRBJfnQxTDunhrskpmGyKTa5r8epY51W+Fk2Q+BXVO/35XbCdJ9s6cUcnar3PsvXb/C1ms6OuaYVfXfD/ss00bq95cC7mFGTiXudCdrZilb0z2aH/BvYY82Ao5Soy77s5BdFELDvGxIcWrjNlEU3VCCrqz1xzazAW4nDgav4DK1ZFoTSXokfo8qqoVjQnrkps/flL1oGgqPO9V72L4UlKvq1Xi7iUrAAsSc0w65czGjhFsGVnly2r5Nm3Ai2cpggJqVpvJD4KNrmd9KvXFy4DO/rtPB+bLRcqg7uywszov0nDiiUe1DT3xI+8EyvO561xuBOOzY2/EZq/rHxMnehqx5wQA3AEq3HVrJTMbvkvnuM31wJUeXlDVLxXBxaM+tphaG95+QQOkHEiKQK4SESsZFB/J7Kixb83osk9xH16QL3ECZmrG1+QEGiN3n6Io6Lh/+678vSXW4cpIvlQb5/5dgI3JeiwJzUqaY9ARM9XQ7jxhndc1m2pd6ymGhqFVjvXo32iU58lQf+enjqPynwJu2Q8hJZeSO4xh5SsBn3fKrg0tZ6YBfVw6Fl09ogfWgDDdtGEq9V93TO1bhBQBRhsMk/rWKBUEWbf5+xgGrymq+UTj84bfbFmHXE3Rdr1u996nJBQk8qN+58hUKwyIERz+eOYoexmxICv2EwQW5XGKqly86DbK9NSNX1MJdl5rULPIOe/UjdxnmyIu6Zu3C7l4/W+dcACbYEPW6XFqVUwH738SkRcdhuyGpeEFPxzQ9kBPY7/6cZ/HNPZrsaxXVXvWQanQvdBHTtgpO+YIBPavlRERBk7dd909sniBYDjdPf9z5VX5YNjBddikX7gMHfVhTitibgNIhViMeAjNNgRejBwEHu8gSXtAQAKZqvbgO1uFPN9m2Fnuvs750xRrlkOI3KGRFG/o2yKfyfwxG6pAtxTI88qsJ7ZYb5pshM4k/+UnTm1QFKrSjxJZozbUsB1mM84NCTctmEM+iRoLvpTTGOZm3w+vfZogY837tioGm+BeQk5xiX4uZYoGZYdClu1xj9d9I88dxq9x4G/2NBy93pOcHc9/lpaTZRUh8rZ7Xxei2IVVaFH+sa3nvgtKymkQbIzE0fsR4uZK/sR7foE1UgL4LB4Eb6dLRO9K0eEKlTxvDVPSSrR8k2rVB91gjOmfxg5lQupOvGXMJ3d7RzsW6ylaPWQq845fSCh7uS8G3JxvdRUz1UOAFrlefjKCD12OkHMFWb3aZR3c2drO6ll3tloPxJjLqBrIwUqDaSyFa6eWDA8ZBWkvqVx5OCSppzrcYGONEPpWGQCfzVNMEgwGan6IMspk6KfhFNboNWI5b8ZY+nzy7WWGBUEl/6HXGunRYGP4DcML/K2ENWLteHMtwm2JWoZfFmXgPWxSP++//3alK7ELfZbz7I3f7MQ7ZIZpKWXvVO5bW1AIQP+wyMycRer9XAT4num+rOCCNFUJjnqtgxt1QQnPGK0oqe+i9Pkf7iR+T6Z2vUyz2SbCu87kOoVjwG4eHvFlTa5AK66k+YjffkTdyJiE4yLiYkGQMCa3M9L1RLOh8tWCOI0KokrnPXgZwJ0g315o094sY X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: fRvotbjRxKbF/IqdIY+oAvnCMcvogOD29eYAEY43QPCGv96s/cpH2I7OIIDywMwZhIDR0IYAON2ti3KiO80iTwDBr8svuf3xcQkhudI96DhLYU9Jg3gRBvhJBa/m6vx6SstL6Jy55NMJq2eP6vXkYNh4YTfhss/1O0PK6meB4tJMhuSQpVfwChERIU2fQBtXsuQ4yrtIxEXcwjMhPDY9kCQ7CAwAJF+Qn0bZWN2aZLEVl6Sk0vNNKsE11PQ0x0gw+xuojOKGRp6pAlcjOUQFn+0SN6XiVSWjEbHJxCcj5/g8xwzq+MJXC+kEZRjlAy33+ZJVgs0aGUfB8LAQ8ZT0J4PHLcEBu3G/KbMaic2+3/8BAH4TI88rU4qd8vhQ9U3yaj5tXY+0VULyNsSK4NyGWuTnXiIRaaeoxPtFsx06yWozo6dUex80h1d/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-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:58:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777683052771049226 X-GMAIL-MSGID: 1777683052771049226 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: 143028 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5228807vqi; Thu, 21 Sep 2023 17:23:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGx0CXzUj6ZjHDZNLIEiWpwZvQAT9mhPTtwmp/ZhaJfK3QUdLn1X30q6CV057L8Mc/fSEBb X-Received: by 2002:a17:903:11d1:b0:1c1:e7b2:27af with SMTP id q17-20020a17090311d100b001c1e7b227afmr7618714plh.57.1695342228974; Thu, 21 Sep 2023 17:23:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695342228; cv=pass; d=google.com; s=arc-20160816; b=Y5TnqWEzxOXdfe6J6qOJxRk3jDDNRjDmbTgQAD68utzbz5T3+RzmPOu+RzjcSw/Ffn PwjyoNy+8vZAOGXv1kDJGyWr+uWJdF4Oa6R3XuwUEXyxQ2puk0SA0LusiWMJ4Kavd6yG qLXGbpopvtnN9s0xquRxvK2RGkbps65mA2hx/K89Co+BE0FVpOw7LxDFNGXtU1ACSZwm slXoJAVfJkz3mQHy4M9yT2yXMQgGReObmMCShEPTDDMItm+7aBbJ+BxRGYnqwk1TTcck skJH+QYuUWmjYHMQ523V9pNISwJE+WacZcbUyps3ceIh492BZX46shg8G2c96XqWdTJh HuAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=MSdCmzhVS/I/zLXGiVcgOOj2URLRbWRWQQI6ktXwUqc=; fh=vvTzGQq2kjyMXlnFq0LWLmmDSFcqxM3YcNXUiN4Pqss=; b=e8uTo+x3j0n757UpVSAkCbgOURuC7yONjqluWkPQXKJLQoONhCZo6lj7Flkml1ED4C MH9PPYgLNhHJaYFmrQEHO5Yvuo+8cJLqN/KmK8pucKfc5hRemlNVMzdpOkctxkCl6msQ 5c7+W9qeQ+jrWknpccyGp1uMYTNE3RZhPgnN3yZCG+nOwJtofjd9vgg/5tMhq6P2tYpn +eNs3WCFuSfOs5WbavWJTh44uQmmgsTF3snPSzR9gj8FjrhZjskZ0fn4Zo0lUNMpDtap Q47xzxNj2sq7WUlsTIVlseFs3KkV4w7BhPuMMXldQkda8WeVBlu5Vkiz9YBprQfNXCVL YA5A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=KWLP1lWV; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Nk7IWFaD; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id c6-20020a170902d48600b001bf3fe55e78si2593199plg.600.2023.09.21.17.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 17:23:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=KWLP1lWV; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Nk7IWFaD; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1331F8375C8B; Thu, 21 Sep 2023 14:06:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232630AbjIUVGR (ORCPT + 29 others); Thu, 21 Sep 2023 17:06:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232810AbjIUVFB (ORCPT ); Thu, 21 Sep 2023 17:05:01 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA77EADF37 for ; Thu, 21 Sep 2023 11:14:22 -0700 (PDT) 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+JdNNoIJvqiqayHYTgHwyN31WYCzdMyFxroMeAI6bweHIGP04OPttlL6GmD78SK+QdGZVRu3UzPsj+6BTnY2k17hlVrk/HBUbpZ/fitMualfeAfGkU+VVFR5tLYVZRWSOW9WyiXd97mV5NombuWuq4z+DYQNU8XUD+gnQovyOqBLDSkOaHPTnKvDY8hV9DIAlyhindG+PpnUIywTjTrWhMGd+epO1W6ogGFEHInpcpSbZhYtjfrXNpKRrpZaJ+dSDWdVyXEttiy3ZzpktVuJX/sqVMUn+wvm9bgiyR3K4dI+HY8mgzoZC4X8aLL1QaNGvJ6ppC/fgxsKd0PLp4dMKSntxfywG88ApXXU1JeUK79T85m+x65klVW25mQHJbM9j0qDyruvGBZCdEcF3JUZRoga7a4QOsZzmUgZ1h7SW5g91qhDCJE6LRsnxOfv/Di7eCekPlzQkGZrKqkAocJkGL+j7+zn77Mw3u6rHx0J2vwl8BVc8MthlwJvqmABqVsUpdGya8cM2pYUX1QMbAm1ZbR1Eb6i1FF+oBFdAWbyl/Bndn3+DD9Q5/nZ2Vq8mSF9hnEb8xd+F3oj6+wvkNcyTx+sCfW427BzMHbEYWels+668JbgBFJfEPajgc3uXhE0eJ7UHEsEHzqMYv4B/sNVSJaS0T7Y6zYswZwrzDbO7afYPN0zNWRhpsD/Qlcu6YT8sC2Vs6OxLAJLxDOTZ+BR0sAJgpqrE8q4Nco41oUBsA8dRRXW05ATD/q7fLckmg0mahogJ1syR3aYWe9yjfC/qg5Pq3OvpgYp8SOOyo86FVfcrKavNPVW6M9WwLNjjb6W4nbj54IMs+PN/Om+SX+lD/5CbekWVdO9V0l/hyjiMJuQFDoT/YWlJn0MVRDupU+FZjmxH7NfPB9qVz5WJf4Iz1WWYlpAB1xNIdzCK7cSmvQObOJg+8skFeT4uYSaPz90Ms5OdP4Yne7rr7BK3pJmPJx6F/pvYP08358dXF X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: a3mEdCfLpgmMKHhQ5g4HNi7abSn5/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-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 21 Sep 2023 14:06:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777679542853767619 X-GMAIL-MSGID: 1777695172588615072 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);