From patchwork Mon Oct 16 03:22:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13422444 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 61E00CDB465 for ; Mon, 16 Oct 2023 03:22:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE9A58D0020; Sun, 15 Oct 2023 23:22:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E994C8D0001; Sun, 15 Oct 2023 23:22:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D61F28D0020; Sun, 15 Oct 2023 23:22:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C40618D0001 for ; Sun, 15 Oct 2023 23:22:51 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 95B99120A60 for ; Mon, 16 Oct 2023 03:22:51 +0000 (UTC) X-FDA: 81349877742.08.3883B87 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf07.hostedemail.com (Postfix) with ESMTP id C40AB40014 for ; Mon, 16 Oct 2023 03:22:49 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=AQY7y+oz; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf07.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697426569; a=rsa-sha256; cv=none; b=wTmG6MFgXO2pwCtOAkz4C65dCK2+VTjREbfpZMxsPJN4cn+9AohZXbLQy0El4Ws0iTbpbO A6p2zJi/6U0PdIxRUg/bC96YWrJhffIEmT0AEx52pPtUwt2BcJEhbUJOZUE9DnpGYDqEeW CrQVmSEA0K0c5iBAymFVt1A94LkKFkw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=AQY7y+oz; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf07.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697426569; 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=7MLK4HxQMsxrLAQzNmdHMtQCN++SQMztyyHR1MHkRQQ=; b=gMXBlwMJHWTw49yDUWiVwa4DNV9Ia0WYlBn1m2aDH/BoUpB5G5LGoZaQ0QsyO+66u2icVw tR6g4a9oEtDGCpnLO9naJDvCBtsiDK0cNsnrkmUxv6MWTV1y4ZaTXmlg9NNQMULgT90p95 7epTUfbK3U009ElDB5FRdED6QaXcnbc= Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-27b22de9b5bso2378873a91.3 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=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=7MLK4HxQMsxrLAQzNmdHMtQCN++SQMztyyHR1MHkRQQ=; b=AQY7y+ozjHCylxvTXRQGRm4qeLic2StD7qupIiVEIgzJCXkHL7yBIAm1Kjg/nfCZnE vMHeL9OfEphPZ1pzjyTQbdYvAuy0hYWxYfy6pB8NrJXWCMLQraCeE5oiN35l8CZJ1bGD QkZ60TdmhDnZ9Rb4ZSUj7VWfu8hg9mv0yuZmR4qkNjJAqWR6vO8lSfDZgTk3AASsX1WF vCpUlPSotNZQvLX/JxcX+vtYo4s5//FZNZQQ+DQ1UruuCcILtfk7JJnUTKGfQ+A49bAz P/bMDwOowBi3H9wbyLG7Gl/Cz4jdyOIDJuVdi1fCKHykobPS46O6YVZuCkhN44gs17fV ySDA== 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=Ky+mNxf+Q+2G9wgBS2UYV5NP8vxvVJmgBJgAGymTQ7fGVLKZwrQCdb5gR/aFFOZOAy bioOXLpWPcSPz7APcwElN+B4WYcYghvY4Ryu0bS9BBQTSAfaD0nc/klpe8r78+4kBHb9 ZPK5IDfzi8vC0Ajz7SyhVB+oh456IaKbncKjttEtWnnxwTCktfjQCxr1BmXugv9X9VaZ hCS/8HB8ohrkczwANvYY24OU46ssGO8daTKrV1tavOVCbAkEJc6+Qe24k0/WsYeNLoqu 0kMvfUOjpyZO1EOr3g2Z0TgZjB2kFwfiqy1E+LdqsPAx9/6uglQITWO9w5szBIp2X3lL 06gA== X-Gm-Message-State: AOJu0YzQdtWUPiwRfyebku8/CefKQeo9fipvlIlq9wjIkmAfQU1XzIHl ObnPRem6Kyb6JiVhksLsGJYzzw== X-Google-Smtp-Source: AGHT+IGUNON6/iy5nHhowUF+lwNS0aMjdLqxBBty2ZXDevKfnR4hUvescHuITP1+A0eJuZZ+fdkYww== 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 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C40AB40014 X-Stat-Signature: dh1ayj37tt8xgyjmm8asypr4534kg4zd X-HE-Tag: 1697426569-238934 X-HE-Meta: U2FsdGVkX189gUJbZMhwVG1rqN+c/s/ck4DPJAhUxBcWW+Mwou86pKQHgl3cQvgcXcknD0+Z88e/lz/0rmYr/hBPsKEvYVQ4pGlilVQm5OuM55LIcYOhpnZHCEf/QSNNnuUfdfW+BNhvJ6nxieyF2znPkRoSCjTHyEyKSxFUJun7NMKPr3k7VrTXoCJNxiujhc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sqJnVSqWOU7FddHVu/LtwoCFX5PxqMCsycQesbOFL2JVtaR4TQ4GG8ex0WtHviG8BCiAegT4q9+O81yyXfcaYMh9Ea6ndWrb8lDueTuy8QMMWMFr8lo6L66f2P++ODx29LzuzfaheWo+uKH8rci94q4neTFVm8Lk71WpwIvAPpSO1CdjsxWLJHHLALKiFg== 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: 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--; }