From patchwork Wed Oct 23 17:07:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13847635 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 ED309CFA454 for ; Wed, 23 Oct 2024 17:08:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D5126B0096; Wed, 23 Oct 2024 13:08:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 75DB96B0098; Wed, 23 Oct 2024 13:08:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B0536B009B; Wed, 23 Oct 2024 13:08:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3A8FF6B0096 for ; Wed, 23 Oct 2024 13:08:07 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D915EAC5FA for ; Wed, 23 Oct 2024 17:07:31 +0000 (UTC) X-FDA: 82705499352.15.DB4CD9A Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf05.hostedemail.com (Postfix) with ESMTP id B25A2100027 for ; Wed, 23 Oct 2024 17:07:31 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=J4GooH+c; spf=pass (imf05.hostedemail.com: domain of 3cy0ZZwYKCHIikhUdRWeeWbU.SecbYdkn-ccalQSa.ehW@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3cy0ZZwYKCHIikhUdRWeeWbU.SecbYdkn-ccalQSa.ehW@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729703132; 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=Cy4VkAGTnueEjEvw1TSjR77Zk0lX1faSNj+Oljrwa2Y=; b=1GUE62OQmjC+sXGoMcKq+VW0zx98uQLq4bKL+k/ugCnsP4wFac39GRLdodScaas1xYE8iL IjpOZR9MDUI1E7PeyVcs70hE5094eBDwd4TgGz1xepo9eSA/lOlh+mM/prkHF/WQyCGBDT E8aEc+JwTQ+ivl8Dv2jNWeMk96cHacI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729703132; a=rsa-sha256; cv=none; b=aJA6/23rkF6iJdN8ztWxsxGIqi5oF/1YFv7H3q+z4bEb01/TjwNQFRmt0tinKX57J/Girs 5I18lfJMh9dVwb3fpt087inurk/WOptAH/EVaJYouH8rxgnz30gbSbPsvkhYXQYdCila0P NTO1GOICk8Xw3JxIqVQOB/vXRDOSE+I= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=J4GooH+c; spf=pass (imf05.hostedemail.com: domain of 3cy0ZZwYKCHIikhUdRWeeWbU.SecbYdkn-ccalQSa.ehW@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3cy0ZZwYKCHIikhUdRWeeWbU.SecbYdkn-ccalQSa.ehW@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e2954ada861so17274276.3 for ; Wed, 23 Oct 2024 10:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729703284; x=1730308084; 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=Cy4VkAGTnueEjEvw1TSjR77Zk0lX1faSNj+Oljrwa2Y=; b=J4GooH+c+yDEKfWScuX06MUnjdtMF9da+l9PUrh228OL2OGK0YlODh7Hr51i60aVgc ygUlOj2L8Q+uE/PHC/HE62LQiGomaLDqdzcA7e1iBoWupE6JQipE7nNBJXQE+hnGUVHz NTQvYb3+CZVvaAokHUx+AVdUfZ1icUhLhwVM5ugvVjK8wcA8x3e17N/plAA5bAfeuVQu tVc9Q2f9R8IRC89NjaAN5D/uXL16O0YTB5vLWSQe2iZqJ9ST3kseT52FIpIOvRKI3s1l SW6aus4WcC0O1/VjGtcANZOeKoBVWMpcm+HnHIBC5PKufcWtK1JrhloXr6/PgB1jfEvT poDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729703284; x=1730308084; 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=Cy4VkAGTnueEjEvw1TSjR77Zk0lX1faSNj+Oljrwa2Y=; b=mSSaxmkL70PAAVk/vAqpbBdUUeX9P8Bh8V4OP9CoANlzYHUwjK3jzjeLhHrC50Z2h7 Bt9t8GYG9Oln9CV6O7tsCkYBeohtgusJK9S1Vix5jrOjh8dz/Dw07PSAlAUcNlivUdVu +GYmQHYrgYLKN1jhktG77jVg5vsWtthVXGds4ue+i4Eby2E/XJcYDjbeRuqDNWdfIkPA BH8PM69wcEMOYrIutiFInF5AGaBxYcKNThWA69GsJWwoe9pjipi/Bs7uutoN9wDC7SA+ MI4Al1Scw87wcreYyMnVKBVSSI9oZVTVB0pJwB4Jxz6ske5Kcp+ARqsVdyFu5euUqZ8A 5tCg== X-Forwarded-Encrypted: i=1; AJvYcCVEnu3Fo2/BTStkf0FYzKpx7YT9YHW9dT+oT4NQB0kc6tFeMui8M7gwF1r7IRbBNHPfgwxuvmk5gw==@kvack.org X-Gm-Message-State: AOJu0YxF7/pem1XnAlsApatBEERn5uWB+IknuIKVn71zN/o+1g2RJZ0q jzSQJ28B7lELfMcK+13YH2C1RFd6zEnq9PQ1A+7bM7Qn6qTZiM8QX/6Sp0nhUP9yoazvh7+gksy VqQ== X-Google-Smtp-Source: AGHT+IG5P3EOBq94xAhs93OihXu6fn1+vh8Hj0b9Xh0nro0ohDjLm9Tm7P85Bm8yXiSBBXuIOUCegUy3OSE= X-Received: from surenb-desktop.mtv.corp.google.com ([2a00:79e0:2e3f:8:a087:59b9:198a:c44c]) (user=surenb job=sendgmr) by 2002:a25:7241:0:b0:e2e:2b0f:19fc with SMTP id 3f1490d57ef6-e2e3a631bf2mr3476276.4.1729703283882; Wed, 23 Oct 2024 10:08:03 -0700 (PDT) Date: Wed, 23 Oct 2024 10:07:54 -0700 In-Reply-To: <20241023170759.999909-1-surenb@google.com> Mime-Version: 1.0 References: <20241023170759.999909-1-surenb@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Message-ID: <20241023170759.999909-2-surenb@google.com> Subject: [PATCH v4 1/6] 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, urezki@gmail.com, hch@infradead.org, petr.pavlu@suse.com, samitolvanen@google.com, da.gomez@samsung.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, maple-tree@lists.infradead.org, linux-modules@vger.kernel.org, kernel-team@android.com, surenb@google.com, "Liam R. Howlett" X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B25A2100027 X-Stat-Signature: kp8wnjk3cxiot3jywykjtsirac4kxytz X-HE-Tag: 1729703251-525926 X-HE-Meta: U2FsdGVkX1/JlAGg5Vm80/L4HISZrxogqYVBEiZAZt6O+cK6hLZDPvy/u0Os+kzp/IzsA5e+jZ3iQg4sF31VWDtDp7Oa42p3OQTWdoZVS77KhijOlbrXpKWDo44oRcrkB0hDMo154sWk4c0yE0gZ9MuMaDX0OUQo5AwTtt7cwg8HoddYY3ot/VoB6dDVvwUBnei3yjtBLMIcSIulZTnzZNISY0e96TE2kX8mSaM2Jh1+15ZdjQclz2ZAh9To6d6qAEYI7Lnbt/Sihft4kbb78ZIg8CWt7g3wlUaZiaFDMe/zTxllyxNU7IbjL6pHiMLdM+XOPCzZ22G/Z9ZHPgrrKA43acxhi996Huku1FS47rfLPCu52BBPZZSgzhB2N8P7SplKuBjruKe3wsBP0D1VdsGi0TB9BOiaJ1recIykYX58rdO2U83SAMrFhfTfK9rBDIa98zMuBtIihMP4IJinn3aJi8hQNTURPtSccmZWdOgifzM3WavVpOcQTg5cGPPPGIws7gzC/CJsfTJI+z3Idv6b02wbtYYCLydyaL2uU5q6HhUGyN9s1OsSHBKG17OVO5cqOY6M+knCh8HHlf+hUt2i7h0QmckJe2iztjNACqNzA0RF1ng5daB71zBc2/uN0+lWhDr5Bts2zvi6tR9IfM6ik2QdX0HdbMi1ReAciUu/vNhPo4JCyhbhkNwpvGDpaE3+4L6hlJGquWzbs7pAeponjXN7QgmRFhu1ChF6xYQqTUfvr2h7lpMLYs3dHnDtUpyZmFHP6H7G0+C0UU1tt9KzP0L4sUzjP56oqc3/d7RGywzjEk9Iwjcvltt9ihi5QGvu1QvwLnrcbJKtjKJqnRPbqe+aVHLkhrnA0N0mij0WXTxyAXjMJHoFYr2zYT8UZqfu/ylj9j/Wa5bMGskXnA7V4LWxxuwzv360rz9W3CT8zEJ9324dU5MWYZIlxxgG4TWl/J5BbP9pySkYhn+ vo9fHUVK xtCOhpUL1J5MHWO0ZeINIIV843K1YQ/S4/E3scUAeuGxQVy/+bAxdqRgAtCo/CzO8xfmiW4P4jGzB5llPXUTBVOSYVipWHFnNoeoXyj4J/jrPyRB9lDz2ZVKGNpcKimE9pHHVizeVNCSFGe5bmjxX3bX6lPNEnfZcgwiscyewnY1erQCsNIZe+IVoLk3xC0qtWejswEFWfPOgT63/haol9Gv5dGHZwzhe436Wv7xpZYIM1nSMEMOGmIQNZD6HPT3QlxfQrxJ1Gg+t/Ho06yEkgKZDxyjl8tAuLIoUQKGdPLCGgCjvjwAT/x1Dy60AYQUmMU0JLenxpJqB5bXz7jrXGUK8HtjQ6oLcz+/7Es502UJUP9M+s0q9RQrdZ0Tw0r5UG0PP4l0m60PfVJsGZDQeO8GVFStto6yk3fD4Rx2Cg+cfLpjnFJZHk6LJef++/9tWSlvsWgaOtMHYTaEfmyGhLy3u0geErKpg+Lh0iDecLa3ltDydqGfcTLaLP7X/zCWCr0EGqv/urG0KsrZ3p6mFtc3YoheXEPGWlbr7G9oV82U6kUB0Zf+48xRONew44ZNSIC0xpMbi1iUocLBGJUbB642JfEzLgvlFPAVFvp4g7w0klHE= 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 mas_for_each_rev() function to iterate maple tree nodes in reverse order. Suggested-by: Liam R. Howlett Signed-off-by: Suren Baghdasaryan Reviewed-by: Liam R. Howlett Reviewed-by: Pasha Tatashin --- 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 61c236850ca8..cbbcd18d4186 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,