From patchwork Fri Sep 22 15:38:52 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: 143809 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:910f:0:b0:403:3b70:6f57 with SMTP id r15csp80873vqg; Fri, 22 Sep 2023 21:37:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHL64UFN+WSbn3nU+r7VaFIH9hwnxQkwYhfI7Uc4xn43l6iFnxBUrb4sUEcZrvqMlp01E6Y X-Received: by 2002:a05:6870:c148:b0:1be:d9cc:d902 with SMTP id g8-20020a056870c14800b001bed9ccd902mr1797437oad.57.1695443853188; Fri, 22 Sep 2023 21:37:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695443853; cv=pass; d=google.com; s=arc-20160816; b=am4znnaho96mrTiLRWbkORuLfqPvDLAphD06Av3TvEK4nKsYW+x50XC90aE5yuJEDR dZVTW/eRjr0g7Rt7j8S4F7Z6TEqGGl+F9PhrpOR9dqGL3PiWwu9itQsknHF3SqhoPUxd vMrzoYZ+7NOAS6mRcAFAjcCzc7+hhSl/7ef2t4zGbnl5jBREwwRZMYS2bnCx89+91JPz 7LJyB+XpUbacyN9T4jzqfHH/Sis/qoI/tBRORvyLLTBNfbd5OwzOdziof4Mszco90zlC Lb9/yT3Lw/bWSs4YaTC15Tu53T5cbXmp3UqjdurTJ25zMrsZprCbEs5EPR2QFbbYQoRR yynQ== 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=as/fYKKuaBR5SblYrUiYVM2b/c0CwsDVCICaaLgl1OA=; fh=KmaJAYhgqwj5hGzMSmlj54MdDku7Q8wo6TyLkTlDQYo=; b=KcIcn7VFMtwGsZDOgZLwf/W4j90qULyNHyLV2uaiQG0MiNxcyn089vMAKQe94yqx2S qCwVx1TmJA7FcXKxZK/oqPqHiCyqYpOwV+NlWxWTSGSoJJ6OuwXlNVA/0iy/LNoXgGOH YNANDg62q4xHIUVzZSM+jvowIm6TuR4VkDpRTR9SSf+d1DrXm23+jVBob3KGfiH5S0b3 94gTd4TiB+Ybb0wthBcg38O/F3W12BlACF2JeHXZVktTpQjRz2PUFQCmO5tvRtHklT2D LxIkEzU4pnhSxTJctD0mpTqfOVLfO7xsoAiPdWWcpb/SefvlhT9f1J/UevWj7rKkHNXW dosA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=WlV7Cx6Z; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VTd0mzA1; 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.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id fa25-20020a056a002d1900b0068fb3451deesi5532474pfb.290.2023.09.22.21.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 21:37:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=WlV7Cx6Z; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VTd0mzA1; 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.37 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 snail.vger.email (Postfix) with ESMTP id 0EF0F80C592E; Fri, 22 Sep 2023 08:39:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231926AbjIVPja (ORCPT + 29 others); Fri, 22 Sep 2023 11:39:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231285AbjIVPj1 (ORCPT ); Fri, 22 Sep 2023 11:39:27 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D3A4139; Fri, 22 Sep 2023 08:39:22 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38MEETBJ022692; Fri, 22 Sep 2023 15:39:09 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=as/fYKKuaBR5SblYrUiYVM2b/c0CwsDVCICaaLgl1OA=; b=WlV7Cx6ZPp745iFmXQQD/zKuZesjsighFCZDDQKSQi3UQxQ9sT5WUgcOQcyflWTAHjSA gGQHSIwFx3hfU9/6uXwJBc+7n0TOxSFsMQaa8josW794GTYTGmUvCqKu2+flcsZurzKV xpaOTNgKSpj6erpBg3x1B/PJDkFdlQvvepm4n4/oxyf4SeX0/rHNeQ/EOG3mqrclfP9O wVvLFxw6m0O6NNsPhzQqSZQWX+s7uX9Z3JZv11aZPGcwa7lF8jw+dMdIgH8nicxfrRW7 6IFZdp7odmohl4goKSiD7jUTal5vzJmx5rQFf68napCI/GcRDJzvM+9SvvX4wuvW5cuw 0Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t8tt024xe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Sep 2023 15:39:08 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38MFRTh8035067; Fri, 22 Sep 2023 15:39:01 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3t8ty2qppt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Sep 2023 15:39:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iXjNUP3a4W3Q3a3SRj3kqvBr95IRddhqRnEnucv9hc431RM+mR4vJiETMhTNM7ATh0sZzAy6ftmk+4WYxM/4Hk43IUzQxSJRqLGPpJsceZtUs2MTKCudxb7sXKMhl3Qvm2mzkpwHxEvexntpNp6KC4bJMmXAKVi3NgPibdQlbdWQa4+uWwwLaGiMsClQ4KPzC6IFyEhOD+4plgGG/vUhJix1ECPGH8Gbw3cA+UeNJTNbbkzSXz/6Aax0tNYZN2JouKzJ+O8hONNVWl8Gsm498QIfwukSl+y1T44jEy1mI7G91Z1DYYmG/eWiWWYB8/XqFrIqmjYtdY+Ey2047rTa4g== 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=as/fYKKuaBR5SblYrUiYVM2b/c0CwsDVCICaaLgl1OA=; b=b6oVFHnRFyZwBgzsnfYpo6xeAdLI3pzXyb8ZnW7n1wMnf7QTmbgkIPTEDJFvRMMkyuDNG0YfdA6lDvLTGWblrzn5sgWuk/09kagISi4ryr65fUFU/YMufLN/XhT1LkKklae7Ctox3yhAeMyNoPz8JSHVOkKPLMDm5PkTEw68gvw5kksHADZpw5NaO8BAjwy0xTjOSl4OTtyvGK5iuq0eqFIZ5Z3XBrY6c8gDgoGXPQLFj68QpISxPQwzQ0Cz+vweyGMrj5jBdU6KcPMYw/LMG8F0PQaO2HkkOPjGLIYNQd7tQqn797a5aHc3z4u81tUMKEArEEMLOKUBdwiSgNi9hw== 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=as/fYKKuaBR5SblYrUiYVM2b/c0CwsDVCICaaLgl1OA=; b=VTd0mzA1JWTq8Aj5Uo5hx+kLOPSmyyRAS+M5mvgQKnaE/3qwbC/wl9eYaWfss/P+/Ln2ncWhaWRqUWRudHe+pULH50X3k053tNMgkfSFhWaw/5xCMhv9eXNHdSLqzc1Jh3f7RxFA1ssjeaJ6qsTkiF35cVd3XOOT1TnNYbDX19g= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by CO1PR10MB4561.namprd10.prod.outlook.com (2603:10b6:303:9d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Fri, 22 Sep 2023 15:38:59 +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.6813.017; Fri, 22 Sep 2023 15:38:59 +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@kernel.org, "Liam R. Howlett" , stable@vger.kernel.org Subject: [PATCH v2 1/2] maple_tree: Add mas_is_active() to detect in-tree walks Date: Fri, 22 Sep 2023 11:38:52 -0400 Message-Id: <20230922153853.767603-2-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230922153853.767603-1-Liam.Howlett@oracle.com> References: <20230922153853.767603-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT1P288CA0023.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01::36) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|CO1PR10MB4561:EE_ X-MS-Office365-Filtering-Correlation-Id: 4306140a-566e-43c0-5105-08dbbb820a2c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mxAXr9ZAZ0oW/ePBnSeiWES9NikMBytbqbQUsji3uOTRVbafBttsZahHBK2FVl98MTepQ7tgrmCMwYddwEuWX0tETZjHOWuXB/gfsXSSuEztdCqxoOOGuq08g9Nw5aSVfmuSdKFw1BrHSe+JjLSzV2aOwsTNEWd+6tG6NNtQcNhlGD9fl/aujg5GylJLa+4oNXy0xM/HnRAxO9/7yU8uUuAeB2aeePKp/tLB8NuiK3YG2OKvK5R2ILHHHESQg1GFog/qjmh5tI1g9wzdK5tkqKC8kPYScH9G9O8yIFVF/nwVBJlWcM0pjHqkl+AHAdvhEj3bYMPstAPBbIQ1BMtNiLKZZJFmMoihBEb0RqIDq9TNcp6ZaW9mYbftugCiYBam1eTEdSzJxg12YPVeyWj+4c5QPCBIfYugOU/ElBvBjcQUiKc+j4SPZVmvcRDcUL1XlCwT3sSYsg+GeMeVmEkXP4x9IL2d5+PAs1AYQae6WWxsKkZaWqI5w6CsCGLnkXOuuznnGfk3IS8y3T33u1Kq7lL/w4b+zKfMe1TYbWDRsv9k08aN+SM2sCrJ7rIaGagN 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)(396003)(376002)(136003)(39860400002)(366004)(346002)(1800799009)(451199024)(186009)(316002)(66556008)(66476007)(6916009)(66946007)(6512007)(6666004)(6486002)(6506007)(1076003)(2616005)(26005)(36756003)(478600001)(5660300002)(2906002)(38100700002)(8676002)(8936002)(4326008)(86362001)(4744005)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oKv693aXgx6t1dKjwvMuZ9qcyNPwjGN4CL7HtQOg6P7PSgcqkNgJCyY4Ar6slh4y8QN0qimmLHv9nx4+dZLmQZ5xKXmfNO4nvQMk9A5Fg6NuRqIW9rg/fGYqQmfQk4axvXMFIn4I7ze2A0UrXBk4gDjRNwkpIsxNA51/fJPfJnbUD0FPB72MQrkQM/iBAOUzuvw20YSopB9llGjEXw8Tza7ve/AWwL2yEbsGpDr6iODZu9B9D74wdjQB9OJ51Flo/bA/cyTL6EF1+y82Rf+nBC8Jpx+XGqWBltEKZIVVc0HOdB+ZCfO8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B9iG2L5GO5rGgS4fxDytWA5ebvojZIJDRWWAtvwcDrs8a623Nlm8unKcEKab1ucQd81ZDmIbS+DzAiX/u6IpIKZ64kovsCqObFIjY9hrZignMMfdCP9nZmxCPLDS0IX7J4iO7MpCy6xjo9V3i17pWQS4VpoLO57EREoB5ZwggkOfQ/LqJwbvXaebVF3cFH/petag95OVwHRiT6b/np+ng== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4306140a-566e-43c0-5105-08dbbb820a2c X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2023 15:38:59.4660 (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: K7Iup9L7VPgtFk+sb+zUtIN091pDiXXbFj0KWLUnRsHv5ATy4oop0Oq8quPS4MCHpZW4qA7v86J1qJ5/mg8wog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4561 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-22_13,2023-09-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 malwarescore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309220135 X-Proofpoint-GUID: 8GHqLJ1NXscxddU5ITDEKPXRuXHBoDs_ X-Proofpoint-ORIG-GUID: 8GHqLJ1NXscxddU5ITDEKPXRuXHBoDs_ X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 22 Sep 2023 08:39:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777801733438028467 X-GMAIL-MSGID: 1777801733438028467 Instead of constantly checking each possibility of the maple state, create a fast path that will skip over checking unlikely states. Cc: stable@vger.kernel.org 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 Fri Sep 22 15:38:53 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: 143697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5897669vqi; Fri, 22 Sep 2023 15:18:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFF4tHiHLlW4Y2Ob7jK6WGe+65pHsL/xint2C9zRavW0OxHYU/bfILPrYzsgN2LSJXNmlZ4 X-Received: by 2002:a05:6870:ec87:b0:1d6:3fa2:5b6e with SMTP id eo7-20020a056870ec8700b001d63fa25b6emr852607oab.46.1695421128479; Fri, 22 Sep 2023 15:18:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695421128; cv=pass; d=google.com; s=arc-20160816; b=vWPekMTZYWiN3LuLfg6vhwDSn56ERilzGmkem+upJrj1QgiaPW/+t2Vm48qXh61cNL kAF5FXc3Hw+noGdMwSrpvyn8qtO8QIPVkI9iMJWeXxF+KxzRDDEoS3dukzloIEzjZOwT TUgq3cvG8re297i3DtYG8tr7pbSYsPsrERv1cyvPwVeJ693WVDsZD4Lx4E5lav+4HbzL hRqR6I9FZzr3+8bf5moCUCHZ4jOrZ30GTZX6GFKexBaB+IT1NJmLC/qL48x8leUYlv7m pyCl0q+yqoSvraxdfYRRAOWWO1zL9u2jxTNm7tp+xGnzehvmX0g1UuibQXqR1on/xWbk /FrA== 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=n7HMNGW0DLdIWS1oDQuLBkxVS97BEvA55qvFbneqnOA=; fh=KmaJAYhgqwj5hGzMSmlj54MdDku7Q8wo6TyLkTlDQYo=; b=SGJ/0M3pHYCzu8KOBePvYic7elV0F0aI49vQ3QIrxAPf6iBRVutnIFhMPlt+RgPjce KV3bSn553OBO91FUv0m2GxUreDCoBd5SBFKKpVYqXvhjGIVF3clRK93HqNnN0mBCIQFX OoNN3u8IzWak5LeCxs9ykuxrBu3TgjrX8divfPAZt4rkmIzqkxW5MFvhpik87bWL0SW8 rd1Wbg86QaaiAfxrntrRv7rmctmtX9umjFZugm6ses2le8mVkofDzc8tx96/0d//zHeP wDG+TPIy3uYoRzFGC5sJJVKcZLatTy2YxZ5a9/jouPKwPPdd0HiTuQrdwfQ6njRH7Bgl l88g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=w74ObqzM; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=JW2rMDYI; 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.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a73-20020a63904c000000b00578a7f5a0b2si4476263pge.403.2023.09.22.15.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 15:18:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=w74ObqzM; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=JW2rMDYI; 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.37 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 snail.vger.email (Postfix) with ESMTP id 36C9F80C5935; Fri, 22 Sep 2023 08:39:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232159AbjIVPjd (ORCPT + 29 others); Fri, 22 Sep 2023 11:39:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbjIVPj3 (ORCPT ); Fri, 22 Sep 2023 11:39:29 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B941102; Fri, 22 Sep 2023 08:39:21 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38MEEMHO002835; Fri, 22 Sep 2023 15:39:05 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=n7HMNGW0DLdIWS1oDQuLBkxVS97BEvA55qvFbneqnOA=; b=w74ObqzMZk+4H+tHQ+1QSzPHwTxZQoqdS39tGL//ByqJWo1GaB1/xdmJ+kkEpyl0CTpF PW0A8fywhKhSPGWWNc8w54RRuMQFOPZMK0SOd3eEgGqJRk3nPKY4pUJCtQQylf+eWUkQ ACC1vTEdTJqNHNr18FR+ofEiSigBaSUqjrl5bRg7ZSf4PaXqRJUZ877gDkctSZ0GsrXZ 7PNpHQvqB1XhfNZmYLsJ+bs/3RdRXZ72vHwVQ+xfZax3e4BBBnAqASTkdr6YmmkNy8Zw ceQIvoICfSlk5sr4N8NhgCwlSXivzVuqTovLoywrAMKdDFu0r5t3PhPGagG3AeSHFe1B rA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t8tswj4nx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Sep 2023 15:39:05 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38MFPexR007691; Fri, 22 Sep 2023 15:39:04 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3t8uhcwva9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Sep 2023 15:39:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=calJjOURpO+v1juT2fFrTAD+ZytoNCd6aQowGVTORiARNAxnCf1LctaDd8u3iW9K1pvygzt2Nk7InID6tcoIbkjDr1lNd7OFTiWREqbHBZfUKsF3mYVaO3H0rzbHSvTnXHTbHgrS7atLiUOwNwYxFIKU5/aL+wMHiPdY+/yp9rOb2Qecy5emRIcvXlM4aT5F/+hB7JdYm4uZEnOCiYSA4G+R8oVMP/HnVAkDLhFOxAW5UPLQ7AdPnwKcSpbvQYTKRHeC15kcwEn/3ETnnFvDcLvoqekO4PJSxpC+e2E5PBCq+pmJY3MHsXiukRxmXYXZlgjSe6JSo77HYnzOanNnOA== 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=n7HMNGW0DLdIWS1oDQuLBkxVS97BEvA55qvFbneqnOA=; b=E54p9PEwABlk9VaGDh/LPmBELoFaC3A0qOK9LPIgZRU4JNLe1iDGbherjD3Cqf/HYZgz7gw+bTYbd6mrCNuYtgSz/qpYRN4lnW+O/XSA0qJH85k0OcAESwtxOaPgI2YA+mBi6rTgc0NLZ+UDSxEyqKYLKtvwh7ByulPdQLebON2KLvukdVTZpXgcRkNUX6R4VTGMzJHjaesSBfiO9FcsSx5qd3a2RoU2Ujpa2Ks+zStIKSyS1rdxEmzHLChRmIxwLsC7Lf1uAoYSrNUroIl1sCdtJKLs7fNyHBw+o7+y2TMShoNVu5ft8IGBEXeUjg8XJSlS7H/zN5Ztfk83p7ps0Q== 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=n7HMNGW0DLdIWS1oDQuLBkxVS97BEvA55qvFbneqnOA=; b=JW2rMDYI9S5RefHSG3wbBLjdXgEjzms700rPfgzKR8uyT++fCVmlhaskXsZ/yIgqCZDlJ8ZTmW6wc7fEv1IYie9A5d11HM4qD1BU6t5gcMEwEw3dSMBC/eRZqcYXbziv+TJfoH6i+t8iPD3AqUJARnQK+J6uwXE85tAzscOXzwc= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by CO1PR10MB4561.namprd10.prod.outlook.com (2603:10b6:303:9d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Fri, 22 Sep 2023 15:39:02 +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.6813.017; Fri, 22 Sep 2023 15:39:01 +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@kernel.org, "Liam R. Howlett" , stable@vger.kernel.org Subject: [PATCH v2 2/2] maple_tree: Add MAS_UNDERFLOW and MAS_OVERFLOW states Date: Fri, 22 Sep 2023 11:38:53 -0400 Message-Id: <20230922153853.767603-3-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230922153853.767603-1-Liam.Howlett@oracle.com> References: <20230922153853.767603-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0144.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d5::10) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|CO1PR10MB4561:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ed64d54-5a4a-4bc1-4dfd-08dbbb820b94 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XU8HqeQhGKuiMnRgjA4njKO5P284kc2D61pQ098TEXN6zm9gyRqPK7KwAfudlai3WZWVF/y4Z0TfuL1htZVHnxvzwkVzwFyFYLazNlEuYbFJl8wDAgTiJ9nlph9TvbhhVOn1IBG3Z8AkAepJNqvAv98M0wUTNnZROs1bBvvz5rKuKz6xkZ0T9sBnrwx0CO21fABJNo6TjQDGbBib+oB4Y8xjdvF8PusFCL53n6qmvwBi7Sa4e62CwSrNxNctjptCoTFcD9KwClOeBgyK4burRSrpPyY62TPtyD0LP00VGSVy8RtpVSWYLg30fCLiM3thtIWKwwTXvYzFQyHHdVExe8Y28jUyOG8czw/RToyLH470dQLZOr9rnMuEad7VgsLSbHznxvDerc1eMhOiaiyWeEMROfLevPlOTgAnkExodgr1SzDpWbXy/mRsA5BPxApmFP5gAkdljuJ+jK/IXeO9LuCx0RnROsuB/FCJzdxBFgHEbS7WlpYzsNPhDl/n3Z4Cymhy5PTaF+UhU+zV1asGDkNrSVTmoDq9apa1wGOzztw= 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)(396003)(376002)(136003)(39860400002)(366004)(346002)(1800799009)(451199024)(186009)(316002)(66556008)(66476007)(6916009)(66946007)(83380400001)(6512007)(6666004)(6486002)(6506007)(1076003)(2616005)(26005)(36756003)(478600001)(966005)(5660300002)(2906002)(38100700002)(8676002)(8936002)(4326008)(86362001)(41300700001)(30864003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d/l/d7+6LQjHxC9iCUHr3hsbKyItqY98pMSDKMLQmqnWyy5/VOoUf5w2K4jGEaTGGzgXST5damX1LhnvpC9+CsfauWov6yvYEDcg8+/NPGCcOCdxO3ODopMhDq2PhlZggjnBgnrqDH6SrjdMufILwbna5UJiIyB413JTpsVqbP83D3MPLHeZNs3NsMogfYTFoy+B29q2vKA6AjvnVf73rmykwBHSWbYjjNiQafkKjUpdqmyOwaQi3P00NU9q10545hCvdSAMWwIxaWcJZK+4pQT0P+Dq/aYUmplTQIj/CcawcQfItO33N9dHkGV8S+seDOF4Y0RQNHBUAbdtIx1inkCE51MMD5zV1bxm3N7O9jColiS7pe2i/2t/5CAoXEE0w8YQbZ++h9EDYJu1jjBYXufSiUkatcZvJVjf5mRPcCq7yoTKaiO3OWwvn5XtAgdnGDsLfO6ksvMZR70inWm5oVjxWwkgjvIhRB5FAtnGw4dbVlIQfUTtrRGb8QiVnOSGJb3TXgGO7L0bymTtcgH1JJEcAOe7TJSxLlGcAPoRn6KC8dpULq7d4jsqNOI0ejDS0Y1PGxjazcg4QzyvRMgVOjsqr/pis9qt36DOF7NG+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change-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2023 15:39:01.9015 (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: eSXREedlhZuTMFA0brJHbOQleQsPqW5c/I/IAnW5TMFFxG6Aluikr+DfLLEMV8Af/dxvhzR0/amDart6FXkUxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4561 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-22_13,2023-09-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309220135 X-Proofpoint-GUID: YGmkw7Yn5t9erdlXM3NquedQIBTB1X46 X-Proofpoint-ORIG-GUID: YGmkw7Yn5t9erdlXM3NquedQIBTB1X46 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 22 Sep 2023 08:39:40 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777777904963022390 X-GMAIL-MSGID: 1777777904963022390 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 may already be set when searching for a value that isn't contained within a node, 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 Closes: https://bugs.archlinux.org/task/79656 Link: https://gist.github.com/heatd/85d2971fae1501b55b6ea401fbbe485b Link: https://lore.kernel.org/linux-mm/20230921181236.509072-1-Liam.Howlett@oracle.com/ Fixes: 39193685d585 ("maple_tree: try harder to keep active node with mas_prev()") Cc: stable@vger.kernel.org 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);