From nobody Tue Feb 10 02:49:32 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84608EB64DB for ; Thu, 15 Jun 2023 13:11:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343827AbjFONLZ (ORCPT ); Thu, 15 Jun 2023 09:11:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343710AbjFONLO (ORCPT ); Thu, 15 Jun 2023 09:11:14 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 648B226B1 for ; Thu, 15 Jun 2023 06:10:51 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1b4f95833c7so12705665ad.1 for ; Thu, 15 Jun 2023 06:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1686834651; x=1689426651; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rh1upVsLkWtnKrYRXZBQpn/CVX3v0vcX/4UFjQ1Vcrw=; b=PnvoyOBWI0174VERzdCx/bjEaYkDquh7yUGjQ50/UMkljqo5RjJXjL/cpgyU0TzpL0 eH4VXPKnzVaqjcP0gOrMx+1QHFabhbbyvY/b0lpA7NNL3TpSSbiM5VkBsMKRfz9VcWo2 lFwoUO7O78+d9CNvG3CfhEJFuWdZ8b1+UY+22FceCZ1Z5L8AhIi7hCMxeK3Nv8H36S9l rpau8waC19HwkB9lNxumaKNM/lwcYVUZc1+ee++CYY+F7cyGfZ46ler+HLrq1LcRvZAN eQsUxGjTPIwUCUuGKYO2Lmqr+uiqKzT6QsnoYFz+N2wYgGq3hiijfpQwjmPzO1Qqg6X7 no0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686834651; x=1689426651; h=content-transfer-encoding:mime-version: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=rh1upVsLkWtnKrYRXZBQpn/CVX3v0vcX/4UFjQ1Vcrw=; b=FPjfkBK4VscN6vbOSofvMw2Qw4FD1Kehmudr4zvuVhzHroHobCxBsS5vEtfrR8T6pp en2esUDEdONuqo7iRVScA9lW1Z4UDFnq44FPd5salKoe8LlxAbmJGeGKnpnn3QUKftdv ZaAlivtHoKwJI8J19zWGRc/1L2tHa2wfkQ7c25vF9fZ2hh08QMwqNynAO+GWz00XNFCI kF9ihrIgts0H6OHBPv1daHPDCPVkH5IxHKOIhxB3DDN++FUH1OscON8JQJbLPYUTz2pF BzwOJASeFASmsRWbJC4FFkfU60UdC4zMoMQpgjdRCYBWF7wtKNIgIbvnnKNF4lgV+HFo Ul8g== X-Gm-Message-State: AC+VfDw9Zj4+JRxytXvRCC5uvjhhEfHzqa2PuQD87HYDluwZlRTM5KRK f/vBkHcaIRVkTV390pYUjsnoGl9/yfFA2Xv5/XE= X-Google-Smtp-Source: ACHHUZ6kYlTrHFDEkqjnopSe0wt5bMIuHrwtTI/7vuPr5aH9vc14N6FGbaSoQP1LNTuYXmE9OOVpYg== X-Received: by 2002:a17:902:7042:b0:1af:fd3a:2b7d with SMTP id h2-20020a170902704200b001affd3a2b7dmr12733721plt.48.1686834650878; Thu, 15 Jun 2023 06:10:50 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.249]) by smtp.gmail.com with ESMTPSA id x1-20020a170902b40100b001a804b16e38sm14036019plr.150.2023.06.15.06.10.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 15 Jun 2023 06:10:50 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH 7/8] maple_tree: replace mas_logical_pivot() with mas_safe_pivot() Date: Thu, 15 Jun 2023 21:08:58 +0800 Message-Id: <20230615130859.21858-8-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230615130859.21858-1-zhangpeng.00@bytedance.com> References: <20230615130859.21858-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace mas_logical_pivot() with mas_safe_pivot() and drop mas_logical_pivot() since it won't be used anymore. We can do this since now all nodes will have node limit pivot (if it is not full node). Signed-off-by: Peng Zhang --- lib/maple_tree.c | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index becb4c224e57..4c9f40322f5f 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -728,33 +728,6 @@ mas_safe_min(struct ma_state *mas, unsigned long *pivo= ts, unsigned char offset) return mas->min; } =20 -/* - * mas_logical_pivot() - Get the logical pivot of a given offset. - * @mas: The maple state - * @pivots: The pointer to the maple node pivots - * @offset: The offset into the pivot array - * @type: The maple node type - * - * When there is no value at a pivot (beyond the end of the data), then the - * pivot is actually @mas->max. - * - * Return: the logical pivot of a given @offset. - */ -static inline unsigned long -mas_logical_pivot(struct ma_state *mas, unsigned long *pivots, - unsigned char offset, enum maple_type type) -{ - unsigned long lpiv =3D mas_safe_pivot(mas, pivots, offset, type); - - if (likely(lpiv)) - return lpiv; - - if (likely(offset)) - return mas->max; - - return lpiv; -} - /* * mte_set_pivot() - Set a pivot to a value in an encoded maple node. * @mn: The encoded maple node @@ -2202,7 +2175,7 @@ static noinline_for_kasan void mas_store_b_node(struc= t ma_wr_state *wr_mas, goto b_end; =20 /* Handle new range ending before old range ends */ - piv =3D mas_logical_pivot(mas, wr_mas->pivots, offset_end, wr_mas->type); + piv =3D mas_safe_pivot(mas, wr_mas->pivots, offset_end, wr_mas->type); if (piv > mas->last) { if (piv =3D=3D ULONG_MAX) mas_bulk_rebalance(mas, b_node->b_end, wr_mas->type); @@ -4911,7 +4884,7 @@ static inline bool mas_anode_descend(struct ma_state = *mas, unsigned long size) min =3D mas_safe_min(mas, pivots, offset); data_end =3D ma_data_end(node, type, pivots, mas->max); for (; offset <=3D data_end; offset++) { - pivot =3D mas_logical_pivot(mas, pivots, offset, type); + pivot =3D mas_safe_pivot(mas, pivots, offset, type); =20 /* Not within lower bounds */ if (mas->index > pivot) @@ -7003,7 +6976,7 @@ static void mas_validate_gaps(struct ma_state *mas) =20 gaps =3D ma_gaps(node, mt); for (i =3D 0; i < mt_slot_count(mte); i++) { - p_end =3D mas_logical_pivot(mas, pivots, i, mt); + p_end =3D mas_safe_pivot(mas, pivots, i, mt); =20 if (!gaps) { if (!mas_get_slot(mas, i)) --=20 2.20.1