Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp815552lqh; Fri, 31 May 2024 19:38:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXV/oyHXpYI0ymqWS5xpZwOwW/1YrSTWfaVQsrtGqSBSF063PmEiY+9FMHZ89LXJgSYXeEE5/R6DglGELwShCxt0rWvii0h7mBY0lNpUQ== X-Google-Smtp-Source: AGHT+IHbNkyEOM6NEdZbf6mDsMf8fxoChioj1WvyoAwDiBYEiTQoO/fbyPSPJGTnKAX5fP/c7hxg X-Received: by 2002:a05:622a:1213:b0:43e:e6e:21dc with SMTP id d75a77b69052e-43ff522dbb8mr35094091cf.12.1717209488014; Fri, 31 May 2024 19:38:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717209488; cv=pass; d=google.com; s=arc-20160816; b=v15V1fBN3t/Jnfhc3qau4Yk7XncelfGqKpTUr86X8aX7PlkQrpUFLaVd+gWy0piD4x aeLUB6C1F/GLUiSaX71XItJ+itIaU4k2GWuCF2kQ+AzV89Gr6CgzCZBXKdg4r1e0LIBa kiz+xNBhrRLrptsaxHaDW9iYFu9RvVSctpJ3V1aYmG49UdLXjSR7I1Q1A6EIboy7Bywj OZi/pu6dmAGfB0qUQV749Ig807RXyhmFPbE2nM5DonZkVJtX4c4IddrdGMJ46YcVKwRI O2LgP8PPJnFyMuhKzDApVIXD4Yo08Ifd9u1GYYgf/sM4Gw+qRHuksM5lKPCVJmoRjP9k j/9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=eDNMabYW2abbHXnVWwFSqG9v75QNgOfpcXzt7NGTMHM=; fh=4NdVVJDstsDb9sPtPkFVrcXwzI+70ycjhFfhKAQGSX4=; b=psmiuNbH5xGS/qzHrder0fsB0L4iZyEoMQM3NiVfx2X/hQfP0wJ1/euwJYbri630fm w2pog31MhjjESokUaHVxVxbBsWfbYiCRnfRzPE3LWBqM7v/oDW41ckbo8RX03rdIllfo 8A3ttsYXjJ4WqWm99+vZGfC9b4H3H30UUUYJmOwjvECJR+OYEf+ln+d4U3+1U+wk47Oi F3MPbdkqa709040KPEW4dyJTpGYj+jPwAt3ZD3f3hRlG++of6ZuOriM4Il1QZbu1yra5 1zUD4IMr6DmgACK7Qp++8XM15Ij8BMR8Q4wtKsLVg959xavySQOA7iZZNGZ2QiRcBcs1 2wvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NCKjWnus; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-197651-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197651-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43ff259d2desi32118941cf.624.2024.05.31.19.38.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 19:38:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197651-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NCKjWnus; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-197651-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197651-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B49491C20D05 for ; Sat, 1 Jun 2024 02:38:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A05556FC5; Sat, 1 Jun 2024 02:38:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NCKjWnus" Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EEBA6FA8 for ; Sat, 1 Jun 2024 02:37:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717209480; cv=none; b=jXmnR3JF0A4E3brPbolF8DJUsbOp6zeQv2FrqRxeNLpFGFaisOW8RsBvWQ5fSvV+et16aSG3k9gHiEv/kxreHg5WDMoArwNr54Zqmmy/x70qDqnt9kRuEg9fDSEK27WXKRj7mGCS4CFaUvPSCsBJe4Z58fli9pnnKAwFjc+W2uw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717209480; c=relaxed/simple; bh=h0vhYBVZVGaI8yXhnl7nr0T+/KncbGl3OwsuldQ0xMU=; h=From:To:Cc:Subject:Date:Message-Id; b=iWMBacsO9e7GwNPOlaE+7rtPwaVO/FGx3D14Ldjjk9e0xXwDrorrWYeAnKv4I71QeeJgp+YIUzdCXzicCVCU8kFknL7eLWus4zT4GNJ1H0vsns1luazKjVTKOY7roZDiCW4r+3NUVudc98YeUO+VqBQx54/0sw4DiX8ITViFkn4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NCKjWnus; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2c2070e1579so32474a91.3 for ; Fri, 31 May 2024 19:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717209479; x=1717814279; darn=vger.kernel.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eDNMabYW2abbHXnVWwFSqG9v75QNgOfpcXzt7NGTMHM=; b=NCKjWnusnjb1YU95QJbcqTGpl4On552N4RJ/9ydF7zoxfHH8tJZ5/9ngD92l842sbW iU7PlO3wutFMpo7ty8e8hc9iW+nyf4vVY0Re4TQ51JBylfEizcEcZVgAz+YEn/QGusiK 4qVgU3C7s5ca3YErxXAyNSGkno+9EHyHShLmrGOr/tfA35J1vjV4W63yO0zk9FFGTAIy UjsYGYj8a2o28j1XVgjGT1pWSKuiTNowmX0sqjG8eMxjKsj6C9d0r8C2LyX+gTJBpyS4 WVan25LPjmd9xH86ct27pKLLIfsEnhWvsfMPnarbvDF+r+t+P1FeMa1qzqdEPP6UKoYG ev0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717209479; x=1717814279; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eDNMabYW2abbHXnVWwFSqG9v75QNgOfpcXzt7NGTMHM=; b=izHbDMg/Og+RUqaOW9MBiyrZebCz11y2WiVVrjDvOqx3uyZxPpC2puuQezlhnFLR6n 5LT/jvUo3BnBYFW0zUiMH0n7jNF6SFrvm6FICQFxO6MJUaQHPME4RjnAJa0PWgyOSyn3 UYSBNf3C8fLn8RUobzgqIuct44mvz5AzX90hFu7HUVPpeO1XBLrjMdfh4n4PCSDiQOwo fvaSX8h4h47IYgqrkMjFnq9XYLjKmMq2yB6iX8Pjcn5ar9Rz/I32f/Z+JYogetZ7OQiG QR7pMv8BVWSFpwFzvCMPsQQZNH0cGu95F2yZ7ApgL2qmH8xwR4OvRm0pVgwQ30kYzEHr 3dAw== X-Forwarded-Encrypted: i=1; AJvYcCUtsJUy1y4DLQe6Nw6T5154Ci14SHyVpdrN7cqK4/wNiCGWs96zvJG/NUjJBMyR9jjpB5eCbdiV8ujDQkVdk7Vofl8e15PfxtVb0H8N X-Gm-Message-State: AOJu0YwtRL0NY5AfVTtTSrzskBhakveVz4n+h4E860k+dcnf+TXDbVW2 xNX0hmP0uayXHHHEF8LPU6ATEfMW5jmH/19YOsxekxsRMY1qrWg9U9T52mLj X-Received: by 2002:a17:90b:19d2:b0:2c1:948b:6f2e with SMTP id 98e67ed59e1d1-2c1dc5d5698mr3162951a91.44.1717209478737; Fri, 31 May 2024 19:37:58 -0700 (PDT) Received: from localhost.localdomain ([180.69.210.41]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2c1c2831639sm2399858a91.35.2024.05.31.19.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 19:37:58 -0700 (PDT) From: Jung-JaeJoon X-Google-Original-From: Jung-JaeJoon To: "Liam R. Howlett" Cc: Jung-JaeJoon , maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] maple_tree: add mas_node_count() before going to slow_path in mas_wr_modify() Date: Sat, 1 Jun 2024 11:37:14 +0900 Message-Id: <20240601023714.21226-1-rgbi3307@naver.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Jung-JaeJoon If there are not enough nodes, mas_node_count() set an error state via mas_set_err() and return control flow to the beginning. In the return flow, mas_nomem() checks the error status, allocates new nodes, and resumes execution again. In particular, if this happens in mas_split() in the slow_path section executed in mas_wr_modify(), unnecessary work is repeated, causing a slowdown in speed as below flow: _begin: mas_wr_modify() --> if (new_end >= mt_slots[wr_mas->type]) --> goto slow_path slow_path: --> mas_wr_bnode() --> mas_store_b_node() --> mas_commit_b_node() --> mas_split() --> mas_node_count() return to _begin But, in the above flow, if mas_node_count() is executed before entering slow_path, execution efficiency is improved by allocating nodes without entering slow_path repeatedly. Signed-off-by: JaeJoon Jung --- lib/maple_tree.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 2d7d27e6ae3c..b42a4e70d229 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4176,8 +4176,13 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas) * path. */ new_end = mas_wr_new_end(wr_mas); - if (new_end >= mt_slots[wr_mas->type]) + if (new_end >= mt_slots[wr_mas->type]) } + mas->depth = mas_mt_height(mas); + mas_node_count(mas, 1 + mas->depth * 2); + if (mas_is_err(mas)) + return; goto slow_path; + } /* Attempt to append */ if (mas_wr_append(wr_mas, new_end)) -- 2.17.1