From patchwork Fri Oct 27 03:38:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13438094 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06052C25B48 for ; Fri, 27 Oct 2023 03:39:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 649676B0386; Thu, 26 Oct 2023 23:39:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F9126B0387; Thu, 26 Oct 2023 23:39:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49AFA6B0388; Thu, 26 Oct 2023 23:39:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3A1156B0386 for ; Thu, 26 Oct 2023 23:39:10 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 140FF1CAF63 for ; Fri, 27 Oct 2023 03:39:10 +0000 (UTC) X-FDA: 81389835660.15.122A8E4 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by imf04.hostedemail.com (Postfix) with ESMTP id 415734000C for ; Fri, 27 Oct 2023 03:39:08 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=TlpYTaSH; spf=pass (imf04.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.215.181 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698377948; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tMjhw76FECkOO5zRdU6IjOHgP+3TMOQK2mZ19zJdvuE=; b=wqXlM+DB69bPQpNNTx3LFJC8SaJtvpSa6BCu3eIFPwGKI2pUtTkXJNv3tnI7s38nuLnglW RMqAjZnWqPKMlWAb0F9/6xwHYxHIrOsyLvM4ziRZUNPeKV6ej/Tsjx9vrHJiYNdP9zancl oR8BVA4NiM7y26p+VAWr5pXlI98O788= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698377948; a=rsa-sha256; cv=none; b=v9cAsIKGudpCrBjMD1mexvWUN5bZotL95razLnwHSsgTSGO8fpaGakXHVEpcKueKInscGt /wTBtMD/cYEcHORsDrmf8l50MtI4FxVaMtPe3T6FR14qgfCLo//1mMeE4dHR21hUV6LHw8 NimIvFFEqLkF4yYBb15RBLyCXHwQVYU= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=TlpYTaSH; spf=pass (imf04.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.215.181 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-5b7f3f470a9so1332776a12.0 for ; Thu, 26 Oct 2023 20:39:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1698377947; x=1698982747; darn=kvack.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=tMjhw76FECkOO5zRdU6IjOHgP+3TMOQK2mZ19zJdvuE=; b=TlpYTaSHDTozxFc2Q6mTuuqZHiY3qWwSD68s4ArcIbLJMGu2Kzeu9dp+olJYLRyJD5 0J3GX1qHRktLSRSUafwNpAm/2eSEfLkzyK8uJ0LgP/2zGlGNdxCZTE25aVKbBmh+Y5Ih wWbBAOWQjjDCILqw5d8vAe/WZnQ98WQ8btclj/oLvzHsie00BOVrx5DlVdhsiA53UV8C mgywIoZc6oylNnYxzodwl3Sx5xFGm5wuwpK1peY2EeQfMSGMAkGsfHU9Cx6BJxCA8eir CUaww2XA1SmPplXayibf5RSbJoEu5bOErVF2aNnzk9qi+8DsQpOFzLijxEVrsn683vxq 23eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698377947; x=1698982747; 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=tMjhw76FECkOO5zRdU6IjOHgP+3TMOQK2mZ19zJdvuE=; b=mYK4EOZqIvEne9aSiIXMsmRELSwBYbQaiRY3kjasvcYHf0FE5xYcfHDY7lmkYnlBmV EOJlhhgLxMh33u0DRhTrXr5Z4Q4KB4MkuJJShUl6TifjMFj59qxyvkrVGCgHKHQ0uqbY QEOQUckwryc+YBc0nv3gNwM4kTet5YZtLFEGVrvPTvLqMMoUlM/N2962PZYT3P2ZLhAU o6rTaGP1V/BkYBr8p+gwrVUBxno3NtUG/XHdaKFQeKVp3SzhXFa/0eL6uM/mDqsI5x1T Egv2IK49lO2/P+i+BUm9tKwqihW98zljFxQ1aKXjwFLV3uGRF3A/4vrMzffKDuyschR1 dc4g== X-Gm-Message-State: AOJu0YzmJ56B4+g6trFhXEK2YecQcORCcRLhTM2+Ws5OmOxojOb4XpTQ pqKHmng8QALkdjjirmkIWRr2QQ== X-Google-Smtp-Source: AGHT+IE+9o1D6mC/tBfbhMEHSHxO+4OKy9VNzv+o8iR1rqr4G54ZqAEfL4OOVueaw3fQnMy76xQeKg== X-Received: by 2002:a05:6a21:3d89:b0:17b:3cd6:b1bc with SMTP id bj9-20020a056a213d8900b0017b3cd6b1bcmr1812360pzc.14.1698377946837; Thu, 26 Oct 2023 20:39:06 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([203.208.189.7]) by smtp.gmail.com with ESMTPSA id ms19-20020a17090b235300b00267d9f4d340sm2345676pjb.44.2023.10.26.20.38.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 26 Oct 2023 20:39:06 -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 v7 01/10] maple_tree: Add mt_free_one() and mt_attr() helpers Date: Fri, 27 Oct 2023 11:38:36 +0800 Message-Id: <20231027033845.90608-2-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20231027033845.90608-1-zhangpeng.00@bytedance.com> References: <20231027033845.90608-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 415734000C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ewdkn9bk8jb5am5eirkp5rf7pk51d8sz X-HE-Tag: 1698377948-851270 X-HE-Meta: U2FsdGVkX199lK6Sz3/a1E8lRCEDRxKwRHcxDdh4YIUOU9eyRTJJ5ZKF40yBDF8fuJuu3i6DxAYG+Ss/2ES6FdJ9vQz9DNFmPHX9RB64fDgD6l28DEZmhVyazT5EfDWu/uXHJDhgih6oeSOT2DuMC6Y96j8gKvE2i3rgq9BqRh2n1cFsw/43/GBgzpw4QibXeJfMfiStajF4vS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PFtJvv7gzmleR3ND255oO4J/dM2YGWDy/LxWNlFkZmcui9Ci/AJJjQY8XTG2pBYxhHiGfce9nq5QyWIw8P5OWo/bk9bbp5HL7sbzBkgH2CUBTk3llPrrPRWiZxPa+Al3M+YGHvPlhtYKxojIJ4OuBdrxHLVXrD/Jx1XXjxEs89oEbdr66byIfOfyoknO8nLlFu6C3jkDY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 Reviewed-by: Liam R. Howlett --- 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--; }