From patchwork Wed Aug 14 16:19:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763710 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 1CC37C52D7B for ; Wed, 14 Aug 2024 16:20:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1D566B00AB; Wed, 14 Aug 2024 12:20:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA4626B00AC; Wed, 14 Aug 2024 12:20:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF7946B00AD; Wed, 14 Aug 2024 12:20:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8E7FF6B00AB for ; Wed, 14 Aug 2024 12:20:23 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 623E6141182 for ; Wed, 14 Aug 2024 16:20:11 +0000 (UTC) X-FDA: 82451363022.15.991727A Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf04.hostedemail.com (Postfix) with ESMTP id 017AF40007 for ; Wed, 14 Aug 2024 16:20:08 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=FA1pacCm; spf=pass (imf04.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723652352; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=H7wKxpEJwe8slGwjyrSc9cjrvQv+dSZXxkMjvMrzgqo=; b=HPaVALIITw/QGXJNRbBp5CF6IIFdWAO2pkf//2sTxTCcOvayUmcRrh1GAC9WkSBWx5OSjb X1UZdaIzmSkiPIYAsD8x3uGw9zlUu0Bsi0mDkZLldWCXJpoqJJQT4dX/A57Hhf7SpD/J5k qyvILCcntKKJmEBsjBVAmARkbkPObys= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=FA1pacCm; spf=pass (imf04.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723652352; a=rsa-sha256; cv=none; b=J0y2z4B9exYaC9gYH7Vun7+DSyGvgCfkwnJFUnOkcoMIXyWov1nDNAAoLrQR62JnmpPdzT r5hF3fqOrX+vSXvesY27V2mYZt84YQysQiCk7tq1yddKCd8WA0XUhjXc3xFPQpmnnqirjT 0xwCwF2LK0g2Yx/HBmFqHDPCo9j7bO4= Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtbbE013643; Wed, 14 Aug 2024 16:20:00 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 :mime-version:content-transfer-encoding; s=corp-2023-11-20; bh=H 7wKxpEJwe8slGwjyrSc9cjrvQv+dSZXxkMjvMrzgqo=; b=FA1pacCmf4kRDc1Ob IuXhF2UMItZNQizOH0DZ4CEt3KJ+5yCt8vcXtelmYBu7dlZWARQwmcmXkyPxwShN 0rqN+rpccT/cz5kAcHrPp8Enc8XIKxTn3+mUuq3duVy2dAy8D2/yPWYYvCqPKImf lEGalAjaOw8IndVGzlwDpgIINZAaxg/WWMUdk1SWof8ZfS/G0dhzOEQMA8ygQD+j vipsdoaKAdZcfb5FiZNQoQixSFIsRCHEpjAQQIhehGUHOIhLYhDZ8L2cxOKTNzZ7 AxJkxghw426HTCZzgpDIzrp+dQqAC5puQdBbn2PLKiShwEgylTHCRlV6DwDH9zx2 Zeq+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 40x0rtrsu4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:20:00 +0000 (GMT) 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 47EFoG8f021115; Wed, 14 Aug 2024 16:19:58 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7sx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:58 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 47EGIvCO035951; Wed, 14 Aug 2024 16:19:58 GMT Received: from sidkumar-mac.us.oracle.com (dhcp-10-65-174-212.vpn.oracle.com [10.65.174.212]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 40wxngn7gt-15; Wed, 14 Aug 2024 16:19:58 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, liam.howlett@oracle.com, willy@infradead.org, surenb@google.com, Sidhartha Kumar , "Liam R. Howlett" Subject: [PATCH v4 14/17] maple_tree: remove node allocations from various write helper functions Date: Wed, 14 Aug 2024 12:19:41 -0400 Message-ID: <20240814161944.55347-15-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240814161944.55347-1-sidhartha.kumar@oracle.com> References: <20240814161944.55347-1-sidhartha.kumar@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-14_12,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408140111 X-Proofpoint-ORIG-GUID: vZ3iApY1g4hjGhmvvlhdYKM7awe7RSw7 X-Proofpoint-GUID: vZ3iApY1g4hjGhmvvlhdYKM7awe7RSw7 X-Stat-Signature: q319yt5qw8ia331dttrzujygm7pskffz X-Rspam-User: X-Rspamd-Queue-Id: 017AF40007 X-Rspamd-Server: rspam02 X-HE-Tag: 1723652408-909389 X-HE-Meta: U2FsdGVkX18p8XAGWISCck4nd/ZJxf1SUARaJKJQjZELwpeQakr3Vna37nel1BcqXVUkLZ6IakDLBTQ675L85uIpbTE7fPu/CMeOtrXLojwlx0yRE48eqKnMCzh4L3aBLcHhJoeXT8BXaZJj9xvXN2lB/5RIpLg0OG5qbtKxqggTIgVwfA+Ch70pl57uFzgyn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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: List-Subscribe: List-Unsubscribe: These write helper functions are all called from store paths which preallocate enough nodes that will be needed for the write. There is no more need to allocate within the functions themselves. Reviewed-by: Liam R. Howlett Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index d5e020dd93fa..5f79be184377 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -2976,9 +2976,6 @@ static inline int mas_rebalance(struct ma_state *mas, * tries to combine the data in the same way. If one node contains the * entire range of the tree, then that node is used as a new root node. */ - mas_node_count(mas, empty_count * 2 - 1); - if (mas_is_err(mas)) - return 0; mast.orig_l = &l_mas; mast.orig_r = &r_mas; @@ -3029,11 +3026,6 @@ static inline void mas_destroy_rebalance(struct ma_state *mas, unsigned char end /* set up node. */ if (in_rcu) { - /* Allocate for both left and right as well as parent. */ - mas_node_count(mas, 3); - if (mas_is_err(mas)) - return; - newnode = mas_pop_node(mas); } else { newnode = &reuse; @@ -3341,10 +3333,6 @@ static int mas_split(struct ma_state *mas, struct maple_big_node *b_node) trace_ma_op(__func__, mas); mas->depth = mas_mt_height(mas); - /* Allocation failures will happen early. */ - mas_node_count(mas, 1 + mas->depth * 2); - if (mas_is_err(mas)) - return 0; mast.l = &l_mas; mast.r = &r_mas; @@ -3427,10 +3415,6 @@ static inline int mas_root_expand(struct ma_state *mas, void *entry) unsigned long *pivots; int slot = 0; - mas_node_count(mas, 1); - if (unlikely(mas_is_err(mas))) - return 0; - node = mas_pop_node(mas); pivots = ma_pivots(node, type); slots = ma_slots(node, type); @@ -3699,10 +3683,6 @@ static inline int mas_new_root(struct ma_state *mas, void *entry) goto done; } - mas_node_count(mas, 1); - if (mas_is_err(mas)) - return 0; - node = mas_pop_node(mas); pivots = ma_pivots(node, type); slots = ma_slots(node, type); @@ -3765,9 +3745,6 @@ static noinline int mas_wr_spanning_store(struct ma_wr_state *wr_mas) * entries per level plus a new root. */ height = mas_mt_height(mas); - mas_node_count(mas, 1 + height * 3); - if (mas_is_err(mas)) - return 0; /* * Set up right side. Need to get to the next offset after the spanning @@ -3851,10 +3828,6 @@ static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas, /* set up node. */ if (in_rcu) { - mas_node_count(mas, 1); - if (mas_is_err(mas)) - return false; - newnode = mas_pop_node(mas); } else { memset(&reuse, 0, sizeof(struct maple_node));