From patchwork Mon Sep 2 04:41:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13786701 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 61731CA0ED3 for ; Mon, 2 Sep 2024 04:41:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C75018D006E; Mon, 2 Sep 2024 00:41:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C26A48D0065; Mon, 2 Sep 2024 00:41:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A28958D006E; Mon, 2 Sep 2024 00:41:37 -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 7DDCC8D0065 for ; Mon, 2 Sep 2024 00:41:37 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 27BEBC175B for ; Mon, 2 Sep 2024 04:41:37 +0000 (UTC) X-FDA: 82518549834.04.631634F Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf12.hostedemail.com (Postfix) with ESMTP id 62C374000C for ; Mon, 2 Sep 2024 04:41:35 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=LO2cvda6; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf12.hostedemail.com: domain of 3_kHVZgYKCBUDFCz8w19916z.x97638FI-775Gvx5.9C1@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3_kHVZgYKCBUDFCz8w19916z.x97638FI-775Gvx5.9C1@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725252019; a=rsa-sha256; cv=none; b=ttq5qMzknG/FeMAw17gwQqan9I2xr3FXVT8/nN3Cn0ft/GYxaZDDULY2LAXan/oXq+o4NI iNzgFe7R7FEfXgNA1uJfre8ALObpZMmJ1AV1Bw6r93aj3yNHrgoOP1S6gCcdnzU4yQftX1 kpVhENYNyUH8JShLnowt5J6eGMjfRQM= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=LO2cvda6; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf12.hostedemail.com: domain of 3_kHVZgYKCBUDFCz8w19916z.x97638FI-775Gvx5.9C1@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3_kHVZgYKCBUDFCz8w19916z.x97638FI-775Gvx5.9C1@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725252019; 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=kLpU39ux3x2TTO/xeONsOF6qZRhVUZNcpjltFBicrmM=; b=mO0lTsJfDytIO8Ljg7NnQthyUtWiaGD090ey4jKjH7klb9jYhRUHoPJl0l0gF4JFhOphws aoIA4eC6wkOfBVaJwTEJZhBEafYxxAPZnvwGktd3IJGl05rjILii7lgCXjtYzSt+xNW/Nh G3+urVr4mRHiHzF7JE3+kYu1SayOvvY= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e0353b731b8so6521035276.2 for ; Sun, 01 Sep 2024 21:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1725252094; x=1725856894; 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=kLpU39ux3x2TTO/xeONsOF6qZRhVUZNcpjltFBicrmM=; b=LO2cvda6wAecAHAMNk0YzCiHvG7uRE9CwlzZo/c5boL1WQgpNwCJ3noebNFtFIT4XN dj3dpcK1xHPLScsFPXKcYN6RX98h5YZuIOemHWYr7BOBDsuBv2zA0oSBzN/qJKEpLb1J oD0z4Cb6enk4z3yVGMjET9NGQIv7ASdyIalqtDa/6fu6CdAZTdYfxbWAmDq0SzuHW9FQ q7g5PzNfDFoejm7L0oPlohWcmljEiuenxG8nhYTCaz+kJX7e/dsTXyf+osyQHrH27XDc EvfUNlYeMvlYevbRd/ZsDLXypY3MXp7+qtBCA2i41J0NqaeANCDSmBl/53gqPGVQGILU ifnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725252094; x=1725856894; 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=kLpU39ux3x2TTO/xeONsOF6qZRhVUZNcpjltFBicrmM=; b=R62swJIzplzenHgfFYqxs/+fXDBaUMEUsFd7KVQ5acskp/rV1GDCmrtgNjsMBuk8tE KbIIaA1W12+kwU3iHecAR81v2Gm7h/cWRIuKIhSKRmTJB8pCPyX4qHYiyPxz2SIXF5hS 1iG2Xe1iitmyRGf4jNQizfFYaETa2klHBY26Rp9mEqwtBPQr+jQZnkmxGE7YDsT9tzY1 Fm9B8txuO/vgp+bKSNiCeDOytXYZoCNKu2BsqNEMWPsFmfSorpeelFb2XbyutMpAKcFp u1eupzdyAKvfSDsoN9/0xF8pTNe5hsYsccoWuPp8W1NtSL8Aq6kkSUeTut2iCDDCJxaW pfdw== X-Forwarded-Encrypted: i=1; AJvYcCWtxvMCHQUjx0jcVucQkh9NO3WhQHNS5eDbamL/TQqEJESH5rd233Vove0sO5SOSCuNvo7RYnxAaw==@kvack.org X-Gm-Message-State: AOJu0YzyVTgXN0ZHhKjrlxbrdCdlheCsFxQfjg7BifIyMHjJfujWDXm/ GsbWi4l+M86b2nFMxL67IxIHHYnXdevtAVC4fTvY/HZbqSbE8hhGWWnl2lMsSe1wutyAyPkzCHb XtA== X-Google-Smtp-Source: AGHT+IE+2G0xxDfv2kbdFSiqwhGjdz1DeNRKuCcVpqvSyerK6sADotCLCA7OoS3t5ommCEFjIJVLeySgq3I= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:7343:ecd2:aed:5b8f]) (user=surenb job=sendgmr) by 2002:a25:83c4:0:b0:e03:3683:e67f with SMTP id 3f1490d57ef6-e1a79fed1aamr15821276.5.1725252094100; Sun, 01 Sep 2024 21:41:34 -0700 (PDT) Date: Sun, 1 Sep 2024 21:41:23 -0700 In-Reply-To: <20240902044128.664075-1-surenb@google.com> Mime-Version: 1.0 References: <20240902044128.664075-1-surenb@google.com> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog Message-ID: <20240902044128.664075-2-surenb@google.com> Subject: [PATCH v2 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, 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: 62C374000C X-Stat-Signature: onq9sga3cffpkh5z8z8d874fcuqnypzg X-Rspam-User: X-HE-Tag: 1725252095-276518 X-HE-Meta: U2FsdGVkX18JWeODbnWb/sgzlbNSFwCksN2fCkaoxYN+0zPkt6flKBcW4tmM24Q/1wRWEviHT/MC+1OZVn0AVM04SsWm2uFAa3RVMz2VI72DA4kgfEfdOV+8R2lIJ9ZjaR4Vb04ZN59WZNCqRXKSmkfSdxp57h4hOSquCVpxKbwtxWiY8yHZjPRN+c8SCmna1v6QL9N/t6YYTij0CMGobCXE8j8O8uNQONnWoG9c92mFZulldRuaTjW6ZHtKxEX1c5UIMqPBuBMf1UXDOzv04qqnyabG2WxliZAkO+YnLgJL47x7mLzAOe3xI/WgPhjG26p2yQbai2x1hlg/H/4MvCFwXgb24jVB30165m6CCdYPcxY0YHUJUMSKxSXfgJucGbzNrZZYx9C9JxXNG4M8hdDCipFtgm2mbtiFPfRtY8vQ7XhyhPXQn+2vj2Yz/mVyASD9LhsQwjKP/j3Tu3Sf0ERTsuUWhfH76hgmTUPWiSlq5RHFpXeLyfTXiKMVIavRK74mTMTtBqh28oeV+5gAuCu8QDbUB7CgBAVbYdn32mTxQBxo4apnybjwL5yMKVAcJm80jLxZpr4pI2yevSl2YK1k099lsV67F1RwmcU1T8io1fCCNHNXvLBU5HhxFOBqZ6CCwV5iSKkLEF3J6P4wCT3PJGneZLGjcGe2gUzgS8mSqtu08rwAKChzN9F4o994NUaHMvwJyl7Z+lAPfOVCY5heo6mFojTvUma6hgPWgCweD9JLl6eJrxkgu/s3WQGaPse9ZUKnCJtzWD0LzDmmHIwVY7/3gztXhQ2zAoEaurHqBM+0v4y64TiArAVa82PInbDj6oVxTYDRFW9IlCHaNw8mDOA/2GYX0aaaRJO/K8nJmgf00Uz4T+rl0KroIplwvEKTRtKSUSlDcexmeygphNB+TWvTISkZ8vSd/1k6iGkITKI1FV8KH98wza5Mnll1PO3ja+c8RNGJTxJvmaC WtHwyMAF teKeE8DKaPfSfKU/aS7p+boafZ0Bm0JUOu5Ij8tEyESKRbAPo+Hv6cr1oTR0JC3QRDBn+LwrcGuGiSXdTCcOzgwB0xliCnWCc8NhIRG64/+ZMNXqG57CDmPV0+5+67IXjvdlQdupUx3V4UVJugSe/od4gqy92RmBG/uklWrF1c+YdAmFBVDmjAcRuycx/JxJaLvkFm215RcMbnfjWyWleY6NkhNN+AEl5GVuoFPSJC36UCw3g0fv0HuNwOviXq8LDjfC/mwthS46PuSrL10XTCd+MBPj4f0iLtmrnYo3nRP66VDTZUzq3dxeF191/DduKoyQA4XTI5N+9TAWfk2MauOacHAxFIe/SWdrZph3tFO7KGXCnagpbTsaf3ZMt2IkorUFB2Teh7ICAqGhPHKDgnGcQsV5P1HeFkF4iXzQ4wSJ3BsbhJZdVQ3epzzPHOAOfVB02dDl89TDw8KuLI0rAdbUkw4/aZnxAM+eC07jOWpY59cr63b/kxLuEe5YISQfCeELAl30Qj2YAUcbh3wAH+yBIySxvGWWGythijzQf7TGDs/aK1xlfzVtowxHZYfPdiEAI4euwyTj+nMlfSm/Cqm9oDg/eDqO8bGpY8XLvc4Z4Cgk= 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 --- 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 8e1504a81cd2..45e633806da2 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,