From patchwork Mon Oct 9 20:16:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 150315 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2100881vqo; Mon, 9 Oct 2023 13:18:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOeDMotNUXb8zWv4goc/nq8zY9MeQZEGD/vBEb8vWlrw0j3IhDMW0mP4IptkAdcQrfe37D X-Received: by 2002:a05:6a21:6da0:b0:14d:446f:7212 with SMTP id wl32-20020a056a216da000b0014d446f7212mr21114888pzb.46.1696882682498; Mon, 09 Oct 2023 13:18:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696882682; cv=pass; d=google.com; s=arc-20160816; b=MyUua1eMspRhZzN7skZUBBVvZ62ZDpr7PJhm+zFBv4AtqzUtU55xTHNCpYAAmX2yOe HajUdrOaj9cQg/iNsbNEasPEVyBFs+CX3m4VPJV6DmRgk6DhMoc2W491M2EMujPngXFP jVPqwYjA55dXJeIk1F5R9MQR5Ha2tCtfVw7Vx61bE1vfS/q/Wumk8Om9q9nEAzbfpLxk RDzjdoKzcg7WnwfSs4oOZPZCaQi/7zvbwYyWxOOzbmkISBGvCLujaVOELnXhCL7KIENW e8ShIrckwD1sbbAp0JJQ6L033JYtYMmIRlPNYTb0RAB2IRrF2q1g2j9Fn5lIzkelfsc+ 2bjA== 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=qirXWJvA8h9aKwndFTNsBebfC7irUS9otO/qc8bhdII=; fh=B8hmr/q5j3tCmv46TiFW349WPKYIK+b/KkTcg+TQCdo=; b=dPqXFjDaRjL6hb19NQqKZG7lxVKLyv4aMhktNBd0CbCFzNnEGcnrsoCMJtPSYcHlQM oQCkq7+JKBtamd4U2SwSaiu9NH6SZzxGdTDrG4vnw39YFkGs17zuGMF7pCq64MaYjsCI IzRjcGYhbrp/3w5+DZrrO1mHjSdF4duQtjvZoM7hdNcUQqC80ctDIinSDiX9Q+P60Alz h/Ez9IroAXBXL8y7mpnYhwEGM2UKlNtYk7IP4rYzGuUp1SemAGFJoNla0CtFYFYlpfA6 mWkLD4XZP1C89fOwEr5BVtncrYtVrTwvNEKvg8iK64r8dt6EO9k3Qj7svtN38pIkiPQF 3frw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=EveeYi0P; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=l1d0BEQJ; 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.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id u8-20020a1709026e0800b001c62b9d56f8si9911925plk.606.2023.10.09.13.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 13:18:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=EveeYi0P; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=l1d0BEQJ; 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.38 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 fry.vger.email (Postfix) with ESMTP id 2634481D6D99; Mon, 9 Oct 2023 13:18:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378542AbjJIURd (ORCPT + 18 others); Mon, 9 Oct 2023 16:17:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378545AbjJIURX (ORCPT ); Mon, 9 Oct 2023 16:17:23 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C85EAC for ; Mon, 9 Oct 2023 13:17:21 -0700 (PDT) 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 399EY2IQ011918; Mon, 9 Oct 2023 20:16:53 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=qirXWJvA8h9aKwndFTNsBebfC7irUS9otO/qc8bhdII=; b=EveeYi0PVsVERIlQAG5rqigbNlyOtIfDWCL7h5fHEwCFf3Eshrsf7nn3TDrSs26yLpjA qVZD/9iMKMSvJCJwoTyo3U8m/hlfq0t82X6fyRD1qrrNtG7jkHoouw/rTfY4+9nOjDDs /wBAQ+RRTXvVFnui3sDVwAQbDGDM4H3xr4t37TuaQvZgKhyg6ORwyJ4DKdjXy3g0bYOj bd7Kap+nYNoYgA0FuB3HRiSyL1SjMEvgXS9n7OM0/w8X39zywFQa6gOiNWtHIo+7j79L McNztdrL7GAAoYc7C6hL3/kyLRrA9YGvXY+x7Tc6zYNUyuJY3Q/VeH5euhgdOgW7YuZo lQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tmh89s0vj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Oct 2023 20:16:52 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 399JTbNC032075; Mon, 9 Oct 2023 20:16:52 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tmfhntnaj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Oct 2023 20:16:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U5asRYoVqCxJxRGeK2bA/fNQYk71/pUFwKYaO5x0xb0+8cdobjTF0/P5x6zb+ogVVgU691HppyineHemCm4e9w4+cLsW2Jw01mqCD6O0PhkLIXD4UYkTZL/MwyVODqWoE/c8lkC0D+Nbif327urg41h9hbVC57Pw2XnuNObFwJu8lfvm43dbHlAC8el2fLi/pAdQGBCnbSnaIpNg+Dhe/2/uHLG4xDe+2dUfCNLa9XiowCCRDnEvEPRQbpnqbPB9br3Xl0eMZtkeAclaDRZU30Lk/IRyLemPPHm3fdVWL0neKmL4xE7LkeBbzPOouTbzGc1rJFZuKr90MoTN/ORZiQ== 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=qirXWJvA8h9aKwndFTNsBebfC7irUS9otO/qc8bhdII=; b=E4Mb5A7rLIxQ8qGfF2WdrE6fYXlsRZyst9oXkAwiSSZtt/PgkPz8PfO3R17HvhL7Vy7F3EMichreabseOwmaxfeZDKpvpqRZOjFZOC4ES3mOFK7oDF+FzB5kQJE4xEYK85MYt3Fq8my9w5DRqchovDjhe1yNVfOilFKXLFtjT9nrtl3Iu88MruNTkyG3kc8hnKA3aHVNqwnoVqC2Wx9Ka6x1m4+254fmPs5gTTo9qoImgAoGxUB97AQ0SJyMzIOQQTdAhoG1fdQR2o7M3t59MmuFNf/wo1FYHLxOSxHqXGJAceXg6XyMNBhdm1d0tn56YFbGamiO6XdvQUlv8uLDZw== 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=qirXWJvA8h9aKwndFTNsBebfC7irUS9otO/qc8bhdII=; b=l1d0BEQJMCnNQhqSE17zwA4l1cXb8R5dgiaEiWxQxVoxnFYbRO4sjIKKJcJlEEqaFnxVjBevCP6lt55x+GGdG+kkKBMHcubX++ty/pMYxsiDJDcox48J2qRWpfSm9d78KOsMGxAhbqXyYavYp/Nr63nd+m/eFvYUhsaSpGdG3mA= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by SA3PR10MB6998.namprd10.prod.outlook.com (2603:10b6:806:31c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.35; Mon, 9 Oct 2023 20:16:50 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::e391:f2a1:a9d:967d]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::e391:f2a1:a9d:967d%6]) with mapi id 15.20.6863.032; Mon, 9 Oct 2023 20:16:50 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, maple-tree@lists.infradead.org Cc: akpm@linux-foundation.org, willy@infradead.org, liam.howlett@oracle.com, zhangpeng.00@bytedance.com, Sidhartha Kumar Subject: [PATCH 1/3] maple_tree: introduce mas_prealloc_calc() Date: Mon, 9 Oct 2023 13:16:37 -0700 Message-ID: <20231009201639.920512-2-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231009201639.920512-1-sidhartha.kumar@oracle.com> References: <20231009201639.920512-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BYAPR05CA0064.namprd05.prod.outlook.com (2603:10b6:a03:74::41) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|SA3PR10MB6998:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a0dccca-548c-4159-5d9d-08dbc904aba0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b/y61+ZAW3jxgv0dmNdwcCKFsZOQWY7xr2nxjukvf9pZHsYez7R38kFcfMHnabgI8q4gD1M+A5ODg8YfMh8Ex35QNW7v8p3xry60YP0wZ2VX8EXtqU8iZSXCb0FgprAqOzoz71bpNWyyJrM1DshivwfXSK94qHCjUngY7J30Gn5YFYhLIE0UoloAQOUCfPuhr8EEJ0WJyscGM3a6VM0VigpnWfYYSoM1QwZN2KoR8oeEAWB0sAd0Kdhay2TLS9dJNMBHtZBhOV35tYROX9ZjAK2PYSAYwIGfsosIxxv2h+7sbvHR4fEaH2ANEVSGtFgkXwMLgB3xUlgtQGzbWJt3qYo4iqTcgdTJhG/JvCR9VRH7270FGdIcubc3dhmze225iy14sHHfCXy2wQRHfQzgMjqAwL3hk8Yj2DWsx/8DssOHx6JUlCCFKcYALAQM+RwzNXwty3dFBil4kSPw4NSFEwRkgcxg4jkTbobDaaOx0V9CKinoJwvKa6QTQkLbe9GDSvHI6DgNmDGMEfRsWhBwPxvO3Y017jiuBJDrlplAOxFAxHd5wq8GuiNKDfiliNcO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(39860400002)(376002)(346002)(396003)(230922051799003)(1800799009)(451199024)(64100799003)(186009)(86362001)(38100700002)(36756003)(6486002)(6512007)(2906002)(6666004)(478600001)(8936002)(44832011)(5660300002)(41300700001)(8676002)(6506007)(4326008)(107886003)(83380400001)(2616005)(1076003)(66946007)(66556008)(66476007)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PHrn/oGpVDfRLf6LgwB2mZSwCwbyH6VIcPYMw72IjnqunncrNx1OgCH8bzMMS+PIemHjGU/cKVnHqbRCy5MsvTatP46j4Wz6y8P4m6CGE2KaNOUt2v9RMgMBlYUUs/e1hOszScnEQkmUyz+ZwW/n0dU5pkZlPJQgV8sD1DWaSr/zRB7EG/CSGWsI7qEgxNZYg/Tn/sXujofZQiXfnvIZ54gzQph9OeTQ1ruD1D2ttKxG8extdyeGHn6CN49f0xP83WRwiU1x+RzwgApjeZN0bxfoWNbJ/vwblGckEeuZqhJM/B6yy9NbO83LfuxqVBLgvkZGZrGzO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TPOzBTwn/wBuaK3nAoQ8RRHkp+9myC6FOhuF8K+8pzTCyYu32R7c/BS9t0w2+r95wkMKYTQE0vzExmtc9NksY12/Ich7cxVLSKfyNYRbZTqbKlX/wHJ7LNGFFkht2y/XBZMxF2pERCqoHMFmhjHgbiGeXMNwWbIoj99Kk0RQQV259Ulbb21mTcCVO3O/jzL45Ro2yoVAMqaA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a0dccca-548c-4159-5d9d-08dbc904aba0 X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 20:16:50.1200 (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: yvqlpW2FLWSjrN85OXYZe7RgOdQJqSrHXuuxxG10Ii4z0SpjIREhAtiJ406U6Rh4hvrkTcvA/47XsB5kQ5Hl2HxfMljtaiobIVjxR31q5DY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB6998 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-10-09_18,2023-10-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310090163 X-Proofpoint-GUID: tBPHSQ_DDvz0WgzcexM5jbV7pd205Ghk X-Proofpoint-ORIG-GUID: tBPHSQ_DDvz0WgzcexM5jbV7pd205Ghk X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 09 Oct 2023 13:18:00 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779310455823898619 X-GMAIL-MSGID: 1779310455823898619 Abstract the calculation used to determine the number of nodes needed for a store operation into a separate function: mas_prealloc_calc(). Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 85 ++++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 35 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 0e00a84e8e8f..e239197a57fc 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5418,6 +5418,54 @@ void *mas_store(struct ma_state *mas, void *entry) } EXPORT_SYMBOL_GPL(mas_store); +/** + * mas_prealloc_calc() - Calculate number of nodes needed for a + * store operation. + * @wr_mas: The maple write state + * + * Return: Number of nodes required for preallocation. + */ +int mas_prealloc_calc(struct ma_wr_state *wr_mas) +{ + struct ma_state *mas = wr_mas->mas; + unsigned char node_size; + + if (unlikely(!mas->index && mas->last == ULONG_MAX)) + return 1; + + /* Root expand */ + if (unlikely(mas_is_none(mas) || mas_is_ptr(mas))) + return 1; + + if (unlikely(!mas_wr_walk(wr_mas))) { + /* Spanning store, use worst case for now */ + return 1 + mas_mt_height(mas) * 3; + } + + /* At this point, we are at the leaf node that needs to be altered. */ + /* Exact fit, no nodes needed. */ + if (wr_mas->r_min == mas->index && wr_mas->r_max == mas->last) + return 0; + + mas_wr_end_piv(wr_mas); + node_size = mas_wr_new_end(wr_mas); + if (node_size >= mt_slots[wr_mas->type]) { + /* Split, worst case for now. */ + return 1 + mas_mt_height(mas) * 2; + } + + /* New root needs a singe node */ + if (unlikely(mte_is_root(mas->node))) + return 1; + + /* Potential spanning rebalance collapsing a node, use worst-case */ + if (node_size - 1 <= mt_min_slots[wr_mas->type]) + return mas_mt_height(mas) * 2 - 1; + + /* node store, slot store needs one node */ + return 1; +} + /** * mas_store_gfp() - Store a value into the tree. * @mas: The maple state @@ -5474,49 +5522,16 @@ EXPORT_SYMBOL_GPL(mas_store_prealloc); int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp) { MA_WR_STATE(wr_mas, mas, entry); - unsigned char node_size; int request = 1; int ret; - - if (unlikely(!mas->index && mas->last == ULONG_MAX)) - goto ask_now; - mas_wr_store_setup(&wr_mas); wr_mas.content = mas_start(mas); - /* Root expand */ - if (unlikely(mas_is_none(mas) || mas_is_ptr(mas))) - goto ask_now; - if (unlikely(!mas_wr_walk(&wr_mas))) { - /* Spanning store, use worst case for now */ - request = 1 + mas_mt_height(mas) * 3; - goto ask_now; - } - - /* At this point, we are at the leaf node that needs to be altered. */ - /* Exact fit, no nodes needed. */ - if (wr_mas.r_min == mas->index && wr_mas.r_max == mas->last) + request = mas_prealloc_calc(&wr_mas); + if (!request) return 0; - mas_wr_end_piv(&wr_mas); - node_size = mas_wr_new_end(&wr_mas); - if (node_size >= mt_slots[wr_mas.type]) { - /* Split, worst case for now. */ - request = 1 + mas_mt_height(mas) * 2; - goto ask_now; - } - - /* New root needs a singe node */ - if (unlikely(mte_is_root(mas->node))) - goto ask_now; - - /* Potential spanning rebalance collapsing a node, use worst-case */ - if (node_size - 1 <= mt_min_slots[wr_mas.type]) - request = mas_mt_height(mas) * 2 - 1; - - /* node store, slot store needs one node */ -ask_now: mas_node_count_gfp(mas, request, gfp); mas->mas_flags |= MA_STATE_PREALLOC; if (likely(!mas_is_err(mas))) From patchwork Mon Oct 9 20:16:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 150314 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2100783vqo; Mon, 9 Oct 2023 13:17:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZcrvEWLuY3/fBNiPBVfLUMhJZIgwYDPlXrpYmM76i/PavOLptyWxfbIQZTZOKV1BKwjUG X-Received: by 2002:a05:6a21:3284:b0:16b:79b3:222b with SMTP id yt4-20020a056a21328400b0016b79b3222bmr13538381pzb.34.1696882670363; Mon, 09 Oct 2023 13:17:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696882670; cv=pass; d=google.com; s=arc-20160816; b=FNWfUlX4CbPdgk0wT1FDl7EgUeJGOl9/RLS0tcf/7TIKbpg3BSygKwrga2dXewzYgk 3sqgjIsrJVKvEQY11EMsVCZrxkXnBS61Hb/DezXMrrELnv0Inri70q6D9Qo18H1aCSXe iRnwAlJYGmUZ/SFaIOyItDihXd5uCLybkbWZ0Er0KM6LeLefH9YqMcE8Co2aHxAI7Ixi Tb/LrGgawtQ22I4PD0Q+1BF58GtdNTwySV7XzaqhXGxvMpv310mhikVhSTF82YO8GI4B KzGk4OSAS8HnI8ao3E0MXscndge1dbiIskUE26mNYegWbSSlkL4aetpd53Tn0CyMbpyV tvuQ== 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=4H5BtvqSc+0mOYg98doViY1SX0bCxITXGEXdoB6sLAM=; fh=B8hmr/q5j3tCmv46TiFW349WPKYIK+b/KkTcg+TQCdo=; b=YEIeJAT3w6AhUGTMqRFNDimbRY40kiELAbHCBedpZMp6FzteYlllVNNUy4II1D0In8 Q4z4Vl2jTuvlf3xfSba3ZAn7jdf2d2pFJZ/dg51kGtUbM264AyBAQiEGB3B3HTRv3c7Z 0dKhCXcGmconpaaOvbGJkJOpUOm5ev6yXIzDUAnD0RpCrdLX1i/2cyFns9UNO+VLNeSK puSAA1aLNdUZ2WLXB4Rco98//t4IZJ2az9n6UAS7lddtn/FvPPZxYRkQYxOunpbjAC1h NKD+fCza+3RrY4E7EIAazAm+5jCVIMk7EKOEVDKRD0V4tzH/TWC7dZu99ObatelK79B4 oi8g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=ujT23XKE; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=TdLjyEH2; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id f23-20020a63dc57000000b00588fa0def27si10047609pgj.796.2023.10.09.13.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 13:17:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=ujT23XKE; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=TdLjyEH2; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id ECEEA80BB223; Mon, 9 Oct 2023 13:17:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378591AbjJIUR0 (ORCPT + 18 others); Mon, 9 Oct 2023 16:17:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378586AbjJIURW (ORCPT ); Mon, 9 Oct 2023 16:17:22 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9869B6 for ; Mon, 9 Oct 2023 13:17:19 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 399EXxfB014979; Mon, 9 Oct 2023 20:16:55 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=4H5BtvqSc+0mOYg98doViY1SX0bCxITXGEXdoB6sLAM=; b=ujT23XKEa4nsStIg2waYnxP8CJbixv4PuMHqKhSQjZ2SsHsNWevgZVFPsaLtXMvaMBrO 0DCoKZNKOGhdXMPXtsP+9G9+wCsyL7DEoYozcKx6AyiEqnnRYEdkgnegy/bQ/WvLfiP5 78KvcIm19SbtD1/oieSlenAg2q0j8+FWK2Q68DRMuuE0iC9WdD5cwKUMOMMc+2hY5xi3 Tt4KvUNsqBRLkHRYHjqC0bEgTEMdmGW0+zBWL8En+NzY1kqV3FXC3sxoCoiKxfmcZar9 1FTrlvOLC+t8b+zy61np8EklQOYxKXnpOLNxYJ0bqNf0MYftriAYoMxd+eQZwbMwV7UI lQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tjx43kmbg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Oct 2023 20:16:54 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 399JV8q5032145; Mon, 9 Oct 2023 20:16:54 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tmfhntnbp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Oct 2023 20:16:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iH00Lwo+wX++A266L4wV3K3CXPgllYZ7hWgP6UswUMJJHt/4sQ9zDlrK2G+o5tynaYRWH+UyElx17rUS1iU7slC3+kh4qdUifcuhsfbgkV5OIb6E7KeGKCqzi4owaTo2J9FnSAqnclo2U0T3aeQOBLFlxyHWGGFIhAKeDgLvRqtfKDZvQO/0yjSt/jCIAh73pQVhdVHT0TXApFU1ZwFofUNZvmjrG/I9RP6NI1jKldgDA3VdiMBGE+j6HFjjmPZ8CohaZZ/Z6ZHiZQwGOyEFDNhxbL8UgirM+0zw/MFF6koiDPzD1MvmPuhPvctT0nrT3pxtjXvbvgNizDh1tuLNcA== 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=4H5BtvqSc+0mOYg98doViY1SX0bCxITXGEXdoB6sLAM=; b=fMD707e2ZFbunYtQmMVJVw6l5F+IuQAgOCBuDrgIpc4nD6Q0PaFu/VKWd3H5d51JhSOvopFiC+sQRqnbjmBuxdfStZz9HEu1ddt9IXmE8qtzVnlHvkEIwgPorAuJFW7pZG3NdZwfL8XcKGSumX2RcnjjI/t0xMgTVCNBFceznLUEHCThbsl0hGZPQQ88SWZ5Lum9Q5d/aO0GuHpxIXZnyZ/oeXgdvFmMWjC6BHn0qWv2m4owAZ0CruNuCOB/ZDisyXfirriy7acBpC+n/8HysgF2luJr2tVnYSnoHv63db1e8r7JRuk74Wg3QechjCcR16zU++9t2YMX7/IoMmuIpw== 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=4H5BtvqSc+0mOYg98doViY1SX0bCxITXGEXdoB6sLAM=; b=TdLjyEH2KpbTeQX+VNaECaT5c16v8t/fcjb5HqUnKpZ25qFWFliTpf/L0JsSD+9zkxNSOSdFo+sCkgHicBKNQs8LbKlc2ECL5UDg8hdKo7+57dLo88ItsjrLUqu9n7gquEnv8NTeGVifG8fComXkD7lr0uMYBz932DF7b52v5Mw= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by SA3PR10MB6998.namprd10.prod.outlook.com (2603:10b6:806:31c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.35; Mon, 9 Oct 2023 20:16:52 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::e391:f2a1:a9d:967d]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::e391:f2a1:a9d:967d%6]) with mapi id 15.20.6863.032; Mon, 9 Oct 2023 20:16:52 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, maple-tree@lists.infradead.org Cc: akpm@linux-foundation.org, willy@infradead.org, liam.howlett@oracle.com, zhangpeng.00@bytedance.com, Sidhartha Kumar Subject: [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp() Date: Mon, 9 Oct 2023 13:16:38 -0700 Message-ID: <20231009201639.920512-3-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231009201639.920512-1-sidhartha.kumar@oracle.com> References: <20231009201639.920512-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BY5PR04CA0021.namprd04.prod.outlook.com (2603:10b6:a03:1d0::31) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|SA3PR10MB6998:EE_ X-MS-Office365-Filtering-Correlation-Id: 2de33596-c95f-406b-19d1-08dbc904accf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M2P9cZnWrh8m/33tYCndTboE7nyH7P8HMx9DM0cVuHPui/3vpkP/a2CXGxUmsPZN/6UeHLbQjc/kRQ10q6ZbmFW1Oc578Rp9doohqUKAyIMAQATwrfkPKu6S9EHLQRYx/TPLTAlSH/YVPLfXITpGxAsffVQ039SKAz5ZvlXBSYAkyl2mYIlKLXgja1EJjRp2na2OCi8KuvdScikmysKo3CH3mcEywek4yNz00hR7f2bt8SrnQzObHjJQImkbVyYs2aQztJ988awdnsRV9nsNvqSR9wTbkL28n3yyZnimvE+fIwZGmhttJ4N4oDhK5v83SbXZy2+7rt1FK6Wv4Ut+SHD2hqwNQ9ViryQ0pioFMwnpblGuJiw/tedrkbRqw3DZMaaknyHB0lAhWNvanw3InLp2kpA8cbyrf35T8Q6Hk59f7MZzo1f402a72NL8QyQ0opLf4bQFE++oyxrTB0IMNfk3bpbtPKSPd0gXw2U1zOsydmNy3v1TElK43dq+YmRmiV5XWijIgOcNgdUYfQh1AnqTjpvHaw9HIWICmpkOsQpZdRaaxUvvwVy9Y5Gtk2CF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(39860400002)(376002)(346002)(396003)(230922051799003)(1800799009)(451199024)(64100799003)(186009)(86362001)(38100700002)(36756003)(6486002)(6512007)(2906002)(6666004)(478600001)(8936002)(44832011)(5660300002)(41300700001)(8676002)(6506007)(4326008)(107886003)(83380400001)(2616005)(1076003)(66946007)(66556008)(66476007)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CYNtsjwMFytaiHutQniWb+QtCfJ8wzdZx3US3L+9n+zOXCMB9BZxeeYhOClT8WEXudUUffy1vKcGf8R3saRqF9erdlPCJ3UAUglquNfJqFQKe1aOinrkHK72eTZVoDM129nsCKz7URJdO76oADGwMc/x7GlE/l/ByHg4gGFfh3Zm//SyL1CYnXN3RrmhmfWWoikOrVBocDi7xp5zEG9dUdluLpz/d3kRkBvlqC8drCNK3MBoDPmFONbDO1LspmS32uJv8QH9dhyTqKlh+AUltzZyNhnpjHpr5r7lHFe/hIId4foE+oqXPHAYoOWeD2LdBKja/2PPO7BVjgIOk3q+6rlfdTe2HUbfgjIoD3qck3Jgu75dT53MXkce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IUJI3CAMljKeJqDHgjSjieqtJ9roj2CI+4pIvXi95SWFnAiFeMyt6Pok7tMB3GKD6hD/qLRq3Tgibw+Z8lpFhSk5uNHtYHRZ/V14DJaj7I3UDVHd9PcPx8g0+g4QKRe19U2e3FPnoF6CvJuwgNrS7AGkdRg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2de33596-c95f-406b-19d1-08dbc904accf X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 20:16:52.0423 (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: znOV2H6GjDyY0wwOtwwh6BmvzYZdzEYKiATTmdXiw/tfSZ5aS8Vtqpwu6ubu85gb/EC0XqvFLsiyGprtXvpISkf+8vcoIES60Hljveo1Ab0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB6998 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-10-09_18,2023-10-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310090163 X-Proofpoint-ORIG-GUID: kf9SUGuqoWXaUrzWB7HsuGtKv3iwpWjE X-Proofpoint-GUID: kf9SUGuqoWXaUrzWB7HsuGtKv3iwpWjE X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 09 Oct 2023 13:17:48 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779310443010642095 X-GMAIL-MSGID: 1779310443010642095 Preallocate maple nodes before call to mas_wr_store_entry(). If a new node is not needed, go directly to mas_wr_store_entry(), otherwise allocate the needed nodes and set the MA_STATE_PREALLOC flag. Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index e239197a57fc..25ae66e585f4 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5478,17 +5478,33 @@ int mas_prealloc_calc(struct ma_wr_state *wr_mas) int mas_store_gfp(struct ma_state *mas, void *entry, gfp_t gfp) { MA_WR_STATE(wr_mas, mas, entry); + int request; mas_wr_store_setup(&wr_mas); - trace_ma_write(__func__, mas, 0, entry); -retry: + wr_mas.content = mas_start(mas); + + request = mas_prealloc_calc(&wr_mas); + if (!request) + goto store_entry; + + mas_node_count_gfp(mas, request, gfp); + if (unlikely(mas_is_err(mas))) { + mas_set_alloc_req(mas, 0); + mas_destroy(mas); + mas_reset(mas); + return xa_err(mas->node); + } + mas->mas_flags |= MA_STATE_PREALLOC; + +store_entry: mas_wr_store_entry(&wr_mas); if (unlikely(mas_nomem(mas, gfp))) - goto retry; + goto store_entry; if (unlikely(mas_is_err(mas))) return xa_err(mas->node); + trace_ma_write(__func__, mas, 0, entry); return 0; } EXPORT_SYMBOL_GPL(mas_store_gfp); From patchwork Mon Oct 9 20:16:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 150313 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2100694vqo; Mon, 9 Oct 2023 13:17:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGal7qM0bKNIlLNDyVA7SDE4+nc/GASny4idY/+GxuaYvRQ3xIU88Ou2EfdeBrt5IKd15lN X-Received: by 2002:a05:6a20:1585:b0:14c:84e6:1ab4 with SMTP id h5-20020a056a20158500b0014c84e61ab4mr15852643pzj.33.1696882658834; Mon, 09 Oct 2023 13:17:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696882658; cv=pass; d=google.com; s=arc-20160816; b=05ddCu8VZm5Avpv3VS0ZXcB/Y5CCkbCrDyTy1espweN4lV0AmL9yWX8dbX5kjfDQJs PvqwZde+wyVWsJ8kF+gMHJeT6KOa2Uxa87xbFixVUaDMHgedVIRU//FfiJ1USB0NnY9J YNLTWmKCbWUuTegpQem7dUV2PwkNYguyNai4xuF1itbBvUyR/UGPHsngmJH12FuaXEfX WzAcihkRHtfZnigObwmhVAQlzeZhJcPvNHwkNFYl0HRCJa4DyIe+DoxxJ1+JACteBNvx 7BxDksloF9R56QtY9lSjGwE48vS94A5s8Yr9zINJqlIEetPlmyKtX7Yv8S03K74IgUeH t06A== 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=c+C0Up3JY+XTwnKP8pH7ffh6BG1JcU/dITRtObHkDu0=; fh=B8hmr/q5j3tCmv46TiFW349WPKYIK+b/KkTcg+TQCdo=; b=Y3jCWC4AQBuKiUFFmAj4HPHVUKkHb6gEdLqDsBLLnJ4YbUF6YRl7YAX+OBk181Y4EX i+zF5Tay+Vwb/sp9/JE/qkxy53Oi+G7AACghnWZwvXuQgYwU+RyZsfS70rqziDLASiPY InSyq1gPnUNijl/Bb35liWY6L6OIq9oOqhykOmb4M/1kgtfBWr0W+nPrDkC91Ulr9dZw anS+FPVBnIufh2bbNxMdNqxFpBR3eA3jQ+cUgnerSExWnWNU4H6iLAS12GrZoBzg20lp u2gNT7hZZ+dkky2HVuVPgdXEZdAlVNifFAJIX0TzdDdeeSVjP0nW/ACbfZD6wLW6x8yr Ic1A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=gy3PqR8w; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=AJCvqtSz; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id cb7-20020a056a00430700b0068ff659af62si7925902pfb.106.2023.10.09.13.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 13:17:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=gy3PqR8w; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=AJCvqtSz; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id D43FA8113424; Mon, 9 Oct 2023 13:17:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378585AbjJIURY (ORCPT + 18 others); Mon, 9 Oct 2023 16:17:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378583AbjJIURW (ORCPT ); Mon, 9 Oct 2023 16:17:22 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C15A7B4 for ; Mon, 9 Oct 2023 13:17:19 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 399EY145015043; Mon, 9 Oct 2023 20:16:56 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=c+C0Up3JY+XTwnKP8pH7ffh6BG1JcU/dITRtObHkDu0=; b=gy3PqR8wjIndqAAVNeKvYlIShVC+/TXJZx0MNNWfkCwwBq0s/o8mtZAiNm4IMFa5Z/+n S3tolo1FeGNcZYtPol/dD/uykPf/28QcPGieFbXF4woF8z+mXKsCsON6+bWpfXHmaxGA qpQ2XmUG+JSZTEayqAHMWBqyMdK5v1NuVKnribzuQTCQGLmhiSjNaTsw9WJbUAANsmBW Yk2Sd7bXc9kclwPctP3BtNwBJbwB2WwdswsUkdnMC8doeuqqlNp0K36MrvuVahoAqgwK h2JSoCHVOlRs3ow/+GEHu55NSBX4KVc5Z/gt3bKqWul8ZUmA1Co1l1aIrNV26XuO7Hda /g== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tjx43kmbk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Oct 2023 20:16:56 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 399JSjFK032134; Mon, 9 Oct 2023 20:16:56 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tmfhntnct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Oct 2023 20:16:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AJ20xaangTy70mbcjiTZh1/AQKCsuqmYSI/5u05zPv4cCu4R1oecbqvlJhTzeErcHkuOYASiVgz2GYxRpSYTulheJd0Nmmn6KQbTbSUxB2padLchBE7bkVFIcQHPLkCLQ9QS7YuJWO+UFocS8HEpWDuUgTJS4c5JlhBf51NIHh3HGaoey+mwlCYJEUPYeSNdhy4VTILCz8cvvKZ8+/ORhggpj3wh6orLgUmbsADKlPESFmyhMXVYGv2bTtYIqL6mdKy06ZynfauL8MPLJERQd926XwKh1IjqNxgPczeB/gxZB6NMDO1Cf/vGEB+/1BIglPMc/vgYn098imHtHs4nUw== 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=c+C0Up3JY+XTwnKP8pH7ffh6BG1JcU/dITRtObHkDu0=; b=gG0A03gpQkYRdNi5huZUMNnTk5DjpWGvGOcJru+Mz7A4AEU9oU6aIHpth5v33qctja2H9FgztCzPTMMRMfLZhdX9JghwdvdMYYwoFofGP2p1fSVsLVYjWrSN2NTOl3d55NfpYl2Hl0448ybS6+8PJu6lLW5qFwWHQp++zLh9A5jixerJ7i/VU8AJ28C2dCt3NqBRotfDTKCLkIf/kbMhwtEmHuC0NacsB9wg8GxP8+1Hedys/6jnU9haY3SYSDPvmHITPMLARqrZGf9qB/PCjXRbPf01t2CwzLLgjFGbcwp0bRiproLJFp7vxdWxmz8gWS7Fcfnqbo5VLU35jRayew== 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=c+C0Up3JY+XTwnKP8pH7ffh6BG1JcU/dITRtObHkDu0=; b=AJCvqtSzGnyFHKGo7PH/V3zUFK92Pv0dU0cpYczWZVcjMK23mXoOwM6ZyIewAMT5vifdOrBL8f4Xu6nrjR/t5uOoR6HpJQG718Uy2O2CMZ5MyIjmcY903JGaZ9NSllPYxhI242PGULB602D1IO8Dqxj3aqBjkBhe5Fbi9zvquoE= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by SA3PR10MB6998.namprd10.prod.outlook.com (2603:10b6:806:31c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.35; Mon, 9 Oct 2023 20:16:54 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::e391:f2a1:a9d:967d]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::e391:f2a1:a9d:967d%6]) with mapi id 15.20.6863.032; Mon, 9 Oct 2023 20:16:53 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, maple-tree@lists.infradead.org Cc: akpm@linux-foundation.org, willy@infradead.org, liam.howlett@oracle.com, zhangpeng.00@bytedance.com, Sidhartha Kumar Subject: [PATCH 3/3] maple_tree: use preallocations in mas_erase() Date: Mon, 9 Oct 2023 13:16:39 -0700 Message-ID: <20231009201639.920512-4-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231009201639.920512-1-sidhartha.kumar@oracle.com> References: <20231009201639.920512-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BY5PR03CA0019.namprd03.prod.outlook.com (2603:10b6:a03:1e0::29) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|SA3PR10MB6998:EE_ X-MS-Office365-Filtering-Correlation-Id: 85e6d612-5a5c-4264-76b3-08dbc904addc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y+RlPVqi1jEuRy3ZepAhh9ppxhvo5PMPd+eSkXnluWEszbinVfQTyEHLk7NILYQRRmKrUrOElEa7ic/JH5zm4u4tzEC4yiet1kJyf7b1oKtIOZ9z/OeKkZVEH3UNfZ9DQ8pSkXAZALi4KJQP+f1DSpNKydrqXMqauw+tUwGXEQ1u3poUjlT93Od2TF+Y23ba1Rs5GIdoASUlm/966A7mp279M/lUr7WD0n21vhfATpiLP9sjmDBO3wmVlaAyeVhNGYr99N5vf3LduGKhUKxr8Tft2FhbIGSiapSigFXwAncdc5j7wUoNvkn/yfcYY79VSKfiAkgZBweKiwkZPaMVOVmHI/eJm1NjGq80n+Rom55yQpxoRgU4/CcpgUjG1feEGFrqByNFT5HLaGydlwEzlPwESQGP9fhD/UztSrFexG4Wxk55UFoKsqqlF3muOGkZ4mblhRiW5sa4czIx+29Rh5i7YhTKVwWyq46P2P0bXIP6xV5mGmp1r0/b94cPY4fiubIDL7KJc6juKNrH2a2rdipAE5Xpe480WAPPT+4KbnoskzbL9KplD18bZlwAGHAx X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(39860400002)(376002)(346002)(396003)(230922051799003)(1800799009)(451199024)(64100799003)(186009)(86362001)(38100700002)(36756003)(6486002)(6512007)(2906002)(6666004)(478600001)(8936002)(44832011)(5660300002)(41300700001)(8676002)(6506007)(4326008)(107886003)(83380400001)(2616005)(1076003)(66946007)(66556008)(66476007)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qSjvAf+CIWgA8DemDlwA/mFCght6eH2I9oQ7FU8p/xSgEzerehr6cZRXwn/lkQ4RbV1g7DVh0pykVXiPq+n4ZaWJgwllBosc8qVs4m+DNamJhJCW+PwR/4G6v7lW7DUhhq+jpRkhGZO+eENqiyuBpEoGvIh1vUeh5lOSj25A3hJL8bYmLOunUUEwR1xG9oFkgylQePTazT+BlYCQjermlUw8Q8XeptkqgGsVUgHx5JZsQk1u7h74q6hkcJiA0RrExwggoclYFg72Qtsabbpq6058GGgLUFn4SoAED3R1ZoS6MoPiiHCoxYvswuEuxsWkr4mvKseyPHXSO8aLSjKc+b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MD7WRvvHPjbv1TBSHlAP7GDIn/cAsDAfcioxV1MVZzvhk+a0aWCLFOX+j8UEG9rbYwjFL2EpcKYrY4OWdHPYWVRRYjSWTmKZonR9nT9JNxTYwh3LnvjeAmhwDIasOutvFnf5Kd7C16JO68sc8/JW/VwuqSok2Dyb9dng8wr2FxM3dsK4HMu1xx1vpHm8sBxWpacO52FYBH8Qsxaf9XPYu6w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85e6d612-5a5c-4264-76b3-08dbc904addc X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 20:16:53.8756 (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: y1JtZZZtG0JFgD4pGvgnZFE/b1YzHok5mDx0hU5wfX+btbwt8XLg6Zi3/dbdQAgOurrsXsFYfZSjFYMsPAIoE/52HuGZFnEohy5CDHB7uOw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB6998 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-10-09_18,2023-10-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310090163 X-Proofpoint-ORIG-GUID: eCv_LeMYKs0QFhuROODa5p2IY5Xdj5O2 X-Proofpoint-GUID: eCv_LeMYKs0QFhuROODa5p2IY5Xdj5O2 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 13:17:33 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779310431334455189 X-GMAIL-MSGID: 1779310431334455189 Preallocate the number of needed nodes before mas_wr_store_entry(). Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 25ae66e585f4..ef8d4b6b4456 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -6191,6 +6191,7 @@ void *mas_erase(struct ma_state *mas) { void *entry; MA_WR_STATE(wr_mas, mas, NULL); + int request; if (mas_is_none(mas) || mas_is_paused(mas)) mas->node = MAS_START; @@ -6200,14 +6201,30 @@ void *mas_erase(struct ma_state *mas) if (!entry) return NULL; -write_retry: /* Must reset to ensure spanning writes of last slot are detected */ mas_reset(mas); mas_wr_store_setup(&wr_mas); + wr_mas.content = mas_start(mas); + + request = mas_prealloc_calc(&wr_mas); + if (!request) + goto store_entry; + + mas_node_count_gfp(mas, request, GFP_KERNEL); + if (unlikely(mas_is_err(mas))) { + mas_set_alloc_req(mas, 0); + mas_destroy(mas); + mas_reset(mas); + return NULL; + } + mas->mas_flags |= MA_STATE_PREALLOC; + +store_entry: mas_wr_store_entry(&wr_mas); if (mas_nomem(mas, GFP_KERNEL)) - goto write_retry; + goto store_entry; + trace_ma_write(__func__, mas, 0, entry); return entry; } EXPORT_SYMBOL_GPL(mas_erase);