From patchwork Wed Aug 14 16:19:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763698 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 61AEDC3DA4A for ; Wed, 14 Aug 2024 16:20:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 74F566B009A; Wed, 14 Aug 2024 12:20:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D75D6B009C; Wed, 14 Aug 2024 12:20:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 505036B009D; Wed, 14 Aug 2024 12:20:07 -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 2AC126B009A for ; Wed, 14 Aug 2024 12:20:07 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4F2EEC1047 for ; Wed, 14 Aug 2024 16:20:05 +0000 (UTC) X-FDA: 82451362770.07.CA77A8B Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf08.hostedemail.com (Postfix) with ESMTP id 1B4DC160030 for ; Wed, 14 Aug 2024 16:20:02 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=KWWc+eVT; spf=pass (imf08.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=1723652346; 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=DrUVd8Ocr4EBUKoIid60LZ74yaHvtLUZiDCAkpS+Tww=; b=jkteB5VueAMmzDV+sM6mbt6jXMrrEyzrNvVSnqrMXAgOyj0ybLnzo9GSZjx4hlPcd8Y1zn wpBKE7qvvyET4ajcNqvFnr38+HFbYjoUY2Q+NsEZ2EAcWH0FFRsh9mrYPgqwneeY7J7532 gQ4gHmcQ46NTFOrLEOGSEBYliPvubrA= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=KWWc+eVT; spf=pass (imf08.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=1723652346; a=rsa-sha256; cv=none; b=LoYdKFFTDT62JwxGtCEsFD4EF9Wyk/r+YR+uF7ajdtLtDMIxV5XGU86PXzUMhpVIqSOsMM WMroWo98NL+8wm8mwxHpCGwBCdUOC5hL44MoF6Npw5SgyTRSX5SbUFG8x6e65+w4xNSSPY LUs1u/OAb4drrDBLQFiKfs1gYqygmCY= 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 47EBtcoM013696; Wed, 14 Aug 2024 16:19:50 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=D rUVd8Ocr4EBUKoIid60LZ74yaHvtLUZiDCAkpS+Tww=; b=KWWc+eVTxu1rIJZZ6 rMAdO+mGNmNk95hmtiWDlW7kveyeWNruY/48N1MqXPGZN+LCrgVKJNKLTDBcoLQ/ s84vE0/qtoH+DRCc05Q2GKEr1Ziza3BrRMgX8UGt1/Gtdrhkkj3L9TGfAAJVzSey hCzLsNujCb/OfYyKHJ3RZ4kJczgjNOfm9qsahwK98/uNGzEDxe5IDiryb8ihVfWi GbSYFcwoLe4tTDTb3mHfAS9xsE3BHxreCtRMhjYw9c2YjurDSzs/0AXbYY7pPHPH wDsOc9dilvekKHIdnqD3RevTq9d1y+JQWVP3EB+Rk8k8b5CoDMrAA/4P3PiqGfmz B1P/A== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40x0rtrstq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:50 +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 47EFqAgF021061; Wed, 14 Aug 2024 16:19:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7jc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:49 +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 47EGIvBw035951; Wed, 14 Aug 2024 16:19:48 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-2; Wed, 14 Aug 2024 16:19:48 +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 Subject: [PATCH v4 01/17] maple_tree: introduce store_type enum Date: Wed, 14 Aug 2024 12:19:28 -0400 Message-ID: <20240814161944.55347-2-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=842 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408140111 X-Proofpoint-ORIG-GUID: _eke-QWlv1NOCLsekQJ5eHK2j9FpMEtH X-Proofpoint-GUID: _eke-QWlv1NOCLsekQJ5eHK2j9FpMEtH X-Stat-Signature: eycofw7sj4xoykfbbjiame693erepye4 X-Rspam-User: X-Rspamd-Queue-Id: 1B4DC160030 X-Rspamd-Server: rspam02 X-HE-Tag: 1723652402-704621 X-HE-Meta: U2FsdGVkX1+yii0B729xpjMdi1vRRWb6hNcY61JSdrhdc7YmqAEWuJo2UC/aIiON7Ph2cnG0YY/08SAbED/6ldBUMSReG7nsMAmBvlS2Df5ztigkQyUGscyVN7kVLOuYAVEgKkzCLcuQuikALUxvWJFMCDxRaPYK5qIqzcZU2WLU0ptuKhiJjldgC+dpFiJdRrlsMJe3Y2idwqaQhUqSVvucPAfs23I5R9nnQQF/mUYUoxtl9GOrCoM99UEe3o0BkjdUIl10CICuYblGBFlfbxJcBz0cTa4tj6l1S64bFf5o34Psx7pV1x0GxQV1MCX0tMjuWEbpW6/IooOeDMtoquB3eVWYAxeXwBlU3W8jor1c5ZmomfD0/6/j2yMIB8bvmjPs73QugTkzbdPww62ggw0BGBu3jdIGOZoMjH6nDBJYf7Ukb/LPImpMLNsHeq4saUO59NT9FtbEmOEaNRqebsRFmSlOT8NYzn5xUVMcE8OOe6qyv3ge7bVHXXhAMlIiNqgVJ5kSyMD5+wX2/3YCD+GN8kLqI+OTY700FlBjhcfdOY+IXVUTGoRDdR+H92+ahYsb19mlZd5+V7cOozRaAV28h27XmzfNljmwH6+4OVP5b5Jq6F5vxoBLYGf2NjaPrBHAaMZgSzvlqTsu6BOMTcz9wFAFSaCEWAbVM4/3jIkiUiX+vWqyXatwaEtOoUFnL7/S26SEPuXqnBpw6FdEz07dBmAURGxD82OOENCKWy5AX1L4l26XfetqfgKXX9vowNyjhXGxIoFNVJ1OSQh6bO9+RP/Sms28BX6CY9MJHGqUFzTFXUG3rzxbKJ4kgi41yaDvjdQ7lVQy+C6Y8ikV6fJUQ41VY18pzD88GgUV7Q+Tz8SUcT3DAQOF/nQBf/qb12fBANDYuyK+xAsJWh9dQnDceOJjp6hFuaijjWRa2F0XJJn8Eoh14A3NcU+ZI3pQXQx/TUn8zkXTlQbJ9wy EpZAP2pB HvoQS6XmI/itPoOfo+si5n34Ipv8/LQgunijmgvIfcs4U87TReWzT3rQDBTNC3z2VEhrXOgZm53Mox2hGSMJjid6Hwo7aWQxXLvR9uQGi7WWtdkwKWOk78OmtxYUgEFSpaHOXc1aZLVSMNWFaMpV5ngHxSUYtSRncRxj5976i0h+jjSmQVztFj4UgmkJYL5/fjkn/8EXTtoWLFdKqP0Tx0Vf/QvUBFm0aCLBxGcgSqtBAFzAfuhA5JHpm7a8IUtA0fkfw 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: List-Subscribe: List-Unsubscribe: Add a store_type enum that is stored in ma_state. This will be used to keep track of partial walks of the tree so that subsequent walks can pick up where a previous walk left off. Signed-off-by: Sidhartha Kumar --- include/linux/maple_tree.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index a53ad4dabd7e..8e1504a81cd2 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -148,6 +148,18 @@ enum maple_type { maple_arange_64, }; +enum store_type { + wr_invalid, + wr_new_root, + wr_store_root, + wr_exact_fit, + wr_spanning_store, + wr_split_store, + wr_rebalance, + wr_append, + wr_node_store, + wr_slot_store, +}; /** * DOC: Maple tree flags @@ -436,6 +448,7 @@ struct ma_state { unsigned char offset; unsigned char mas_flags; unsigned char end; /* The end of the node */ + enum store_type store_type; /* The type of store needed for this operation */ }; struct ma_wr_state { @@ -477,6 +490,7 @@ struct ma_wr_state { .max = ULONG_MAX, \ .alloc = NULL, \ .mas_flags = 0, \ + .store_type = wr_invalid, \ } #define MA_WR_STATE(name, ma_state, wr_entry) \ From patchwork Wed Aug 14 16:19:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763697 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 EB7D2C52D7B for ; Wed, 14 Aug 2024 16:20:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15D4B6B0088; Wed, 14 Aug 2024 12:20:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0E60C6B0098; Wed, 14 Aug 2024 12:20:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D93AD6B009C; Wed, 14 Aug 2024 12:20:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id AA6E06B0088 for ; Wed, 14 Aug 2024 12:20:06 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B374DA7D24 for ; Wed, 14 Aug 2024 16:20:05 +0000 (UTC) X-FDA: 82451362770.13.04F9709 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf11.hostedemail.com (Postfix) with ESMTP id 5C27540020 for ; Wed, 14 Aug 2024 16:20:02 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=UQ8J287A; spf=pass (imf11.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=1723652332; 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=NhGg+QKJ9Cb1suH4rctcJIF6xt0s6tIqw024945p4eA=; b=GxVdyPOmeFE2g4Ql1K7aq0JMsG63lx8bs2rhyLJVcz7QDMXW6jeceP25hSfKd2aPQYUi1F u8cpDaBuGbugFsyRIdHsZq+GWp7nnYC7uyBafkVCfEcyKqm6nO7EJ0fpn5OiFN1uap988Y 3PcSlUsX6PEoSzpKaA/+WEGinwBcFJA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723652332; a=rsa-sha256; cv=none; b=mfZMwdJY21fBbhyorYbp00yORcsqnpxv335QQbXzdboct4QbiLjNFMpkm1ZAKtDVUVvkG8 /eUiwoUFCIcjKpCpoe3QfrzOi/mJTR9Cm34bLomDLHo867WwetySltigbmtRbIKV3F7Pnm 09M4wb53Xomg9ybTlSBeSVrJ4NWcdLk= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=UQ8J287A; spf=pass (imf11.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 Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtalC006074; Wed, 14 Aug 2024 16:19:51 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=N hGg+QKJ9Cb1suH4rctcJIF6xt0s6tIqw024945p4eA=; b=UQ8J287A/AK9Npdca Ov+rZCRM4dgCcSXUfpGm84RWxkYYxYYssKGns1NKr0ItzsbSHF9lmwirr5VKyniI /M9TmqrVfy0o2Ob6Dt5iJWyqJeNG4E2ZDP9llT7HdyCQW4PLQa6e98BGt9dGeNXd TwXAydt/g2mH8i83e3bAWTk6kJ9wdkly+O1de+NUhgO/HqLHDFDznLwgP6F2MnZU xDeq/iBA722OU93t7r0P4LL755kLaIzODQv6CXdPfZkn1AD3hywkAhC9gwqoP66n KjdnC2YpA5Z1eACJvqvyvaDpgBWSvFncIGOOTS4tb6mYbZXHErW98wNaOmgdPFfj r5OXg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wy4bguaq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:51 +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 47EFoG8V021115; Wed, 14 Aug 2024 16:19:50 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7k0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:49 +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 47EGIvC0035951; Wed, 14 Aug 2024 16:19:49 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-3; Wed, 14 Aug 2024 16:19:49 +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 Subject: [PATCH v4 02/17] maple_tree: introduce mas_wr_prealloc_setup() Date: Wed, 14 Aug 2024 12:19:29 -0400 Message-ID: <20240814161944.55347-3-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-GUID: XJ_CCdNwqMeWJj7i_OdRelDsnSBxqvoX X-Proofpoint-ORIG-GUID: XJ_CCdNwqMeWJj7i_OdRelDsnSBxqvoX X-Rspamd-Queue-Id: 5C27540020 X-Stat-Signature: coq935xeodnzcbc1yb3d9nmwtepw967m X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1723652402-711101 X-HE-Meta: U2FsdGVkX19LrXWbg1OTp574hl+fLgQerTg7428Y6JbBeUHZe8RYZTG54JZTlTvmZv5zpoNbYlE5iitGrFZ9yWFwaSxtjeAft4ZXb0zZcEP+MEShUdEbolSPeuBz+4s8IK+UYvngIbGV/ndPY6irFtJM7+8tv/tiUtnhKOhLXpaEvj7pODSqItOjuvIDoBk9TrwQq3ilJIs0++7Ivj6ZMeRNuYlq+vFZDetNpggJXg+e71MAHOtQQX5+WE35D9xDjLHzBKn+hoqefBMe7Kl2hWlUfoZmeAbuaPQq4dulv3zjsama6eJI9dyNLWLcCoUWii4RV0u1UEviaqXdQcHaVkc+k/WRz2o6LrFP8CMCMYfwQ2PL7VVYbgqqTmy1IbnoYevwVx2Ba6EPhYAFk3U3cWmFI4WiQvUVZGMLk+33LIh20qUBL/l8vGUXlXoz4/vkw7/Ct7E70pKdF+muywKgxr27nBWiDUobkta0VZE4hwQdoiID+PlFIDWVlFuoh55+QDzR6QikAl2w2CUWPAlFdQ3bNhzrq8e8djDH5FHOUOfDJTD+gGwgN3yYU507zeQ3QfazHq0/fQR+yLGYfArxrTNLzqjuOk/R3WVmXdV99+/UxdCT0+gh1yeWbMKAJ9KOF1asWw7s4V+/GXoFX2XFG/Dqtprs9JqEG4aQpv8c2ssZ0o+ymrjSP0MaAAqPWkRC7Zsa80RfCtmzi/4NNn7ikhIUat+MaUvyLLHKiUoRO6SRF1ipiSwSGW1z33WG8LG9wG2WhY//S9d1MB4Bs3izec8waOOOs+PUApyETLpAQrNI4yZXKyHYiougbPOvN8/Gq3Q2EYSAtWLU/dO6S+jk9QOVAG2cuow6Kl+cKrODFB3LbHYrwOLKD009Yu/X9rNjXXoX0MRHbq6NY6ZZWt8tkPNQFAjhqdQrzVKCICY0kX4pyl/YtWyeu6vcMT23fj4Cp81ndUSLcyg1sJuBMXA 5A8h2V6I q0UO7Vcee/WfJf07mBFA+wrRdo/tYFibgiE6eYtUHEo/TszAQFilGDlDAtV14dW/nFZlPavs+4I26W3pDq0Oure/S/ol1n4MYsIEhULk8UdlQYHWbORhjLsXknvHAQmUckO6ayCyfnCCoU3zJdmWip/7KNKxgATYo/b31g9kzLTsAE/pQhVVtpQgvyAp8pxScktODLt8RAT/4DXLFZKV9owbZGNngk/qCuQtTzAfTvhb9KPZbSA6TUCZ++mtoQ2Jt9QZTm+alCUj2FZ4= 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: List-Subscribe: List-Unsubscribe: Introduce a helper function, mas_wr_prealoc_setup(), that will set up a maple write state in order to start a walk of a maple tree. Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 884e2d130876..407c0be6e42f 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5399,6 +5399,13 @@ static void mas_wr_store_setup(struct ma_wr_state *wr_mas) mas_reset(wr_mas->mas); } +static inline void mas_wr_prealloc_setup(struct ma_wr_state *wr_mas) +{ + struct ma_state *mas = wr_mas->mas; + + mas_wr_store_setup(wr_mas); + wr_mas->content = mas_start(mas); +} /* Interface */ /** @@ -5509,8 +5516,7 @@ int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp) if (unlikely(!mas->index && mas->last == ULONG_MAX)) goto ask_now; - mas_wr_store_setup(&wr_mas); - wr_mas.content = mas_start(mas); + mas_wr_prealloc_setup(&wr_mas); /* Root expand */ if (unlikely(mas_is_none(mas) || mas_is_ptr(mas))) goto ask_now; From patchwork Wed Aug 14 16:19:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763695 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 7BA46C3DA4A for ; Wed, 14 Aug 2024 16:20:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A827C6B0083; Wed, 14 Aug 2024 12:20:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A32AB6B0088; Wed, 14 Aug 2024 12:20:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FA576B0093; Wed, 14 Aug 2024 12:20:05 -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 6EB966B0083 for ; Wed, 14 Aug 2024 12:20:05 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B38921C4B4A for ; Wed, 14 Aug 2024 16:20:03 +0000 (UTC) X-FDA: 82451362686.12.37FAE04 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf20.hostedemail.com (Postfix) with ESMTP id 636BE1C0028 for ; Wed, 14 Aug 2024 16:20:00 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=KkI9jY+E; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf20.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723652320; 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=qTtBzc2HUrnD0EKBLPylJelpcf3wUNndt/MP7eAKeGk=; b=JSwc8+kn7CU++HOon9w3O6z/aWDVGVyTGzJP29hbbs1wA9Zv+8fYqEIjgcVfDZehqVVPYu gvnsH0k9Kq84SavIJaoX8TnxSGvh+gcQODDoByuyeZ00pLd9h6bav3en7BHZpkstqsXewO iJ6jvr55FmUvGcLzhWm4oOA8W/YxDLg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723652320; a=rsa-sha256; cv=none; b=tyKV0g31Uw0lHTS0hgB5lyfBIh3F5P5vG7YRT0MJajsCNyEz4ySp1RN5WMkYTLaIZ7OfJo 1oqbz+31+CZaGCKX3O3PYEXH6mnnjZxuJcj6MXJmOTbMppKiKxsfbg0tkcstmt26kCibSm ILv58ZjOO22nATmLOT1YomMR1xo76D0= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=KkI9jY+E; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf20.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtb8N007187; Wed, 14 Aug 2024 16:19:52 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=q TtBzc2HUrnD0EKBLPylJelpcf3wUNndt/MP7eAKeGk=; b=KkI9jY+E8SErnHR07 OydZ1z+tbnA4ZEqn0PXpLYUNR2W81XwsZWJ+m/qY08nIjge57mxHxkVFeWR13AGC ICfexAy46KRyH2P+rKNNsDgDf78m2GvaffYQyMI8e0d7n2v8aXwuGEyF3hcbEsL2 HhOMsVK5ZV6Cmkb+Jcy9sC68RDOipCsmh/5xBii/PeavWF+ngx8hn526DaBnGlQZ 8+qVk8nDypTgGqfT/r0VVxLbU3a/u1EVur6N+F8LDYf1XhFvNcO+aAh9cf0j4wZq f/+P6zbSEhljLS/uBC0Ds2Iad2x1+yg0BMn0rVu+dOWxV+ByzPG6qCsd/qKS48My jISXQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40x0398m0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:52 +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 47EFY5Y3020945; Wed, 14 Aug 2024 16:19:51 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7kp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:50 +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 47EGIvC2035951; Wed, 14 Aug 2024 16:19:50 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-4; Wed, 14 Aug 2024 16:19:50 +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 03/17] maple_tree: move up mas_wr_store_setup() and mas_wr_prealloc_setup() Date: Wed, 14 Aug 2024 12:19:30 -0400 Message-ID: <20240814161944.55347-4-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: eY-2fWbxE3ooirXwYLmMSjR9_L3EgGHl X-Proofpoint-GUID: eY-2fWbxE3ooirXwYLmMSjR9_L3EgGHl X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 636BE1C0028 X-Stat-Signature: if8k9co19w8htpnj1zk8i7m7act8n463 X-Rspam-User: X-HE-Tag: 1723652399-891487 X-HE-Meta: U2FsdGVkX1/OOMJAwvibLTARh0NVx927t7r3b7/6qMAOmKb47UD3jwsVGUFQe1y/biXqNWTy+FXOQjc0566wC1ZbQWxAYZqDC5iTwjutapb9H7nGb/Cld7ddTpuwBGJjeb/BuQ3tp1cU2h06ifuNCVPEzlEw2V6hiNRdi4RF4pKr3VRKTTupuHeP7aX0eYP4oMzyBsyDZ/3iMwpT2j0A6q5474UiW9hIC76cQOqQTa5K0gbwW1Uze/EG5BwLljaZlH+3azrxDi+duhUYriMLZFKf/3IwtKZsTAOLd4Cde2fCjDaReSEvFMI0ClHoTUAYiAGx5J1dc7dJ0URSU2TlBwNsa6xSWucdB6ggmzwCIJOc/8IeTmyVkp/XJdzS1Q3FdgBTtNYt0goVCAvE/0qQ8MxJHBPKslkDRBggOzLztEKO9OFT6fWtMkTuMFbKaab9ASx3gXtbdHA4FJRfrKWd2j6xorhAfpl0q61w4p7f3hX/ZiJSiflcad13w22Axdfqj2Fpf71SZIHR9GaWO2TX6hS/SJ7Kx8Lvsf3iSincMQd/uavWHcxHuuHtjcW90xcoX91lrRnAVDUChcp3KoZCd+dy1F1ktOaA0yhepWFzM3vdu2b7gRhtkbMbSSHofgQX//o7thRtV1BfI14La3Mx6MrhMik2+E3vEwc+A+Rqn2qkokwyNvlAj1G3hwrESb9Lc+wQ+IrOpTFdqA4B+SgOSFs4bnamCCcqB9nixdfKgeKzal+zGYL+7jGaHIwMY2opi4ZwGxionSgECnfDd4eK4WO0A5xyJIAIhtnA4ZXK9dkGvt/87eIMaW5ZLz3FJTwTJG6vqApBP1lpRMQv+Szx3xqr6j3YSOId7QwYXDtMY2rTAfTXLYNn8F5Cw2UZ9D8KDO+cYNayjAnSeUltySmWrPkAPgXZTo0xUHtmhpc49yGxdd12kUO3jSRl1iDjhjJzKQ2TMLvKhP27FstfeZq niJjjPVK 89Us6nIlz63aI1DSWS36ZVTCcsov/WkJcp7XjV3Awg2tp8eccdz35fxJQ5XP9tP1yiEUjnrPQEv2cvOkpJ0XhTKM9XuSPJI5yCKwISqybmjQ7GPei/UBrDCO7QlxYK18uydhHSblvPiiQD6nD53/SgPySg6jiIyTtcMaiiTri9JnWnd6ROyfm1jkrmNEYXywN/LgaMjp4Oi8eLLS7q/owZy6dgTVIkBtWEQvbMVdNdHxf5oMBzJ1PGogFpKLIQB4S0bjkh5Oi83VUaPs= 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: List-Subscribe: List-Unsubscribe: Subsequent patches require these definitions to be higher, no functional changes intended. Reviewed-by: Liam R. Howlett Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 96 ++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 407c0be6e42f..de4a91ced8ca 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4227,6 +4227,54 @@ static inline void mas_wr_store_entry(struct ma_wr_state *wr_mas) mas_wr_modify(wr_mas); } +static void mas_wr_store_setup(struct ma_wr_state *wr_mas) +{ + if (!mas_is_active(wr_mas->mas)) { + if (mas_is_start(wr_mas->mas)) + return; + + if (unlikely(mas_is_paused(wr_mas->mas))) + goto reset; + + if (unlikely(mas_is_none(wr_mas->mas))) + goto reset; + + if (unlikely(mas_is_overflow(wr_mas->mas))) + goto reset; + + if (unlikely(mas_is_underflow(wr_mas->mas))) + goto reset; + } + + /* + * A less strict version of mas_is_span_wr() where we allow spanning + * writes within this node. This is to stop partial walks in + * mas_prealloc() from being reset. + */ + if (wr_mas->mas->last > wr_mas->mas->max) + goto reset; + + if (wr_mas->entry) + return; + + if (mte_is_leaf(wr_mas->mas->node) && + wr_mas->mas->last == wr_mas->mas->max) + goto reset; + + return; + +reset: + mas_reset(wr_mas->mas); +} + +static inline void mas_wr_prealloc_setup(struct ma_wr_state *wr_mas) +{ + struct ma_state *mas = wr_mas->mas; + + mas_wr_store_setup(wr_mas); + wr_mas->content = mas_start(mas); +} + /** * mas_insert() - Internal call to insert a value * @mas: The maple state @@ -5358,54 +5406,6 @@ static inline void mte_destroy_walk(struct maple_enode *enode, mt_destroy_walk(enode, mt, true); } } - -static void mas_wr_store_setup(struct ma_wr_state *wr_mas) -{ - if (!mas_is_active(wr_mas->mas)) { - if (mas_is_start(wr_mas->mas)) - return; - - if (unlikely(mas_is_paused(wr_mas->mas))) - goto reset; - - if (unlikely(mas_is_none(wr_mas->mas))) - goto reset; - - if (unlikely(mas_is_overflow(wr_mas->mas))) - goto reset; - - if (unlikely(mas_is_underflow(wr_mas->mas))) - goto reset; - } - - /* - * A less strict version of mas_is_span_wr() where we allow spanning - * writes within this node. This is to stop partial walks in - * mas_prealloc() from being reset. - */ - if (wr_mas->mas->last > wr_mas->mas->max) - goto reset; - - if (wr_mas->entry) - return; - - if (mte_is_leaf(wr_mas->mas->node) && - wr_mas->mas->last == wr_mas->mas->max) - goto reset; - - return; - -reset: - mas_reset(wr_mas->mas); -} - -static inline void mas_wr_prealloc_setup(struct ma_wr_state *wr_mas) -{ - struct ma_state *mas = wr_mas->mas; - - mas_wr_store_setup(wr_mas); - wr_mas->content = mas_start(mas); -} /* Interface */ /** From patchwork Wed Aug 14 16:19:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763700 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 CF9A9C52D7B for ; Wed, 14 Aug 2024 16:20:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 10E036B009C; Wed, 14 Aug 2024 12:20:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 099596B009D; Wed, 14 Aug 2024 12:20:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDCB86B009E; Wed, 14 Aug 2024 12:20:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BA4206B009C for ; Wed, 14 Aug 2024 12:20:07 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6DEEBA824E for ; Wed, 14 Aug 2024 16:20:07 +0000 (UTC) X-FDA: 82451362854.01.D3A31DB Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf07.hostedemail.com (Postfix) with ESMTP id EC69B4001B for ; Wed, 14 Aug 2024 16:20:04 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=nZBIKsmq; spf=pass (imf07.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=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=zOe6rYReOJ9R8LQkfQkW5rBoXsJ7vwbdrjrfz4Pketk=; b=SwOiYyxLRkIZkc4VzuKtbix1STIyejwh0UjN4THos0WG9ta1xHfxjDGKSVjDK/5kT4DWIZ erNzMJBFTq40p21SLlcrdzpcn54mTicWYpqzy2pDPVzQ6IL9P3NNNl9uy1S6klGyrYFnXI QzD62ma3lxYT0zWZ4NKUPxj4x4lbTgw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723652334; a=rsa-sha256; cv=none; b=WUtw6Uw2oWnBVpOGCyalmpnaKxPCBKdSnGrblU2Vke7ENNvSzni7STcdmtqi3tkKWhpNMR 4oE7Cm0pyxjMxIG8zRu10+AatBc3N9va2QYW1mJiy3ZkFWJko//inok+ryAV/oqunXQjIK W0fwjiq5NSNJbF+qoBTvZfHRskvHa6o= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=nZBIKsmq; spf=pass (imf07.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 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtZ2p028354; Wed, 14 Aug 2024 16:19:54 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=z Oe6rYReOJ9R8LQkfQkW5rBoXsJ7vwbdrjrfz4Pketk=; b=nZBIKsmq3qfVDaDOR NFFfs0Q1jRlhfa5GlaKoXfrdhdqeTn+TY3tZzmF2j5K5d6uungZgFxi6qMHhAMmQ RiKNhom+4tcnMagmGVicBeo30y8Fb7A1ldRREU8N2Y8ECVkHlYxn3ACEy+QYZ4yD u+fja3wHjXel0jgu37GTyaYjVQj/DOPVqp10MEawmBRZ7Z6H0DjfndUEm2Tv4CwB MLZzaEjFXpd8l1qt2aE3pGlBysVMoCA9AdaRD00hsm0Epqqa/2IpmL3vMbJorien xvwlLcqBzQfVgqyXYYsjOqtGEAmV+jdnzXtx2iKR+4VxGEerEa2jE/Zp5ZSKzAcw 9zwZQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wxt10shw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:53 +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 47EFqAgH021061; Wed, 14 Aug 2024 16:19:51 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7ma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:51 +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 47EGIvC4035951; Wed, 14 Aug 2024 16:19:51 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-5; Wed, 14 Aug 2024 16:19:51 +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 Subject: [PATCH v4 04/17] maple_tree: introduce mas_wr_store_type() Date: Wed, 14 Aug 2024 12:19:31 -0400 Message-ID: <20240814161944.55347-5-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-GUID: 2sRgIeRR8qHOa4oJ-mYnfXbiem0eaLIF X-Proofpoint-ORIG-GUID: 2sRgIeRR8qHOa4oJ-mYnfXbiem0eaLIF X-Rspamd-Queue-Id: EC69B4001B X-Stat-Signature: xo8s5ktea5cjqrmgdrb13oy4i6rhzc75 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1723652404-69057 X-HE-Meta: U2FsdGVkX19O6j10c4Ff9imPJZk5SkgjsfUgHZD5YKpaNdfB3Lj8tCsNxCRHbQSAofh8/nDh+S/tH3OwybsqMVN/edk2IDZQdANkKpZcJKvTnanXN9CFF2X6nl/Aq5A149BCAZF6z2pzeyvO20e8behZt3MBUgUZu7ipAL2cMch+xHH7/OzNQlUkvGzqVwd4FDUuB6lZTqMDJWWjVBKZu1BlON3FyES/8I1nMzW63GtE8PEllEjB04AmtsBcoBX4HbUGvCu/iONnQhOK8EfWBBAdIAXPyK33apwN7SVvLTL6Fc6BVIUqNP2a9rqJxmFRr3N3646Jqvn19Ae4f0SB8/WNV+oLyqfA2SvXkVX8oqSLPwAv28xG8U8DScDKB3fJVELLOJnFWsGHriOHf4slPTs4s+i21q+bSV0T91LSrq6Y38QKcRJBp8iNpqqMs0NSCJ3yMJ7JEpliZXxX7kqV68yHm8qgAByHQT16Ms/KPcXBFkx2cRIQJGTahSQBiee4waV55KpbUoXy/Dqc5dpRx1B8W9p/ib1BE7ZbGtAdHoRlNQl2xqCQjWyMuxQNizjvtZeKKc6+ebieaITC9knZsDdM+PBQGrFPyqXCavLmO890rcbEKfLudtGlKlmcWWELrYdEW3r3hreHha5U+b6x1pqw+DV/m3CfGnKTEP3ocbHks1Ey19c1a20fZLOwJQPVPwmDL9qGN1cyxbWJNjfoYkeAVVsQ1q2C1mna9DG35CI2uo8hk2Cji0dyT4uoiSykIqExPrscq+BqAiSqrVa0+6KAEQDmy9CnIlI5bIVHAKPnq+1yhyb7mJHyCD/9lrju8H9ZOWrtWJ0FwYCKLDRTvHIVDA1hgmWVOKoUPgXn9WczY1bIMeP9/KmyehpJzdivBFLW6hb9rPFqs5FcQHS7jB+rx/K1XD+07sDYtDYtWNI1gCbydPh/a7Vt0oXdOuxUOp79bxYY4HUF1SvnPl/ MjhfD7fZ F1PFIsOi+KnkUBMKeh7mqgafmIM23Kyh45oOQLlrGyCm/ORtPa2cHGgv+f+vQrTtcK3Dd7GQq3fu0e5r8DHNZwAy3tuWrWpXitLR9wtAWp/FCbn5Eespgv3dmMUbYyz+h00PZsPUR2jE7SRnFFasZlImzHr78bTKmtqOlGVT802Y7ieNTPSpYyubZsdmrhyBzWfW75mrEL+o2honyxXVEAjy94SuAz05PGuIuIddOQ8PGB/S/K9qxLNvKawnsyRsSrTJBwZsWQKq7N58= 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: List-Subscribe: List-Unsubscribe: Introduce mas_wr_store_type() which will set the correct store type based on a walk of the tree. In mas_wr_node_store() the <= min_slots condition is changed to < as if new_end is = to mt_min_slots then there is not enough room. mas_prealloc_calc() is also introduced to abstract the calculation used to determine the number of nodes needed for a store operation. In this change a call to mas_reset() is removed in the error case of mas_prealloc(). This is only needed in the MA_STATE_REBALANCE case of mas_destroy(). We can move the call to mas_reset() directly to mas_destroy(). Also, add a test case to validate the order that we check the store type in is correct. This test models a vma expanding and then shrinking which is part of the boot process. Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 217 ++++++++++++++++++++++--------- tools/testing/radix-tree/maple.c | 36 +++++ 2 files changed, 193 insertions(+), 60 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index de4a91ced8ca..d0b9b3795b96 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1372,9 +1372,9 @@ static inline struct maple_enode *mas_start(struct ma_state *mas) return NULL; } + mas->node = NULL; /* empty tree */ if (unlikely(!root)) { - mas->node = NULL; mas->status = ma_none; mas->offset = MAPLE_NODE_SLOTS; return NULL; @@ -3890,7 +3890,7 @@ static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas, bool in_rcu = mt_in_rcu(mas->tree); /* Check if there is enough data. The room is enough. */ - if (!mte_is_root(mas->node) && (new_end <= mt_min_slots[wr_mas->type]) && + if (!mte_is_root(mas->node) && (new_end < mt_min_slots[wr_mas->type]) && !(mas->mas_flags & MA_STATE_BULK)) return false; @@ -4275,6 +4275,146 @@ static inline void mas_wr_prealloc_setup(struct ma_wr_state *wr_mas) wr_mas->content = mas_start(mas); } +/** + * mas_prealloc_calc() - Calculate number of nodes needed for a + * given store oepration + * @mas: The maple state + * @entry: The entry to store into the tree + * + * Return: Number of nodes required for preallocation. + */ +static inline int mas_prealloc_calc(struct ma_state *mas, void *entry) +{ + int ret = mas_mt_height(mas) * 3 + 1; + + switch (mas->store_type) { + case wr_invalid: + WARN_ON_ONCE(1); + break; + case wr_new_root: + ret = 1; + break; + case wr_store_root: + if (likely((mas->last != 0) || (mas->index != 0))) + ret = 1; + else if (((unsigned long) (entry) & 3) == 2) + ret = 1; + else + ret = 0; + break; + case wr_spanning_store: + ret = mas_mt_height(mas) * 3 + 1; + break; + case wr_split_store: + ret = mas_mt_height(mas) * 2 + 1; + break; + case wr_rebalance: + ret = mas_mt_height(mas) * 2 - 1; + break; + case wr_node_store: + ret = mt_in_rcu(mas->tree) ? 1 : 0; + break; + case wr_append: + case wr_exact_fit: + case wr_slot_store: + ret = 0; + } + + return ret; +} + +/* + * mas_wr_store_type() - Set the store type for a given + * store operation. + * @wr_mas: The maple write state + */ +static inline void mas_wr_store_type(struct ma_wr_state *wr_mas) +{ + struct ma_state *mas = wr_mas->mas; + unsigned char new_end; + + if (unlikely(mas_is_none(mas) || mas_is_ptr(mas))) { + mas->store_type = wr_store_root; + return; + } + + if (unlikely(!mas_wr_walk(wr_mas))) { + mas->store_type = wr_spanning_store; + return; + } + + /* At this point, we are at the leaf node that needs to be altered. */ + mas_wr_end_piv(wr_mas); + if (!wr_mas->entry) + mas_wr_extend_null(wr_mas); + + new_end = mas_wr_new_end(wr_mas); + if ((wr_mas->r_min == mas->index) && (wr_mas->r_max == mas->last)) { + mas->store_type = wr_exact_fit; + return; + } + + if (unlikely(!mas->index && mas->last == ULONG_MAX)) { + mas->store_type = wr_new_root; + return; + } + + /* Potential spanning rebalance collapsing a node */ + if (new_end < mt_min_slots[wr_mas->type]) { + if (!mte_is_root(mas->node)) { + mas->store_type = wr_rebalance; + return; + } + mas->store_type = wr_node_store; + return; + } + + if (new_end >= mt_slots[wr_mas->type]) { + mas->store_type = wr_split_store; + return; + } + + if (!mt_in_rcu(mas->tree) && (mas->offset == mas->end)) { + mas->store_type = wr_append; + return; + } + + if ((new_end == mas->end) && (!mt_in_rcu(mas->tree) || + (wr_mas->offset_end - mas->offset == 1))) { + mas->store_type = wr_slot_store; + return; + } + + if (mte_is_root(mas->node) || (new_end >= mt_min_slots[wr_mas->type]) || + (mas->mas_flags & MA_STATE_BULK)) { + mas->store_type = wr_node_store; + return; + } + + mas->store_type = wr_invalid; + MAS_WARN_ON(mas, 1); +} + +/** + * mas_wr_preallocate() - Preallocate enough nodes for a store operation + * @wr_mas: The maple write state + * @entry: The entry that will be stored + * + */ +static inline void mas_wr_preallocate(struct ma_wr_state *wr_mas, void *entry) +{ + struct ma_state *mas = wr_mas->mas; + int request; + + mas_wr_prealloc_setup(wr_mas); + mas_wr_store_type(wr_mas); + request = mas_prealloc_calc(mas, entry); + if (!request) + return; + + mas_node_count(mas, request); +} + /** * mas_insert() - Internal call to insert a value * @mas: The maple state @@ -5508,69 +5648,25 @@ 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; + int ret = 0; + int request; mas_wr_prealloc_setup(&wr_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) - return 0; - - mas_wr_end_piv(&wr_mas); - node_size = mas_wr_new_end(&wr_mas); - - /* Slot store, does not require additional nodes */ - if (node_size == mas->end) { - /* reuse node */ - if (!mt_in_rcu(mas->tree)) - return 0; - /* shifting boundary */ - if (wr_mas.offset_end - mas->offset == 1) - return 0; - } + mas_wr_store_type(&wr_mas); + request = mas_prealloc_calc(mas, entry); + if (!request) + return ret; - if (node_size >= mt_slots[wr_mas.type]) { - /* Split, worst case for now. */ - request = 1 + mas_mt_height(mas) * 2; - goto ask_now; + mas_node_count_gfp(mas, request, gfp); + if (mas_is_err(mas)) { + mas_set_alloc_req(mas, 0); + ret = xa_err(mas->node); + mas_destroy(mas); + mas_reset(mas); + return ret; } - /* New root needs a single 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))) - return 0; - - mas_set_alloc_req(mas, 0); - ret = xa_err(mas->node); - mas_reset(mas); - mas_destroy(mas); - mas_reset(mas); return ret; } EXPORT_SYMBOL_GPL(mas_preallocate); @@ -5596,7 +5692,8 @@ void mas_destroy(struct ma_state *mas) */ if (mas->mas_flags & MA_STATE_REBALANCE) { unsigned char end; - + if (mas_is_err(mas)) + mas_reset(mas); mas_start(mas); mtree_range_walk(mas); end = mas->end + 1; diff --git a/tools/testing/radix-tree/maple.c b/tools/testing/radix-tree/maple.c index ef5b83cf94ea..ad42a36231fb 100644 --- a/tools/testing/radix-tree/maple.c +++ b/tools/testing/radix-tree/maple.c @@ -36283,6 +36283,38 @@ static void check_nomem_writer_race(struct maple_tree *mt) mtree_unlock(mt); } + /* test to simulate expanding a vma from [0x7fffffffe000, 0x7ffffffff000) + * to [0x7ffde4ca1000, 0x7ffffffff000) and then shrinking the vma to + * [0x7ffde4ca1000, 0x7ffde4ca2000) + */ +static inline int check_vma_modification(struct maple_tree *mt) +{ + MA_STATE(mas, mt, 0, 0); + + mtree_lock(mt); + /* vma with old start and old end */ + __mas_set_range(&mas, 0x7fffffffe000, 0x7ffffffff000 - 1); + mas_preallocate(&mas, xa_mk_value(1), GFP_KERNEL); + mas_store_prealloc(&mas, xa_mk_value(1)); + + /* next write occurs partly in previous range [0, 0x7fffffffe000)*/ + mas_prev_range(&mas, 0); + /* expand vma to {0x7ffde4ca1000, 0x7ffffffff000) */ + __mas_set_range(&mas, 0x7ffde4ca1000, 0x7ffffffff000 - 1); + mas_preallocate(&mas, xa_mk_value(1), GFP_KERNEL); + mas_store_prealloc(&mas, xa_mk_value(1)); + + /* shrink vma to [0x7ffde4ca1000, 7ffde4ca2000) */ + __mas_set_range(&mas, 0x7ffde4ca2000, 0x7ffffffff000 - 1); + mas_preallocate(&mas, NULL, GFP_KERNEL); + mas_store_prealloc(&mas, NULL); + mt_dump(mt, mt_dump_hex); + + mas_destroy(&mas); + mtree_unlock(mt); + return 0; +} + void farmer_tests(void) { struct maple_node *node; @@ -36290,6 +36322,10 @@ void farmer_tests(void) mt_dump(&tree, mt_dump_dec); + mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE | MT_FLAGS_LOCK_EXTERN | MT_FLAGS_USE_RCU); + check_vma_modification(&tree); + mtree_destroy(&tree); + tree.ma_root = xa_mk_value(0); mt_dump(&tree, mt_dump_dec); From patchwork Wed Aug 14 16:19:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763709 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 60C26C531DC for ; Wed, 14 Aug 2024 16:20:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F4876B00A8; Wed, 14 Aug 2024 12:20:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A37C6B00A9; Wed, 14 Aug 2024 12:20:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F6116B00AA; Wed, 14 Aug 2024 12:20:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 006856B00A8 for ; Wed, 14 Aug 2024 12:20:16 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F0BCBA10B3 for ; Wed, 14 Aug 2024 16:20:07 +0000 (UTC) X-FDA: 82451362854.12.4F9FD38 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf21.hostedemail.com (Postfix) with ESMTP id 795191C000D for ; Wed, 14 Aug 2024 16:20:05 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=U47gcGkn; spf=pass (imf21.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=1723652333; 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=UGEoYZW0sw4JTr+KtFllFbwfaNVoSsnR7nGvPPo51B0=; b=ecOFYVxa2pPrTTnpIEtpToqOoeoNfjcvNA26QvRODgJExvgeRrvDU8opVmr0Ycs6EDtwoY Hbe/Rjzzn+j3gAMsIQ4CNpa+VYLmNGMH3GIwKgs2DMmxfnBbd8co2n2crtIMmthGldde3I pb/K68TBo5mb5ib/G0VnfPtOo1jnsgg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723652333; a=rsa-sha256; cv=none; b=Qh3Yev7AVMebnreES49l2pR/1UiiaR78pWiPlmidg4hCIT4rXWCtNM5QabOxA1yOIHAllY B88SHm4vtrYwHVC+KiUEOBq9d+EIo6K2xhFUooB6yDa6u8POz3NrNmZI+RIG+mAJ7rOtBt 0xSUT9K7W3zn4+bCCuHuDi8zr7Vx908= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=U47gcGkn; spf=pass (imf21.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 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtZ2q028354; Wed, 14 Aug 2024 16:19:54 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=U GEoYZW0sw4JTr+KtFllFbwfaNVoSsnR7nGvPPo51B0=; b=U47gcGknT2xsxJP8j a9Y7GWU4zPM8Jy+OuCj0mjpmLsrNuaa3u9lcz8ISjgV+Pij4bMdU2mzVUsc9SY+4 W0qqP0uTwLYutr3bs7dmgsd4YY81viTX/kk+8bI9+Dmwjr/O9fuJscrvM/gW7XHL IVz3cgPxgDBHB1xH8xNCgRJJNalWCKKrSE+8Zw3AyWjWxaVNktBZEOo/B4wsxwXm Ftuf5dROFN0BQBQeADiTtmKbX3012Cyo2XHqtXNIEcmlpy6QTyiqAc8YK+KNhefv +SdtWTT2Fo54UTyBsH3Qey7mjiStkPCiWYq/0AKqXJx8J2Y6z1HAWfwl5oeUYiUj CuLsg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wxt10shx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:53 +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 47EFQeGb021164; Wed, 14 Aug 2024 16:19:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7mx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:52 +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 47EGIvC6035951; Wed, 14 Aug 2024 16:19:51 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-6; Wed, 14 Aug 2024 16:19:51 +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 05/17] maple_tree: remove mas_destroy() from mas_nomem() Date: Wed, 14 Aug 2024 12:19:32 -0400 Message-ID: <20240814161944.55347-6-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-GUID: O2M6SR9o4ay1I-4Ym4vLae6geAmveOtk X-Proofpoint-ORIG-GUID: O2M6SR9o4ay1I-4Ym4vLae6geAmveOtk X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 795191C000D X-Stat-Signature: 41bwrmazeiidd85tekjafad33nh96kjt X-HE-Tag: 1723652405-299414 X-HE-Meta: U2FsdGVkX18/JJK0ILfC4TLmw23zwm1SzdhC9c2MVnhkwuHcz3fE+6MaEwCn/GBFZ+XRAgRMHk2XoVG+I3XqLehhuLpe/bMC2wB43ULqcKolsURMgC7V1fhA4hdWYng6DBI2OQpKxWXcmdQw8pfZrxtig3KEpZSQsQX12HglmAc1Zv29oQ45dDWdSqWJOZJhNeyPW6NebDkznMVD3KdY67Ig4A3Q0rWZ6GGufsNShtR/9Gvq2y4HGcOVIbCQrQwg1MTNL2XATwasqeSY/1X1VGz0K5gEFIZ8WG2ehGMj1p7TehVdpjH+/nm6i+B0/9BD0EOizNSAyNSbPpSRQECnJvNpVcyLWypGqKnQ3D9iLAblXH6IenPaGZRzpSOwYeo9iFn/eHoIhs2TgV9chNiabIKZs/jx7MvJ3g2f0tf7iykDI8YHrro0v8VXA9w+LXG+pdjID4QhmNcKkTCbrifq9PngYmX5Nbwt9RTVUAcuY1oGgoP2s/Vu0cgeJATawPOTr0hc1mMQEIJIX8RRvvrBxLSukSnmr5TNUY3c6QEoV4y3gj2w1k3xHX8O6m+ZGV/DoVEm1O0u854fERU5zw96ASK26hh3M/54hUfyY+C3MVR/G5xBvRL9K5T1G07v2oWOOE7uHXPZ0yKvLac5pYo63gNtRuDeQLHLiPMk7C/OInb52KE3i7E7jbGgOSAi0xe/+0EHZgcdYIBftFCe4E0YQc/TZmwXioInkgS8XvVkX/Hdp6tWB4DNACaAp11ENexAdD+NpzG7W+2AJLUwwsRS7Vil0YKduv6oE2dfPOWfNZAX2Ah/F+miCvBH4AYWGwJuWzp75BS6rUX4cyfHhrlW69HohrwCWDOTj+V2fj5Y9K1PDCqiQT7d7QI4P1gICEtVGgQj6EnUaJrIXx1cQDItSIzYQb2m2pdDTVgTP3ColIuiya4JkX1sQEEKPWyyum1yeaAO49eP7ucYRz6vrGf pntf0TA6 f7lxqrjDHfh+Q+rKrYLk8CnS+SLO7iWfeSvE77x5EOvX1LYsyW47fLeNSoRkWg1xRGXygbkJjCZrcbRvUlBOB4laYGUk99UBu/8kovuOMZOOTWBN525tUBueI/u8iG3MLyVVOEepsCBQOmKmHfNZ/5s0mSCOBWTrQiaE+lsjapQ/Iaa1aXVFxBs2CvW3vcVZ5WH5I+6mUVLUnl76U2stYPk09Iv4pd96A7/2+cdigG73xmAFYy2EieNOGFL3jdPfRvVQyooj75cvlcRo= 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: List-Subscribe: List-Unsubscribe: Separate call to mas_destroy() from mas_nomem() so we can check for no memory errors without destroying the current maple state in mas_store_gfp(). We then add calls to mas_destroy() to callers of mas_nomem(). Reviewed-by: Liam R. Howlett Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 37 +++++++++++++++++++++----------- tools/testing/radix-tree/maple.c | 10 +++++---- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index d0b9b3795b96..58985107cf00 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4519,6 +4519,7 @@ int mas_alloc_cyclic(struct ma_state *mas, unsigned long *startp, if (*next == 0) mas->tree->ma_flags |= MT_FLAGS_ALLOC_WRAPPED; + mas_destroy(mas); return ret; } EXPORT_SYMBOL(mas_alloc_cyclic); @@ -5601,21 +5602,25 @@ int mas_store_gfp(struct ma_state *mas, void *entry, gfp_t gfp) unsigned long index = mas->index; unsigned long last = mas->last; MA_WR_STATE(wr_mas, mas, entry); + int ret = 0; - mas_wr_store_setup(&wr_mas); - trace_ma_write(__func__, mas, 0, entry); retry: - mas_wr_store_entry(&wr_mas); + mas_wr_preallocate(&wr_mas, entry); if (unlikely(mas_nomem(mas, gfp))) { if (!entry) __mas_set_range(mas, index, last); goto retry; } - if (unlikely(mas_is_err(mas))) - return xa_err(mas->node); + if (mas_is_err(mas)) { + ret = xa_err(mas->node); + goto out; + } - return 0; + mas_wr_store_entry(&wr_mas); +out: + mas_destroy(mas); + return ret; } EXPORT_SYMBOL_GPL(mas_store_gfp); @@ -6374,6 +6379,7 @@ void *mas_erase(struct ma_state *mas) goto write_retry; } + mas_destroy(mas); return entry; } EXPORT_SYMBOL_GPL(mas_erase); @@ -6388,10 +6394,8 @@ EXPORT_SYMBOL_GPL(mas_erase); bool mas_nomem(struct ma_state *mas, gfp_t gfp) __must_hold(mas->tree->ma_lock) { - if (likely(mas->node != MA_ERROR(-ENOMEM))) { - mas_destroy(mas); + if (likely(mas->node != MA_ERROR(-ENOMEM))) return false; - } if (gfpflags_allow_blocking(gfp) && !mt_external_lock(mas->tree)) { mtree_unlock(mas->tree); @@ -6469,6 +6473,7 @@ int mtree_store_range(struct maple_tree *mt, unsigned long index, { MA_STATE(mas, mt, index, last); MA_WR_STATE(wr_mas, &mas, entry); + int ret = 0; trace_ma_write(__func__, &mas, 0, entry); if (WARN_ON_ONCE(xa_is_advanced(entry))) @@ -6484,10 +6489,12 @@ int mtree_store_range(struct maple_tree *mt, unsigned long index, goto retry; mtree_unlock(mt); + if (mas_is_err(&mas)) - return xa_err(mas.node); + ret = xa_err(mas.node); - return 0; + mas_destroy(&mas); + return ret; } EXPORT_SYMBOL(mtree_store_range); @@ -6523,6 +6530,7 @@ int mtree_insert_range(struct maple_tree *mt, unsigned long first, unsigned long last, void *entry, gfp_t gfp) { MA_STATE(ms, mt, first, last); + int ret = 0; if (WARN_ON_ONCE(xa_is_advanced(entry))) return -EINVAL; @@ -6538,9 +6546,10 @@ int mtree_insert_range(struct maple_tree *mt, unsigned long first, mtree_unlock(mt); if (mas_is_err(&ms)) - return xa_err(ms.node); + ret = xa_err(ms.node); - return 0; + mas_destroy(&ms); + return ret; } EXPORT_SYMBOL(mtree_insert_range); @@ -6595,6 +6604,7 @@ int mtree_alloc_range(struct maple_tree *mt, unsigned long *startp, unlock: mtree_unlock(mt); + mas_destroy(&mas); return ret; } EXPORT_SYMBOL(mtree_alloc_range); @@ -6676,6 +6686,7 @@ int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp, unlock: mtree_unlock(mt); + mas_destroy(&mas); return ret; } EXPORT_SYMBOL(mtree_alloc_rrange); diff --git a/tools/testing/radix-tree/maple.c b/tools/testing/radix-tree/maple.c index ad42a36231fb..c5b00aca9def 100644 --- a/tools/testing/radix-tree/maple.c +++ b/tools/testing/radix-tree/maple.c @@ -120,7 +120,7 @@ static noinline void __init check_new_node(struct maple_tree *mt) MT_BUG_ON(mt, mas.alloc->slot[0] == NULL); mas_push_node(&mas, mn); mas_reset(&mas); - mas_nomem(&mas, GFP_KERNEL); /* free */ + mas_destroy(&mas); mtree_unlock(mt); @@ -144,7 +144,7 @@ static noinline void __init check_new_node(struct maple_tree *mt) mn->parent = ma_parent_ptr(mn); ma_free_rcu(mn); mas.status = ma_start; - mas_nomem(&mas, GFP_KERNEL); + mas_destroy(&mas); /* Allocate 3 nodes, will fail. */ mas_node_count(&mas, 3); /* Drop the lock and allocate 3 nodes. */ @@ -161,7 +161,7 @@ static noinline void __init check_new_node(struct maple_tree *mt) MT_BUG_ON(mt, mas_allocated(&mas) != 3); /* Free. */ mas_reset(&mas); - mas_nomem(&mas, GFP_KERNEL); + mas_destroy(&mas); /* Set allocation request to 1. */ mas_set_alloc_req(&mas, 1); @@ -277,6 +277,7 @@ static noinline void __init check_new_node(struct maple_tree *mt) } mas_reset(&mas); MT_BUG_ON(mt, mas_nomem(&mas, GFP_KERNEL)); + mas_destroy(&mas); } @@ -299,7 +300,7 @@ static noinline void __init check_new_node(struct maple_tree *mt) } MT_BUG_ON(mt, mas_allocated(&mas) != total); mas_reset(&mas); - mas_nomem(&mas, GFP_KERNEL); /* Free. */ + mas_destroy(&mas); /* Free. */ MT_BUG_ON(mt, mas_allocated(&mas) != 0); for (i = 1; i < 128; i++) { @@ -35847,6 +35848,7 @@ static noinline void __init check_nomem(struct maple_tree *mt) mas_store(&ms, &ms); /* insert 1 -> &ms */ mas_nomem(&ms, GFP_KERNEL); /* Node allocated in here. */ mtree_unlock(mt); + mas_destroy(&ms); mtree_destroy(mt); } From patchwork Wed Aug 14 16:19:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763706 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 4FFFAC531DC for ; Wed, 14 Aug 2024 16:20:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 505166B00A3; Wed, 14 Aug 2024 12:20:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B4646B00A4; Wed, 14 Aug 2024 12:20:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32F956B00A5; Wed, 14 Aug 2024 12:20:11 -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 115826B00A3 for ; Wed, 14 Aug 2024 12:20:11 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 357DFC105B for ; Wed, 14 Aug 2024 16:20:09 +0000 (UTC) X-FDA: 82451362938.03.8632D2D Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf17.hostedemail.com (Postfix) with ESMTP id 137D640032 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=EArQVfEA; spf=pass (imf17.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=1723652311; 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=F6//Jvlc/D0rvk43vXh/wiNs1SFnxWF+1gX4poKKCEk=; b=IQ3J6I5blCjVxQ5FFTUC2GFLEzlixcEeTyAIDl54zzACe1Ax3TClp5N6MF/ypsApNMd7NE cnY74EjYH1vl1g+rDBhG/ulggJSXRwDukzC8KeqaM+PBbyPxT64SzQYo3Z7/yq6PvSEfah iyEZxnptBbov5QvyvDCbDeXM1vHHNOA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=EArQVfEA; spf=pass (imf17.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=1723652311; a=rsa-sha256; cv=none; b=Ue2cyGSTx1pZU9jY8xXzKN8QdKxfCyt2EJSY8BybcWWtAjoGUYJ4c8OmuANouSdnBy9jZZ 2ttz+la/BzaZasx8zH+R63j5y5oAJ4Fjlc2IHqXupbPMhzXurlWJsCpbDwJT6XBfInDVta 1hBeBCqrtshfQlLCYr6kpDq8GYI6lH4= Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtcGx006145; Wed, 14 Aug 2024 16:19: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 :mime-version:content-transfer-encoding; s=corp-2023-11-20; bh=F 6//Jvlc/D0rvk43vXh/wiNs1SFnxWF+1gX4poKKCEk=; b=EArQVfEALrEoJo2oM TigFy7GcqqR6qe/rMjdeX7uZtN/u7IthiZ/k8iyweor+C8RN1oPFzzHv0MMJADfC QWbmKxp28rUv1lxJ0Xlaiyact4Xd73fcE1F3U/9HR9/nQnuZWQkH7kTdgSJYZvUE yI/3VXYIneYdxAeFtcgCjXEcB0B5zcH7Gyo3fYcyo2kBt0czoCKx7g+hnH55jBiE PIotWrUKfJwt0UDN54h+s3wPWlXsewI5GDbsNIUF8HySb5xLllmfXhUzAtea73VP +AYbc80574IrKeizuPa4TXJOQFWUG+dMGHzC45bg1BexChT4FQXhVnz85ssELssf o/Kwg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wy4bgub2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:54 +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 47EFePwq020583; Wed, 14 Aug 2024 16:19:53 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7ng-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:53 +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 47EGIvC8035951; Wed, 14 Aug 2024 16:19:52 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-7; Wed, 14 Aug 2024 16:19:52 +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 Subject: [PATCH v4 06/17] maple_tree: preallocate nodes in mas_erase() Date: Wed, 14 Aug 2024 12:19:33 -0400 Message-ID: <20240814161944.55347-7-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-GUID: 4IOsR78Mk9VBiSAdzsFvMZEOU7qiZRxQ X-Proofpoint-ORIG-GUID: 4IOsR78Mk9VBiSAdzsFvMZEOU7qiZRxQ X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 137D640032 X-Stat-Signature: ycpcqkutxtffzuwpayaoqso1bqnst897 X-Rspam-User: X-HE-Tag: 1723652406-598463 X-HE-Meta: U2FsdGVkX19TJiDO0dTd9c9/H+sXnLhSF+JpQ1n3l9Yn+tyxdhtiTs/Bl39rgWXJqojXO17yb//eKETS84qEF3fTpYghZ+euDwRRHibNDUiSWgZj8+vi387MnbT5BfLcy+dh2FcT7OuQ7cFbe64F02dxay2wD9THcHVl0CnDt34iElQGULJ/HN3yXd0sk/1Cre3oD7QR+cD6s9R7PZqq3VuRqzuKernUZNvFH0NFCMj9wpdlvDxgl8h0mQK/d1Q3QK1+sh/982KmHTtM+dXhpu8S7pwxF6/N+BghGQS3Vmal3FVmPJtDsrnBBeuEtKZDeOY35gJ54mPfJlKVsNg0TxfoSftwv+1Mjfw5IocXFb0Tl3vrX2dfeL1JNpef/KFwl3F99jbML+flTV2NKj+Nkb4JUUnni7bwyiTSxcHUxMHYX1l+p57YzIXPUWX3RDVRs4oxzvABgChhcaBJCPhzQ4n/VCI/bbi2QqjKH8v5qwKrZMkIVrrYe9rZsKH5sxmnbJ7g+/lTb332pcbbsJL8hppKb5xBpmUxwVfTWbT9FluqEJ6indmkaUU67l3/Rlrzv+SFW7MaaB0b0IDRsU73EiH5YvEzMJqjbzLTFxfolTSWKwOBhw8WwjluK55XOP77iOvfpj2NpLugfbrfcDpzEcjE8WZxxqyERV/1SWhO7G06R/s0G6nLKhxzW8rwtPWSm5zuY9Sq1NwMZi5hiUG9C4vvMldsed3YIUNuouso12Fdkw1ozEmjYao5j7TpQBniinX7uqXTiPAu9sX7sW6D0UKLTy07sm1zxBB6hdRaj/z3WHsFrn60tbEqsdFCiRA2MD3tAQrrG2reILa6M48YTUJns4WtIympdfdBQ7Qbufcgike9uyjrCo6kCdD2g8SNgwLYDsHvzBdHcZEiyqKDMhZ22JVhEPtWFT/2s4p7SH3oSoQ0LqJp830p1/IYlDLXue62cB6q302wZTApkJS RIbLcqgy ONJQ/HIRzGkj3V/ASnXnEG3H6piHESMXH4D6FPc7Stc2ZkI9ID85cdFk35H58VsjAOqL6MymDefNNDAsAmHVzlwUuScCa9J78koDAUpIOOYDD3gsZr2yvGoMYYxw4FSZOv4Y2VfHozwpK1cShxhZMMNGUAHIyXngM6AVpnyklpjTw0u6LvR9x/wXvAi8rJ/RMfw+neHCFnJWP7itUENYMt+d8aWXpB2hf35ITKORk+ExZjhcmwE87bxAZfsnjld73V3G02T4hZN/PVc0= 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: List-Subscribe: List-Unsubscribe: Use mas_wr_preallocate() in mas_erase() to preallocate enough nodes to complete the erase. Add error handling by skipping the store if the preallocation lead to some error besides no memory. Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 58985107cf00..8ba52ffa778e 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -6371,14 +6371,18 @@ void *mas_erase(struct ma_state *mas) /* Must reset to ensure spanning writes of last slot are detected */ mas_reset(mas); - mas_wr_store_setup(&wr_mas); - mas_wr_store_entry(&wr_mas); + mas_wr_preallocate(&wr_mas, NULL); if (mas_nomem(mas, GFP_KERNEL)) { /* in case the range of entry changed when unlocked */ mas->index = mas->last = index; goto write_retry; } + if (mas_is_err(mas)) + goto out; + + mas_wr_store_entry(&wr_mas); +out: mas_destroy(mas); return entry; } From patchwork Wed Aug 14 16:19:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763703 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 91806C531DC for ; Wed, 14 Aug 2024 16:20:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 860886B009E; Wed, 14 Aug 2024 12:20:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 810786B00A0; 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 5CB386B00A1; Wed, 14 Aug 2024 12:20:09 -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 16ACE6B009E for ; Wed, 14 Aug 2024 12:20:09 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B444781058 for ; Wed, 14 Aug 2024 16:20:08 +0000 (UTC) X-FDA: 82451362896.09.9F16315 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf21.hostedemail.com (Postfix) with ESMTP id 970B61C0010 for ; Wed, 14 Aug 2024 16:20:06 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=F3mLM2xR; spf=pass (imf21.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=1723652394; 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=yQLRA/Ga16U7VMfZQaR29Wpf+8YrtU3+vrypmAwrPwY=; b=V25ZCHLzFmYQyWb1byu120dyXwypfXBfqs+k+FCvBhfI2GgtaAtkOpsMgZA2n7PUiJYNKC UZg1AVc1z31+U9AY1LW84QGolydPn9rDaJkCzqmR75f6yeY4WE4r8t3eeQKR8lnxc91V7m tIbWRviF8djH1dR1qtHhMNTf32+yGmc= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=F3mLM2xR; spf=pass (imf21.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723652394; a=rsa-sha256; cv=none; b=OKQ4sPg7Xe2LHRNcTwmgaSU4Xhn8W0b7KCkTHJ/cScHp43APT0AL/4tw94ypolWXF2N62D KdtxLP31adPISDAKbe0FCizlGIHfbUBYnHoJrOapJS6WWLXQP7U1ocxauR/38+NhLXPFfT WYgaieMO9Lm1BMccFrjxWfIFhiPbjio= Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtWAs015137; Wed, 14 Aug 2024 16:19:54 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=y QLRA/Ga16U7VMfZQaR29Wpf+8YrtU3+vrypmAwrPwY=; b=F3mLM2xR4tJ3Oq+yS Z6ZG4TQX6FgoktAaKwRIiQ2RwkyHITAtmNWhllAFHYq8TDsWJCV8nQGV0iMiw7Sy 1A/eFAAXojAnoTXeiip2NCWbq5Mcp4WoFZ6x6GHdbUvH5CJkiMH269kO78MGveuO FShW7X+nLVVzrgD2rtesW/YSWmtwNH9vkui/mmoQbaRHY6BqWZeyFTFdm6vTbjZX HzPGiHln13VHhEPsLdBFvAYIHtNB2vsXe+S1zkhNmpRzhdZCwdLv7HMHDN6sX9Th bAKDvXXRfc6gorraHM5btgJn4L+uzx6yKt8sy6Z292px5dTuMpcSAeqz5HqPy7iN +5ShQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wy030v8q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:54 +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 47EFCIm0021084; Wed, 14 Aug 2024 16:19:53 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7nn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:53 +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 47EGIvCA035951; Wed, 14 Aug 2024 16:19:53 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-8; Wed, 14 Aug 2024 16:19:53 +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 07/17] maple_tree: use mas_store_gfp() in mtree_store_range() Date: Wed, 14 Aug 2024 12:19:34 -0400 Message-ID: <20240814161944.55347-8-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-GUID: a4z5tUvF5q0S00dZBPlU9FsYu2pVjaT8 X-Proofpoint-ORIG-GUID: a4z5tUvF5q0S00dZBPlU9FsYu2pVjaT8 X-Rspam-User: X-Stat-Signature: qkzzmgqdm7pfsohzh1nctofcb4cw4m7t X-Rspamd-Queue-Id: 970B61C0010 X-Rspamd-Server: rspam11 X-HE-Tag: 1723652406-634325 X-HE-Meta: U2FsdGVkX18fhn4aYRKJ8R0hrrzHLfU0hVhkzFb4B44hG0HtHb7QAF9SQ/NUUNgwB/M6E3ztadvR4y2uTh9mWbphUc8u7bnkvrS4rGNXJbpWJ5d2lXtUyKnBqF8pF8DPbwqQCWCtd3eRYLVr61gY3U719yIjnXN/yjxWiIOTul7JSMC/BeI5fpw363yeGhY9GUdtAy8mhW7amUK3yUTTG6jS3yxhb0gdumShJOXUS1DAELIsmcVqsVjLjcSCm8k5ZsqE/FjW3+20FXQJ9bP/1vZ9p0Z3SyAwkdv86JiTFHhwKDs7OPvdN+spg9lJ+NHSpa0TZqULrZxn71NUHKTjDhgfDuM9tNmbmmKCbmVq9qHrkmdx2p5JOEgZexfXdws6J7ofzS3YVAg64xiPJ23ubt4v+EVAKL8tBmRM9jsndmypqKcGhbi18h+ZZamZjgy0cxyoBm2w6q8z7lEbVF4X/K0c9v5mVh6hAMKaD48tuZQDM5YoNN9ZOBgsUeP+6IFBwGxJXM5W4jW3jECeloiNCUuwMHhy/Eckm+fZ45NtCuPIRzTrtwD0IaPAI3tnkdnkOVYSC+gxmqc1WRQm5qXz6ucupzMijmr4P7/pMR/8Aut2se3EgkcXo7N766bazsG8ABoDP43zBtJq2qREBNz6oyKjoY9gNDpUv6zd5WSmfSnjb7MUOZ41PIncSyFZNVM98N6eCnJXX4dLyJHz8dTmQTB7IP4TAR0PDwmYNHves2SKPpEqILPkpQFUudYVoSjndiQcf0JoF89KAPJeMr/8gIaO4NPEA8VOrnK9ZKw1CUghJajKwlPvNvFClEbPlYm/4HfrgNLciD6s8xJdYo7lg+sG7jUPAojK4VJzBfMXldZ/pGvjHvHs5N25ArK0eQakybbW9JKspOzTFx92ke8EUwUhcc55+ZSqfYn2FtxiLEDZ42Hn1i2KnJgOT29ywcCNR2o1dmRpZQHnbQrmkUI mxNMkIF8 Dg+d4A5NZEReItkVZBix7oTwnQfk2NpWcoEBWyoK/cH/ho5dwi+thugHheJJgNCYbBbmDTx2UPRbTQlabKglE1PsVjymJL9YB0kbu3YFVOdpyjZIpACsttoYJ1wvc8RuXsukORuQvu/HQhFNlxoIbP/yWB+VwqBFo2iISVR+M8w4MzCIp+uCSOs7p9mqsVblYi8ozeSjRzNzJe6Z1v8SZCdHosPksZ8BqIeWPXGmaHge7a+niUK8Gb3khXI9Ctllsii0e4gVJtW7cTVg= 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: List-Subscribe: List-Unsubscribe: Refactor mtree_store_range() to use mas_store_gfp() which will abstract the store, memory allocation, and error handling. Reviewed-by: Liam R. Howlett Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 8ba52ffa778e..e01e05be6301 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -6476,7 +6476,6 @@ int mtree_store_range(struct maple_tree *mt, unsigned long index, unsigned long last, void *entry, gfp_t gfp) { MA_STATE(mas, mt, index, last); - MA_WR_STATE(wr_mas, &mas, entry); int ret = 0; trace_ma_write(__func__, &mas, 0, entry); @@ -6487,17 +6486,9 @@ int mtree_store_range(struct maple_tree *mt, unsigned long index, return -EINVAL; mtree_lock(mt); -retry: - mas_wr_store_entry(&wr_mas); - if (mas_nomem(&mas, gfp)) - goto retry; - + ret = mas_store_gfp(&mas, entry, gfp); mtree_unlock(mt); - if (mas_is_err(&mas)) - ret = xa_err(mas.node); - - mas_destroy(&mas); return ret; } EXPORT_SYMBOL(mtree_store_range); From patchwork Wed Aug 14 16:19:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763711 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 B0EFCC531DC for ; Wed, 14 Aug 2024 16:20:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C8BE6B00AE; Wed, 14 Aug 2024 12:20:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FF816B00AF; Wed, 14 Aug 2024 12:20:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57BED6B00B0; Wed, 14 Aug 2024 12:20:27 -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 2F1866B00AE for ; Wed, 14 Aug 2024 12:20:27 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 83DFFA10F4 for ; Wed, 14 Aug 2024 16:20:09 +0000 (UTC) X-FDA: 82451362938.22.7EB85FB Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf12.hostedemail.com (Postfix) with ESMTP id 31F0340018 for ; Wed, 14 Aug 2024 16:20:06 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=IFROYWw4; spf=pass (imf12.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=1723652350; 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=+5J3K/HmIJpRQS4W/uJ6jgAlZokAeNKvisghgsHFKU0=; b=4+eRu6YAvsR6WglX4xyf73acutgviMdRXF2/Rqu3VOsh6pg7dZl1WR2MhMeAEW4HjbxoDF DDqWKk0vaO/WAumt92KTmq8eOIFIeMxsD4+FDWJ5bdAQV1JNfkvirI4DC1VArN/qOG2mo+ rKVrwfl+p0EbQ5yTgzRFjbMW0lEPaSM= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=IFROYWw4; spf=pass (imf12.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=1723652350; a=rsa-sha256; cv=none; b=jse5hwET88fyJVCG+GY/a0x1hskf3/OeMr4Fe8DG7A1UCFC0KUipaugaFAE6ycTKmCoMPT VHmgOpXp02NR2WOMwqcVQerkhDK/xb9h2aqHqE5XFSCh7+uR5FCzbqLVNZ9uhv7fVBaQgP I8uABYZEp2cX3u2H1LDauRelz6gxSuw= 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 47EBtcGU013664; Wed, 14 Aug 2024 16:19: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 :mime-version:content-transfer-encoding; s=corp-2023-11-20; bh=+ 5J3K/HmIJpRQS4W/uJ6jgAlZokAeNKvisghgsHFKU0=; b=IFROYWw4SAoarkD55 MsNWVCctGE1pd0Ew5UTbymaONaxdBjtebyEa1n9/wmDF7dL9VA+78p/CiBLM1QLy RN0SlPWgVdVlsXyvvH7x5IDFT2F6w9l88oy31lr2Rmw4fEnxQnzaJC4OZKtw1YND USS7MFTPH9KhRI95sA7zwQBX53ZjqTxd0lrJyw8MmsyGI7M8+R5/q2G3kv7TooVY 5LJCZI+Eaj33ff7mA4OPi2niFDwJe+ccna+AMx+kqquYM1CIqQmRZCCM7htljCML /vsjMAM06danwcyZc7rT3n5gic5IN9HnKUJA7PlXTWvvL28YVW1hutQk+ius1Spl Nfw8w== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40x0rtrsty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:56 +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 47EExw9p020871; Wed, 14 Aug 2024 16:19:54 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7p6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:54 +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 47EGIvCC035951; Wed, 14 Aug 2024 16:19:53 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-9; Wed, 14 Aug 2024 16:19:53 +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 08/17] maple_tree: print store type in mas_dump() Date: Wed, 14 Aug 2024 12:19:35 -0400 Message-ID: <20240814161944.55347-9-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: KemaFXtiYByeyAQpqzfRLHYt45KvpHLk X-Proofpoint-GUID: KemaFXtiYByeyAQpqzfRLHYt45KvpHLk X-Stat-Signature: 43rsfct5kqx4iueebp8i3m6adi7rcoak X-Rspam-User: X-Rspamd-Queue-Id: 31F0340018 X-Rspamd-Server: rspam02 X-HE-Tag: 1723652406-445217 X-HE-Meta: U2FsdGVkX19nR2kpPOQ/pqEWrm1wtaS4GZYiFozuEngV6VvJBjix+N1n8kOuQFyp7cDzpAoZbRMcz9LgBHhs/6OuWdh3/vMTTtzuG2EHSHLy8aWDehsVyGsZM0uUZDftFfscEXcN5OzS8Sa156yUatIl/LwUDU2iUSSEpfWOGNr9Q1wb7WGri3V3nC36wOGhbJkXUuuGClmHZKY9gaCQdAKLgn6GBHKdQoGf80LcxtnZfI136xvO/Zyqf1Y1rxcLwQbum632IBXIzz0xc9Hi6D3CuDxwH1wdwNIPeherIJ8FvEXG6rLQB1RGippGVLT2SkBzDxQIu9r+/4UzXzoa+Bpms6lDM9gFxay/F2JwuJASLqi1ifRkKSBEX6cQrTyb6I7q1AslfAJzKTQRdytdW3aqcEElI+D+Ygsg3bAs3pxzlJucJ2sd8iWsgCJc/bUlqojU+PANItY+f8SeiQyavgf8RdiULqgkraiDgW7ALeboiJs3uvgwtBCdhL9N2QYdJ1NHkYXWcZMlAw+p8QfxXJetHI5olsD4hDKh29AE2JiM5WFyj2vSmg4iQPCBxnRx9JrLUJjgSA0FfnMnaxDsU1DPE0ZpwN+2Q5pTB3Mdp71E+LyHu84IHOy3X9vdSWXdkOD6+c0yiHN4mKB7lEQzQoaoPNxIfin2Dr9Gp/4jgpEEL+BVqyI2gnb6cOXn7Rmw3Fo8izcRTxVX0VGQVAPW7RmsPlCFN8Gdyvjaj5HJiEYRJNb/Vle4ohrpYZjL8kBi2uRkAcX+C3UK9Y25uhRg1A5r8HGVmrlR1Qi7KDpKw6QWlxSseROOBlGwEzWGqSIS+eA82LF0oteooMPPOwuhZoG0DhbVEENh4e9M/7qwsIOx/zIOJtrsXsizUlSV7Ozo4C3RaBUjWqZ6zz6qQz2oJPRPbbDF46MblaLy/4vwCGiYiffpkc2Br0k9UC/Ou650ODk/mYBcxwe0uAhVgil /c0IGMTG jhKJLpIJgY6uFV78I1mRw9W28e8tS3oCnVJF8TbUi4D1LMPBJGuCXwSMhO0BSv6Kre7YXI4dOL6qYSBLiOeZoB8W82g87ywzn+VCXuQeCtRp8NKVWfX5xJvrBQU11QSP51hhVnoUAQLdOou3clk7Ztwa7gowYVAZwTyDUmPSZwFPHyCG5GvlTE0lq/t4QQ4meskVMq0KtHWfgfNt6rGMEohFnfBoSC57pzjhlqOe5fZe9+V7KQT84g7mUoolCx6QAgB4X1VDfDbYIbMQ= 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: List-Subscribe: List-Unsubscribe: Knowing the store type of the maple state could be helpful for debugging. Have mas_dump() print mas->store_type. Reviewed-by: Liam R. Howlett Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index e01e05be6301..a1689fc6227b 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -7760,6 +7760,40 @@ void mas_dump(const struct ma_state *mas) break; } + pr_err("Store Type: "); + switch (mas->store_type) { + case wr_invalid: + pr_err("invalid store type\n"); + break; + case wr_new_root: + pr_err("new_root\n"); + break; + case wr_store_root: + pr_err("store_root\n"); + break; + case wr_exact_fit: + pr_err("exact_fit\n"); + break; + case wr_split_store: + pr_err("split_store\n"); + break; + case wr_slot_store: + pr_err("slot_store\n"); + break; + case wr_append: + pr_err("append\n"); + break; + case wr_node_store: + pr_err("node_store\n"); + break; + case wr_spanning_store: + pr_err("spanning_store\n"); + break; + case wr_rebalance: + pr_err("rebalance\n"); + break; + } + pr_err("[%u/%u] index=%lx last=%lx\n", mas->offset, mas->end, mas->index, mas->last); pr_err(" min=%lx max=%lx alloc=%p, depth=%u, flags=%x\n", From patchwork Wed Aug 14 16:19:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763694 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 7DA5BC52D7B for ; Wed, 14 Aug 2024 16:20:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F74F6B007B; Wed, 14 Aug 2024 12:20:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A70F6B0083; Wed, 14 Aug 2024 12:20:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06EE46B0088; Wed, 14 Aug 2024 12:20:04 -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 DD0CD6B007B for ; Wed, 14 Aug 2024 12:20:04 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0E07A121284 for ; Wed, 14 Aug 2024 16:20:04 +0000 (UTC) X-FDA: 82451362728.02.000040C Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf04.hostedemail.com (Postfix) with ESMTP id CAFB240023 for ; Wed, 14 Aug 2024 16:20:01 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=UOpT1u7X; 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=1723652330; 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=QE3jLMhbqm5q5B6AQVQeAXFLzswsHx3Oigu5M+migRk=; b=EPOUHlp7yuQgdefzPStfE2MEjwzRsgwfvYv3Ow7up/s8ceIWWlXV0Zgg+ThCojbNEImftI PtzTOjxqnbp8RFTnsVgOSPSk7TxvnW92BCtDZyjvZdBO49AxnE7L3aAqSTN/POXF/YEIAw Vfas+SZ6TpR0UMYR/EHT+nkqlg+Fxe0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723652330; a=rsa-sha256; cv=none; b=YgrsaeQvc6qzzpwFXJrfhCscTKTbnDQp3TgYRMaMKJEc0+JFbE5AvW6nZGY8e9EH2sRfCj n8qJYGuCI81UiZcT2IjNGPk51x1ONsPVQ62eawyzoGU9EDOuahIMJACwzeQmsx/NkyDgME 68HVBUR5mAbjRqzqBmGH90MPPQ8/4uI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=UOpT1u7X; 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 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtaej007052; Wed, 14 Aug 2024 16:19: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 :mime-version:content-transfer-encoding; s=corp-2023-11-20; bh=Q E3jLMhbqm5q5B6AQVQeAXFLzswsHx3Oigu5M+migRk=; b=UOpT1u7XABBNy9u6n 11Ws01wlN2+kvSwhXk28LE/xqi+hBvd3YJs++RDwwG1LZjkX63Zvl0IApuP+Qs6E jGRmFGuqNKC+iIJWLp/j8A6KrqaMOXM50qwHCZueMqdV/U3KXeGrdu5yDsCWluqq esVO9bB++EfwfM48H4dSExTQG3OtvtlZAPKp3t3UfAtXZlJqQcuJbxcEFmQP9+vO gTI/MVWKyKB5CDk5ui/kXKq0sXeckur0B/0Sg0WEMau4+YUrto4GE1VSD1Ea6dun DQMGiNqHRTLj5L3vn9dVYuu+TDmUx2ku8Z6HlitF+JE9ZZ1+PL3mpCqk6+kBFvS/ OfUjA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40x0398m0j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:56 +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 47EGCmUe020856; Wed, 14 Aug 2024 16:19:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7pu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:55 +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 47EGIvCE035951; Wed, 14 Aug 2024 16:19:54 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-10; Wed, 14 Aug 2024 16:19:54 +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 09/17] maple_tree: use store type in mas_wr_store_entry() Date: Wed, 14 Aug 2024 12:19:36 -0400 Message-ID: <20240814161944.55347-10-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: bg50TrhVVWz8g9rwKKayfyCa375nXiqW X-Proofpoint-GUID: bg50TrhVVWz8g9rwKKayfyCa375nXiqW X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CAFB240023 X-Stat-Signature: pnwsr4cfoai9guqtspxo9dzc1c5fkcs8 X-HE-Tag: 1723652401-741105 X-HE-Meta: U2FsdGVkX1+4svopUzyY/cBlUjY9dTcqG/4gyYWvYpIVbtU/vyKMZ9/ZKonEr6VkObWBBOUkxXGoL54zrDk4rQCpQoOPMedOtseaOpssPW/U7IOpPWEPxfyOVABtGc7VIjGwGlCauxN8LZaT54HeOw5GZsyYIv6RRyo2/mBB371/TVpY7GQg/98iZ5RN17pc75jqrotseuCYv8udgrgB9dbP/oRl1YZQKllMdNoTbJG0B1f0ZSbUg8JSLBz6iGv3JG/X8FSz2JtsYwbjallQ29J+2G9IhXciUlU7nKwd1MhaY9thYvgLHcNV57b6hyrI7CF7i5Ew0J97YtSem85iChiQtmUgWvk6DbsVcsgOPYrD2jCuvIhK9L5Dnaj1bjeuqW+B1zgeQcL9l0PY9Xe+mYkPrqMUkI1op6bgDkRGLOjqLvPBoyjp+1uj/elFQsncB7HSDiHVTmLPsRPhWhElu3DuP8SA5tANIV9fWCHvvaLkmPF6OFDKnUfTqFGqKEFPO6qX0tAgrevO1powGYUAT5VmiSlGF4QmMS2t0VL6xBKHV7J1Aj1k1MMWudxS9mXMmPcjB9aP/xmgYJfkJL3ZadsrSufKW0yf4Tg9mV50j3RvQyocumQ8+FY+SdIbVEh1nJBqcFRBlmruuEioUvanNHVBKGOzbGEvFp5F2WhhTGjjWJEXO+tfdnMROHMMmCqjjb40+zu19Sk7sfOGnYARG0cAjECNzkClTQFP2KHolkWIY1uRB3zttflUn1qLc12I0hVyeso+i04YA33rrWNgCiOJOdZosh4FrBDpbaltUwZZL39VrHK39TZu9v9x6TLRdfev416eJU//defoPmdLU/v5Ea2xrgC/fVPdvdyumjSGPMv8ixqo5YMiFBViHiDWbGR3rYhzDcTtuF3bEKddlekolCCeA2dJPy3vggjjvu7jMuaKPYK+qCWyx1QLrgOw9Ifwmx2YUFsy82qTN9p l0TJ8dSv jaVca6sEYmlJL766gs91U6b19tFfMwIBsnF6foFYONiQ/+SrFI8Ze5iYcJ7OP+SHW9HyLTH39BrejjD4zLA33g8ltMGuEpj77u39NueNfuwtgJlPqDLl7am3KnTfBmalFxvGQN6lwyy6QixL2JIOpGmBnqXlaqXc701i92b+KInWfBPIPQz+LaT+nX09DV5BQ9cqZ3u8wnBrZ2zFpm7I44JKg3TpmhDOt9dPwXEmpI82HULYO++cdWGy2DnRv8+15QUPkoMPI+RaVs+o= 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: List-Subscribe: List-Unsubscribe: When storing an entry, we can read the store type that was set from a previous partial walk of the tree. Now that the type of store is known, select the correct write helper function to use to complete the store. Also noinline mas_wr_spanning_store() to limit stack frame usage in mas_wr_store_entry() as it allocates a maple_big_node on the stack. Reviewed-by: Liam R. Howlett Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 90 ++++++++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 38 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index a1689fc6227b..2242e07a46dc 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3780,7 +3780,7 @@ static inline int mas_new_root(struct ma_state *mas, void *entry) * * Return: 0 on error, positive on success. */ -static inline int mas_wr_spanning_store(struct ma_wr_state *wr_mas) +static noinline int mas_wr_spanning_store(struct ma_wr_state *wr_mas) { struct maple_subtree_state mast; struct maple_big_node b_node; @@ -4206,43 +4206,62 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas) static inline void mas_wr_store_entry(struct ma_wr_state *wr_mas) { struct ma_state *mas = wr_mas->mas; + unsigned char new_end = mas_wr_new_end(wr_mas); - wr_mas->content = mas_start(mas); - if (mas_is_none(mas) || mas_is_ptr(mas)) { - mas_store_root(mas, wr_mas->entry); + switch (mas->store_type) { + case wr_invalid: + MT_BUG_ON(mas->tree, 1); return; - } - - if (unlikely(!mas_wr_walk(wr_mas))) { + case wr_new_root: + mas_new_root(mas, wr_mas->entry); + break; + case wr_store_root: + mas_store_root(mas, wr_mas->entry); + break; + case wr_exact_fit: + rcu_assign_pointer(wr_mas->slots[mas->offset], wr_mas->entry); + if (!!wr_mas->entry ^ !!wr_mas->content) + mas_update_gap(mas); + break; + case wr_append: + mas_wr_append(wr_mas, new_end); + break; + case wr_slot_store: + mas_wr_slot_store(wr_mas); + break; + case wr_node_store: + mas_wr_node_store(wr_mas, new_end); + break; + case wr_spanning_store: mas_wr_spanning_store(wr_mas); - return; + break; + case wr_split_store: + case wr_rebalance: + mas_wr_bnode(wr_mas); + break; } - /* At this point, we are at the leaf node that needs to be altered. */ - mas_wr_end_piv(wr_mas); - /* New root for a single pointer */ - if (unlikely(!mas->index && mas->last == ULONG_MAX)) - mas_new_root(mas, wr_mas->entry); - else - mas_wr_modify(wr_mas); + return; } -static void mas_wr_store_setup(struct ma_wr_state *wr_mas) +static inline void mas_wr_prealloc_setup(struct ma_wr_state *wr_mas) { - if (!mas_is_active(wr_mas->mas)) { - if (mas_is_start(wr_mas->mas)) - return; + struct ma_state *mas = wr_mas->mas; + + if (!mas_is_active(mas)) { + if (mas_is_start(mas)) + goto set_content; - if (unlikely(mas_is_paused(wr_mas->mas))) + if (unlikely(mas_is_paused(mas))) goto reset; - if (unlikely(mas_is_none(wr_mas->mas))) + if (unlikely(mas_is_none(mas))) goto reset; - if (unlikely(mas_is_overflow(wr_mas->mas))) + if (unlikely(mas_is_overflow(mas))) goto reset; - if (unlikely(mas_is_underflow(wr_mas->mas))) + if (unlikely(mas_is_underflow(mas))) goto reset; } @@ -4251,27 +4270,20 @@ static void mas_wr_store_setup(struct ma_wr_state *wr_mas) * writes within this node. This is to stop partial walks in * mas_prealloc() from being reset. */ - if (wr_mas->mas->last > wr_mas->mas->max) + if (mas->last > mas->max) goto reset; if (wr_mas->entry) - return; + goto set_content; - if (mte_is_leaf(wr_mas->mas->node) && - wr_mas->mas->last == wr_mas->mas->max) + if (mte_is_leaf(mas->node) && mas->last == mas->max) goto reset; - return; + goto set_content; reset: - mas_reset(wr_mas->mas); -} - -static inline void mas_wr_prealloc_setup(struct ma_wr_state *wr_mas) -{ - struct ma_state *mas = wr_mas->mas; - - mas_wr_store_setup(wr_mas); + mas_reset(mas); +set_content: wr_mas->content = mas_start(mas); } @@ -5582,7 +5594,8 @@ void *mas_store(struct ma_state *mas, void *entry) * want to examine what happens if a single store operation was to * overwrite multiple entries within a self-balancing B-Tree. */ - mas_wr_store_setup(&wr_mas); + mas_wr_prealloc_setup(&wr_mas); + mas_wr_store_type(&wr_mas); mas_wr_store_entry(&wr_mas); return wr_mas.content; } @@ -5634,7 +5647,8 @@ void mas_store_prealloc(struct ma_state *mas, void *entry) { MA_WR_STATE(wr_mas, mas, entry); - mas_wr_store_setup(&wr_mas); + mas_wr_prealloc_setup(&wr_mas); + mas_wr_store_type(&wr_mas); trace_ma_write(__func__, mas, 0, entry); mas_wr_store_entry(&wr_mas); MAS_WR_BUG_ON(&wr_mas, mas_is_err(mas)); From patchwork Wed Aug 14 16:19:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763705 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 80BC6C52D7B for ; Wed, 14 Aug 2024 16:20:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77BF96B00A2; Wed, 14 Aug 2024 12:20:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E5C96B00A5; Wed, 14 Aug 2024 12:20:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 380BE6B00A3; Wed, 14 Aug 2024 12:20:10 -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 0BBE26B00A2 for ; Wed, 14 Aug 2024 12:20:10 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B0E9380DC8 for ; Wed, 14 Aug 2024 16:20:09 +0000 (UTC) X-FDA: 82451362938.28.6792AE7 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf26.hostedemail.com (Postfix) with ESMTP id 46677140003 for ; Wed, 14 Aug 2024 16:20:06 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ka68dGYh; spf=pass (imf26.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=1723652395; 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=hIn+8Yybfsr43/VXbr2dLboHCSAINfu362LGlbxAENo=; b=D0WgykZGwIhMC+NICuE9SvKAIryNwuHgUjQHPs5Qp/CE9R14Jv0UtDtfcXvWQUe2d7Pw4G qN/KMo2bYIDtx+Qx/R/BEuGwsFBLN/or0/tqeHWH+Vat2T1THQZOJGWuoGdOG1TSE1pO0J 3lczRJPHQW41R2dmcDyjc2AGODkjsLg= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ka68dGYh; spf=pass (imf26.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=1723652395; a=rsa-sha256; cv=none; b=DUVo0BeZCd5bB84TXKaKNt38bkXsuMmb+gzeiKY+P5gl7xULQjAVmjBqiFVNf7+YZguaAS xLrcJAN5LGhVAZpdxch5x1rS9xusfd0E5iy4fgpyXqtoeAeqmOeZTmsv9NFKSSEf2i53XV c5Yq8Wf7O0gZKoW3vh9IvquFF97BYn8= Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtbNK006104; Wed, 14 Aug 2024 16:19:57 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 In+8Yybfsr43/VXbr2dLboHCSAINfu362LGlbxAENo=; b=ka68dGYhm1Xqj6yu0 K5fC28UFxeARsgcEQTd+TXLxOUBI63cP6S2h8jpQM95oaCjkZBwxc9anmwSsS2aD LHkcjoxks3v9UNNtC0auQvhtRIxietTzPzq6Op57O9PW/WjRXFli0sO5x/7Rj2Mn EEHvEIjTm7Qzdp7aKE3yoNVmflNb+HE8C/W2k7GJcU37ifynndlll6i7MtTd+rhT fCA+GfOCo/ndmk0+9l96Sm++c5BIXDCx6Ik86naRcJar6+V27AjqTnDH2LM+EY3N 1o3FkNlmjB9Gc8GJY//1f2/1macb/Ye1bYV7rWSFciUhGogSZOkZSGOCaEgTFvsy SXcuQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wy4bgub4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:57 +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 47EFxhpc021064; Wed, 14 Aug 2024 16:19:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7qe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:55 +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 47EGIvCG035951; Wed, 14 Aug 2024 16:19:55 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-11; Wed, 14 Aug 2024 16:19:55 +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 10/17] maple_tree: convert mas_insert() to preallocate nodes Date: Wed, 14 Aug 2024 12:19:37 -0400 Message-ID: <20240814161944.55347-11-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-GUID: oVTmzFlSWob157LVeIvGqKVdGTcYWCQB X-Proofpoint-ORIG-GUID: oVTmzFlSWob157LVeIvGqKVdGTcYWCQB X-Rspam-User: X-Stat-Signature: ikfu5exwmg7bryjys4hdgfo3dfehc8wm X-Rspamd-Queue-Id: 46677140003 X-Rspamd-Server: rspam11 X-HE-Tag: 1723652406-536550 X-HE-Meta: U2FsdGVkX1+8YdvFZFVZ8aGjKqXfT0HCO7OjIaj7XTfi4Sz3Qie0nJCIlqC5yUIgYc7JSstO4GgevuFFQG981FFqrPQc9NPNsvzrorehAhp0HGAcPaDDfS2bYMFV0iQnFJWqnY5CwhGJQtneihBHnQdPkMtFdBpyWOTg05K6x+AFeMm267RllcPRjVjBBd9j2YJvYj44OokUouVxyOPq0OeQOuIi4sAMQKVMybRIs7NUtklRa1ygL79BiSIfx2aQcCMoO+jSY+Q/f3nk+4quzz2iy8s3j3xknP+KvjkQ8N1ECEI0d4pBBWC+VsNOW+l4h5zYUKXrujNxT9N9YmcGIPY7jyXCeGyo+v6cIIc9zouLnmoQymV9VnTsu2Nyo7nnCdZV3rT5IV+iOhSS2FWfXCaKyjDUPenM+/y/oSA2t/yOg7oMggLhZMJ2GZHD/tXVYcMErhB7nvuzf1exnEJ0m4FEtcjYdJNdsjXIL2texoI3su7hbt4dXuYmMiVtvlxvB1iV2vPg6X/L3GSA+SkY608OJzEBrNYe+SEHXs/LV9ACAlsRRxXxbn7AwHgdhpmp0wF+08ov5n/J7w0EcVL4MP559+KgyaSjAoyWZLkZlXWMtlNP6tcgkEDFIz6LElnW6XnuXGbzzC5vCxpX7sAqw/tQDDeYQK9r06z/I/msbDmEBjjNpTajF6efvy21dLls+z6YqKCJJ4FvgsNSXQudCGh7lIKxwSY0Zx94UTl+QcR6SaaTRAwuXnnMFWO4I5NrRuHw8Qxw3MbaYBSXkDb87sPHKZ8RERG4oWsLli5GIQl/IecuenUNcSYIyjpgMf3cYqR/UlOla9FpH8tKp7ptkGMr3JZifW4oDjEXCQDaY/wJWDe3c1rXhnyPItCNt7rErqbUhZMy85NR93ufhDwyIy2XT+ofGywKFUh16ik29uhf3G+5LHLuwX4EjWFAFMK5ZFBgGY0U3Tq1e0Y2pqF wZ+m9ph3 VrtrSrT8/FN3L/B/CWwthD+0gV/jKSVGMT3IBomU4v9ZndnL1As1TzFS3KxVL5UdaBSaOxzjIjnxP6cxcLHBb4gvI7BZqBOovfw8ccNF2zSXiyD7AdcUoHdIFE3VizcF/yoYQnA8drNuzSAW6dTh+MFt7KabwpQnPJs+qrZfGk7d32tLziSxo66MXeEuLAXJRrh6WvD+sq3n/4Op0PnLy7Eu1Pu0QM3GKIptdNeJzphprJsaHjn5X+D1nhXQ/YDcCbtvW 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: List-Subscribe: List-Unsubscribe: By setting the store type in mas_insert(), we no longer need to use mas_wr_modify() to determine the correct store function to use. Instead, set the store type and call mas_wr_store_entry(). Also, pass in the requested gfp flags to mas_insert() so they can be passed to the call to mas_wr_preallocate(). Reviewed-by: Liam R. Howlett Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 2242e07a46dc..bb940f61d713 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4457,26 +4457,24 @@ static inline void *mas_insert(struct ma_state *mas, void *entry) if (wr_mas.content) goto exists; - if (mas_is_none(mas) || mas_is_ptr(mas)) { - mas_store_root(mas, entry); + mas_wr_preallocate(&wr_mas, entry); + if (mas_is_err(mas)) return NULL; - } /* spanning writes always overwrite something */ - if (!mas_wr_walk(&wr_mas)) + if (mas->store_type == wr_spanning_store) goto exists; /* At this point, we are at the leaf node that needs to be altered. */ - wr_mas.offset_end = mas->offset; - wr_mas.end_piv = wr_mas.r_max; - - if (wr_mas.content || (mas->last > wr_mas.r_max)) - goto exists; + if (mas->store_type != wr_new_root && mas->store_type != wr_store_root) { + wr_mas.offset_end = mas->offset; + wr_mas.end_piv = wr_mas.r_max; - if (!entry) - return NULL; + if (wr_mas.content || (mas->last > wr_mas.r_max)) + goto exists; + } - mas_wr_modify(&wr_mas); + mas_wr_store_entry(&wr_mas); return wr_mas.content; exists: From patchwork Wed Aug 14 16:19:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763699 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 134D3C3DA4A for ; Wed, 14 Aug 2024 16:20:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9AF796B0098; Wed, 14 Aug 2024 12:20:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88CC46B009E; Wed, 14 Aug 2024 12:20:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A0B46B0098; Wed, 14 Aug 2024 12:20:07 -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 2C9656B009C for ; Wed, 14 Aug 2024 12:20:07 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 60C0A1A0F29 for ; Wed, 14 Aug 2024 16:20:05 +0000 (UTC) X-FDA: 82451362770.03.321A551 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf22.hostedemail.com (Postfix) with ESMTP id 5FDB2C000B for ; Wed, 14 Aug 2024 16:20:03 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=SJ2szo5b; spf=pass (imf22.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=1723652391; 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=5uQINWFWZQNV6tNI6ezaoBToRmo3e5PavdxTeJelrlY=; b=Wlxv9nAAHrLVTEnrNgkf2mNPV/H42bA1f62yIcYEPocbtNaN6HNHaEzeBOX+M7Mmj6yWOS XdVsqRUFTGJ6lo59sPr3mygUySKL0ZFKuk0kw6/t6VIq7JlDKnwvckPrFErOeK5GBKGNky M6MKP6zWCktat9Yef0JIo68COWJa+AI= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=SJ2szo5b; spf=pass (imf22.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723652391; a=rsa-sha256; cv=none; b=LWG936UbLWIqNf3/U7B1KHqHCABQcjCszag97I7lB4IsCz2cB5Y/FBOn3az36OdnD4tdpO m70/CLJVRxmbQ64ubVHeT2ARY9TPnvjGOlL8VaYTu1dj9Lv4hWTAHUo/ooU/ReP9K8fKEo zfFJiJo+MlYvbdh5FBOfhOeMm0EEUk4= Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtWSQ023329; Wed, 14 Aug 2024 16:19:57 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=5 uQINWFWZQNV6tNI6ezaoBToRmo3e5PavdxTeJelrlY=; b=SJ2szo5bmYygJs7sr vwuNA8ci5Rm2wFJjsyhy1CfhVc+dCEdltUeDABnZL6P0PpUIgIn/hcOHhYTkTQfj 5FVjatKDKcbp3ZtqI6UQgM++ajnqedvkE5YpaGo45DIkw47RkWzeTVoTL00IX2W/ GBJ4vW7F9R04b6V33f5GHCP7S2GNgl5v8gwMyFMgOGXMkHbt3hcd0/VBcZ3OqMdR HfbRbVlla2cB6DrPtM7IxDeruzX9MM8/gLB7CSfCW+5ak4JjPiEw92Ce/u30kkqs dBde/7gaxm/EzGGnsDnsSzwH/HVSPzUD0tDRJFhkxKUQYeH+X8PqGQ/0T+VFcYTS aVMcg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4104gakdt4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:57 +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 47EFrm2f021836; Wed, 14 Aug 2024 16:19:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7r3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:56 +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 47EGIvCI035951; Wed, 14 Aug 2024 16:19:56 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-12; Wed, 14 Aug 2024 16:19:55 +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 Subject: [PATCH v4 11/17] maple_tree: simplify mas_commit_b_node() Date: Wed, 14 Aug 2024 12:19:38 -0400 Message-ID: <20240814161944.55347-12-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-GUID: ilu7tFYRhKBnBl3wIDCZ1J5O7IMopA3I X-Proofpoint-ORIG-GUID: ilu7tFYRhKBnBl3wIDCZ1J5O7IMopA3I X-Rspam-User: X-Stat-Signature: uw6ceog6px5hm5ipy9m5kqbtdudcci9w X-Rspamd-Queue-Id: 5FDB2C000B X-Rspamd-Server: rspam11 X-HE-Tag: 1723652403-90096 X-HE-Meta: U2FsdGVkX18bBeVrWfk8XBlzl8flLRbthVYATlmaSPnpYqNVH949cE287ei8Qliok/mnJ0WniHocv4eHpM7pnNegJIjjTwt0tIQP/6ypkg9x86wvwUTZB12iZfzkmpuH00aroWlDFKfkVr0x1s5TbyGduBV7Xp+8VIOBrhJ3BzhtGPjrPL8IODEZEIX57nd0INMHlLbvy47bokge933KlbZZnwyMavDybj6fDaGj9/rYb+ut6IZUxDqo3uFZVeyPMkBG5E4cT5YgAYvC7lx8WrdCJ25jOKTFb6T3rQMs9t39MsoAkKz2vj5BaCeJIDjrRepYq75Ln3UCeNe/hICQ81uosQ76pz/mzdCUSYvHTnR4C0eZglqMv8qK1nG9I9IUwk4Djarb7++LTGEFcwTgZiVvDTHYci46PPQ3+fRGIrQUP2JQ83Kdu/Y8TTxGamVYxsPs52ab6cWRapHaWogIsEUP8UCrzP9CydIZRKR7T57vh3Gv5iM0Ih2vHkfdLvsUGMam5uM4cspSUo58JG7K8xE6hlDQSnYKFAVzjfjtFVIdcpjecWxOwpABBYKIQGFz1FWgrF6uBpKMusEsdw5ZfoXlk3Xr1vkqH9zHDq5AVzGkJRERpFr/9v4uFpwctfFh263FCE8Hikh/EzpuN6nEGZSh8ebdJGY2hwVGili0V+ePvdzVwhqvJsTZ++2A5u0tFSc64wq3vWwY1Ubw9FNjH4jI56UHT9I2O0pRh1JLmZ4Fx39DCK7o+3qtt8qJKVmgBfR0SBSi6C4+pAWudVafCi9kbMJeh5bAH0jaxV2q919qhALk3m6rZ6e+ZDVmYvdBG4KeOj09TKbPnSEP4GvvyKHiQeyOuUnRaaQD3nF6cmGsPhYh9dJdTqYVgOHaTiQojDR5GqdFkSE+bYoUYJOs/mHZAuzqPWVLq+/nNwLeimJKNXlbSfwP5NSSUrWkcXEGkQa/auZcrdis1BOo7OT UATNdjER NDulfV0zjuJDzaHdB9e+Ir3QmTRRqsDcNnqOcMF5MmszlQ7buP06/oRvBafMIOZSW5iByyC4+ZzvRTnnI7trK38ZdwveEsf4c/6qHDjYvr6rF92G7jICqff/1UE1FBmlhO+Hi3fvIRxhmNRn+C+0WCoNeP8vpTrqFKNrIQAWKUocWireCIE4Y2XWg2gAFmsrlsyDdngqAyYIh6se8rC5+YOl4+NncxBZd25AH87xhaW1xBYFhH/XX36bJ+oqAoew8XMa3wyQ6pIYR59/46YgTpiR0t/VjAZ6+n2Q5kIXnqtCy4AY= 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: List-Subscribe: List-Unsubscribe: The only callers of mas_commit_b_node() are those with store type of wr_rebalance and wr_split_store. Use mas->store_type to dispatch to the correct helper function. This allows the removal of mas_reuse_node() as it is no longer used. Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 64 ++++++------------------------------------------ 1 file changed, 7 insertions(+), 57 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index bb940f61d713..0314e9b52621 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3395,72 +3395,22 @@ static int mas_split(struct ma_state *mas, struct maple_big_node *b_node) return 1; } -/* - * mas_reuse_node() - Reuse the node to store the data. - * @wr_mas: The maple write state - * @bn: The maple big node - * @end: The end of the data. - * - * Will always return false in RCU mode. - * - * Return: True if node was reused, false otherwise. - */ -static inline bool mas_reuse_node(struct ma_wr_state *wr_mas, - struct maple_big_node *bn, unsigned char end) -{ - /* Need to be rcu safe. */ - if (mt_in_rcu(wr_mas->mas->tree)) - return false; - - if (end > bn->b_end) { - int clear = mt_slots[wr_mas->type] - bn->b_end; - - memset(wr_mas->slots + bn->b_end, 0, sizeof(void *) * clear--); - memset(wr_mas->pivots + bn->b_end, 0, sizeof(void *) * clear); - } - mab_mas_cp(bn, 0, bn->b_end, wr_mas->mas, false); - return true; -} - /* * mas_commit_b_node() - Commit the big node into the tree. * @wr_mas: The maple write state * @b_node: The maple big node - * @end: The end of the data. */ static noinline_for_kasan int mas_commit_b_node(struct ma_wr_state *wr_mas, - struct maple_big_node *b_node, unsigned char end) + struct maple_big_node *b_node) { - struct maple_node *node; - struct maple_enode *old_enode; - unsigned char b_end = b_node->b_end; - enum maple_type b_type = b_node->type; - - old_enode = wr_mas->mas->node; - if ((b_end < mt_min_slots[b_type]) && - (!mte_is_root(old_enode)) && - (mas_mt_height(wr_mas->mas) > 1)) - return mas_rebalance(wr_mas->mas, b_node); - - if (b_end >= mt_slots[b_type]) - return mas_split(wr_mas->mas, b_node); + enum store_type type = wr_mas->mas->store_type; - if (mas_reuse_node(wr_mas, b_node, end)) - goto reuse_node; + WARN_ON_ONCE(type != wr_rebalance && type != wr_split_store); - mas_node_count(wr_mas->mas, 1); - if (mas_is_err(wr_mas->mas)) - return 0; + if (type == wr_rebalance) + return mas_rebalance(wr_mas->mas, b_node); - node = mas_pop_node(wr_mas->mas); - node->parent = mas_mn(wr_mas->mas)->parent; - wr_mas->mas->node = mt_mk_node(node, b_type); - mab_mas_cp(b_node, 0, b_end, wr_mas->mas, false); - mas_replace_node(wr_mas->mas, old_enode); -reuse_node: - mas_update_gap(wr_mas->mas); - wr_mas->mas->end = b_end; - return 1; + return mas_split(wr_mas->mas, b_node); } /* @@ -4155,7 +4105,7 @@ static void mas_wr_bnode(struct ma_wr_state *wr_mas) trace_ma_write(__func__, wr_mas->mas, 0, wr_mas->entry); memset(&b_node, 0, sizeof(struct maple_big_node)); mas_store_b_node(wr_mas, &b_node, wr_mas->offset_end); - mas_commit_b_node(wr_mas, &b_node, wr_mas->mas->end); + mas_commit_b_node(wr_mas, &b_node); } static inline void mas_wr_modify(struct ma_wr_state *wr_mas) From patchwork Wed Aug 14 16:19:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763696 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 D4BD3C531DD for ; Wed, 14 Aug 2024 16:20:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C59B36B0093; Wed, 14 Aug 2024 12:20:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C0B186B009A; Wed, 14 Aug 2024 12:20:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A32336B0098; Wed, 14 Aug 2024 12:20:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 88A546B0088 for ; Wed, 14 Aug 2024 12:20:06 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1AA9E1C4A22 for ; Wed, 14 Aug 2024 16:20:05 +0000 (UTC) X-FDA: 82451362812.15.CE6B3F6 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf29.hostedemail.com (Postfix) with ESMTP id 666DC120009 for ; Wed, 14 Aug 2024 16:20:03 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=hEGTWlE3; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf29.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723652391; a=rsa-sha256; cv=none; b=Y5k45RDOFczgr3DOQqmUsXa2W+4QlD31QtCSJ8uEGfJlYO1RO4s5xLPMnK9W/1SkcIhFir bPOxOyPRt16UV4ddEPkJfndxTLSD/4ww4MYaDlf2wmgTSuP32v7f8QRqIbl5qpnbR+RJ9F S7U+vTyLk00ld7tvcoQdl/A8SZAKswE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=hEGTWlE3; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf29.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723652391; 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=lOqX+rCceq/tSGDWm6o1Tnunt1j5x96KRSeMshi7zdM=; b=U7TY2Xgi3NJUI2tLhgrt2KIBQFQ+sOd0PYdm3EyEQOOp8/CGE+x73U1Tt21JGQ2WL1hT6w uYnJlJyyRvqgxdWnHmH4ugm+3QsC9ls6JbpXTNbMAwvdUqUH4gA3YnpwItsTPiiKzDtaH/ Y5/d70gL7mii+RFI7p4Lnn4t9a2FOwQ= Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtWdj023335; Wed, 14 Aug 2024 16:19:58 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=l OqX+rCceq/tSGDWm6o1Tnunt1j5x96KRSeMshi7zdM=; b=hEGTWlE3FUBaaykV9 QBO2pUGH+qBaZaALNI2hRgT7fQMOaUfagEjT36aP2SvGeHjkwjvrLMEDnJydpjeA QTIPUwja6X88b/j+HTKz+hTAmKdGjla8HmsPb/vybHSK7ESgkrGVsX5QHyR2MYjI AXW/6ViUeo0lT98+c+KFaD65EEvPiWUDpgSQjZx30+dPj77h9pUPK9Ninav6gbZS QlMklMSK55xfqoxXgaHAtEIuTj8AEDWjpWwPJv3f5041NSualldCjhefmmOvZnXS n1nBJ628mLnwAZybWFSfmAOT8BCyudU7YGuYqr13C1Y7dQUM/oB3WnYkgD0mLofK QnOkQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4104gakdt5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:57 +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 47EF5PPm021193; Wed, 14 Aug 2024 16:19:57 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7rp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:57 +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 47EGIvCK035951; Wed, 14 Aug 2024 16:19:56 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-13; Wed, 14 Aug 2024 16:19:56 +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 12/17] maple_tree: remove mas_wr_modify() Date: Wed, 14 Aug 2024 12:19:39 -0400 Message-ID: <20240814161944.55347-13-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-GUID: 7bCT3OyQlrF79LGUa3r-rM7oUGHDZ4BB X-Proofpoint-ORIG-GUID: 7bCT3OyQlrF79LGUa3r-rM7oUGHDZ4BB X-Rspam-User: X-Rspamd-Queue-Id: 666DC120009 X-Rspamd-Server: rspam01 X-Stat-Signature: z41dx7z9x4oynso34nq6xag8nnj3pgd1 X-HE-Tag: 1723652403-369693 X-HE-Meta: U2FsdGVkX183j2XOzDhoCzD9QWno9pEXqeCip98rksMcI+RRviJeUdC9KJ13D0uyGXfysw7EOKp2i1whkoZKz1mMAmCwD8aWOgbVTe205I2T5dp8fDdGpiU+jqUVRFOLUUmFEZfUhaGF0NxQk/Tdm+9bkrPj/wc1GygUp1dNY+g/3vHDPg6OjgQiYt9tFZ8eTryRqUzb6/h5aS0x6Vq0UKHLQbBGAwTIMZVtYIIhcyA9RO/tW9zoxqq5bsQI/0SGGyjnUBG5wjNjahLs0fw5HtdqtYPIGIto1GGW3HG1DdnesM+VjMi3Hz4McvmelH4VyJGBz7DCLPkgsHp6zsRdNvGAZTxd12Hp1Z0F1CAr7rtp/O8vlH2WCAjkbZxk0SkJb2tcBJWuvjsclR+5ydmDi032/TH8DGfCO1TY/sqlXmcRNX53fauNkhtek9mGW0j4SF3TyRlb2gDO5qFaHNS0Fm6s+x+Au4AffyzY/+flYZI1Hovaqcco5K/jkW/NiudBoCi18jt3+xfWFIVqxSGTyTHvnYgSHQeW6GdkK4QoOsYWYGq3qQpdpRf/rmLu3f1zRveXrVlEYgp4DCm4PBxMEfk6OmriTU4Q0gpCV+dWPvO6yxVHUnYlsCLOqqGZU3OB/cdwLqkskHr6kF6ZGg4oYbjrpQ8N18OVOlrA+xAce/8dQC/emmVYa+Bc2OObZ+nmQ3Wqn8DjqTmbU+QZMind4ftDkR/k3dgmXNW/ld8YXwvOKVb06rU97xbObmzqpfupd+et9s/sJKOTSZ61RfDDJRQaO9AnS/+yapFIEaBDT/3ce2QcqphgQPBDA00UhWaF390t2V2HpOZEVw6zQXtsu9YTv0QpxJfbpnnz5xGfnctMSjGpPC+KqWEQ1C07kVPJOv1w9OhRRmtHdA1mkX8ztNQFLLnKbJcEUtRGivAR+jUVVuL60CmU5EwOUwdJZfvtH7vNy04rpScxAqyfmKl NjnbThb6 SoK/0GMgb9TqaxD5ChR6s/utqcng3i/GJW1FZ2SQKw7HPz0k0I5e4+h8NZG5J62gAo6woFpYQ8bTl0n0hS7QMw2Eijbw6zpKwaJ7/5Q2SIOZNxiV/WxDxTqFr6LiodU+N+Q1YhIacsAmZgJBRv9LLDD5dMn1gfKGaIWdsXfKTQGDq8orBmFsznLixTnu9NMZG5L7oXGugNY7G9hghPJgmvAnwLyNjQv1Lu0kx6DZ3npodhUNrHlRBvySmTFvYSi3ArY/qEVlqZ5QmlTs= 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: List-Subscribe: List-Unsubscribe: There are no more users of the function, safely remove it. Reviewed-by: Liam R. Howlett Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 0314e9b52621..6640ca775808 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4108,44 +4108,6 @@ static void mas_wr_bnode(struct ma_wr_state *wr_mas) mas_commit_b_node(wr_mas, &b_node); } -static inline void mas_wr_modify(struct ma_wr_state *wr_mas) -{ - struct ma_state *mas = wr_mas->mas; - unsigned char new_end; - - /* Direct replacement */ - if (wr_mas->r_min == mas->index && wr_mas->r_max == mas->last) { - rcu_assign_pointer(wr_mas->slots[mas->offset], wr_mas->entry); - if (!!wr_mas->entry ^ !!wr_mas->content) - mas_update_gap(mas); - return; - } - - /* - * new_end exceeds the size of the maple node and cannot enter the fast - * path. - */ - new_end = mas_wr_new_end(wr_mas); - if (new_end >= mt_slots[wr_mas->type]) - goto slow_path; - - /* Attempt to append */ - if (mas_wr_append(wr_mas, new_end)) - return; - - if (new_end == mas->end && mas_wr_slot_store(wr_mas)) - return; - - if (mas_wr_node_store(wr_mas, new_end)) - return; - - if (mas_is_err(mas)) - return; - -slow_path: - mas_wr_bnode(wr_mas); -} - /* * mas_wr_store_entry() - Internal call to store a value * @mas: The maple state From patchwork Wed Aug 14 16:19:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763707 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 2BEA0C3DA4A for ; Wed, 14 Aug 2024 16:20:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 900F56B00A4; Wed, 14 Aug 2024 12:20:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74E9E6B00A5; Wed, 14 Aug 2024 12:20:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EDC86B00A6; Wed, 14 Aug 2024 12:20:12 -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 380966B00A4 for ; Wed, 14 Aug 2024 12:20:12 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id ACA0D1610EF for ; Wed, 14 Aug 2024 16:20:10 +0000 (UTC) X-FDA: 82451362980.07.335F6B1 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf27.hostedemail.com (Postfix) with ESMTP id 8C88540012 for ; Wed, 14 Aug 2024 16:20:08 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mPpvf9Vl; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf27.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723652396; a=rsa-sha256; cv=none; b=Qz6S8QgyGrp3/KJ4GkRK8WiE0b2ATn94Ax4p3tbYnVj+nRexQFnbowdUaTYrptkVPixFzo g0//j4yQMRcyKyysKj76cRXotcNXUYUy0lXH2BBElv7eLWXBby5x0t8hoSmlBVtFQiGke+ eHca5jAOAlOEDIO7/aGp19HgaBwNwAY= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mPpvf9Vl; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf27.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723652396; 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=JU3MqvLejtF8so20hIcXMrVIJrbiyTBFwoucx2atG8c=; b=ejw2GGTGPUTCp0vD48KpcAoVVhJT+tAF5VTW4sbZqbsBGyuluN+llplFw1eE8VnWbFoisB StJL1cFHnTe7pqeyS7YPKtVDcvp27LeDcLCXdI4eeOM6WGJOujQsl792CHXNFxFhIUfwVG 1N0xGJ6jXei2JkQJ0YRv7iXjgz+Hh74= Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtWAu015137; Wed, 14 Aug 2024 16:19:58 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=J U3MqvLejtF8so20hIcXMrVIJrbiyTBFwoucx2atG8c=; b=mPpvf9Vl7mi+SK9ak g8xRjjdemhfyKdIX9++Pje+cowzRNYPv69qLf+lhPmswetGAPmywA94Id71fp6Qy 0iU8aO0zPpYkqZyyeqWGQpWTgfHo4IJNzChyUMQT7xqcGXxeNwRUGYWNDqK4ycp6 ckS9nCQkSiQXU+mz7fkJmyARzi9oRLlUeADEFxDHWZ6aayG5XifxaF6SCCjbwOSc OFN+BdlaWQXnNuYfAOpVnNNe4hOPJ3eYCcF00TuzdTs8TjTOcnpWC1J48wAYSSSE TUeW3E9oh0v7o4v/dABXZg+SCtgIixW4D7Gn2DjlZJ1EtCbR0garOcAatdLbuQeU IVjPA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wy030v8x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:58 +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 47EFoG8d021115; 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 40wxngn7s9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:57 +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 47EGIvCM035951; Wed, 14 Aug 2024 16:19:57 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-14; Wed, 14 Aug 2024 16:19:57 +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 13/17] maple_tree: have mas_store() allocate nodes if needed Date: Wed, 14 Aug 2024 12:19:40 -0400 Message-ID: <20240814161944.55347-14-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-GUID: v3cAlC_zKdtNYKss_wgLLRbQp1Xvee2n X-Proofpoint-ORIG-GUID: v3cAlC_zKdtNYKss_wgLLRbQp1Xvee2n X-Rspam-User: X-Rspamd-Queue-Id: 8C88540012 X-Rspamd-Server: rspam01 X-Stat-Signature: h61qc5njesgnxuwqposz4ea76s5zgozn X-HE-Tag: 1723652408-718381 X-HE-Meta: U2FsdGVkX19qF/QOfUw63L+dEY9JOw4lKne/HthL6vKL/Jtw8mfgx/SqsvKwIp1gDvxYlz2uEobySHp//K3XFvqqFehUv5JtVmSa1InARYy92yq3IgkLmXLDslbev4oZFO973ei0J1z84GXmCLqM3j3EqAShbnkNIws/onXjeb1gtmPW274WJ7zdBeatLypEvykw+KRfPfa5B2/KVdKEBgON0yWdCxAS6INpR6mUJVabr68f9EQbJGzmQlMdK4PfxPnXjl6qn81nVgzVUZrtNvxJix+yUkjyxm6CaP5j3Su+KbXXYSJTlb6uc3SiK3FBOI3DibDDzkERfDE3nQ5hit5m2bEA0JHQIb4y2JuKGon0fLP+GZiIZ77gfjujzwldrp9a4qiU50mi92k6YJPfmsUyOzbswaegnepRDt+9IDZcH9wytKAWaGVZOdRzXMV0MoP7dSwTP9FpILdyQA/Kt/4WOOFvj1nIM4hFWXqv0t8/a4pE1dzqviSozCoh9UVycOFby4N5ovP28znluLVhDFSZSokFb+EivgpQxAPvDXOciDsMAbxJ8YJlFAR1tMrsVOxLcujI8/mh8J//QIoJxBGDRcIlnSo9EtaywshwpP9/wDGaRT1Vnxu+hD027TRkkBrBy1rwMMoUnLe6WENHNgpSzk9elJFk3NglEc0wk8P5gne0l+icCEN5unbE9jyoSa9SMitPr/qUUrZ3rflFSr1kVRyo8dh61b7NvowlGaGry1NuybYinPsAHZVvgRh5AbXqwNKsrTXCFWuwyZQcu3jicoU+Uny5ZfNyVVdAS24FRhlspUYOt3n+mHUhDuL1N56zkUI37zlQZZ/6RuPQLsqDwzQ8QGSusUFkoWyaDA2Xj5kT63WqzZa0zreipMdfPlmMA7KthiScf/OOo0XsAOhMFD0NNBQN8SGMcbxB1vNEQVDTgrzhDRVUQopujiZ+oXr4DKvMjz7zargLQjS tV1FlT/2 aEqh+JNuupzCsPt+5g4NAFY+9dWAGGHxK6B5jPSTwQEl00oUMn1lU2LYK8CqXlu4lXZq9nNf/RT6gGPCGQ3Hpv9d6/OPj0wEh6DVCiCtELaArYR0obN8M2xCKjTI6YGOgGSPAyJQzWQangOsR5Y9Z1TgVOXZy8X5QxuPBATpVtg9fCDIsLxdHvYjIz18IwrqnZz7A2SC10WmF6EvchcJdZadFBfZindVf2NDQ+voGPhaIWTRMaoRRy4JTeCiwK8uhHGm5EVJi6l1DFGTBGGvbTFzk4g== 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: List-Subscribe: List-Unsubscribe: Not all users of mas_store() enter with nodes already preallocated. Check for the MA_STATE_PREALLOC flag to decide whether to preallocate nodes within mas_store() rather than relying on future write helper functions to perform the allocations. This allows the write helper functions to be simplified as they do not have to do checks to make sure there are enough allocated nodes to perform the write. Reviewed-by: Liam R. Howlett Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 6640ca775808..d5e020dd93fa 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5477,13 +5477,12 @@ static inline void mte_destroy_walk(struct maple_enode *enode, * @entry: The entry to store. * * The @mas->index and @mas->last is used to set the range for the @entry. - * Note: The @mas should have pre-allocated entries to ensure there is memory to - * store the entry. Please see mas_expected_entries()/mas_destroy() for more details. * * Return: the first entry between mas->index and mas->last or %NULL. */ void *mas_store(struct ma_state *mas, void *entry) { + int request; MA_WR_STATE(wr_mas, mas, entry); trace_ma_write(__func__, mas, 0, entry); @@ -5506,7 +5505,23 @@ void *mas_store(struct ma_state *mas, void *entry) */ mas_wr_prealloc_setup(&wr_mas); mas_wr_store_type(&wr_mas); + if (mas->mas_flags & MA_STATE_PREALLOC) { + mas_wr_store_entry(&wr_mas); + MAS_WR_BUG_ON(&wr_mas, mas_is_err(mas)); + return wr_mas.content; + } + + request = mas_prealloc_calc(mas, entry); + if (!request) + goto store; + + mas_node_count(mas, request); + if (mas_is_err(mas)) + return NULL; + +store: mas_wr_store_entry(&wr_mas); + mas_destroy(mas); return wr_mas.content; } EXPORT_SYMBOL_GPL(mas_store); 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+Ch70pl57uFzgynVSfy9LirYAjAKU62ayjhxSXnzVBJ784lv1m2DeLQ6KnWfd8TUi3K49ECp9kPCEyEpUB9Ae7Ocng8oImT5UDkXRIw3dkDK+B8ShxoUbtm8DC6jx5iEKSb0sKBWVClb6ntMpZ5xGizhsyvNY8LhkpHEBHpOPYGsFB1Q4rXPU4OK/YhPy+xnszRxCQAkFTCJH5v+yQCKcoD1KyChvMz/MrqjCw+7S2OC1WlWeka0SL+1RVD+0tTmYggZAXGegMSLKuhfD5UK13ta3wS+bnl9yiKRyASAy/Bbo9y0DGdHtGFAyGSQ7UxylMMOH0XwC3Dz5Wb7dAwb7wQ9fczVqaomNzogqj+I4bb1kEsM7tIgVzvDhXaaPPFXxuYJ/AWFgTJzHQOJdH9ruQD7K4QnNzoNMZuXzPDwmn299++C6kcl8usjC8PBXN0Qrf28/RirTk0M8IYWs34ponYxb4+4Dqpo6MyT0BYHz4yrwTsL9ftH125HI0RGv02ZUVxHKjCw8NFZBxBXQe9nzHUE6klw5yL+4neYuswhevqbsT5bNEhInjrBRkRcursPSWGtbsktZnWsABx+2OTAjIIutJ6KnVCrouesMuT9JFN7P5DsD/JTwIXnZ699P/TfscABo+WOFhcpVFfMVOA8z2LAaODdLqG1oCYKDwXdu9GHirMgCglYgYQxJFE6oyxbUdhDkRemtSy3huMyzHWN2ys0xO8N/X91qAdYCct6Q36/xLGIEDFD+I6c2wL8aFw06E/mDyjGD3+Bc26mNAxfp7u068HDEvGas AMBpT/GB DuLH0s+PWEX/0lYb1DmhhC/BcLm39+unVBB5B0dM4NS3/IVSzC88/bggyTY59MVgZGQL+gAHIWRDtx9uLrE3ThzSixxBgoEdWvVqwPR/G+PeOOXrukM5PcKhGwMh3dtJanRsmD9KCv7mmI4hp7mw0lrKz94dYt4PkJtHiLrnxOhzAInOWfWd0JdsIYoyDZXdwR4UNsFUrDYSr9G0vOhDNx8mzX17wRXECt3vrrkHcPoj89Sczn7NU3b2/r4LvL/ZZfN0SA+BWMjPx2KY= 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: 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)); From patchwork Wed Aug 14 16:19:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763708 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 D1C68C52D7B for ; Wed, 14 Aug 2024 16:20:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3575C6B00A5; Wed, 14 Aug 2024 12:20:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 330756B00A7; Wed, 14 Aug 2024 12:20:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A7C66B00A8; Wed, 14 Aug 2024 12:20:13 -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 EF2D66B00A5 for ; Wed, 14 Aug 2024 12:20:12 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9258B1410A0 for ; Wed, 14 Aug 2024 16:20:11 +0000 (UTC) X-FDA: 82451363022.30.E98D72D Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf09.hostedemail.com (Postfix) with ESMTP id D36E714003D for ; Wed, 14 Aug 2024 16:20:08 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=loFM2EoE; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf09.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723652355; a=rsa-sha256; cv=none; b=wGaSwhZ9H6xTCOw5g4gHA60RwWkeS3xy5i7t08VG2bpxf7woGcgSC+oY6cHTHKjj9mZolJ /OsX0XOFy9nCTIqMlA5Us87kHJeIhJUepYf+tDyzlqLyIDhdJWw4BXxVPGYLQ2ZGq9WmRu ozMpBXmt6HaQbGhwcHsNSTM3aS7oFIY= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=loFM2EoE; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf09.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723652355; 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=ojgvkVfomFPmyla9upDrqtBp4pUg5X73oMV30GnXzGs=; b=YFUXRQoMLLDuRHlwxyT9h2452kWaEz8T+tsUTI/b8vUk2PQtfFK6lgdwHkdxejOI/5BAz9 NmIxt8nyGJ7PutcQmH3UHbc8GVOxAJJGwr19Duz1DiZxcISxThOpyrayK/wRPdHFF7RDuy 19CQ0YQquFxfEQJ2VIsWp7QHPtzl5II= Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtcB3006144; 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=o jgvkVfomFPmyla9upDrqtBp4pUg5X73oMV30GnXzGs=; b=loFM2EoEus7A6VxsC HhRGiBXieoRciWl2FxqxJ4XUp7WSIQycNsvNGmTK4bhzG6AdaBKnk/nI4v+n8L0f r7W/rvkzpHrzdT98NoK1n2mLH6BqkAExXFs/1GkoVTYLLAdjYLP3ISHPG7Q6bhR8 uR+X2CUTjoH3Wj8JwAXdqNgbeMh3FY23COdEts49GVtrHJIgaDkkWbTmyHdWOMRD PtoC4h0zXzvQQy9IXxqvsolqBM640uka4DMP+GmZPBjd/kQ3iA4cLiqibR+4mxci YJmQ7N3zrNp5lk/0Lu7cfLFvWDkI7xc+yGSfevZIMNVGqVKzTLuTquzzn9CBQ9SW tu3zQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wy4bguba-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 47EG72um021274; Wed, 14 Aug 2024 16:19:59 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7ts-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:19:59 +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 47EGIvCQ035951; 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-16; 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 Subject: [PATCH v4 15/17] maple_tree: remove repeated sanity checks from write helper functions Date: Wed, 14 Aug 2024 12:19:42 -0400 Message-ID: <20240814161944.55347-16-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-GUID: ZCBd3Df6Kl7Nj28ZCgCzu7Yk76nJyfKX X-Proofpoint-ORIG-GUID: ZCBd3Df6Kl7Nj28ZCgCzu7Yk76nJyfKX X-Rspamd-Queue-Id: D36E714003D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 9jc5hrttqx9e9dgzj9i4kwt6wgnnryru X-HE-Tag: 1723652408-554952 X-HE-Meta: U2FsdGVkX188vhZvD/fJJLT2/gPcbuENMWIY9fEjaOe7G2mm1HrYQrCKgACGZbDlrJFUBBci3htSmg/L1RmTM/TEsTVNWxswaIzU4zCYL9oRelR+b4POk+qjWdrjCsmFb1o8++/c/gB7fupNriUiDWpoMHuIae4PtsMkd1v24ZPRq2uPVHIhyxrtVnY1sW+vrSGaomKEfKig0KikCFlu3/xVN3MgueguBqsAZidkinlG9k11Jd9oksKs9c/uX5RenpwN+XK59bfj/VUfwDj4wvVsrkoxZieJ932AzoVtJX6L4kx/m/Elzv5toIAJjmD0tPaAWw1iIOoZHw1EpfM+iLvWFqSxsUdwZlr2hotUU9J8rmRseIt3ii44ZfdAzfXOchKk8OezIrzHk3GGrZ1gO1N3PI/ZG1HK5szauJlrJFpEesP5HyWqhfKWTu++7An2LZJHmAbcC287Yr2BpsWvmj1daICden1YEJZlITxfeFcypEdHIkfXEoZ29Aqekz6kXXkri7czjT+pJ/dsJ0S0+lYjwaiJ0NbaK14aw0vNv/b8H9BmujOhsaGr233BZOXZhCDXgPuPnJYeAEs5WoxhJlxIMtR9FFFUd8wRZfSlGi4KU5Wy4FD4ZwKvt9QY8LtJy0lhrSsp8/fnUwgFbyu9D4i7gbTFPzxAJp1WIf4GobVrjlqle4YU4RWXT4hoP5/lsPa8n+xAcIqm8qL/H1nvZyajHQ2eQRa4JfleDAw5uC78OPs8GH3FfLtSJK4rbJIYSiPe1qEPd9BdUn5q8k552+DgFhDC8notuhAwYxSf+HNaQDt2WFbifjPbNJMcjMjqNsc9VLWFe3bFVxzMGQiUm9KUVE41IrAvT0Yc88x7UItr1BgsO2ceKqffRoLRlPafQ7V/vbxrK0hJBU2maS8AncMrhQx4hp3U5W4Wd4MB8gChmz/HLvMgxSAeszEaEkUd+fAlCcQ4tL++eRHnmXg wVuvF48V 7vhCZoLXVPBeYwV2sH4aHe0pnpM7w8VzstEEEv1qvgBVJtmavsLKpJJ0p+VbLesRRC2cjjUYNxrbyZDYXjYya8kZwJUcDZIMUS0wYSzafydQ7bk0UDRC8385z0ceQ5MilFe4M5m5PtrPQm0bln7atCl/BS656qxW8oBItTOvICRhqw/J8V23y5VVRPJT/ot9JoOBAegYdTdRurjrPDbAKC0eq4TRFMxywTfiOwdXzqm88/PKckPMBpb0b66f5g1D95iMcvsfqTXi3/B0= 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: List-Subscribe: List-Unsubscribe: These sanity checks are now redundant as they are already checked in mas_wr_store_type(). We can remove them from mas_wr_append() and mas_wr_node_store(). Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 5f79be184377..8c1a1a483395 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3816,11 +3816,6 @@ static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas, unsigned char copy_size, node_pivots = mt_pivots[wr_mas->type]; bool in_rcu = mt_in_rcu(mas->tree); - /* Check if there is enough data. The room is enough. */ - if (!mte_is_root(mas->node) && (new_end < mt_min_slots[wr_mas->type]) && - !(mas->mas_flags & MA_STATE_BULK)) - return false; - if (mas->last == wr_mas->end_piv) offset_end++; /* don't copy this offset */ else if (unlikely(wr_mas->r_max == ULONG_MAX)) @@ -4018,17 +4013,9 @@ static inline unsigned char mas_wr_new_end(struct ma_wr_state *wr_mas) static inline bool mas_wr_append(struct ma_wr_state *wr_mas, unsigned char new_end) { - struct ma_state *mas; + struct ma_state *mas = wr_mas->mas; void __rcu **slots; - unsigned char end; - - mas = wr_mas->mas; - if (mt_in_rcu(mas->tree)) - return false; - - end = mas->end; - if (mas->offset != end) - return false; + unsigned char end = mas->end; if (new_end < mt_pivots[wr_mas->type]) { wr_mas->pivots[new_end] = wr_mas->pivots[end]; 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/vyo8tRsNQANyWPTltmWOpp/Xw4Kgo+zflaIj5cTPEuyvJhNF52YR6Z6eDDB3ZWsLWRDtlss/rTxN9oqhS4FzVEOsWm6UHUX3dVL+gO9WEdqKIHpIVBBKupYel/7tAasLHnb67dHNUfA5N6aqxIrVwess/DKdthSsMZlmoe0VbYnwpZSJVEECZy1M6UpBTMn4WLAaEiHnwvDxNxfCjKmN0eZI8TBe+fHmXD1XuDuqUDiQgVbCwzCuky6KVRJ6N8FQJRVcylbdsFhNVrYZJjiNZ06AN9x8MPjXxe9dQjGj3/IyHRkGdl4iKQ3YeEpMdAIfd+OMRwpQv577soy/6W8/eYSeQ5szoo+9z3xiZt8lZS2UOP2icm806cFi/RioWhqz2GEM0hAP1Qu53MPj1sWpB5zWWEk9xjdErIXlK2UFdXbcRwd2FU4hybZTrfDk0Vin07d3jUUT4H232U5cqraa16OLqz4qEzrKNcvplz99J+Ui1sh8hAJwXQsGu/HLilfZ6fqerQ6RG4DvhIP4gxWsS3Vp/L/uZ2J784GjOsMpJGcLienVY23IjrpQtpGV2Yw+jivGoupHQjEvX6U2lZ5OYVyITTZv5h5XqTgDxPeFS3bEWqfA1t1OhqKgKzSlyOem0GEva/EWRgkbibTABMCwGC13drrGTzf5A/7vvDa9YvkKWpHXpXSJ+BYDAoC9cG7UAtheYF0IQbYw65rlx353FpCZS6vT5mp0YuppC32pdEDyQKCMc0sm7oJ/MYaXrYJZzosN1lTMY9Y/pyNygdW/wTXplM9d7Z TWQbNTI0 bh/esItV1ivoqzwYaY4fonqEsErzbbo5HPTrU/3YPQBU1NbgjV4GXtcyQt0Vuri+iJAM6zPx+CCrENLiIPpRbgRJNbCoG+URYQ6PKaG+VSBrLg9uqj1ScB5qyC9n6YooD50f79IUln4d8k6eTCEefuhzzahA2xKRG7XIpxwTlLvEbr3ESmxL7geNwrrx9ExesWqddF94mw3iUxQPx5lfdJISSHuQgbAKgcueOx09+dG0T3jF1ucmmLC86pp78pKCbZKTI 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: 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)); From patchwork Wed Aug 14 16:19:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13763704 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 67FF1C52D7B for ; Wed, 14 Aug 2024 16:20:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 553CD6B00A0; Wed, 14 Aug 2024 12:20:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DB986B00A2; Wed, 14 Aug 2024 12:20:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26B7B6B00A4; Wed, 14 Aug 2024 12:20:10 -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 F26D06B00A0 for ; Wed, 14 Aug 2024 12:20:09 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 94C4C1210A0 for ; Wed, 14 Aug 2024 16:20:08 +0000 (UTC) X-FDA: 82451362896.01.626BA33 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf15.hostedemail.com (Postfix) with ESMTP id 6A9F3A000D for ; Wed, 14 Aug 2024 16:20:05 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=a7lxwfgN; spf=pass (imf15.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=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=FHexjyU3Q15ZZbT4MhKAGdpth4Y64xmG6/MK3RLc4O0=; b=bPwmM2Hf3O7WPqmlHCNx0cL7yQK4GlJ/Kk4N57tvMnoeeso9ypFSSRLSRO19ZEc7pZqoFW QEAhVA4WSLXe9WLSvVJIfAPt6BSHZXAEH5UczSmOoiIXW0OKKY8Kh5g6DcDSuxcM5GIcvl mnzfuwMOBFPX4K87swJvikOpj1bY31Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723652334; a=rsa-sha256; cv=none; b=RB3CbOSLJyaZ2kgqbPWcbZddW94yjEMMVJKZu1lpPpMN4jTHAaVK2XxH1tinkieEdCDVPi 4UpVLiKL8ztFSsDhyWRhjoyyml80OQx1H82XX1Dz5Q6uiwRoKRMkFHpudRj6MuaTN2AOzD Jrxso3RbpelubazCiRCrnoYtC9+NZgU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=a7lxwfgN; spf=pass (imf15.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 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EBtZhl007009; Wed, 14 Aug 2024 16:20:02 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=F HexjyU3Q15ZZbT4MhKAGdpth4Y64xmG6/MK3RLc4O0=; b=a7lxwfgNnDjsTO2gi IiCC/TcYUHc2YOJ8zWsjMKJ1A1iFYEW093yfx7NmkTpBz5e2G2lDRGZK8eeMktnb OXw4iDwouF/aigblf0/WQJL2V+A/RKYBbUPqx13+QbOt4p/jgM195LagvFNWdUOt DP1QH6KooEKv7ghiTtoiN4rEUEAuoSwES2aj0u4XLFVY9mrHjKOtQiSjXEKMy/C7 +u3E5ZGK7mopLYbYnLgp5gCTWi0JPacZTIcPhijjfXExtZjRBMMwDtRIqNmjj3wZ ZfcYN0lkH0QsQ8EFepGI4Ew3TyuCQwgvOkjrCuieVrWTsg2nxKtIngsekmmOod2a HR7uQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40x0398m0t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2024 16:20:02 +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 47EGJ2Cv021157; Wed, 14 Aug 2024 16:20:01 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxngn7vb-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 47EGIvCU035951; Wed, 14 Aug 2024 16:20:00 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-18; Wed, 14 Aug 2024 16:20:00 +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 Subject: [PATCH v4 17/17] maple_tree: make write helper functions void Date: Wed, 14 Aug 2024 12:19:44 -0400 Message-ID: <20240814161944.55347-18-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: l7t_v_9i3qSLTKN8Pp53EdLjA9dyzh5O X-Proofpoint-GUID: l7t_v_9i3qSLTKN8Pp53EdLjA9dyzh5O X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6A9F3A000D X-Stat-Signature: akpstir5kr7zgy8gi333t95uxeh34mn1 X-HE-Tag: 1723652405-320265 X-HE-Meta: U2FsdGVkX19Oh4fwuTagyTIu/uaoiCNSH3WmhwgpfvvlIv1J7HdkvlC1JSOd3+IsIvDYJ9ij0b43CKS2bTMpWN3NqwVOVdMl0okd7NQSt0miNUwP1KSaP+MBVGKWmQa/l9T/PPzDmWkpS61XXsdJad5hqR404MpPk9lyCSjwYF5p2wb4hle7uwvgmdKHe9B8anRe5vuJCB9sHb/dIv+6LErzj6xtZQ4i7Bq3TTD+BN08l6zQGBSyuvrJpPmmAuLiUGvL5XJVLHrvaARThthXwk/dVDm12vD1UfJJXxAksfq+u7DyoNwf7xTFN9i+F9np4/rsQdlHP76PE48F66qHrSSURHrgmpjOCY/cw9eOPfU380+Bie7/SDQecXNUQMLCKwmZAx6RZeePH/ovFqy7jdTUC2xVNK8jEe5252K69ZHEZWh5l49Nb6dfhhwzRZvb5MCoKzPuhrDWxtVRpz4qbAiyAvwhEcc0aha6pIHitjkMY4oIW540yv6zrff2+172oijnE530729g3mTcGrKTtflcTZX3Mto60ibSbuYu75mHwbyJ9QhyOCUkYnboEpyo8maD9FAFAwCCjlnx9jsNl59MzHq40X8EnWMIwDEVw2gJN446/sV38QYM/t8CgP2pHc4NoU/2hgVomRp1mhVZctzqYTogA7F9ItX3J7Ja88Bh0ZikBawuHkiqeZVUzo7VFc6KwwV3do2rBSrpAdl5pBcEHl2LI/CIjx3Gb1Uw5Kfihle0IKNph7c8EMO3lJXhfga5C4C3au9mJJVGvwK69XVq06K+3C5qjMkTzDYK/uar+aUtjFlZaGApHB2iC43yx6gXQAzhlEPwb+iTzbpE9dkGhOZayL5Gcvj/Xjfp2KVN93MG1niH6tKor4+PjIbsEbFYDIZmeaJAu5pcoxJY6Mc4b/kTsEXQxhvtLHAQiwUY29hte1zPhxmF9FNm4cAo43sFUFkJZ5kIZvWx/Lt Zh010hMy jDaE3A0fX0OfWVFpXk4mMSOVRrCc54iSVrXwl7DlbKL1USeBcBCzuvZ7k1zzzKWtn9IRrKDERZYKasw+/WIm58gg78GsvEjD1lOlyDsscRkIUtgMFxdzyFrCcvHM/UKmuXmNAnbGOwT86APcShW+oq9g58yYj8AuPe+u+ROF+loq7+gHM7JfS9ljMGD0a09/XXJ+TfZxagLe53dLBJWc4/alsF2Ao/aCp39N7zlr3vWSlWBWt/7khR7n5qHwtur7ExqRLRpYjmxEu4RY= 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: List-Subscribe: List-Unsubscribe: The return value of various write helper functions are not checked. We can safely change the return type of these functions to be void. Signed-off-by: Sidhartha Kumar --- lib/maple_tree.c | 47 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 73ce63d9c3a0..755ba8b18e14 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -2823,10 +2823,8 @@ static inline void *mtree_range_walk(struct ma_state *mas) * orig_l_mas->last is used in mas_consume to find the slots that will need to * be either freed or destroyed. orig_l_mas->depth keeps track of the height of * the new sub-tree in case the sub-tree becomes the full tree. - * - * Return: the number of elements in b_node during the last loop. */ -static int mas_spanning_rebalance(struct ma_state *mas, +static void mas_spanning_rebalance(struct ma_state *mas, struct maple_subtree_state *mast, unsigned char count) { unsigned char split, mid_split; @@ -2942,7 +2940,7 @@ static int mas_spanning_rebalance(struct ma_state *mas, mas->offset = l_mas.offset; mas_wmb_replace(mas, old_enode); mtree_range_walk(mas); - return mast->bn->b_end; + return; } /* @@ -2952,10 +2950,8 @@ static int mas_spanning_rebalance(struct ma_state *mas, * * Rebalance two nodes into a single node or two new nodes that are sufficient. * Continue upwards until tree is sufficient. - * - * Return: the number of elements in b_node during the last loop. */ -static inline int mas_rebalance(struct ma_state *mas, +static inline void mas_rebalance(struct ma_state *mas, struct maple_big_node *b_node) { char empty_count = mas_mt_height(mas); @@ -3300,9 +3296,8 @@ static inline bool mas_push_data(struct ma_state *mas, int height, * mas_split() - Split data that is too big for one node into two. * @mas: The maple state * @b_node: The maple big node - * Return: 1 on success, 0 on failure. */ -static int mas_split(struct ma_state *mas, struct maple_big_node *b_node) +static void mas_split(struct ma_state *mas, struct maple_big_node *b_node) { struct maple_subtree_state mast; int height = 0; @@ -3380,7 +3375,7 @@ static int mas_split(struct ma_state *mas, struct maple_big_node *b_node) mas->node = l_mas.node; mas_wmb_replace(mas, old); mtree_range_walk(mas); - return 1; + return; } /* @@ -3388,7 +3383,7 @@ static int mas_split(struct ma_state *mas, struct maple_big_node *b_node) * @wr_mas: The maple write state * @b_node: The maple big node */ -static noinline_for_kasan int mas_commit_b_node(struct ma_wr_state *wr_mas, +static noinline_for_kasan void mas_commit_b_node(struct ma_wr_state *wr_mas, struct maple_big_node *b_node) { enum store_type type = wr_mas->mas->store_type; @@ -3664,10 +3659,8 @@ static void mte_destroy_walk(struct maple_enode *, struct maple_tree *); * @entry: The entry to store. * * Only valid when the index == 0 and the last == ULONG_MAX - * - * Return 0 on error, 1 on success. */ -static inline int mas_new_root(struct ma_state *mas, void *entry) +static inline void mas_new_root(struct ma_state *mas, void *entry) { struct maple_enode *root = mas_root_locked(mas); enum maple_type type = maple_leaf_64; @@ -3699,7 +3692,7 @@ static inline int mas_new_root(struct ma_state *mas, void *entry) if (xa_is_node(root)) mte_destroy_walk(root, mas->tree); - return 1; + return; } /* * mas_wr_spanning_store() - Create a subtree with the store operation completed @@ -3707,10 +3700,8 @@ static inline int mas_new_root(struct ma_state *mas, void *entry) * Note that mas is expected to point to the node which caused the store to * span. * @wr_mas: The maple write state - * - * Return: 0 on error, positive on success. */ -static noinline int mas_wr_spanning_store(struct ma_wr_state *wr_mas) +static noinline void mas_wr_spanning_store(struct ma_wr_state *wr_mas) { struct maple_subtree_state mast; struct maple_big_node b_node; @@ -3802,10 +3793,8 @@ static noinline int mas_wr_spanning_store(struct ma_wr_state *wr_mas) * @wr_mas: The maple write state * * Attempts to reuse the node, but may allocate. - * - * Return: True if stored, false otherwise */ -static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas, +static inline void mas_wr_node_store(struct ma_wr_state *wr_mas, unsigned char new_end) { struct ma_state *mas = wr_mas->mas; @@ -3878,16 +3867,14 @@ static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas, trace_ma_write(__func__, mas, 0, wr_mas->entry); mas_update_gap(mas); mas->end = new_end; - return true; + return; } /* * mas_wr_slot_store: Attempt to store a value in a slot. * @wr_mas: the maple write state - * - * Return: True if stored, false otherwise */ -static inline bool mas_wr_slot_store(struct ma_wr_state *wr_mas) +static inline void mas_wr_slot_store(struct ma_wr_state *wr_mas) { struct ma_state *mas = wr_mas->mas; unsigned char offset = mas->offset; @@ -3919,7 +3906,7 @@ static inline bool mas_wr_slot_store(struct ma_wr_state *wr_mas) wr_mas->pivots[offset + 1] = mas->last; mas->offset++; /* Keep mas accurate. */ } else { - return false; + return; } trace_ma_write(__func__, mas, 0, wr_mas->entry); @@ -3930,7 +3917,7 @@ static inline bool mas_wr_slot_store(struct ma_wr_state *wr_mas) if (!wr_mas->entry || gap) mas_update_gap(mas); - return true; + return; } static inline void mas_wr_extend_null(struct ma_wr_state *wr_mas) @@ -4004,10 +3991,8 @@ static inline unsigned char mas_wr_new_end(struct ma_wr_state *wr_mas) * This is currently unsafe in rcu mode since the end of the node may be cached * by readers while the node contents may be updated which could result in * inaccurate information. - * - * Return: True if appended, false otherwise */ -static inline bool mas_wr_append(struct ma_wr_state *wr_mas, +static inline void mas_wr_append(struct ma_wr_state *wr_mas, unsigned char new_end) { struct ma_state *mas = wr_mas->mas; @@ -4046,7 +4031,7 @@ static inline bool mas_wr_append(struct ma_wr_state *wr_mas, mas->end = new_end; trace_ma_write(__func__, mas, new_end, wr_mas->entry); - return true; + return; } /*