Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1766167rdb; Mon, 9 Oct 2023 02:04:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHz2sl9Ik//74nZ7cZnJjp5BfAW1KN4VOypnaCgVTdYJGZQLPgv0rjkWV6WsgWfq49XUVgW X-Received: by 2002:a17:903:24c:b0:1c7:4f87:3dbe with SMTP id j12-20020a170903024c00b001c74f873dbemr14339687plh.31.1696842272457; Mon, 09 Oct 2023 02:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696842272; cv=none; d=google.com; s=arc-20160816; b=Aiji22C++ObmIhgOZAlvfnGtMEm7eQvF0h7SF0paL9xya/l7qw3lhxUK7NmXZyxQeX AHqOIhN2I2so0o2rg1t3FMewyC9Ozc3h79L2Jo3maufhjKLPFG9KCAQuMxIi2cPsVuvh 4r/NlocnvdYp5RhKLS8HdFcJL2K8hD+bffD+Uz/x3nCmM/W1OiAc111kCc6AjWRcUduR tksC94KgwaSPBgUkMnx7dvBKBSE3nzKDqayjtoxGeuQqnRVbaBsCKt+D+PI8b7CbDXCo Sn5KdLu4WaGhd+Raz+4hMIQHHOVuQ1MCPTXckMB4lfSEFi8Vu/irKmSo3b3LYo/g55uY b9kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Vn4VBWQzj5W1GGyecNOIEAPBueVPsjsImBXm9m9YoY4=; fh=W1ujNbDikRM6mL+MA7cZ93eipzimk+g+Mb7QYnlff5s=; b=zWdxK7w/c5uYmnbqA3Rm/J2rBULncUIwot/eWIDh2wVRInvhyq9a0GkucD24Kqwiad /++zrgEePlK7MV48Ye0aWx5Ug1rhIIUP7OT+1Ao5dHvUZBjVELOeaPyPORs6IhdaUTcy gJ1UEj6K74G8v4WjAucZSIyQttxFtJZ9s827h8FfAdx4IxsgcwrVK6+pdL0opAgqTh74 krrL/t3ZdHG7Tm6bckj09O3u29oB3qyH3SdSwqlTmrIV18KECNxvTXFDPsEjEpSrpOlk ssIqy4P7OupxfV+gYkEB/mzfWRCQw7Ruq+nGYfmNA72LvDNj/fU1lVNIIWw0CJTFLQq/ RJGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="QGiUB/Kb"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id d8-20020a170902cec800b001c35864fdbbsi9857721plg.406.2023.10.09.02.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 02:04:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="QGiUB/Kb"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3EE3980212ED; Mon, 9 Oct 2023 02:04:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345701AbjJIJEN (ORCPT + 99 others); Mon, 9 Oct 2023 05:04:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345573AbjJIJEM (ORCPT ); Mon, 9 Oct 2023 05:04:12 -0400 Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FB36CA for ; Mon, 9 Oct 2023 02:03:49 -0700 (PDT) Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3ae2f8bf865so3003909b6e.2 for ; Mon, 09 Oct 2023 02:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1696842228; x=1697447028; 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=Vn4VBWQzj5W1GGyecNOIEAPBueVPsjsImBXm9m9YoY4=; b=QGiUB/KbptGKegNdzw8jChLi0LdKzrPR5ZDC3coGG31Ekd6yqIcSPF2Bw/5YncY7gC BA+HBCOD/9r1P1KDF74CN2H3dyyJnwrYI7nGl+QVpwvRy68D5wNRhFK2XNnOAJugO8b2 Ea2s/x47W1IqtgvzL0GFk23kvipoabMy6VKpObL4fnH9Z3ANIQPn3crEmN+H2/3msl31 sN/0kZsbK0aGwWy9Es8byB3DPjTZYAOXd5uCCpi4HEulyRYk13RVN+YDyTCiTL4QH7Yl 9gzzPUnJFS9EUXEbM7X1I//YeFInsTwlnoRykGF1N8fHF9xKT0Dqvf+gXa+B1qTuLWzD Blag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696842228; x=1697447028; 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=Vn4VBWQzj5W1GGyecNOIEAPBueVPsjsImBXm9m9YoY4=; b=bumXCHERqiFMuKQ4DJiNBHqPViUbSkTqeGb9IEnu/0Mcl5v/itzo+9OCC8/UXbyfos 9QIj1hL+/pXA0cckrWn4/OJRgz5dDNS09IoVg5r/MhtiyPfradsqwbM42eAAY67xmLQS yXUWUrpkcB8KFCV7WrztoIQ4hmGFmZnIZD2AoL9tcADdW17Iv5XbQ4Y7PxUgsWn/XWkh owU0zcY5XEK8CXNk2VoNM//IzEv61iv9I7LCJz9NGlagtmZ6uiOWcCr7/IYgonwIoZvm wdeZEHe5l2xo+JBFXAU/Y9c9imJMWLjPIdUr+ncaumOYHggojQam2bfBp1MzalxAzaxY LkVg== X-Gm-Message-State: AOJu0YwmV4v4JZLhoJcys2EWEGHh2RfNrEC1tXde0ETva3PRbNhmaMiK ZXlHBFAKuYxEEka5IEY8LdUgEQ== X-Received: by 2002:a05:6358:4408:b0:134:c37f:4b64 with SMTP id z8-20020a056358440800b00134c37f4b64mr14018761rwc.30.1696842228498; Mon, 09 Oct 2023 02:03:48 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.243]) by smtp.gmail.com with ESMTPSA id fk3-20020a056a003a8300b00690ca4356f1sm5884847pfb.198.2023.10.09.02.03.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Oct 2023 02:03:48 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com, corbet@lwn.net, akpm@linux-foundation.org, willy@infradead.org, brauner@kernel.org, surenb@google.com, michael.christie@oracle.com, mjguzik@gmail.com, mathieu.desnoyers@efficios.com, npiggin@gmail.com, peterz@infradead.org, oliver.sang@intel.com, mst@redhat.com Cc: zhangpeng.00@bytedance.com, maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v4 01/10] maple_tree: Add mt_free_one() and mt_attr() helpers Date: Mon, 9 Oct 2023 17:03:11 +0800 Message-Id: <20231009090320.64565-2-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20231009090320.64565-1-zhangpeng.00@bytedance.com> References: <20231009090320.64565-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 02:04:29 -0700 (PDT) X-Spam-Level: ** Add two helpers: 1. mt_free_one(), used to free a maple node. 2. mt_attr(), used to obtain the attributes of maple tree. Signed-off-by: Peng Zhang --- lib/maple_tree.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 0e00a84e8e8f..28d8959386e7 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -165,6 +165,11 @@ static inline int mt_alloc_bulk(gfp_t gfp, size_t size, void **nodes) return kmem_cache_alloc_bulk(maple_node_cache, gfp, size, nodes); } +static inline void mt_free_one(struct maple_node *node) +{ + kmem_cache_free(maple_node_cache, node); +} + static inline void mt_free_bulk(size_t size, void __rcu **nodes) { kmem_cache_free_bulk(maple_node_cache, size, (void **)nodes); @@ -205,6 +210,11 @@ static unsigned int mas_mt_height(struct ma_state *mas) return mt_height(mas->tree); } +static inline unsigned int mt_attr(struct maple_tree *mt) +{ + return mt->ma_flags & ~MT_FLAGS_HEIGHT_MASK; +} + static inline enum maple_type mte_node_type(const struct maple_enode *entry) { return ((unsigned long)entry >> MAPLE_NODE_TYPE_SHIFT) & @@ -5573,7 +5583,7 @@ void mas_destroy(struct ma_state *mas) mt_free_bulk(count, (void __rcu **)&node->slot[1]); total -= count; } - kmem_cache_free(maple_node_cache, node); + mt_free_one(ma_mnode_ptr(node)); total--; } -- 2.20.1