From patchwork Mon Oct 14 20:36:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13835445 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 4B94AD18144 for ; Mon, 14 Oct 2024 20:36:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCF706B0083; Mon, 14 Oct 2024 16:36:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA7946B0088; Mon, 14 Oct 2024 16:36:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFAB36B0089; Mon, 14 Oct 2024 16:36:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A12446B0083 for ; Mon, 14 Oct 2024 16:36:55 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7C259161266 for ; Mon, 14 Oct 2024 20:36:46 +0000 (UTC) X-FDA: 82673366622.10.7166473 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf08.hostedemail.com (Postfix) with ESMTP id 0F772160005 for ; Mon, 14 Oct 2024 20:36:48 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=L6c8wyum; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf08.hostedemail.com: domain of 35IANZwYKCFsLNK7G49HH9E7.5HFEBGNQ-FFDO35D.HK9@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=35IANZwYKCFsLNK7G49HH9E7.5HFEBGNQ-FFDO35D.HK9@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728938097; a=rsa-sha256; cv=none; b=hjzYrXNPXy8jkPw8tIWvqIdX0EXBhuAvFXhQ0kedYvre8QB1aKNvtH7HyHUd49+LKq+2fx Cj8MzmmxSMKJDV+0AgzTecaR308puwIJkyFtyjIF5EGWpldBq+nWEgEc+FTmxgsaBNZSgD RMIVdDG25/1/XczXpa3uwblIfJcwsNc= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=L6c8wyum; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf08.hostedemail.com: domain of 35IANZwYKCFsLNK7G49HH9E7.5HFEBGNQ-FFDO35D.HK9@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=35IANZwYKCFsLNK7G49HH9E7.5HFEBGNQ-FFDO35D.HK9@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728938097; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OBL7Vs4MVDC9S11JwgZ8NOTxmnHjmsqVGP9nKZ/sLKY=; b=eNpzjfuYGDoFtTr0AKzuzDkqtyvFtjQZHtlkAWOLWapQblLufGLX8n9hNmaH7kSL/euC9b M3n38rWB6Bc/oJxeEPx/wfLWFb/3g+sayQMdmNBqEWV4Kp84UUAjX65ca4vUimsTNAvN9i hjmZ33FzCoOmaleLqnkwpHQfuobwwvQ= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6886cd07673so85741907b3.3 for ; Mon, 14 Oct 2024 13:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728938213; x=1729543013; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=OBL7Vs4MVDC9S11JwgZ8NOTxmnHjmsqVGP9nKZ/sLKY=; b=L6c8wyum1ny6ENQzvP36JPSzuSVohnE2bjnhsz2tlNWbOKqH16l0jMKBwPEcaRrbBl ho91zrE7H8VZ1LepFGGcuVBKle94u0gS+1uKL7Ep4pdaDc0jf10clDiIUTDRW8/qXuQm JKMGcNmuEufkqVM6GBww4/XsoaXmebIudGWxF6XJXNnf+OEptrDweElAnGyRkw9RbocH bNfG3p8RucEQP/Sm2BK1R6s5r06+iC6+bbiZ5DqjCvRqdclwh0Ukzkm9Agu3HHj1MpmW 3N6+y5XXGvtbdLU5TRplmByXGEj5qmfYvG7JQGdVhUbxtoRiJsNR9yNETNP2qozQ9iWw NipQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728938213; x=1729543013; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OBL7Vs4MVDC9S11JwgZ8NOTxmnHjmsqVGP9nKZ/sLKY=; b=pmSLmdTZZLu6m/Kzcr+CFQ4imhVjt6oAh1aTQytDGSWwZFT8Gc8MVGHRWyuzcMECk6 oHqoVnXCiuVB6vShOi9UX0StI3kTlP4WZfAv/f0itCytiC++RCik50dKlwGikleiOSkr 4AVJVJmcK/dP+NtCqYN2yns0hlLpa/O1CtsZAeWLUiq72DVvdqF+uNS8msAshsBp3tws FqBVz6ZrL8vebq6hS5RhMNVBL6/yVSGOtJG/bAWKvDaq+F3/npWiiPgX/A5sssM4whz3 SyOBJsSapZS2vrzXv9owwMuxIwowpMtltzNe5zJ98m6Wo5zYvrYMMdNeaiPWGcVHdHXe KOWQ== X-Forwarded-Encrypted: i=1; AJvYcCXJBpDXR9BVwGcEp40Yz0WKz/YSrXbG50+nmchM/lb4cwkhZOLvUzMJ4X/hbTmB9ZdrWNYNRQI7mg==@kvack.org X-Gm-Message-State: AOJu0YyVOjYD1nFyRQESfVDMnLD1kWts/uGuFwEi5k05O1Az5Svc1tyB XD2TCux8Kq519tjy+12Xd+FkRjtW3l+d+MRg81h/vUfjAs7M8i2eUjjHhnpTmcZKYE3HBWSUDR0 ehQ== X-Google-Smtp-Source: AGHT+IF2H6wJeGtAPLdmfc0iDyPr+v9IGwfu4WR2zrx8HQDicf0QvWblIiwnCcZ6i4e+0edwH2bII6UptCk= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:915:bdd7:e08a:7997]) (user=surenb job=sendgmr) by 2002:a05:690c:7446:b0:62c:f6fd:5401 with SMTP id 00721157ae682-6e347b4b2edmr460147b3.6.1728938212594; Mon, 14 Oct 2024 13:36:52 -0700 (PDT) Date: Mon, 14 Oct 2024 13:36:42 -0700 In-Reply-To: <20241014203646.1952505-1-surenb@google.com> Mime-Version: 1.0 References: <20241014203646.1952505-1-surenb@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <20241014203646.1952505-2-surenb@google.com> Subject: [PATCH v3 1/5] maple_tree: add mas_for_each_rev() helper From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, corbet@lwn.net, arnd@arndb.de, mcgrof@kernel.org, rppt@kernel.org, paulmck@kernel.org, thuth@redhat.com, tglx@linutronix.de, bp@alien8.de, xiongwei.song@windriver.com, ardb@kernel.org, david@redhat.com, vbabka@suse.cz, mhocko@suse.com, hannes@cmpxchg.org, roman.gushchin@linux.dev, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, pasha.tatashin@soleen.com, souravpanda@google.com, keescook@chromium.org, dennis@kernel.org, jhubbard@nvidia.com, yuzhao@google.com, vvvvvv@google.com, rostedt@goodmis.org, iamjoonsoo.kim@lge.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kernel-team@android.com, surenb@google.com, "Liam R. Howlett" X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0F772160005 X-Stat-Signature: jf4a7ioyybosqi8km6qobsrb1guacd49 X-Rspam-User: X-HE-Tag: 1728938208-707914 X-HE-Meta: U2FsdGVkX18UZcECgk2K3IPZGLXmO/hl9Ex4W0zHp1dM5YejizrrYktagEpboeXm0hNkcQIDJLxn5BRBRBccriPvvfX5uMBQm0VJNNQe2UYSL8e1s1IOk9cAXV7i1DOiA/qc1Dtbx6o4O6fY/93MiUR6S/P5vPy/LQTWkqKN2kkCJ4XZttt2acNiTec8uFYGwWlUVG1aOpEVZjrETX4eEZzFNjnIGRgINKp6hBoHrGZPDVh47ojJVa8+nqbPximq+gcEeLPhfidkxnNjdE330rjSQvdO0fIkThW9eK3ryLEwu0hlzqL0MprfcppVTdq2wOmng5a+ycQ+OjZR+N+qjsBIXhIN70kbMeVit4TPDUXBe5RV3BUPuTeuigDhd2qgZCvOAknfLOcsfR9CxEK7Hf4BXi08EWPfp0HzhhrzRsPdFErS8pM9HpMzH1FqRKlIEAohC3JWkqyKQcMln1Gs9UGTK/4/c3ze05xACQx4eRxLG4DCeUipGXIt3hwHGckEPuQ7CBDAHp6s2CPWsDwQ1FeYhS2QRUFRLYNcftD9n+OCU/pxIlfuVg4/RhXHewM76GmidVDNyk9RH5dOT3Jex+9VuUQ1guEECNPRYPjxWjdbyZL/IZoh2EMVIDOiJWxQs4oxWSSJWOSeGNMW9NgU/Niu2hNvJG6RWQRLQU3BjrSgDUP0JIt4P6ddP+r4TnozqJF6LE3TldWXtZcEM2uE+0EfDsrbPDgJtFXweNf0U3yMGk1gJRPcOE2vV4CVmdSyj98bCEgEwPwzKI41IbcUFt1dXVhV61D07QatfdVdfuiO7pVnI93kT7KlmqsmZxyWJs9ImCNdSZ1JTt5zu2bCWInKOAQL1hjB9YdJdFr5oOHMaeinplOBsKKbbz1/kE4whmcFVcP5KA53Enjn6JIeabZtPeeSlWOt9S3ih3ld7ZVPc2WiHUao4FF0hmI2TBSu5Yfs4b3JtBw9RymQcaw 5ejHjW5a YQqwqQJtQ7OAtkYqvBOCj9bGekoK4hoHVJKzxahngNabu463/LIAli7nF60QORMM81taA5GzVWus4i8SLhgPzqm3RqCsUPc9wgVpIKmhZYJlpVfh7bEZJg1pYTjFPCnedA2bHykH32N0HmUmdoLikGW2HKQLg45YNHFt+8rvfNFp3ssik1xeZu9a+kuYqz5CtOMUg6yIFkpBljKkZ2kaa6hK5iTnPPaWDLz4oohjXXoym0FCXBY79/xHsQKyXDWnlwlg2y1GYcz0X7Zm+S57c+IjgcqvPDBgtdxM0r3ZJnxeaxF7DueONofFDNA2fDHmPfhMTi1eh6zcnmZwjiVIP4GkZgVyfnNXCWwv1Nl1UbKEhuYBlB/WlOoewDfTMbptf3dq4kqz+zFWAXaApoartOQ/OLSBmLY98a/ySW+lOEwwmTSd4V9U0ydBahzJzPdygDwfIILPl+5Vb3rPwJhhK0npLkYVc5/RVcpqb8UI1GCUnPXJTm+3p48Igw6hW5f0w26ulE4DebS4ylOTrADlZUnel3GcP1MEfQOisLDfVGRx/9Lmh5knn3UgO/3h6upFl8EKoxFhC6mSBtXFK7axA9LMDX44bkxfzArss11J8F8eYy8M= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, 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 mas_for_each_rev() function to iterate maple tree nodes in reverse order. Suggested-by: Liam R. Howlett Signed-off-by: Suren Baghdasaryan --- include/linux/maple_tree.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index c2c11004085e..e7e2caa1a95a 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -592,6 +592,20 @@ static __always_inline void mas_reset(struct ma_state *mas) #define mas_for_each(__mas, __entry, __max) \ while (((__entry) = mas_find((__mas), (__max))) != NULL) +/** + * mas_for_each_rev() - Iterate over a range of the maple tree in reverse order. + * @__mas: Maple Tree operation state (maple_state) + * @__entry: Entry retrieved from the tree + * @__min: minimum index to retrieve from the tree + * + * When returned, mas->index and mas->last will hold the entire range for the + * entry. + * + * Note: may return the zero entry. + */ +#define mas_for_each_rev(__mas, __entry, __min) \ + while (((__entry) = mas_find_rev((__mas), (__min))) != NULL) + #ifdef CONFIG_DEBUG_MAPLE_TREE enum mt_dump_format { mt_dump_dec,