From patchwork Wed Nov 27 01:27:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13886480 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 2DB41D66BA3 for ; Wed, 27 Nov 2024 01:28:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 335956B009B; Tue, 26 Nov 2024 20:28:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 26EC66B009C; Tue, 26 Nov 2024 20:28:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BF976B009D; Tue, 26 Nov 2024 20:28:48 -0500 (EST) 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 D8AC96B009B for ; Tue, 26 Nov 2024 20:28:47 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 960B5AEE58 for ; Wed, 27 Nov 2024 01:28:47 +0000 (UTC) X-FDA: 82830140484.25.2605B65 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by imf15.hostedemail.com (Postfix) with ESMTP id 859E1A0012 for ; Wed, 27 Nov 2024 01:28:40 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DLv0VkYg; spf=pass (imf15.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.128.45 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732670920; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=yGoWvxrLajb7hyVvYTveK2TYJgb5VqgBn1tgaQwG1Hc=; b=Ih6ZYCPFOdfeultJOKDvN8NS91UaqBJB3Nr7JtF2ODVsZp6jKeCt/eR1n9Gzz/vSyesfD0 z71Ki8RRMroWwzRERIVa7O+s7DRfTq7xXlqWIfQ7BD4DI292S4GkxuPJzm/zzcDCUVivq+ 0/SSmOlepOXVdImOIjDTV6iJ4O0jj/8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732670920; a=rsa-sha256; cv=none; b=ueDFS9bt/NmQdjHry4rssm9CBgGE442oTy13tKnhuGUpJ+UHCL67qhNjjlxrWI2gMmZuJ9 Bs2i4gxk1Ob9j5mbaPJbt5MKWMyQLRS7D4eMMujWi8I4SPzIph+bZbRxq/VDIlTLHUSjli E79TnS958I2siagdULerSjSz8HI+vuw= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DLv0VkYg; spf=pass (imf15.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.128.45 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4349e4e252dso26155765e9.0 for ; Tue, 26 Nov 2024 17:28:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732670924; x=1733275724; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=yGoWvxrLajb7hyVvYTveK2TYJgb5VqgBn1tgaQwG1Hc=; b=DLv0VkYgqwJA2xOUOiXgolFE6c4SEJ/ieCCbC8xvzxMc2uIaiOOvvaC5LniyNKe8nB BqXwAWhNIpmbQX4Mc8IpnLqFFgu6Gygrab2Bycta87JCNZA/WuIyIZLsWUfm24V8qaMc nmTvjsH/f1A7CFjSu3Qb5J4mjMWop/onBUORTAS/sGGmQMbm80zhRg1eNyUtPlJHrVEG XshmeE9J71Q7P51YhoK5MTvC8URA4Z2StYd6k990djU5NnO83u8NIom1gpoorK5ZCn2U 56VlMWw/6HHiHZdKZ0DPPbCuNGgG1FN/ptJ4vmM2BT/l+9LEkWDWQAdimTwjjPcdkNsa yegg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732670924; x=1733275724; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yGoWvxrLajb7hyVvYTveK2TYJgb5VqgBn1tgaQwG1Hc=; b=mRW+fTkger9Lb2HJGdW2EXLKmZzPyK+BaGQECL9fEl4xhJyxjnkf8vzHLtKnBmfrAW fsrPEb1E/uUOq9eIlro1NwFO4D6V/lxebGQMxxAXAVh/vWOAf9BrckG1vVuEdacsZuyS 2J9iRgAcN/kWbhf/2F4MFnCw36tblW+yI/Pk/V7z7IFFYa2a3W5LU1dP0b1WtVAYFFsk hMVG8gnb0bUPUBjA3Y/7lK+7YPjONeEaS4aSv1ngMRMkZ6dGbb5K0eZRMy5arNqcwAc2 oHxVnRqMoMu7+9GmwXP/ko+8e1rPt/OI8BZAeiL5rKaqWo6Aa/uidMw115mJzsd+XsSP bObA== X-Forwarded-Encrypted: i=1; AJvYcCXU9IHH/lqm0QA0y19qhGYR2xeLXB5XopeyddghXV/HdSn1yVc1s2yzm3HKF0E6NL5R99MQhQAL9A==@kvack.org X-Gm-Message-State: AOJu0Yz8dGlur+nPJ8xKP/Xb4MQdUuxHkS90H0imkjiSHU+WKEQZAIJn IfX2QpiDkH3MRXXcnabhAao7Z2dWUWYV++baxFZTyUXU9QiWygNC X-Gm-Gg: ASbGncu+Xesk/wxdnKhWMSUfjvuGGGq+oLpR/0MqkDIJrlqW6PY0OSMQ/kvOp5286Jf f4vIqCqproh/gp8NApu+Rl+7oPgyvg45ckQ9CHgfZFyTN0naFwOjKij4kterOTXcz4ZsgOfY22L FAuz5LR6JE7JZA+MAsA95vYGUaSIhVH6ZQ/ZPdHEYy+uLLkuXvHq+VB81o4EHrH3y19n/ZgfkhG P0efcmf3KM4tFpp1giBXDYvG6SpynWcKv7HB9k2A5PiQRr3dA== X-Google-Smtp-Source: AGHT+IEp2736qY44S2GpxqdrL7wZmgfRt2Bp++Tius0R4wmX/MudKoH8gekrNitGvw/POr3KgRWO7w== X-Received: by 2002:a5d:5850:0:b0:382:4493:ff8f with SMTP id ffacd0b85a97d-385c6eddb44mr638021f8f.43.1732670924341; Tue, 26 Nov 2024 17:28:44 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa50b52ffe3sm660431766b.126.2024.11.26.17.28.42 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Nov 2024 17:28:43 -0800 (PST) From: Wei Yang To: akpm@linux-foundation.org, Liam.Howlett@oracle.com Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang , "Liam R . Howlett" , Sidhartha Kumar , Lorenzo Stoakes Subject: [PATCH 7/7] maple_tree: only ascend left subtree to get the old node for replacement Date: Wed, 27 Nov 2024 01:27:53 +0000 Message-Id: <20241127012753.3393-8-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241127012753.3393-1-richard.weiyang@gmail.com> References: <20241127012753.3393-1-richard.weiyang@gmail.com> X-Rspamd-Queue-Id: 859E1A0012 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: 7w4396d33b6gmptaa37e35eu8j9w1szr X-HE-Tag: 1732670920-547623 X-HE-Meta: U2FsdGVkX18eP39CxqE99wI7fjylU42dLffWuBlebDpKoBdwqVi3CKouF1mhXVp9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v6Nt/pV8ZZ5y3Ey66CcSkJ5IBI2ITH4uPNB/WFnj7rtuZ9qebk9eoVvw6bmoPC1uMkHK3/g55WPn2lSNDkZ8QJrWGlXvlAdPTT+2RVMPrdbcXVMyMn5ONN0AwoSaeCeSi6PlC+wr2OFBC3ZOoPOJi/1bCugXzSz+CKFy25GHS2YodZ/kWK7abkU9vjdDhtK1FCJtm78h/FAsCqsUmTC+XIkSDwwwxXKQPu0YrNx5ADME+VydhtizMByuJNxk6vhMj8ngj/j6uM5nd93nHFzuUeEtgOeOO2wov6ZSZTjKUdSQFrjGoL6jugBT9N032sZa4ZrTsyVSQWCXSSGDonzsfi1+BRhGfgiA2aYiL1mxq6L3 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000018, 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 we come to a new_root, we should go up the tree to get the old root for replacement. Instead of ascend both left/right subtree, we only ascend one of it is enough. Let's use the left subtree as it dose now. Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Sidhartha Kumar CC: Lorenzo Stoakes --- lib/maple_tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 4ba9ae68c0a9..2c05919be168 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -2920,7 +2920,7 @@ static void mas_spanning_rebalance(struct ma_state *mas, new_root: mas_mn(mast->l)->parent = ma_parent_ptr(mas_tree_parent(mas)); while (!mte_is_root(mast->orig_l->node)) - mast_ascend(mast); + mas_ascend(mast->orig_l); } else { mas_mn(&l_mas)->parent = mas_mn(mast->orig_l)->parent; }