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) From patchwork Fri Apr 21 13:55:57 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: 13220080 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 1EE69C77B76 for ; Fri, 21 Apr 2023 13:56:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6CFE6B0072; Fri, 21 Apr 2023 09:56:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF5A56B0075; 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 8FAEA6B0078; Fri, 21 Apr 2023 09:56:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 62B866B0074 for ; Fri, 21 Apr 2023 09:56:46 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 286D81C6677 for ; Fri, 21 Apr 2023 13:56:46 +0000 (UTC) X-FDA: 80705548812.04.DEBFE80 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf05.hostedemail.com (Postfix) with ESMTP id C342310000C for ; Fri, 21 Apr 2023 13:56:42 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=IVBst64u; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=JIxvqIl3; spf=pass (imf05.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.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=1682085403; 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=vn69hPZDmzF2R7mLcMZFVIO9gowx2wKB7i0XJROaxts=; b=CsxX5Ww5p1EcMh55GfH1xiftWVWMVvHdkbi1kU1o87xLT406qtwXGlL/QN1+bWtprDwpB6 mWMbzTEZ7qK6ZKIce8NPweZ/8TBb/sW6Wg/mgh+cdM7egVH75oJICuC3kLcNX6UqoGCizh q2B99+heoSPWFD8zlEZI7VQMjaNVWY0= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=IVBst64u; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=JIxvqIl3; spf=pass (imf05.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.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=1682085403; a=rsa-sha256; cv=pass; b=WBH2xrRsGoDz+byXUMN/YBmrqbkKit36Ji5hmqwRjeoTV/cKDqcsTYO+ekG3unolNGcioC 2g2Yj9vCL+VbjVWd9i0I+DCGbNOWak7vPqtOt86+aKlziHiVNTVc8VvQ8LyUHJa7haqLit e/KNBp6xGSaabecheZjkQBx7CExLS98= 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 33LCYxKR025679; Fri, 21 Apr 2023 13:56:27 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=vn69hPZDmzF2R7mLcMZFVIO9gowx2wKB7i0XJROaxts=; b=IVBst64ubvb0qXSVMA65pC+3KfOMmpJemD7Dqfr8Ii9vCWDrMhjzb9immkyca+LeGx6n NwuYhJBoJXVRLEZQBhLX+836fC6dRV98uldEp90wW4obwdN0mJh7cnT+zSWnSioM344O d+cMbX64PqvstV64q6Mg2NjJGbfflf3lIh3G0lubMUtUtB7t0cQax8BUgrvR6keR5SuD NrnEzZYJjWGl9IOEeHcwRjNoompheKhrERhiyGRp1M+tNrIcKAaZOfFH8ZoBptkZqEso kgnxSpgyVtIsUXRH10Ro1eWAX7vHaqwt5hhaZOBkzKm9OmzR8HVyEp+TFH7NyPUnbTOR Sw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pyjucdec3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Apr 2023 13:56:27 +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 33LD7ndq037117; Fri, 21 Apr 2023 13:56:25 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2106.outbound.protection.outlook.com [104.47.70.106]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3pyjcfpwf4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Apr 2023 13:56:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y8trcAMbeOSyCoH9nf2bWoxnO0CVtPstuxgbkqsBfVMkm0DATdFV6XPUvzogiYVL3JJfGldZ5FK7590UXM09KIqKfTYhgV2M3tkv3RbV6J458z3OyG+vuUkHNKrjWrxCoNlufkzqe7vyjfB/SBukBB1zAxycEafKr2bFnmMisDIlV6qNrFsgg0YSY8W+h8gIA74xiG/0gU9u9t0aqswXqSQNyfjDpRED0GcUPWwffuKlxV6FZ7MEJAbrbdIOCnFn++xA/dbyYflPhOBiO4e/zHXyjU7UaOrO84JJgNfTrmXGpYXwGOqk6KxZEqcMd80ci3WBEDSypQwUwqF+Wz373Q== 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=vn69hPZDmzF2R7mLcMZFVIO9gowx2wKB7i0XJROaxts=; b=Vu6B/2NfTCBxX9J3KPnEedFmtD2esadzZQr2amuZvBrj/TMmOgHCWqAVqFdTdT9dJ3Y/PC2d3Dcea+qT1zngeCcyF2NB55aZueXS5gwMK4mBKt04sXyUKIsMSz879nvqrWBZHCwbIfcR1NCmU6Bmu9ebNU9bsjXswliOfm9F7qW5J7ubHMEwnfy4pltMxYjEt8mG6cKErhcsREUxaZN0bSwBUvaNn9lK/4LmQ2gfBDW2UXr8fOk5Imefgf0LfILQmqY29CBzOchQDe9af8zXOZtb94JEY8jXGQD5LNCcaoW+iqwx0Mx3ZtZh/Un/vs4U3yr0vJ8yd/FI5m1J2pfTFQ== 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=vn69hPZDmzF2R7mLcMZFVIO9gowx2wKB7i0XJROaxts=; b=JIxvqIl3LRVGZIHWAf+hb5ktZkDOjnIalq25UeMEJI+k0vqhhbRVcRTETbzXSJNAoqN4eOVWf1hDlzX20ibqcJFTaC0HG960I8rkOkhlcBx1FNy0MxZ+Dy2WIBwBuammkyQxI9NeInMv5Xv1Rf/eKuvOWIDOFKQVejKU8Smy4u8= 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:24 +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:24 +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 2/4] maple_tree: Update mtree_alloc_rrange() and mtree_alloc_range() testing Date: Fri, 21 Apr 2023 09:55:57 -0400 Message-Id: <20230421135559.2163923-3-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: YT4PR01CA0191.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:110::24) 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: fc1f46a2-448c-4e7b-bf7c-08db427031b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vDtI5XRIu29BomPVUwa14ZP84DPS4N+XPsC2EFtXXABc9y5QYtxR8AOEqbZY+yQDnk3a80rJ9xuK625Nt77NTp6SWbyJF2YeifqXiewgk3ys/XwoWMhseZFuLGFNglliHqDNdtk4oj87nB6uxfk66ovo/RLO6DCrE6W6dAc+s15uysz7R4Qc6c8JRoG88B3g0w/qBK/Kpi2tU0QmpQCTa3f8mSFGskqf16YjIb88vNre56lkviV5WUlGpmPQiYhIzOXv9zAtG7G1mllmdWNZTlrckVOnMBjadqhzVwswMU/IOeDhnvBnSM+46W2e4ywbpQ8e+9e9/PBg3NFnOja/LyxBEyB/TLZWCsb5Tg4q37oBvsnlqikYt36/mx44OzJb36cKJKU/pB5s87VQA3WWkjRCWaJ2A7rKvjAnTvs3yxc3AxuYkIpetfTSo/zOWRKj/ZIwUFUIGrogI4ut9ofa3oMIlEEyDgEtDoEiGorHmMEvFMR2RnXUHTASG1pA9SIVrY8oRZxaU0HBSoX+JPenv2js5o74jYdxFAavRVK3DIM8Gdkmbx8+ZE3U3f+EInVm 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)(15650500001)(2906002)(5660300002)(186003)(107886003)(86362001)(1076003)(6506007)(26005)(6512007)(36756003)(83380400001)(2616005)(54906003)(6666004)(478600001)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eo1dhnIB/FUlwrOsoXsyATgPv818NkFPcwAN+eGqBQMw28HnKWW7o9U/p8mIDtxc/neAiAlSom/sfjz49xaxChWUlrrtIISMcBLkv4B1rrwGTuyq50nCoR/AqB1jxC2+Y+dveBL/C1wMy024MSq9orAuWQLht2E9r9uZLWGiKd0Xmbfffk24ktkRCZOHry4pauIl79tP8LHDgP8n4hmpuJ7RfP4b8B1TegVOYTp5fJqKpVkQNv0YJO+BzWMI96fJptOv4VInW/o/7xVDo91FznzGzs/Tw6IfJaGru3PJaUo7UyGLoBCOPL6cJGndoH54Ff0dBOsVht5QvyzyVDUFumUK2UGnhWAzPATT86/2/iq2H6ta4YNvF0QGXk/sjD4SFjzPE1IsjMsZu6e3sJdDx1yX8qjvny1ZidAIHJHR8yvzYQmNR6sMveGe1Uh6Vh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rlLDxLpG1za86VWUA56+zS/DOLLPs+zhKnr1Jkj5bovY+jdv6vHHtWthm4kvGuOUffknoJjWHcDgtg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc1f46a2-448c-4e7b-bf7c-08db427031b4 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:24.1825 (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: P+7t1I/X5GdLDY0OwZXJR+2lNHro0xkyv/2VXg6av9XiTke3kH8ABc6Ngxz+AZVmUR/80UZNk4heW6isWqofcw== 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 spamscore=0 suspectscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304210121 X-Proofpoint-GUID: aTtSmy5RWcPk7whHs5ncTDst9Eehnxrk X-Proofpoint-ORIG-GUID: aTtSmy5RWcPk7whHs5ncTDst9Eehnxrk X-Rspamd-Queue-Id: C342310000C X-Stat-Signature: pg9rwwqj394omjfumx6mptd3e7homsqs X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1682085402-38039 X-HE-Meta: U2FsdGVkX18CpW7vU33g6acZGUq/QEqafaMc3HgMo+x/+wl1zTTxEDZtpci7LZv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g8L6uo+2eyfEBocYYzvozYqLVaiFpgYao16CT1d1RqgyZmMGWmihmj+DXYYsf49ctzCQWMeBXAg4IXX9p9kD8MfkWdPvisx/dNLmJ7glmp2x1d0985hbjqZpukNc1c852laPqk6pCEBW+zVyJckeXR3D+HRH7Z/X3uK+5zVLB++sLTUa990O+qMgEk9fnrLoik3kefFE3ctxtmO3xpDpFvpCmo+63IV3WMA3hW3WVLB3WpPQhORYFnwM1QkNuWZczeHBR8goZbasHXJXuWtWrUuFECwhriPGt5RsgXRw== 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: The previous changes to the gap searching made this testing fail. Unfortunately, there was not a safe update order, so fix the testing now. Fixes: e15e06a83923 ("lib/test_maple_tree: add testing for maple tree") Signed-off-by: Liam R. Howlett --- lib/test_maple_tree.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index f1db333270e9f..4d85d04b26f8d 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -102,7 +102,7 @@ static noinline void check_mtree_alloc_rrange(struct maple_tree *mt, unsigned long result = expected + 1; int ret; - ret = mtree_alloc_rrange(mt, &result, ptr, size, start, end - 1, + ret = mtree_alloc_rrange(mt, &result, ptr, size, start, end, GFP_KERNEL); MT_BUG_ON(mt, ret != eret); if (ret) @@ -680,7 +680,7 @@ static noinline void check_alloc_rev_range(struct maple_tree *mt) 0, /* Return value success. */ 0x0, /* Min */ - 0x565234AF1 << 12, /* Max */ + 0x565234AF0 << 12, /* Max */ 0x3000, /* Size */ 0x565234AEE << 12, /* max - 3. */ 0, /* Return value success. */ @@ -692,14 +692,14 @@ static noinline void check_alloc_rev_range(struct maple_tree *mt) 0, /* Return value success. */ 0x0, /* Min */ - 0x7F36D510A << 12, /* Max */ + 0x7F36D5109 << 12, /* Max */ 0x4000, /* Size */ 0x7F36D5106 << 12, /* First rev hole of size 0x4000 */ 0, /* Return value success. */ /* Ascend test. */ 0x0, - 34148798629 << 12, + 34148798628 << 12, 19 << 12, 34148797418 << 12, 0x0, @@ -711,6 +711,12 @@ static noinline void check_alloc_rev_range(struct maple_tree *mt) 0x0, -EBUSY, + /* Single space test. */ + 34148798725 << 12, + 34148798725 << 12, + 1 << 12, + 34148798725 << 12, + 0, }; int i, range_count = ARRAY_SIZE(range); @@ -759,9 +765,9 @@ static noinline void check_alloc_rev_range(struct maple_tree *mt) mas_unlock(&mas); for (i = 0; i < req_range_count; i += 5) { #if DEBUG_REV_RANGE - pr_debug("\tReverse request between %lu-%lu size %lu, should get %lu\n", - req_range[i] >> 12, - (req_range[i + 1] >> 12) - 1, + pr_debug("\tReverse request %d between %lu-%lu size %lu, should get %lu\n", + i, req_range[i] >> 12, + (req_range[i + 1] >> 12), req_range[i+2] >> 12, req_range[i+3] >> 12); #endif @@ -880,6 +886,13 @@ static noinline void check_alloc_range(struct maple_tree *mt) 4503599618982063UL << 12, /* Size */ 34359052178 << 12, /* Expected location */ -EBUSY, /* Return failure. */ + + /* Test a single entry */ + 34148798648 << 12, /* Min */ + 34148798648 << 12, /* Max */ + 4096, /* Size of 1 */ + 34148798648 << 12, /* Location is the same as min/max */ + 0, /* Success */ }; int i, range_count = ARRAY_SIZE(range); int req_range_count = ARRAY_SIZE(req_range); From patchwork Fri Apr 21 13:55:58 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: 13220079 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 AD19EC77B7F for ; Fri, 21 Apr 2023 13:56:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF3B86B0074; Fri, 21 Apr 2023 09:56:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA65F6B007B; 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 9BDA86B0074; Fri, 21 Apr 2023 09:56:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 697C66B0075 for ; Fri, 21 Apr 2023 09:56:46 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 159F0C0665 for ; Fri, 21 Apr 2023 13:56:46 +0000 (UTC) X-FDA: 80705548812.04.AD601A0 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf12.hostedemail.com (Postfix) with ESMTP id A891040012 for ; Fri, 21 Apr 2023 13:56:42 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=bDt4sMlw; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WzdfU3MQ; spf=pass (imf12.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1682085402; a=rsa-sha256; cv=pass; b=fVGJXpmqXICwROi1K8srReV2cFUIpiNiccfvFZZIM/cAH1u8/SO/f14/NIqyCJK/V4CcFi BOrDYzdLDUasyas8fza6x3lwAOJFZywP7g3m0nEjFrDBzTMwGjakGknt0r5DyFBHgElrp3 g7FDH8/TV0w4mN0JibmSqt//pnZ8HX8= ARC-Authentication-Results: i=2; imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=bDt4sMlw; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WzdfU3MQ; spf=pass (imf12.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") 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=7TPHWbKml+7jE5nazbOtx+SnQImpE8T1NpsH1HJMmnA=; b=CJzGYpOb0r60vz9BQMsMd9uLS8ZxKtuZOwKigaOmxltC5eGr7TdvcAvhb5p4Ksh86rmvWu rxH0g/Ma8pH74aE1YE89Tc0xSwFBaIIB99jn8mibF/aOnSqBZzUhfbEXxrHvFrUohw2moZ HQ38bdHJhcG+YDH8bTGq2X9YFJ3ioRc= Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33LCYeTk014605; Fri, 21 Apr 2023 13:56:30 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=7TPHWbKml+7jE5nazbOtx+SnQImpE8T1NpsH1HJMmnA=; b=bDt4sMlwzk7CyWHXsADIzSMwsdSwXdWRj3uGCWiAL+gVtbE3uYUatUOLwJ09ZuOCHOBe gKXsbqv699H6Bg4hyRKhANmpMr9R0Xb2Frt1cbkFLHWOW+pbaNOh9BR9bJQoPo6xtBqg g0lnG1FNXrmh654liOOo++Na+DhtPjMfWiBRGxk3TdGZ6R8DzMxnMVdnqdE0x/NH6YcX +DG+r99Q8UuO//BD2SCj9jTgGa8V1BiZBjbqFflf55KNc4bxN2xlnGq4IYHSM+lclo8g YRviS6U257bfc1HN9XlRAYPJKqVMy4VWJrjNuK8o2XADx2YzTaCUemRbDt1uEmmAKo5z bA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pymfuna92-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Apr 2023 13:56:30 +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 33LDDfCx037106; Fri, 21 Apr 2023 13:56:28 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2041.outbound.protection.outlook.com [104.47.57.41]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3pyjcfpwgn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Apr 2023 13:56:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HaHgisfzmOf7X4t7WaOxVM8LaeeLUMkKMfOOgOSsrkOaHXOPBZZfhgf5iexYfzwl7XmUWE87dQKIyQao8e8x4wMBUiYPWDFZ9VHdObxZUKqQR9xlvJ8igKTKgzjsW7qrIzowkc3aF1DmdEM7s6GD7mL+40A0ixsq66DoA38kd2FvL0Duc9xcMNu/0a7IfJ6DougWeoc+g7Muk8r4FTrFfJpYg9yICn4QRMKj0jKk3TEjaClaWk5Nc7BNOkKWcs9KHq/d1aQ71zZYDJcaX45mO8qkmTVfr8gxzDd69jsoM8knTiqmZhArDoa05tSSFU5lz6/QCtbRJCbeT8PcXu+d3g== 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=7TPHWbKml+7jE5nazbOtx+SnQImpE8T1NpsH1HJMmnA=; b=DoLY9L1Lg8Pp+hLpRV8Kzh2+1McvIRnGDqAEm0Dp1GJSceSWsw+YebqLVkq64HMKeKKHqB391S7A0/oseKycNsSWz+pQPTk53SFGEA5f8sBRv5XvKaBOzvKGB5eZlsOCSc8JovLz2HMmN55ojo7VDnveL0PrOE9fX0mW3oC/ez+uoPpQHZnKikuRUQKkIOXt7fv4rTjCkRn330FUIdPmP5yenMRp5SlcUf3ojzz4c+Lz3wCXPRaasdECB0AoXKoj2K1zzt7G8ZmQVvDz66fSLj1397YC7dzyziQ9LOrIKyyqqtD4WjqhZKz64NHAWKmTdGCeQpvMZ0f+swFLGaAYKw== 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=7TPHWbKml+7jE5nazbOtx+SnQImpE8T1NpsH1HJMmnA=; b=WzdfU3MQMM8yXRo2FMjDDfJwdjyQ60QYu7v/8qqnvYrqaUxhiuLxR1SuGbUZmdw+uc7S33+BTzTprY9Dl8kwu5QauyZTxrSxDKTCKHb0Wb09MvhhdVyk2e2DglGcyILp27ZQzAE82eVVfx3ddpMpS2HNlGSCSvalSxccOLqVRCs= 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:26 +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:26 +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 3/4] maple_tree: Fix mas_empty_area() search Date: Fri, 21 Apr 2023 09:55:58 -0400 Message-Id: <20230421135559.2163923-4-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: YT4PR01CA0458.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d6::11) 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: 4a7e4c96-1e0d-4026-6c78-08db4270332d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XdahpS22DQUUyvP5taRaU6my1O2l6ezCs+xPa3wT7N64xS9NCzsiQ9/Z4vFetZp7PhhW1eieIKa637P36cAM7i40A5jWH/9LjUBQn0a3KxHq/V8BlVffv/hrtAE6YcweK/bldOtczST2lCUpzQnC3ndLPqm9++x747BonoqwmdjXE73NFTstRyvxmkP1xkx/NhKgqoqtQGdK4996RWPInABWve9JGFzI4YkBG80Jfuh0yjBqsygpEZ3L5b16osvVgGb80MVV/eXZszC5BHDWO+qPJdnimWlKwSOzA2iTOhIpKEeQ1gckZNJLLQo1zs4Dfc+5TdslWbvSN+7M4DNMnMnQXA6e+aLJus6OSHR2SLQzE3aJVmkwt02kprlC/zLZsFBvBor1vKexN3d1LhqfE+SoUS4GxwT4vLb16UM7hkZCirVgQNBSvPLwxZU7eIh0KxJ5+vOLsQTCpRuUdEPNYkkV8w4GzINpuABsK112P6r5uMlRH3srZ3OhkiiQM8XoGxytXppH2cOvLWeVPNod5R038LcORjScO3R8rr4CRfEdv/GK0yQNLMG+662n7Wcv 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; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Oi/mRNp0E+XVTGEBbmVkZjwzi0in6Mn4tY6QSJ/8W115AhnMmupYWcufiw1/H1eyyUllIKuM7b+vM2xNdnMYMmb9GodXkInEWPZXB47WqUvpyehqpXbMhbMmdyZza63O/u08gjHtIUH6wljndEbL1tjecqPc8LZmNIHh1POr9U7BKjHBM6ReqnBReV3BzXHAmF1wJ+jbJ4D2Gfo2AdeGrUQPn9PqrQz+/CDG6b2qSwyjPs6izbQAj3qHGe0s2atSd+LOvgTsNxYuztWhcXLC0m9fEguugtyu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uW/LZ7DhHYiM1CxocB/yjzC7gG6pO2b9PVTPap0u2R+pE2tcnm0/D2p5SwhmIl+RLhcEWTvRBszibCL5HZdY+wuBXnO0NEISh3zSO9T5R3HXST4bZPPy8RKiBHaTn4Z3ru0PQJtxubHytUc6y2iqQCrb2c/A6Us0woj6zgpY0/Q9UTU1bCu9t+pz0rB7uii8tKPjU/Gw/2dOTv8P+LyHRKUYSie4Y7RLBEAI87FucC/9nR/0PFPIY8I2K/g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4a7e4c96-1e0d-4026-6c78-08db4270332d 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:26.6427 (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: Bz9kVsCYohCBgtUmm2HoAieKwz5CaLA6l9ZVFNtOjVvIwI4T+3oM4C1xQ1wWwj265BIGjbNLcnm36/bY1wfuvA== 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 spamscore=0 suspectscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304210121 X-Proofpoint-GUID: XAcGehv1Thb_F5yBuoLg8inbmZcWdz_i X-Proofpoint-ORIG-GUID: XAcGehv1Thb_F5yBuoLg8inbmZcWdz_i X-Rspam-User: X-Rspamd-Queue-Id: A891040012 X-Rspamd-Server: rspam01 X-Stat-Signature: huuyanho1wr4iz1csdsnmw16hcfhxssn X-HE-Tag: 1682085402-335855 X-HE-Meta: U2FsdGVkX19sbrxzxzuLnP+Zrbj1PL5ieuUsdBLzNllOiSjUc51axAD7rGSDX/H9++rLEVADnXSZG7LB8Uahit9M0VZnm3BL78975WJVqd7WAXVo3ZP+2r00bYJ6eIWA72UyWL3m7okFZvzFaieEi4wuZxlMJVJacH6pZcw8jKIQW5xk3arWDxnqO9GxUL9aV9P+jAnY/Y5/InUh7U4+hFW/hiR79IhjiqIwzHcuAAM5nL+488WtsE6FhMHnhC4e72bnLqTCG+ej+rrhxx4rfiGIpsaOPvoi5auC/U4eEF6G/1o2khXliN2TZkwp2rY+ZtiZotiG068ndiyypAo4XnrDMSPpH+9mtqBhBGMRRvkl/qSO/VMfSwHUWW/l+BUgd8jt2mkkPhP42PkahlcHed4w7F0V6XNikIdEXlOtwP0BlOjF6gsbyTKiiG/B/cV/A8ZzZDyAIdqQb+rP254h6jURIWkOJWTrS0kBUZuBUmqWLpAL5ZfSgDOmlkYmxXdLO/ncJTlmDKFpYYo20h67iFzrcKN/ZkOA6PMNwG62mtuoej2a1eoYwFtaWWZyoP8bs9pEzwYxyGsj62QgAFYfF3TIzIf+42zSP87DmdSIpT2wLyQxgqbh1i1FwPQHy8u6Kh8kU3UzbXke0LbNK+ggd2SND3hLUSoN8hgmHH59BkS1kwby5QHQ8tRsNgIw62Oug4dChrPE5VV7uryeL7wfCYiwrTAh0u8+EegJkglTgmxCrPH/ZRtuwTT2rkNi4bMb21oX7Bw/nlDyo0vLTgzk4GmAJhaa2SkrdvP28niSFmXfO+VG715EnnI//KayhYjHoQHOm1sHosOvyA2PqT2m0Ldd6CmvWNDJ+QK9envqUR6nPHIA/PS8dZlpBKf8DOE2m2fIyMmfol9IYCBX5Dm7stleSgyyjsS1uVdoswYrR62mK8umAmEPOjPVUHdDXn7UBOswVaiauaUneSqLLfi Jiqo5G7y Cv1zCGURQetOn29uLuqaOlrnehKdOoYnmyu9NvwLPKyU9aIuXLwLceJm0MQ9u7tJsvhEZu4mVEtqFW36WxjPpvKHpdA9MEc+kJktvBFYS42DEqzNZsZbP9jI1/AVVJQb1Lq6bVf1ez+ENN5hbUP1p5RejV93tqu1UTPPbpAHljusOPoeXbFPdvgskhoZRA7dFGzy8GN3Wdm2yHlBLpAoW3MrQhFJJmTzEyBXe5A5M4sfL1IORF/wKZsyrvPU1rNY9Q8L13s9c0iTlwh4FbejmUBvg1ROvPxZB/6W0ugIJPdI3jcjV1dj6EAYAgRPVlkNErB+zYQlCgoOyyl0C6na//Kxilb61t+QbDmpiOMUC/hVX0RXlmwyRqCemwdCLXC+4vYGmwXykGegHD5hfW+IJLweA6LuSTU2ayce/8tzEdXznezo= 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: The internal function of mas_awalk() was incorrectly skipping the last entry in a node, which could potentially be NULL. This is only a problem for the left-most node in the tree - otherwise that NULL would not exist. Fix mas_awalk() by using the metadata to obtain the end of the node for the loop and the logical pivot as apposed to the raw pivot value. Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index cf4f6cdcaad38..51910c74d4895 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5029,10 +5029,10 @@ static inline bool mas_anode_descend(struct ma_state *mas, unsigned long size) { enum maple_type type = mte_node_type(mas->node); unsigned long pivot, min, gap = 0; - unsigned char offset; - unsigned long *gaps; - unsigned long *pivots = ma_pivots(mas_mn(mas), type); - void __rcu **slots = ma_slots(mas_mn(mas), type); + unsigned char offset, data_end; + unsigned long *gaps, *pivots; + void __rcu **slots; + struct maple_node *node; bool found = false; if (ma_is_dense(type)) { @@ -5040,13 +5040,15 @@ static inline bool mas_anode_descend(struct ma_state *mas, unsigned long size) return true; } - gaps = ma_gaps(mte_to_node(mas->node), type); + node = mas_mn(mas); + pivots = ma_pivots(node, type); + slots = ma_slots(node, type); + gaps = ma_gaps(node, type); offset = mas->offset; min = mas_safe_min(mas, pivots, offset); - for (; offset < mt_slots[type]; offset++) { - pivot = mas_safe_pivot(mas, pivots, offset, type); - if (offset && !pivot) - break; + data_end = ma_data_end(node, type, pivots, mas->max); + for (; offset <= data_end; offset++) { + pivot = mas_logical_pivot(mas, pivots, offset, type); /* Not within lower bounds */ if (mas->index > pivot) From patchwork Fri Apr 21 13:55:59 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: 13220082 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 DF11CC7618E for ; Fri, 21 Apr 2023 13:56:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 729446B0078; Fri, 21 Apr 2023 09:56:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B08B6B007B; Fri, 21 Apr 2023 09:56:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48DE66B007D; Fri, 21 Apr 2023 09:56:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2D3296B0078 for ; Fri, 21 Apr 2023 09:56:53 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1386BA0402 for ; Fri, 21 Apr 2023 13:56:52 +0000 (UTC) X-FDA: 80705549064.17.7B534E5 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf09.hostedemail.com (Postfix) with ESMTP id BB3BA140003 for ; Fri, 21 Apr 2023 13:56:48 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=gNR78VCF; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uGsxpXly; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf09.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") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682085408; 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=4dop6dLB8MYyf4g70fGvheMGvbOaLIxIGFq/jpCiG4o=; b=rITaXURgbF8eYPHHXMgHwHLu0FctdkJUcfI3t6PWaBDvolDrBnpSXI5mW0FJUOD1SMC1lX yyYjP1F5xXChHIeRVxlPs8pOn/CZ94W7kNEJX5VYov2wlfdoGEu2MR9BpjodEjhDpnNYg4 MPWei3IAmzJxSMweTqUUXqLTWJQ+FqE= ARC-Authentication-Results: i=2; imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=gNR78VCF; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uGsxpXly; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf09.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") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1682085408; a=rsa-sha256; cv=pass; b=5aHll8EmW+QKMAV4Tcn1HvEQSz8EE2N2ZrvdEIhSPFMO5Rh2a+heDIK5kEB2ICe1D5fJED AVUKE9goicZ4/4PMHA0mSPtNrc9+TQD16Oi6FOlpyBuBuD9QEx8hWb7W76M36CkYJ11qMK 3hUjH1KLyLdSnwXr5/MEhJbXmrHrP/k= Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33LCYa7w020032; Fri, 21 Apr 2023 13:56:32 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=4dop6dLB8MYyf4g70fGvheMGvbOaLIxIGFq/jpCiG4o=; b=gNR78VCFUDTX0OeN69aV7mcYIYoQaRbwqP88Vz/EJr3t0qY1EmhE5uFiXm81YCHd7SKA hzVgkSXa4V3MRZcBz67ITiYic1z5GjhrQLkZ8jBdWe4CMsRA49noOtCSvJ5g9DNqOy5N bEwDhyvPEUe4VZYzy2PKaT8OIJlWdtdLUywWawXSpRJ3fLdbOzCrJxQMcRhUOzccG6a5 q7i50neae2P4TAs3qb37YpWdPRlESRZxkVceFv1hyGLX8oJvTbF8nwy4+TOFzzdCZrjg x29Djglga+LdZzSYlIbIFZLmVMuObNquo7NkfL4Y6ld3hUDyO3evIaKd2MoBIA7OaCV6 Zg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q07694b6n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Apr 2023 13:56:32 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33LD1gQR011183; Fri, 21 Apr 2023 13:56:31 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3pyjc95yyv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Apr 2023 13:56:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fHIQYEKdDQnxPTYruqI1J/WOUwJZhG6iKvD91W3Cblwvpkxi04UTQKFxtaJ2mKL9fd1hTNzdRfHYovl4lbfCkYGr8oBinrwqyPeraFv3qWCFOTLiYPqwcpPacl8E1mEb7rMu/SPX/n3ge0lMUw2/FHPaEwS3crw22IB2zHsNMxJq78M1eCR56SBlPZ/tTbfXLRmixYUhxlgHGOjyQK8dzeWRDCjEmjCE9L1RhAZDPPaECZHOZ8wC1mE1tVPvM6veA+/Lf7+w8x+qju2spK77Cs+z56Ba4HWj+aGcdRVBUE+BTJJaFEgLFk1nE1P9UyqIRdgGK6QmiDOuINNNeDNWlA== 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=4dop6dLB8MYyf4g70fGvheMGvbOaLIxIGFq/jpCiG4o=; b=EII0hIeePQQnbPWXwf9MZbE0eHMc12nBfffAtTJH/2edsUZ0Ijxsvn97b27bJWJ8JlDdzbe4yqC2uEq2mSU4y7xxWriYpMMv/xGEnY0vRI4ObYksluUNDpUBg02JhJ/CX/leURY1SwzPhe25QUbSmXvmqThfk88Mesy9VCsFfAyisAgYGZIZg/lVMNAGJ9h7cnh8M//mQ4f8x/ytmNDlqOxn1p374CwVxrKgdEu6jMelgrcB4D6egjY0P8vGabVxIu3lrRiRXaX64UAjNZXGkUhIzlVByajXL2s4wj76+4p83zvy+pV9zI8nXumKvX7IyX7bUZFtGzGn4aS95sobfA== 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=4dop6dLB8MYyf4g70fGvheMGvbOaLIxIGFq/jpCiG4o=; b=uGsxpXlyYASWhEySlxJPe276DbWwNG9OB684MPohBRtUPk4zrzjr2oXMSMpFftn+WIY/2jm73edY8B38581D0nIhWWhhbYxZWzIQi9sbIRTr5gCzNEv+d8O3sI4xn84E/sHXNekUXxb+U4+xfnqGjVURBocjbogbPo/eviRGXss= 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:29 +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:29 +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 4/4] mm/mmap: Regression fix for unmapped_area{_topdown} Date: Fri, 21 Apr 2023 09:55:59 -0400 Message-Id: <20230421135559.2163923-5-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: YT4PR01CA0027.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:fe::6) 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: 8d41b251-c89b-4664-8e3f-08db427034bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SbelP2/xAScKNfyCJL/cTEHLD/j6FeLCPHZ1Vt5NOwnK6vgR8JK5DDXpjmj2yxrDm3tGMG2OQpvairm7ksUihCs/fyFYYz17iimbPEhdU9V80qrNXUkG46D/+jCdMFRJgYTnXShtv5y8gZ0ad/Uf/rK9oWMTf5JlHaYJqkKzg3H1eH0zOFYVcMvXoPAVnjWF/hNYHm3I/gepmL2MKSVBr7x45ltZ5rg1Fp5ix4uPDdqRTt/Ug4EkGqP1UOm1t3xisSyFEM3zgj2IJA5XRGI7aGjxMm+hSmPuJXP+aqem9AU41XYL3eQkoSDXmbY2qe/LLL4UxmuzLf804I7F5bzQ9kdHnt0ubOWGkraPPrFqksnwnIfsbWhfbTfeYYJ9m+uDJap/Nhg2R9aF0QAFQsLAj0rzhyzkfWrKI1FYjEHO+By+vStLFKq3W2xFJViuKf9kGj9vLz0ZGryYy5g7FZt4Mc0GT7UhfkoB2PhgsAoUphhGvrZQRM6PSYEJKOv+iop7NuaDGyY8ZZMOycdKVavlNhVoup5v6lkgEOtzId/J2APJZI6NLjYKJNdzvzRzIzfT 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; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9xf2EEHAKkKcyFL6VvhCvXu3LIygxsivqawq/cpR9YL8kXWIDCNh4k3i7TT8oYc8jyneOYlVUkQhWvnr09CjCY34Q5KV2A54Z6/NQ1bT6jt7EU/sXVCegAz9cxNawGb7J85tHOI6yKhnqq0h1CGDllQNa7aWb5SW7WKTxQb24dhQwJZjIK4UZZWnaxnxTaucJvca9ULFEYt30OVMdLNeQ1iPlF1n+5xzwGwe9Pr5Wpzu8jxPr7n6wqXLuhzCReUwOKWrfvx/y4i4lAP//v+a67ov95DMl6LQR5DQedPsmERNdmMLmNEwKGX/bDTLQU+A+hL9R6vB5Q4mJm3Bgiv4GCLVXDqpakZyYAyeftFJvaxPt/HtapwsbOPtlIR3Y1XNFO8hSay1MTAUojrjXmulIeTcOYx0qcC2gDk12tH9H5uRWuURLRHNDzv2CwGG5XVv4v3y6Iebj3J60FJb60FFXH4bO894fJcvgUbAvlnQCSda0b1+mlpL9RNfeq7OUM829y4HYY/E4Dw/nEkM66RpXcQrIsQy5XYfmdHkbdDzz7k8QHpjTNS7aYPlYCnzi48Yijzm4UpCtKnXpEeNeVr61Ud5He3YIS96FCPzis1e6/kE4IhUW8d7IkJryc5fYD6yWL2LByzP7ebthw+aDe5Z8iXtALE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I55GF7rv8/OBxgJiaF98KKht+4TJ4xW6mhohRFI7Kvnn3lO4g71MOJOud27VOZnsz9fn8y1XgT4MS97gfJ7USk8ke0xxWF9YZXd0VVD05ApIEqSCBE4djezsj4wXeeb4OhDi8fhI3olbxjCDP9UeGrP50LVRx2E1QF4a7vcU/WO8/Dlsm61gvUaFsX0beonYpHnnwRLpKiFuZUNoaYKPmsnNQDi1JBJ72Qh+Wkdf9N4Ui8xz00upfO5DV3EecoQr0mS5QdBu9HRWdPVM5B+cxSQZwjYYAvxZWc22jWqmC9rpv9BWucstU7emtVDIvCksuS02JMr+HiKFnHyT0KsZZbi1C1ao0GxBD0waQAlPYx9c3XoEcp+nMNV7AcDLnZYQWRvqJXLT0GJ3x9IwUTzAFis92gSO50AGvN3uithWsv4oFoAgs6Kp88Vi+xNU2dmK0gQNcwIPilQL7/h32B20+1qSEzDUsuBw5LgP9941OPsl6IKNxkdjokL2vMh0Dv4lpPfcHuhw/efwX0JvZ/dVswmJbDNfrNSgLvXg1GIKhQObSxUjxqUP0gQ0j8GFw9Q5Js1s+dJ5CN154XhPYTAInt8Bmnat4oKfB+LwVbJHPDBWz1K9KCR2nBftLXSuVLuN75KwFLjO7BVkQW9D0JfIPHKDZMk85W7dh5G5VjU9MccgXcreNXaVnLgG2gIOBHhmM/sSPDuTIm/87hslduk0Z16oFqY8EerNN8/VAOw0AWiqh3a5pF5dbVAvNfyyTMLuteks+UhQLKQtD5mTwi56XA57N7MRT3qwz+7uBQsoHpcW5A2228ZgUQLhamqCS/fmL8ml5S3UDy+ILaCrMsCbhB1vVZIW7Y8TnYfqoaMqtOQaMh2bnFJFOd/4bpdVjJHH0oWgZlq0Z6B+uGkEvQEpihguc0D0zwUgRDGglIOx2+6cBGRgUQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d41b251-c89b-4664-8e3f-08db427034bb 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:29.3576 (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: ccnuV/UOcaj9DJwG6WZn4YbFHka1OQWFmsU6UgeSXyQH3mjBvxDm0PHxR6WjXzVXDRjSz4akjjEIh8O4+XS5Kg== 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 suspectscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304210121 X-Proofpoint-ORIG-GUID: IjrZg72Bv0EJyEfyIsajhwMHlzOWjOZj X-Proofpoint-GUID: IjrZg72Bv0EJyEfyIsajhwMHlzOWjOZj X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: BB3BA140003 X-Stat-Signature: kmmofjzcp5847p9mjqmini96myj4xuxp X-HE-Tag: 1682085408-199260 X-HE-Meta: U2FsdGVkX1+dY8FD3BULdNdiq+0Ak7pPNXlZ4snEgCa+ul7gYIboPDIVW/YrysMx+WTpwiUuQ1RqvfYHz6mqZ0IV0i30BczhON4m4nn+gN4t+A8xPjbFoPKgzpn/emxTe7PzvbusoBvAK8J2pCIbmK36QxwX4AnN3A4pROcgad5UfzTED57Nq8Ib98BV5SEHsko5M3Rc4i9vDataw09Ke4Nwfe9IMpP63eT2RI0S3wvymgiZw/ugCH2CR9XUR+bydrO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yXqxRn63IBk7KdJVI3WRkzyNhO4qaBjgrxNYt1RI+nyPgCIuMbUrns0FyqndMwD1pCcwkZMvz9OsR4myBjyfsPo5gpmZF3wn/5Ar/yN8 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: The maple tree limits the gap returned to a window that specifically fits what was asked. This may not be optimal in the case of switching search directions or a gap that does not satisfy the requested space for other reasons. Fix the search by retrying the operation and limiting the search window in the rare occasion that a conflict occurs. Reported-by: Rick Edgecombe Fixes: 3499a13168da ("mm/mmap: use maple tree for unmapped_area{_topdown}") Signed-off-by: Liam R. Howlett --- mm/mmap.c | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 055fbd5ed762f..6b9116f1c3049 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1548,7 +1548,8 @@ static inline int accountable_mapping(struct file *file, vm_flags_t vm_flags) */ static unsigned long unmapped_area(struct vm_unmapped_area_info *info) { - unsigned long length, gap; + unsigned long length, gap, low_limit; + struct vm_area_struct *tmp; MA_STATE(mas, ¤t->mm->mm_mt, 0, 0); @@ -1557,12 +1558,29 @@ static unsigned long unmapped_area(struct vm_unmapped_area_info *info) if (length < info->length) return -ENOMEM; - if (mas_empty_area(&mas, info->low_limit, info->high_limit - 1, - length)) + low_limit = info->low_limit; +retry: + if (mas_empty_area(&mas, low_limit, info->high_limit - 1, length)) return -ENOMEM; gap = mas.index; gap += (info->align_offset - gap) & info->align_mask; + tmp = mas_next(&mas, ULONG_MAX); + if (tmp && (tmp->vm_flags & VM_GROWSDOWN)) { /* Avoid prev check if possible */ + if (vm_start_gap(tmp) < gap + length - 1) { + low_limit = tmp->vm_end; + mas_reset(&mas); + goto retry; + } + } else { + tmp = mas_prev(&mas, 0); + if (tmp && vm_end_gap(tmp) > gap) { + low_limit = vm_end_gap(tmp); + mas_reset(&mas); + goto retry; + } + } + return gap; } @@ -1578,7 +1596,8 @@ static unsigned long unmapped_area(struct vm_unmapped_area_info *info) */ static unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info) { - unsigned long length, gap; + unsigned long length, gap, high_limit, gap_end; + struct vm_area_struct *tmp; MA_STATE(mas, ¤t->mm->mm_mt, 0, 0); /* Adjust search length to account for worst case alignment overhead */ @@ -1586,12 +1605,31 @@ static unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info) if (length < info->length) return -ENOMEM; - if (mas_empty_area_rev(&mas, info->low_limit, info->high_limit - 1, + high_limit = info->high_limit; +retry: + if (mas_empty_area_rev(&mas, info->low_limit, high_limit - 1, length)) return -ENOMEM; gap = mas.last + 1 - info->length; gap -= (gap - info->align_offset) & info->align_mask; + gap_end = mas.last; + tmp = mas_next(&mas, ULONG_MAX); + if (tmp && (tmp->vm_flags & VM_GROWSDOWN)) { /* Avoid prev check if possible */ + if (vm_start_gap(tmp) <= gap_end) { + high_limit = vm_start_gap(tmp); + mas_reset(&mas); + goto retry; + } + } else { + tmp = mas_prev(&mas, 0); + if (tmp && vm_end_gap(tmp) > gap) { + high_limit = tmp->vm_start; + mas_reset(&mas); + goto retry; + } + } + return gap; }