From patchwork Wed Aug 14 16:19:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763702 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 2421EC52D7B for ; Wed, 14 Aug 2024 16:20:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 433D46B009D; Wed, 14 Aug 2024 12:20:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21EB76B00A2; Wed, 14 Aug 2024 12:20:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 099D36B00A1; Wed, 14 Aug 2024 12:20:08 -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 CD72B6B009E for ; Wed, 14 Aug 2024 12:20:08 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8595580DC8 for ; Wed, 14 Aug 2024 16:20:08 +0000 (UTC) X-FDA: 82451362896.24.2690265 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf17.hostedemail.com (Postfix) with ESMTP id 520F14002D for ; Wed, 14 Aug 2024 16:20:06 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=kFcyucQ8; spf=pass (imf17.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.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=1723652334; 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=MsIb3HZBRJKwKbgYNU47zxkFCp/jEGMVccONsMnaDqQ=; b=UBq1pok/C/aqI67d3rdA10i91B60zlC+pehEv8CSKOiMOaKUx/FFIPbCjR1qmESXwRnhAH QI9f24+o9a7YTIoUVsCRPwAKQ+PdDN/R2PCc8gXll/9ohsCuD4hCRbvgOvoP9eIFZQre+C H5OqxghixKu3cVWSeTSmFjdFWfsQnoY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723652334; a=rsa-sha256; cv=none; b=nfcef68AsRKpOxdxItqBY8TgAj+6q6iFpnv00Mml5b914tAelYiNRjM76PwseLhv1pVNW9 lzQ8hQnNIVGDVkJq6Fr8lsUcjDyB3GYIopTomD23LrUpWva7OoIZhE3TUP9PpsMgHcYzJU BlgHFse1N5tkUq46Gq4dKr+E1pLGeK4= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=kFcyucQ8; spf=pass (imf17.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtZgV003682; Wed, 14 Aug 2024 16:20:01 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=M sIb3HZBRJKwKbgYNU47zxkFCp/jEGMVccONsMnaDqQ=; b=kFcyucQ8YVhlqm/2e zLjQRFH9KwcsHSgLIgXgtc4cUi8xnXaqO+GOQP3xWAqTOGT2BwjwgK5zxMMD9/WL Rl6ZCQx+F84vjdWCydHhOBdrpb4K5pf5yU0hm25LoafxuUN+O1Ik71KlLnhKtgha 04CcRkqS9SYPpLMcHbWOrnVZhfc0OEhslUCpi+bZ0LNTyqWvLuLDavRZGdmFso40 IyhbVxDR0nKV0s3uTInOCkPoRd9wkbZu0TxnafgDiAdCTHTN2NMB+sYeyyJ4pK+K Ge1fQaPzpYNfaH9F8t1q19tj5nyySR1qkAdnC6slVx/tLp8h8oVgW225htMniquQ aKBNg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wxmd0n6c-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 47EGCmUl020856; Wed, 14 Aug 2024 16:20:00 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7ug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:20:00 +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 47EGIvCS035951; Wed, 14 Aug 2024 16:19:59 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-17; Wed, 14 Aug 2024 16:19:59 +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 16/17] maple_tree: remove unneeded mas_wr_walk() in mas_store_prealloc() Date: Wed, 14 Aug 2024 12:19:43 -0400 Message-ID: <20240814161944.55347-17-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: EDX0ewiXBofFrXhqkQ4euxapwsLPtcCk X-Proofpoint-GUID: EDX0ewiXBofFrXhqkQ4euxapwsLPtcCk X-Stat-Signature: sozat9t4e3hexxxgp6tnesdy6nqp1raa X-Rspamd-Queue-Id: 520F14002D X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1723652406-516328 X-HE-Meta: U2FsdGVkX1/ar5x7czrSR5jViS6lfAGD03jq2LhJ9C2l2AWfKGEaTVwXV5S7kQNjJqrjpIX3sOzPyikUhK9oKQuIstNGg8qAa+IVaZLRlsW610LHs882EAeCWsabVvQ28TjPVBy7A8hmuU5IoU3ooHoGPjJmtrZsMGtzIGsCmx1LDqJqlLip/vyo8tR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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: Users of mas_store_prealloc() enter this function with nodes already preallocated. This means the store type must be already set. We can then remove the call to mas_wr_store_type() and initialize the write state to continue the partial walk that was done when determining the store type. Reviewed-by: Liam R. Howlett Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 8c1a1a483395..73ce63d9c3a0 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3979,9 +3979,6 @@ static inline void mas_wr_end_piv(struct ma_wr_state *wr_mas) wr_mas->end_piv = wr_mas->pivots[wr_mas->offset_end]; else wr_mas->end_piv = wr_mas->mas->max; - - if (!wr_mas->entry) - mas_wr_extend_null(wr_mas); } static inline unsigned char mas_wr_new_end(struct ma_wr_state *wr_mas) @@ -5532,8 +5529,19 @@ void mas_store_prealloc(struct ma_state *mas, void *entry) { MA_WR_STATE(wr_mas, mas, entry); - mas_wr_prealloc_setup(&wr_mas); - mas_wr_store_type(&wr_mas); + if (mas->store_type == wr_store_root) { + mas_wr_prealloc_setup(&wr_mas); + goto store; + } + + mas_wr_walk_descend(&wr_mas); + if (mas->store_type != wr_spanning_store) { + /* set wr_mas->content to current slot */ + wr_mas.content = mas_slot_locked(mas, wr_mas.slots, mas->offset); + mas_wr_end_piv(&wr_mas); + } + +store: trace_ma_write(__func__, mas, 0, entry); mas_wr_store_entry(&wr_mas); MAS_WR_BUG_ON(&wr_mas, mas_is_err(mas));