From nobody Sun Feb 8 15:06:38 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 E9A7EC5AD4C for ; Mon, 20 Nov 2023 07:09:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232019AbjKTHKA (ORCPT ); Mon, 20 Nov 2023 02:10:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjKTHJ6 (ORCPT ); Mon, 20 Nov 2023 02:09:58 -0500 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 6AF0CA4 for ; Sun, 19 Nov 2023 23:09:55 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ccbb7f79cdso29128205ad.3 for ; Sun, 19 Nov 2023 23:09:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700464195; x=1701068995; darn=vger.kernel.org; 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=nUE9ZvwZFQu7umd/mVKa2M3eheT6QrVVeWcfJsSgwak=; b=Nb4FDyNwjN+mOaQPz6vPBmzYYcVrzNF5lLIOTo6NJLZKKaYQ5q9G4XxtppDPLL07Gu 55YA5qrTr1EpcPIQ5TK8SckyR9o0lYdLfVRPrUhc4zHW5a167XSptvC2YGllJZinWSuU nKoOt3fqhCXgiwow2e7Ylq15hCDyYoTaC2FDpRBEm0vA9u9CxCBiGJ9/AEtTA72TyUjN ZikhEjKhKVhxCjkjkgGAg2tA1RmzQaJEDrKfJnaTHB7YYPps2CuOBQergscCtcw+JkNE cwtiQ9ExMewLMDFrNMZqlubgo5z/KDQq0H+fFdj1CdY/aMYNW/X0s1NKw+zN01tvnV/2 LAuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700464195; x=1701068995; 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=nUE9ZvwZFQu7umd/mVKa2M3eheT6QrVVeWcfJsSgwak=; b=YjcNVgSV04kAqK6VRKmWpCBcrFfLcKmghBaEmpwhHeu1HAPqpFl6wyqvVL+a0e7lTp zHc61karxmVchcZiZa72rTSI8bh40vAITP21c6Sv6IJSLowsh1IE2LegHWYwwdlYF1oq oSBedeojA6iThL94DqmEaOh8S7gvRNyodE6U0QOEtDpONzNXAfBeUlAwNQCz7VpeK113 1orLNL2p4AaoWK15htp+tjFWvY87j31MWVX2nFND87mqQSEWKhT5uvv7qbZTRpG/WVn4 7Cz7aKijeFMegv2oYwWh0XzqB3IPMfVtcZgFcR+7J//QJw4T9U0BkwV6IJyiqCoUdZFs gHdQ== X-Gm-Message-State: AOJu0Yx5VXZ+KSifVWp0BtAb8bZ0NE/MF6EDj1vBQ4hBRiYeDVVmTCvT +DXohLnFOZgSvJ1tWuRBgR+Q1Q== X-Google-Smtp-Source: AGHT+IHoQx5VP90DjW6z7hmikj/ILZ20irNIme8mby57GLohgMrwLjCqPd9SOayxbZcQ2cOPovcmJg== X-Received: by 2002:a17:902:d904:b0:1ce:5c04:fb60 with SMTP id c4-20020a170902d90400b001ce5c04fb60mr4374550plz.8.1700464194899; Sun, 19 Nov 2023 23:09:54 -0800 (PST) Received: from GL4FX4PXWL.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id d4-20020a170902cec400b001ce67fab3a2sm3698143plg.261.2023.11.19.23.09.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Nov 2023 23:09:54 -0800 (PST) From: Peng Zhang To: Liam.Howlett@oracle.com, dan.carpenter@linaro.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v2 1/5] maple_tree: Move the check forward to avoid static check warning Date: Mon, 20 Nov 2023 15:09:33 +0800 Message-Id: <20231120070937.35481-2-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20231120070937.35481-1-zhangpeng.00@bytedance.com> References: <20231120070937.35481-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" Put the check for gap before its reference to avoid Smatch static check warnings. This is not a bug, it's just a validation program. Even with this change, Smatch may still generate warnings because MT_BUG_ON() doesn't necessarily stop the program. It may require fixing Smatch itself to avoid these warnings. Reported-by: Dan Carpenter Closes: http://lists.infradead.org/pipermail/maple-tree/2023-November/00304= 6.html Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- 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 aaba453b0d30..067b186202d7 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -7249,6 +7249,7 @@ static void mas_validate_gaps(struct ma_state *mas) =20 counted: if (mt =3D=3D maple_arange_64) { + MT_BUG_ON(mas->tree, !gaps); offset =3D ma_meta_gap(node, mt); if (offset > i) { pr_err("gap offset %p[%u] is invalid\n", node, offset); @@ -7261,7 +7262,6 @@ static void mas_validate_gaps(struct ma_state *mas) MT_BUG_ON(mas->tree, 1); } =20 - MT_BUG_ON(mas->tree, !gaps); for (i++ ; i < mt_slot_count(mte); i++) { if (gaps[i] !=3D 0) { pr_err("gap %p[%u] beyond node limit !=3D 0\n", --=20 2.20.1 From nobody Sun Feb 8 15:06:38 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 E58C9C54FB9 for ; Mon, 20 Nov 2023 07:10:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232099AbjKTHKf (ORCPT ); Mon, 20 Nov 2023 02:10:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232062AbjKTHK0 (ORCPT ); Mon, 20 Nov 2023 02:10:26 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59C0BB7 for ; Sun, 19 Nov 2023 23:09:58 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6cb66f23eddso704931b3a.0 for ; Sun, 19 Nov 2023 23:09:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700464198; x=1701068998; darn=vger.kernel.org; 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=DVM7PlgIWBr9i9hcZud6b5TfuAYyAUUwXwcxlfzYtaU=; b=DHzDbOAmjE9LKoiXne1B9nDYCMqErMoPy670HrwoV4cb0ittn3rsldSt3EdnIfEdJf ekNumQismDpl9IyGwgzzcCF/hy/lAz9BLTG5/BZUtt5tGYywsVMglyuEfabVUjc5O/qQ tONK0Qf3Mx48nkhpN3EA0pAifEVMUFPs8BvR64gg9zbhr8F9Udz3b/UFsT+Cf4u52tee ihUrQv/cdWrseV9c/ehT3FepUMj2HtHg9k/UejSIJRiqWhenn6Hj8VFs6PpswkJjMY8f 6UpgcOKIeevgi0IeUBjBWQ8VzJhum+vYoWEVgDRIOtsiDkkDfcJ8bfFAAo5YmTTVj5ds 51BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700464198; x=1701068998; 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=DVM7PlgIWBr9i9hcZud6b5TfuAYyAUUwXwcxlfzYtaU=; b=GaUtgG4u6ntg4Zme3hzNzr5fSl+oGwjbV/qdxGEeLFsiILkeJXn7l8J+oHHGpiPy4n iTKepjrRVOf8NkRIpc+cPs+SP8TOE2HJgQWfjpPS/pFsALOd1CRRNg/v5+O5LTNJc6WG Mf3fis9Grhads11rHqY9XzBhriLxE1Ng7becvN190Nk4EyfOr5lRafWmig2d1aoodyYa +4EDAWoyHkq2cGYnw/mXm9ML8ooAS+g3q74aYZZfpiBCdYcDibYYq085ojeU7jYIGZel dbQCjbK5uCSCHdAfNZQ7NLTD9rEQNfaTzHmYeEdaQ2uWeVkLXplUxL4Cx1T7YkFCfYVM UzJw== X-Gm-Message-State: AOJu0YxiAqWoEHlIbaD0pcOFzUPx90u8xMptie3nZpX8Cpo80YubEila m7HHfneGHMWqybyQcm2Nt/9UtQ== X-Google-Smtp-Source: AGHT+IE2q1NCMNd+w8RbWd7Y6YzdqD5HzLY3jU16q2z24eHxDGMl4yI/3MCaLdN5iu6cGUkG7j/jOA== X-Received: by 2002:a05:6a20:430a:b0:187:c2be:77f4 with SMTP id h10-20020a056a20430a00b00187c2be77f4mr4769336pzk.44.1700464197848; Sun, 19 Nov 2023 23:09:57 -0800 (PST) Received: from GL4FX4PXWL.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id d4-20020a170902cec400b001ce67fab3a2sm3698143plg.261.2023.11.19.23.09.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Nov 2023 23:09:57 -0800 (PST) From: Peng Zhang To: Liam.Howlett@oracle.com, dan.carpenter@linaro.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v2 2/5] maple_tree: Avoid ascending when mas->min is also the parent's minimum Date: Mon, 20 Nov 2023 15:09:34 +0800 Message-Id: <20231120070937.35481-3-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20231120070937.35481-1-zhangpeng.00@bytedance.com> References: <20231120070937.35481-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" When the child node is the first child of its parent node, mas->min does not need to be updated. This can reduce the number of ascending times in some cases. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 067b186202d7..cc928b5f753d 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1088,14 +1088,16 @@ static int mas_ascend(struct ma_state *mas) return 0; } =20 - if (!mas->min) + min =3D 0; + max =3D ULONG_MAX; + if (!mas->offset) { + min =3D mas->min; set_min =3D true; + } =20 if (mas->max =3D=3D ULONG_MAX) set_max =3D true; =20 - min =3D 0; - max =3D ULONG_MAX; do { p_enode =3D a_enode; a_type =3D mas_parent_type(mas, p_enode); --=20 2.20.1 From nobody Sun Feb 8 15:06:38 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 BE59BC197A0 for ; Mon, 20 Nov 2023 07:10:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232026AbjKTHKH (ORCPT ); Mon, 20 Nov 2023 02:10:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231997AbjKTHKF (ORCPT ); Mon, 20 Nov 2023 02:10:05 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F188E3 for ; Sun, 19 Nov 2023 23:10:02 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1ce95f96edcso8391175ad.0 for ; Sun, 19 Nov 2023 23:10:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700464201; x=1701069001; darn=vger.kernel.org; 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=w9+DAd0kh6Tp0D5lzI/a0yHeYFuqsn6U0+a+XQf0dsw=; b=BY+4TiLPFASyKbgIbtsCrhuE9GKt9XaJ4XOMxxvucaRaIcFCCDk93+PXAjrAUFVVEw njJPugZ2qtKr0U2tMwMBfXoME2/kckA22L3PvTUsvUF2zxfrZuT3fOvr8mqo/56KXCmN QlZwxbE7o5ZTyVsHNMl2oroQ05irfROypkvksI1jT0m4D9C0de5rXimc2Dzaq1THXy4H kofUDr+qBzC7aaa74Rtf7Z5aO9hAMWioYBnw2AFPSZOdw3HISNwXSjN7ayHDlYmmOIM/ 6VW+JSYMGnwQwXYO1SqeLqSyuLYVpv6yI/9Ig9pqP6ed9osI32eXn20cIhFBrg0vmpoT wDLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700464201; x=1701069001; 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=w9+DAd0kh6Tp0D5lzI/a0yHeYFuqsn6U0+a+XQf0dsw=; b=rH31eCvzXxUETDQz7Bu9y1sBJXDCzPn2R7RjPiV8FoDQGbWuvvP+n56zMBamx/BkxI RnIt6WxXy1SVdJuHbSmPlCDmPcsQl9TQCmqQEPTn2ZDbyNkjkI4rnw5bC/bQhz3wnJyu 75ODW/N39yQHA73Wo7/SIq3ZNrGQnHeRfoti1HJCREG0k75hcz0pH/9IkQojtCsEL3d7 Gn6zz3q/cengG/Pi1s3VKGTARREZrIpzX44FtKbk/eo7ozd7gnj6fsazwFw9LpRmlkL3 5cWcgwcMGWpqYjONIy44wxjg7ZB5Zs77GoNkjIzqvNJ5rig2I1zdAm5zZ/Kc2rOpdy2m WHWQ== X-Gm-Message-State: AOJu0YyAThS46AQYMnQrpgvhtil6+p1w2+5xlilZB/D5n2j/xNZOlAUU GSqxSTkf3G4eAnGyAzfICMzeig== X-Google-Smtp-Source: AGHT+IGNvUs250aFwRwvpMkhOgmdzOmS2EHci8LS5ZEc+jeuyEGmhe+PjdF04JneUJX4CWCT5jVIdw== X-Received: by 2002:a17:902:ec82:b0:1cc:5549:aabd with SMTP id x2-20020a170902ec8200b001cc5549aabdmr5176361plg.8.1700464201587; Sun, 19 Nov 2023 23:10:01 -0800 (PST) Received: from GL4FX4PXWL.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id d4-20020a170902cec400b001ce67fab3a2sm3698143plg.261.2023.11.19.23.09.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Nov 2023 23:10:01 -0800 (PST) From: Peng Zhang To: Liam.Howlett@oracle.com, dan.carpenter@linaro.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v2 3/5] maple_tree: Remove an unused parameter for ma_meta_end() Date: Mon, 20 Nov 2023 15:09:35 +0800 Message-Id: <20231120070937.35481-4-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20231120070937.35481-1-zhangpeng.00@bytedance.com> References: <20231120070937.35481-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" The parameter maple_type is not used, so remove it. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index cc928b5f753d..3d894f849e57 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -930,10 +930,8 @@ static inline unsigned char ma_meta_end(struct maple_n= ode *mn, /* * ma_meta_gap() - Get the largest gap location of a node from the metadata * @mn: The maple node - * @mt: The maple node type */ -static inline unsigned char ma_meta_gap(struct maple_node *mn, - enum maple_type mt) +static inline unsigned char ma_meta_gap(struct maple_node *mn) { return mn->ma64.meta.gap; } @@ -1587,7 +1585,7 @@ static inline unsigned long mas_max_gap(struct ma_sta= te *mas) =20 node =3D mas_mn(mas); MAS_BUG_ON(mas, mt !=3D maple_arange_64); - offset =3D ma_meta_gap(node, mt); + offset =3D ma_meta_gap(node); gaps =3D ma_gaps(node, mt); return gaps[offset]; } @@ -1618,7 +1616,7 @@ static inline void mas_parent_gap(struct ma_state *ma= s, unsigned char offset, =20 ascend: MAS_BUG_ON(mas, pmt !=3D maple_arange_64); - meta_offset =3D ma_meta_gap(pnode, pmt); + meta_offset =3D ma_meta_gap(pnode); meta_gap =3D pgaps[meta_offset]; =20 pgaps[offset] =3D new; @@ -7252,7 +7250,7 @@ static void mas_validate_gaps(struct ma_state *mas) counted: if (mt =3D=3D maple_arange_64) { MT_BUG_ON(mas->tree, !gaps); - offset =3D ma_meta_gap(node, mt); + offset =3D ma_meta_gap(node); if (offset > i) { pr_err("gap offset %p[%u] is invalid\n", node, offset); MT_BUG_ON(mas->tree, 1); --=20 2.20.1 From nobody Sun Feb 8 15:06:38 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 8B7B1C54FB9 for ; Mon, 20 Nov 2023 07:10:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232123AbjKTHKj (ORCPT ); Mon, 20 Nov 2023 02:10:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232090AbjKTHK0 (ORCPT ); Mon, 20 Nov 2023 02:10:26 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41B8ED8 for ; Sun, 19 Nov 2023 23:10:06 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1ce5e65ba37so17696755ad.1 for ; Sun, 19 Nov 2023 23:10:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700464205; x=1701069005; darn=vger.kernel.org; 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=BJAegsGMEAsqPHcwildrmHLCgFp9mNVCImkTSvfwCSs=; b=RZuvEUTwzMJaXyQftBdE3+xXTm0zN6PT0wf9hzJwVo/OhkE0EGafVPBX/+TBSiDIud jBvNgzE2mSjt1WKQOJ6QgtKfVaLscjLD+leKspUrmwNAOFe0twS7IoPoCo8z2M2zzvwh d0Mg2XjhIORdFse/Nl5UkqaQc1bt9BsOSfW1gSD0gFBfHpmkUkLQkxN8EDnhB0LQaCCo gwB0h8sWwHAp0bmCehzeC1LQWphh2LomZtoCKHd9+TLXjOxLyYjrh2pcOAmWn6dEPhbX lqmc6AYl8psUIotbi5D9l/ZZKg/S1InPmLOAQWJTYh4iUjzBlic972ecRT+JRIKCxVR0 6tPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700464205; x=1701069005; 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=BJAegsGMEAsqPHcwildrmHLCgFp9mNVCImkTSvfwCSs=; b=L4GoeUwUppWvmxUkHdLio7QNSRrji/I3rhKAWEmbPLwvOmfW4KuuKycbvjxAEFi308 8hEAqXptGfFMmLy5P4nObk9J8I3rpsZF3nS9a71053yny/mKBlo5DBFPHJciExLMDsPt MrjyN6VQlj03X1KO6dQJf+Ap+Gdm5qyhzczGnbJvmsHv+mAvVE+DxfFwq5r2xWJTSeiz ZFyuwcwo1GGKvqeC5ZK08bDejWJqYzmpQ0eW+8uOSZa/v/bKBKaFROrVxIB60TrB15V4 N+Sb8IzKNXH7ApFCzRXww4ujk2iTB1Qp53JreqGMoyA9jc2MdFHtH5rnhgtEDi5O7bDS Tn8g== X-Gm-Message-State: AOJu0YyhiiMVdfzPlejudOgPinCDzlAJewoLhtIcbOHaA1KVBUBbaldr D84e1t/pS2EKq/IVlS9JY+sJ1w== X-Google-Smtp-Source: AGHT+IHMWj5eJhGQVYHhWGVAjEcPR1r+lH672kbdri/DDnFDTKkMrBGTSEq1F8Cut7W5CdHqO1+75A== X-Received: by 2002:a17:902:d2c4:b0:1ce:6630:1585 with SMTP id n4-20020a170902d2c400b001ce66301585mr7924553plc.23.1700464205725; Sun, 19 Nov 2023 23:10:05 -0800 (PST) Received: from GL4FX4PXWL.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id d4-20020a170902cec400b001ce67fab3a2sm3698143plg.261.2023.11.19.23.10.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Nov 2023 23:10:05 -0800 (PST) From: Peng Zhang To: Liam.Howlett@oracle.com, dan.carpenter@linaro.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v2 4/5] maple_tree: Delete one of the two identical checks Date: Mon, 20 Nov 2023 15:09:36 +0800 Message-Id: <20231120070937.35481-5-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20231120070937.35481-1-zhangpeng.00@bytedance.com> References: <20231120070937.35481-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" There are two identical checks, delete one of them. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 3d894f849e57..bf64d080b376 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4117,9 +4117,6 @@ static inline bool mas_wr_append(struct ma_wr_state *= wr_mas, if (mt_in_rcu(mas->tree)) return false; =20 - if (mas->offset !=3D mas->end) - return false; - end =3D mas->end; if (mas->offset !=3D end) return false; --=20 2.20.1 From nobody Sun Feb 8 15:06:38 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 701BFC54FB9 for ; Mon, 20 Nov 2023 07:10:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232050AbjKTHKQ (ORCPT ); Mon, 20 Nov 2023 02:10:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232040AbjKTHKO (ORCPT ); Mon, 20 Nov 2023 02:10:14 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56CABBC for ; Sun, 19 Nov 2023 23:10:09 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-28398d6c9f3so2439543a91.0 for ; Sun, 19 Nov 2023 23:10:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700464209; x=1701069009; darn=vger.kernel.org; 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=G+DYEnQ+jfZcUuq4nlzb+NkHPQ+JKHORa1x2uG9sVgs=; b=NZFXLqYCWva3LUJ2NbXLcOWmUWd3w78fY4SiRo1FnbetqeSEJwNhUql+okYxf07aKb a0JDRgUQAzZH5zGts7Kcv2j16K/BRwkVBxj9DjDoyirNvex7/y9dfeSCAgVrk6eB6pOY j04FltSNADeiAbsjGTsLSu3jXpn4fn3DtGG9NqGq/b5vNNXUZ0f75UFPbzA/uU9eaiiV pouFgA63CBjOvVzb31qyS0MqL1rgTrNeFfd5vBbeNOnMoMuHTLEIOMzF6ApETZG2dQvt 4sv7g3hkah8462gpRqg8XbTtlIaDmvkvLWNzENjDp9fACuLF63JexmwA5PUGs3gSidmq x5RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700464209; x=1701069009; 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=G+DYEnQ+jfZcUuq4nlzb+NkHPQ+JKHORa1x2uG9sVgs=; b=cbkEq9jEqQKUAiaRSxm6ofdvAjmX0NskhPn/yQW/Vm70o1gplkYz0KuAmi/nFDSK+l Wruw69S6IoxVNoZSJqzNsvBQopCkTw2CZ5v5f6dShjdGMH2bqI3t0lXfLyTPOWwyUKno t+VvKM8JW0e4Qbd50HtBUNjb2rIBduAQS5B17EKLzMmLpSvIqBrnOTfw4s/R/Hb501LD ULOLX/RtbuacWy9G6uV8X1AoAocrwBLjTFGvJQy6ajb92avR2ejqm93EtVLY5Wp+nFp5 x+niPwQ19UfvKDm/iW8IlmaMB/HHsouyVjo9ERIep2JH/mEhWgchJF94gjJunQY/lIXD LsuA== X-Gm-Message-State: AOJu0YxTuUDqoLiBEUrloxQU0BpvNbWwhdS4K3rRc1ZzQfS+R8vVE1eU K1apkqxjvhmBsIihY/+9OHkE3g== X-Google-Smtp-Source: AGHT+IF83+lkbrauzNf5VU39sKkm3EJmrNtdZZs24FDn4zfpE+cr9/s7OrmNO9P9Edg8qWo55ZF4Bg== X-Received: by 2002:a17:90b:224a:b0:280:4829:52d6 with SMTP id hk10-20020a17090b224a00b00280482952d6mr6485131pjb.29.1700464208748; Sun, 19 Nov 2023 23:10:08 -0800 (PST) Received: from GL4FX4PXWL.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id d4-20020a170902cec400b001ce67fab3a2sm3698143plg.261.2023.11.19.23.10.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Nov 2023 23:10:08 -0800 (PST) From: Peng Zhang To: Liam.Howlett@oracle.com, dan.carpenter@linaro.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v2 5/5] maple_tree: Simplify mas_leaf_set_meta() Date: Mon, 20 Nov 2023 15:09:37 +0800 Message-Id: <20231120070937.35481-6-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20231120070937.35481-1-zhangpeng.00@bytedance.com> References: <20231120070937.35481-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" Now it seems that the incoming 'end' is already pointing to the last item, so we can simplify this function, considering only whether the last slot is being used. This has passed the maple tree test suite. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index bf64d080b376..89f8d2160277 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1964,27 +1964,13 @@ static inline void mas_mab_cp(struct ma_state *mas,= unsigned char mas_start, =20 /* * mas_leaf_set_meta() - Set the metadata of a leaf if possible. - * @mas: The maple state * @node: The maple node - * @pivots: pointer to the maple node pivots * @mt: The maple type - * @end: The assumed end - * - * Note, end may be incremented within this function but not modified at t= he - * source. This is fine since the metadata is the last thing to be stored= in a - * node during a write. + * @end: The node end */ -static inline void mas_leaf_set_meta(struct ma_state *mas, - struct maple_node *node, unsigned long *pivots, +static inline void mas_leaf_set_meta(struct maple_node *node, enum maple_type mt, unsigned char end) { - /* There is no room for metadata already */ - if (mt_pivots[mt] <=3D end) - return; - - if (pivots[end] && pivots[end] < mas->max) - end++; - if (end < mt_slots[mt] - 1) ma_set_meta(node, mt, 0, end); } @@ -2041,7 +2027,7 @@ static inline void mab_mas_cp(struct maple_big_node *= b_node, =20 ma_set_meta(node, mt, offset, end); } else { - mas_leaf_set_meta(mas, node, pivots, mt, end); + mas_leaf_set_meta(node, mt, end); } } =20 @@ -3962,7 +3948,7 @@ static inline bool mas_wr_node_store(struct ma_wr_sta= te *wr_mas, dst_pivots[new_end] =3D mas->max; =20 done: - mas_leaf_set_meta(mas, newnode, dst_pivots, maple_leaf_64, new_end); + mas_leaf_set_meta(newnode, maple_leaf_64, new_end); if (in_rcu) { struct maple_enode *old_enode =3D mas->node; =20 --=20 2.20.1