From patchwork Fri Apr 21 13:55:56 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: 13220078 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08AA3C7618E for ; Fri, 21 Apr 2023 13:56:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C7706B0071; Fri, 21 Apr 2023 09:56:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 550A96B0072; Fri, 21 Apr 2023 09:56:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 354A06B0074; Fri, 21 Apr 2023 09:56:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 200F86B0071 for ; Fri, 21 Apr 2023 09:56:46 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DAA994042A for ; Fri, 21 Apr 2023 13:56:45 +0000 (UTC) X-FDA: 80705548770.05.053F88F Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf04.hostedemail.com (Postfix) with ESMTP id 8742840011 for ; Fri, 21 Apr 2023 13:56:42 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=kC6FRTPJ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=fsF9hU9P; spf=pass (imf04.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682085402; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5F/Bt3x+K1203VADB6V9nMCJXcerC4oTfDvth6igwBY=; b=DS5KbeautgEv176Q9IC7prHgCgUVEjKb5kE2qTrG2o7SKnoWPuRaRHejA8+E5o4KiGQAFM 5NX43wCReseutwF7FYnGlxtyfYbINTuvij3RfcOQsUcRbZll5ovV1ztPQ61Hg0Vgs+PDen emPJW9DMGl7FFdCr+YZuRDmVqwn75bE= ARC-Authentication-Results: i=2; imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=kC6FRTPJ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=fsF9hU9P; spf=pass (imf04.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1682085402; a=rsa-sha256; cv=pass; b=zMUfnpjuRTUGxqB2TSiq3VIcy/OkGs7AXAXSl6wW7AsvmxFFGHwXVHh4Gjzpa7H78Rbn1Y 3cLZE8m3qLxf+eqNGaZAmMkB0fhV0pYHdsUpbXLKgtDHgvkmu0kvu7TIu0s1hiOCMDviMS Ain1chxkr3oZR1DCdO1IrrI5uXvnHYg= 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 33LCYYre006655; Fri, 21 Apr 2023 13:56:26 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=5F/Bt3x+K1203VADB6V9nMCJXcerC4oTfDvth6igwBY=; b=kC6FRTPJHPKQoqSqI8DU9K6s4/ReqjYyn+W+oxCeOdFZYU/o9o0W87UengcdjtSiQcJ2 D7UmzyHaz8NDru6MG1n0muhc8Z262VlNG4bQIIHsp/Jrrwmu1F2Ubi2oMMndNKiLF5Qf 8YLVkDQ5DjMg5jG9ldGeTTkgMaY9Nu+fTqbkycvj5q5XMm9cMauPGDkxpFSiv7TuM1c5 ghtltpCyXC5xmVZUICZtT4ZMfutLYIZgfToMeq4Nl8DT+JHXH73QS+OE2AGedymAU4tQ Ft7stj2by7of6ytMKW3QflM6IJOti43oPF+KqehBLFFXjEjhuYtne7+TFOXbmXuqITnm 0Q== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pykhu5b2k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Apr 2023 13:56:25 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33LDLLcr037785; Fri, 21 Apr 2023 13:56:24 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2108.outbound.protection.outlook.com [104.47.58.108]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3pyjc9n99n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Apr 2023 13:56:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Te1RK8Fm/gsm99TfOe7HXUMWCOCfh5C63h0NnQhJu6yplm7XyLAQts/MY1+WAViQ7vmK8zg2dc0Z8kNbgARkW7B6tuJ2bfyXTeO0lvQn/JqjodethcAVgZCdYabUCQWhqR81lmCOGm/szOXAmkgPiqYP3YEiAJ4yVPXUdNsUhMFZwgDzq2VcSjpLf7GYA1FQGpJsutCWovTYLCBA4NXSi2RfLffugAm1Av4+mZ5X6W2Jy7ntBLmrswXWDJ0OskJMcWkf/olUF6JsrzS7FNezLdtSb0ifOJ/dj+Hy5TkJBaywr4+osqLdyIBpGBhwsSGONdYHTUdS1VFiKrjOEMNRKg== 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=5F/Bt3x+K1203VADB6V9nMCJXcerC4oTfDvth6igwBY=; b=Aoie/MBg/OKC5i0w5CCJM7wA6ifeOuc7EClVg1SbK/2RKoOUlca/VtG3PT1NGE+iKKtkIF7BoE34BZ/1EC46GBLJEqIPGHMlmOQk0iD11hGzvT2gRMv/RIoNZVFz8C4X6IKDW/PyUDYrX9ylmCZ6ib+vT4FdHhE61BrjcWZC4WjEMSnxaU98ibIAKgdif8yHjfAY3/sloy60is9QoGPt6miDPLCG5AOw95cAUbgRK0D/ucb8yVSJSIRT5oK1csB1BK5nXWhYR6HDB1KqXfAn6P5Nx2a9U/BAUUa2LTjyDdwMkIxapQBhwKNewjTUfYHe4dxjYgZSdE8w6LPUaLQxsA== 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=5F/Bt3x+K1203VADB6V9nMCJXcerC4oTfDvth6igwBY=; b=fsF9hU9PiFktzwL96H1fDoww5IAGusaR17zHwjkuQSCKIm4MuH8qBTl3SHk3+qNBEI8dWSLbJSWtFxg4K0ShmMWJxpZ0a/cW32NaKH70A4QbkZHK++7bpaXKx+fvAFWxd8cmm/Xa8xt4xMcugFBBNCWTKqVVDghEQAB/bS96TRQ= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by IA1PR10MB7540.namprd10.prod.outlook.com (2603:10b6:208:445::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Fri, 21 Apr 2023 13:56:21 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8bb9:2bb7:3930:b5da]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8bb9:2bb7:3930:b5da%7]) with mapi id 15.20.6319.022; Fri, 21 Apr 2023 13:56:21 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, maple-tree@lists.infradead.org, Rick Edgecombe , Peng Zhang , "Liam R. Howlett" Subject: [PATCH v3 1/4] maple_tree: Make maple state reusable after mas_empty_area_rev() Date: Fri, 21 Apr 2023 09:55:56 -0400 Message-Id: <20230421135559.2163923-2-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230421135559.2163923-1-Liam.Howlett@oracle.com> References: <20230421135559.2163923-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT1PR01CA0100.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2c::9) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|IA1PR10MB7540:EE_ X-MS-Office365-Filtering-Correlation-Id: 45d5221a-4acd-423d-e990-08db42703053 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z8Us/q+D1IJJCmx159B4nLNkzdm6tkmn+IxEU+bzMkkNMIxs8gR0pS+SNXFkZ0+/+mfSGiG2IcA4W5zwRa6eJh3szO7RaEt0Z+iRR9ewDL6vUI/Raz2u4etSNIOufwmyTOGc5tlLIfoMAvutYEakl/ND4Hvyn2vzi4Ybmr5bXXHHm0ejqpvm/5kCcDh0gxw52lSYtyrn16T2zkUD6whfZ6Bjy4V6n80cVMsOTQ40WaiQEAKWxWCO6CPSbNkC1MdWvCoRN+3tUk+cGAsmo//z47SMg4SVlVPSizoiCAx0XfDNFzRlTGmv/N5w6O3fFxQ/lx3/l2NgZkN3/PZAvcJifV/kbPeD5AwWN3zwaxorOVCN8F0vWDFnu7Ka8drtylG6Vf5nPPM5NCACtibgSKP6ax/xejfyV8pFU28i1RD9LeT9pqN49w8M8IfEBmHqC/mMOFa1d9yuYxxDATnjXRV1LulYFc7SfU8+ILvGTd+VKtNf2haj7uNYqpKRZXNBROpExhed4rjk2bQLbSzZRB1ElqJ2XK2hJKCqIGtXDFFrma9J3PsYlpioKLDrQriz2z9b X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3022.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(366004)(39860400002)(376002)(346002)(136003)(451199021)(8676002)(8936002)(38100700002)(6916009)(4326008)(66556008)(66946007)(66476007)(41300700001)(316002)(2906002)(5660300002)(186003)(107886003)(86362001)(1076003)(6506007)(26005)(6512007)(36756003)(83380400001)(2616005)(54906003)(6666004)(478600001)(6486002);DIR:OUT;SFP:1101;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R0V/lXqXfhs0aqpEackDX0XfHkWoqxHLQCjJulKWNwKb7dRvKgMCicOjDy/12uHRRR+UxmOjo6PJ1rWPfAzHmb9Q1fqSnRBI3nLPAzl2tLlVwrT/IptSrFmBu4JTrFglDlHz2zbtmnsRIua2hLt1Kb8XyTDx8J7eWl9Ea7DfOIHfAksKA/v3DF7OFgI/MSzfIC+b/zgXYRhywUbvWTW3JUsIKl3uTWR3mjI2smc+tBDrVVBkiEmP6zXcgLOCs7bfKHu2INMY9hJqGGj66Di+B7ol2GZwor+UfayNU2duyp7cL+NPwqqXGoaVbzaDbvoherAMf/QnPm/Xo0UGk4ESKTaX1OznZjIC8o6UKundMXtGUhSsE0Sviii+zscMcKLljWNQWkw3p5HiFj3tmykGe5K4qVSNnjK5WU6dO/RHeSnWViPU79ChBvkthsA53dU6f36eQYZDiPByENn45tDBblDYJZXN8+xzHv/cZ5vi+CNH4Dw6JhpyT2Sox5rvBp96WoeuAkNHWlMhsw+569iMENcoS1K+698hvQ/omFEaz8Mv9MV/NZYQ5LcMCUuKBbC6wcgkSlWaP2g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45d5221a-4acd-423d-e990-08db42703053 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2023 13:56:21.8625 (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: WD3iVoEjU+kg3OFzR5BRinRqlKJ8d6K/FIPtj3QBPtN597J+6hkHTmVBYTeg136+TPBDaKMfN5x62dPSWOY7ng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7540 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-21_06,2023-04-21_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304210121 X-Proofpoint-GUID: aqNtFYBhF03XyZUJNARd2tSoJb7B5tmP X-Proofpoint-ORIG-GUID: aqNtFYBhF03XyZUJNARd2tSoJb7B5tmP X-Rspamd-Queue-Id: 8742840011 X-Stat-Signature: dtfb5kswc5yymko4pqc3c5j1whxuj71p X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1682085402-69589 X-HE-Meta: U2FsdGVkX1/Wt2xKF8NXQ/Iii4EYTys0/HUZAX933uDWIyxhN9jIenuCKSXIhX1EOdd+sivaQQGkBS23NOfAb8e0ljYM+e0qZ1o4DbNg9tWcQnQGWPSHVnlRiLsfpj0aa0wHk+N0hHyb4DM2AuCwm9haWUKRAK3fw6Ia664hB0pNyWSiiJ57Gd1+ikQ5gXnGPF2HAEFCgW99yLNCFp4WrZE1+4z/mS/11CNvB9GE7RplFD8ocdW4zA3nAuXzUB+o8r8bAC06zBTjE9QH3+7Qvhw74YGwUJoS58/nflyiK/VaoQY/ZMi7ucC4iGZ0lhw+MvaNOg13P97Sjzsyqkr4ou+fJxDDUruXtdOlYbDedZmpp25I3WWqS4a0mA56KEctW3lZpZmojjhbfY6A3RGntC9tnkMOxF6a8bdruvuKf+0G7edBUmxtgzbZlvKn3ruzI7rbOfDXibnSdzlqUNp3n97tp+XrKrue+SSjASY95Bz+TOG1t7vHyYaMEllA8GYltqsRlANmuzBJAbZuuzwpEKPYwU3+gkjC9qKToMd/MTZu2rjEZ58EuXyrNHf1v/3ThTWyPf/WCDQCtpTI0aBmsCK7udRuuli5uh/d7SfFKnLvWnLx6Vrj/h2B0t7cKRUTDL5ewNnE9+uCUpsV26QWOWpV/SqP5BE2jAj+KZSVsF+xA1MsTYSklZhRYcsk/SOKC7b/AdZqYW3CQyyMTKlm6jMcTd/qPCmnzj9aSqIOuXSUcHg0h/hKQhUZXC+Y07yTvgYKJBYgXTsK7QCVJZ3v4BtyS6apN2yAAMyJDeO6tNsXDAkog8DXQhzGt5Nx6RZw+MdxZpbV7QQEN2dt/7co1aeBNLZ4ddp37VUMG0c8AFkjsxiLfmRkDdD+qTLWCLfRQ6H4P4FxkUL4ca6V/T43VQ5MpLRrFClOJW7ZJAELdsRIoWC5ZspATv/iMwkaakbPiITEWGXpTVZ/3ayioqv CiOc0H23 mdydv8nsH1vlY7l2h/NnwFwndBsX3Uc9UHlycWOusnx2QDmwGJ1aed5y3AThzp1/bzQpHutv3wq+vYohq41hgOUVzQEtMaQh25ioBcWubFUixwI6ywpiRQk5E7Dzlu2lgT1wW92m6idyD7wYoAM2uer99lg/TM0+hvikWYZyiUFJrhn5mfkhkQhG2XtEvtDYwHZd12GsTZ7NFaQ7ox8y80UG2VjOBRH9s8AZ1KkESYHDFSyW3ENARVdNsg/t1WFoDHo5gZcKC2rbGAMDiYln5euFdFURpy69VgQbxZkLPZ70quBa0KqfMxafZLseRcSni32qW0hotOo/DkTc9ufr3i+yXzFmVgghATqcMJ7d8fXcRf2/6/XNM67dci8klN5RcMKlWJkeyDAZFKBYv0oaqlICCGJGtD6dMK4XNS09oULscJwc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Stop using maple state min/max for the range by passing through pointers for those values. This will allow the maple state to be reused without resetting. Also add some logic to fail out early on searching with invalid arguments. This also fixes the currently unused mtree_alloc_range() and mtree_alloc_rrange() functions validation of limits to work with a window size of 1. Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 4df6a0ce1c1b6..cf4f6cdcaad38 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4938,7 +4938,8 @@ static inline void *mas_prev_entry(struct ma_state *mas, unsigned long min) * Return: True if found in a leaf, false otherwise. * */ -static bool mas_rev_awalk(struct ma_state *mas, unsigned long size) +static bool mas_rev_awalk(struct ma_state *mas, unsigned long size, + unsigned long *gap_min, unsigned long *gap_max) { enum maple_type type = mte_node_type(mas->node); struct maple_node *node = mas_mn(mas); @@ -5003,8 +5004,8 @@ static bool mas_rev_awalk(struct ma_state *mas, unsigned long size) if (unlikely(ma_is_leaf(type))) { mas->offset = offset; - mas->min = min; - mas->max = min + gap - 1; + *gap_min = min; + *gap_max = min + gap - 1; return true; } @@ -5280,6 +5281,12 @@ int mas_empty_area(struct ma_state *mas, unsigned long min, unsigned long *pivots; enum maple_type mt; + if (min > max) + return -EINVAL; + + if (size == 0 || max - min < size - 1) + return -EINVAL; + if (mas_is_start(mas)) mas_start(mas); else if (mas->offset >= 2) @@ -5334,6 +5341,12 @@ int mas_empty_area_rev(struct ma_state *mas, unsigned long min, { struct maple_enode *last = mas->node; + if (min > max) + return -EINVAL; + + if (size == 0 || max - min < size - 1) + return -EINVAL; + if (mas_is_start(mas)) { mas_start(mas); mas->offset = mas_data_end(mas); @@ -5353,7 +5366,7 @@ int mas_empty_area_rev(struct ma_state *mas, unsigned long min, mas->index = min; mas->last = max; - while (!mas_rev_awalk(mas, size)) { + while (!mas_rev_awalk(mas, size, &min, &max)) { if (last == mas->node) { if (!mas_rewind_node(mas)) return -EBUSY; @@ -5368,17 +5381,9 @@ int mas_empty_area_rev(struct ma_state *mas, unsigned long min, if (unlikely(mas->offset == MAPLE_NODE_SLOTS)) return -EBUSY; - /* - * mas_rev_awalk() has set mas->min and mas->max to the gap values. If - * the maximum is outside the window we are searching, then use the last - * location in the search. - * mas->max and mas->min is the range of the gap. - * mas->index and mas->last are currently set to the search range. - */ - /* Trim the upper limit to the max. */ - if (mas->max <= mas->last) - mas->last = mas->max; + if (max < mas->last) + mas->last = max; mas->index = mas->last - size + 1; return 0; @@ -6360,7 +6365,7 @@ int mtree_alloc_range(struct maple_tree *mt, unsigned long *startp, { int ret = 0; - MA_STATE(mas, mt, min, max - size); + MA_STATE(mas, mt, min, min); if (!mt_is_alloc(mt)) return -EINVAL; @@ -6380,7 +6385,7 @@ int mtree_alloc_range(struct maple_tree *mt, unsigned long *startp, retry: mas.offset = 0; mas.index = min; - mas.last = max - size; + mas.last = max - size + 1; ret = mas_alloc(&mas, entry, size, startp); if (mas_nomem(&mas, gfp)) goto retry; @@ -6396,14 +6401,14 @@ int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp, { int ret = 0; - MA_STATE(mas, mt, min, max - size); + MA_STATE(mas, mt, min, max - size + 1); if (!mt_is_alloc(mt)) return -EINVAL; if (WARN_ON_ONCE(mt_is_reserved(entry))) return -EINVAL; - if (min >= max) + if (min > max) return -EINVAL; if (max < size - 1)