Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2261596rdg; Sun, 15 Oct 2023 20:23:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECpWxbeLa1+5kd8OW7zjRdN7xw4DktV5letzSt31zodkefcxo/ZXXnROAZQ0M5CBg1xB3e X-Received: by 2002:a05:6358:910:b0:13a:bd3:3f85 with SMTP id r16-20020a056358091000b0013a0bd33f85mr38569515rwi.23.1697426613996; Sun, 15 Oct 2023 20:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697426613; cv=none; d=google.com; s=arc-20160816; b=W2NcUWMq8Z/3dIUAGG3yO2zhh56ckZgyPr0vRMTXt7kjs52O7+Xm0ljWQheCwsXFRb hysmpbEIxczBgL0+CDmi1ErQPHqweLZGBpvBfmvKnU0D4/6qM5HKq7rZGdTUYYgt4s/U hs5euZMZITQ706BnBYHTFfq9B245cZp6Q7J3dS5t6/Lx/RasWeqlwav2rSc1K5QXnZjB D3O8DsPcF5YZJYVPqiYEyQARNHS259dLuQHwj3QvzAUie1b0IubUmefd2rGWzPDvUQS3 1q9ZtRwUVzTvQd0ELMAl4viBQTnyt+/oxVgrjtOLDOHyaqnXaUYASJTzSvyErQOaeUGb W7oA== 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=7MLK4HxQMsxrLAQzNmdHMtQCN++SQMztyyHR1MHkRQQ=; fh=W1ujNbDikRM6mL+MA7cZ93eipzimk+g+Mb7QYnlff5s=; b=RYzEzAyvkeWvny7b/l6VNyQ84FMkk102JDT56uQAttjknJP1McICn3hJanFmctDO2q maOh+d+CPGV9Z2JVxtxbZBwuryKvYAm+Cv6guSfTzz9X/Js0yxOCSAKj5lIWbj5whpZi Hb66lmsGeEbW+amKZYFYBPStRWhYQ/IbcIOrcY/QfJfw68Ad+jaY7WRS0AhyYHmL/Q4s LF58FbXWKc5swDdo0PIsRCp8XRQ99MYirhdZa3x7h8j/3L3JO2BDfwkzadZrXV3Cxixw h6DdhoAclG3Wp8Vymp6gO/MxkS+OCZmYfo1Y1W2ydSMjpWcZ76NF18wVoB2EjAyXznLa QhsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=f2wN4xQO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id h11-20020a65480b000000b0057806be7290si9517277pgs.451.2023.10.15.20.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 20:23:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=f2wN4xQO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 6938B80620BC; Sun, 15 Oct 2023 20:23:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231547AbjJPDXT (ORCPT + 99 others); Sun, 15 Oct 2023 23:23:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231490AbjJPDXM (ORCPT ); Sun, 15 Oct 2023 23:23:12 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B1EFDE for ; Sun, 15 Oct 2023 20:22:49 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-27d0acd0903so2387917a91.1 for ; Sun, 15 Oct 2023 20:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1697426568; x=1698031368; 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=7MLK4HxQMsxrLAQzNmdHMtQCN++SQMztyyHR1MHkRQQ=; b=f2wN4xQOCM0f+nThGjAETD6mMdWTSPkmkKiG8kleQKCm6Mll6niSRKq+BeaUigBJ/b aHVu5V76nZcV2/e6sTGU4U7daNWFPyiocKph/7hXn+0NiTxcLYc8MJqR2D6bFtWlvBvp K4znW/+Hoq28Wd7FoS7jY5snH2FrXpnufdpyiMncHr00t5Z48MTUsREn/1/wuCJM3w8P KYqHGugQs10QIq1bYted9mGeoou4HVoQVP8FyZEOrzCxd3pH7fgryHypxedWpgJhILmR l8/fFQVTb0vFE6R9WL/1jOTP6flLTMFFm7OXzKXgVFUjK8OZc0z9yQfNjGTphnADtj60 CB9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697426568; x=1698031368; 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=7MLK4HxQMsxrLAQzNmdHMtQCN++SQMztyyHR1MHkRQQ=; b=Mc1UeLVoGPfzPky8MHkDPt5DvSkgCr762NZfqCczS1cElELmFYSmPnxYxNgtVFbKdU TXAZC5c8NxnYfBEdAWn312X0NYfVfjuCwtSw8Qbh/fsE0dN3qjiTQcW3wL5mM2Af3vLR +pPqitPE33GewHFzO4fnxVFSFHxY943UgvGo5zrL+fFQBkJHrICkNb+QdnBMea1DPfN1 zgYTiiCMnIdLpG2Dk9Z3z5d3VGI6FzaLm8OMOnDzjDEyofG7OUDN3JKAATh9oqs1Xk6D K+3FgU4BkOFuUbwYlxboatfwsileuDquj8Ex4SSyS9Qm1FJDFHj3qQ339gFIUPiVR9yA sdKQ== X-Gm-Message-State: AOJu0YxdEJJxsOahK46a86BUPdZ8dAwqBMf+W1OJ0foD8Qx50fUxpW2S 5TY2K//N8YvIez2LoR0qCZLHzg== X-Received: by 2002:a17:90b:4b4a:b0:27d:54b9:c3c5 with SMTP id mi10-20020a17090b4b4a00b0027d54b9c3c5mr3463142pjb.17.1697426568534; Sun, 15 Oct 2023 20:22:48 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.232]) by smtp.gmail.com with ESMTPSA id d8-20020a17090ae28800b0027758c7f585sm3452770pjz.52.2023.10.15.20.22.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 15 Oct 2023 20:22: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 v5 01/10] maple_tree: Add mt_free_one() and mt_attr() helpers Date: Mon, 16 Oct 2023 11:22:17 +0800 Message-Id: <20231016032226.59199-2-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20231016032226.59199-1-zhangpeng.00@bytedance.com> References: <20231016032226.59199-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Sun, 15 Oct 2023 20:23:31 -0700 (PDT) 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 bb24d84a4922..ca7039633844 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