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 ABD374266A2 for ; Mon, 29 Jun 2026 14:42:53 +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=1782744174; cv=none; b=nUvWVIc1FNZjvzGl0Z7C+qPgHEQvRWcB4WzaY9k4sb+TCs2RHU1chnLRb4jmqYItadkjhRPdYnQVmMx4n7KQbyxVr2FLLm7/gznT2zYbViMCheweNbWtm+/4AHhcfZnRdHeyvDQXpbG6qnNxmFNOi/QaTfKdSPTH6Rmn9jhrUKo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782744174; c=relaxed/simple; bh=TY2wGTY9lsiP50tuDIEKVZZI6ffEkvZZftV88GvvQ5s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Va/sT+V6zBEUkb/gRd/wHhv8NV9j/LE9HImuLcCAg7HX/3WL5d85JAHwm4CqAZd0D6pQRqfsJuwCMkramaeJjpXjGCnVLc0T/7KO/Uty7PS70O2/YAGZqOPXKhB5Fbq3QaGn1Ip+zwr9ZGyf2W0JjY54MwjEjlq7SNyK5AaUb2k= 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=kF/nDrHF; 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="kF/nDrHF" 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=BDYO40C3otyc6wJw4wPvItsggsDazRYQojvAiTMkGMo=; b=kF/nDrHFbEKSDBZJqaqdUxEOZM N/5wRlMnCc7N4K3u4LC7H2/Dm96WTp8QFcR8xGyEUw5hN7U3z3Iz7pcA4gUx24+FzD9RsP3xN9XCX zPwVLHZ/LlRtArGUT+jVYiRABSIIVGE7p9bAsVRroZU4BMql40EVN/z3YfgJhTNula0sMc/sioWco nda8/WHj20Eb5OnwFpv3gVTuLURC0uM7fg3wAf2aEUm+VOOljFmyxmt/enUNmapYsjtVAAoerfpir sPrxQUWjufAe6OBVs8rQh036kEr4ovIYAedekRwyK71ct5LIp9I7A4ZsbANw4A7qgmnT6lbWAauzu 0fOgegGg==; Received: from [38.23.173.23] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1weDCH-0000000EueX-0LsT; Mon, 29 Jun 2026 14:42:53 +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)" , Jason Gunthorpe , Rik van Riel Subject: [PATCH 13/18] maple_tree: Document that erase may use GFP_KERNEL for allocations Date: Mon, 29 Jun 2026 10:41:40 -0400 Message-ID: <20260629144145.1572283-14-liam@infradead.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260629144145.1572283-1-liam@infradead.org> References: <20260629144145.1572283-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 State that the mas_erase() and mtree_erase() functions may use GFP_KERNEL on allocation retry. Don't just depend on people reading the documentation by adding a check that will warn of the use. Cc: Jason Gunthorpe Cc: Rik van Riel Signed-off-by: Liam R. Howlett (Oracle) --- lib/maple_tree.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 67cc480534e96..c5efa3e2f7461 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5686,6 +5686,10 @@ EXPORT_SYMBOL_GPL(mas_find_range_rev); * Searches for @mas->index, sets @mas->index and @mas->last to the range and * erases that range. * + * Note that erase requires allocations and will use GFP_KERNEL to do so if + * necessary. If the allocation fails, the internal lock will be dropped to + * retry. + * * Return: the entry that was erased or %NULL, @mas->index and @mas->last are updated. */ void *mas_erase(struct ma_state *mas) @@ -5694,6 +5698,14 @@ void *mas_erase(struct ma_state *mas) unsigned long index = mas->index; MA_WR_STATE(wr_mas, mas, NULL); + /* + * In low memory situations, the allocation is retried with the gfp flag + * GFP_KERNEL. The internal spinlock is dropped in mas_nomem(), however + * the external lock is not dropped. + */ + if (mt_external_lock(mas->tree)) + might_alloc(GFP_KERNEL); + if (!mas_is_active(mas) || !mas_is_start(mas)) mas->status = ma_start; @@ -6040,6 +6052,10 @@ EXPORT_SYMBOL(mtree_alloc_rrange); * Erasing is the same as a walk to an entry then a store of a NULL to that * ENTIRE range. In fact, it is implemented as such using the advanced API. * + * Note that erase requires allocations and will use GFP_KERNEL to do so if + * necessary. If the allocation fails, the internal lock will be dropped to + * retry. + * * Return: The entry stored at the @index or %NULL */ void *mtree_erase(struct maple_tree *mt, unsigned long index) -- 2.47.3