From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3780247A0C7 for ; Tue, 30 Jun 2026 19:09:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782846564; cv=none; b=kNLlZGVx21XrhTDgiZgImAZyqbMmHbD5kn7nBNlRHdqlUmVZv0U1CNiQZ19ObckD+CMHtqj6SGHbSWjIChcVWPe9mTNTj2rYtC9wFUXsBjSBsjybrvU8juWgmXrd3jhXneqBkIpZX7gm269ip0jY+54U5P8UPZoHtDfEY3STifc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782846564; c=relaxed/simple; bh=UmaVB/hXxfGgDVSOqiSfaVoJYV0Alu/TQXumR4a92Vw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y1e7qD0v8VlpzBavzwhMm5+umnDZjFYqmk7g1p/yffOkTIqiJG8cSyHNShyihEyy5EN3tC070fVI5LJlYrktX4yTM/MCnaTTIetJDKpZP83PAkG6bupWTZKqY0NrZgZ3oJAGizqqO4o9VqtxuAXGQM739W0IF7I503R/nTWztA0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=evAwrmmJ; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="evAwrmmJ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=oefyTdRYkFTzp7WNDrEG46XjgxfzRa9VZQuKV2Obrl4=; b=evAwrmmJU69p6QrsY4DlVv6Pr+ ccVtz+TxMmHVXjTzAj7QIj0U+O5Ic9JvGbEEPow6/IMsIM+35nu1AB8ayxmCryGn9+CsZ0hLbx5ZI 55Z4lleCnoiSyp6hbQ7LrVOpMrLKhdj/PH/Eq5TRz83y90Q2dhPbfoWgwZOyE+OLytH2WNiYBvPfi 2fZwpRnIReOglNaPUsA3Cl6MNpW1bGxyKDUiORpkO3vQvzGgT8A7ihxrVBw0MQWoUdR1nKmTmOtL7 Ji9xUwASUCMnz/nJAOi5sMfLp+FXCNaSDiN+C2pi7P+30uiZYlbxftcxLiAoUwjRFwdutHDJhIa7N YwSZ3LZg==; Received: from [38.23.173.23] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wedpi-00000000657-2Rod; Tue, 30 Jun 2026 19:09:22 +0000 From: "Liam R. Howlett (Oracle)" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, "Liam R. Howlett (Oracle)" Subject: [PATCH v2 19/19] maple_tree: Add helper mas_make_walkable() Date: Tue, 30 Jun 2026 15:08:43 -0400 Message-ID: <20260630190843.3563858-20-liam@infradead.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260630190843.3563858-1-liam@infradead.org> References: <20260630190843.3563858-1-liam@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit A check in mas_walk() was incorrect and caused inefficient use of the maple state. The same issue existed in mas_erase(), but was left unfixed. Making a helper function is the obvious answer. Signed-off-by: Liam R. Howlett (Oracle) --- lib/maple_tree.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 4336a98763984..06cc05b79fbdc 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -261,6 +261,12 @@ static inline bool mas_is_underflow(struct ma_state *mas) return mas->status == ma_underflow; } +static inline void mas_make_walkable(struct ma_state *mas) +{ + if (!mas_is_active(mas) && !mas_is_start(mas)) + mas->status = ma_start; +} + static __always_inline struct maple_node *mte_to_node( const struct maple_enode *entry) { @@ -4446,8 +4452,7 @@ void *mas_walk(struct ma_state *mas) void *entry; mas_may_init_lock_check(mas); - if (!mas_is_active(mas) && !mas_is_start(mas)) - mas->status = ma_start; + mas_make_walkable(mas); retry: entry = mas_state_walk(mas); if (mas_is_start(mas)) { @@ -5683,9 +5688,7 @@ void *mas_erase(struct ma_state *mas) if (mt_external_lock(mas->tree)) might_alloc(GFP_KERNEL); - if (!mas_is_active(mas) || !mas_is_start(mas)) - mas->status = ma_start; - + mas_make_walkable(mas); write_retry: entry = mas_state_walk(mas); if (!entry) -- 2.47.3