From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795921924; b=QbYEa58VbIa8VSK94ZJKIulpUV1dbwrqXR7qUcsRLjqj5uu8QxMieGRBfay0+3DQYDyZ hNcoON0E8zunXHTlLFmmhLkEj82cpdwyHvXhlY0ufR9At5ccBHFlPk6NuFMOvZjd8e7iX cSC8jBPoAWuo6BK9qgThkmc1AgvLHL7eZvra6RWF3xsUKFCifMJ/hSJSUweLp5dXCVytd aNqnsi36SCB2qvPvBXIvvXG/cxc1AtZSar+w1hR9cmErthUNVbBteAy0fZ2mfwxEIPF34 YMlfupBTM4d0ZzdlPGRX20OXmTThthpgABs9pNI6ZwmeB5Pdtg8NqwF2Rp1BL6t5OZA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795921924; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-Id: In-Reply-To:References:X-Mailer:Mime-Version:Content-Type: Content-Transfer-Encoding; bh=S7NOj3uHHLubNV+5muJuPf5YFGLLHf+PEA8TQoSMtuw=; b=A/gClchkKaKaru25Ea4MOxPFgdkyEMpQy77kGDSORxeSbFqDPRO4R/lT+/3MZgbfN3WA czm4HsADJptyflF2rBQkhOfryyf4eyEkOH4DPvbVi3Zmd/RntwGlhOkD+fivxXQBYEqd2 5SAlEUUONmjiO/I6nMEQVKRLB26qo4D98mqJ9DOevFItVI9JqEaOBt27IavI2zntRU5bD znG9jCYRE5vHwJujsc+j+we/G9mjFAt3T9v8w6LE5lNRFu9KC7u/PeiT2LWS7811zWP/V 9E9H7SekC1NSoqEKAUVyaicIFlsVmcoWs143cL/ckD+MQaMz3bd6BXyzRQCMxYh1lkQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b="2uEU/xdX"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BE22606A31C; Sun, 29 Nov 2026 03:12:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=2uEU/xdX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B17D1F000C1; Sun, 29 Nov 2026 03:12:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1795921923; bh=S7NOj3uHHLubNV+5muJuPf5YFGLLHf+PEA8TQoSMtuw=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=2uEU/xdXjiJ0hAA2YRrHkDpq0yIgs5siKuaxxOaQq0eglWHidgsFbfk69Gt/YpvIO /5qPgg+U7ZFedEuqpkPwmaYKqKH3xUk1wgETlnzsuTTsH0gbuGKiiIin5qrNf4NWH7 e6eNdUrWmdr+KaRlaj6v0GIUv/bZTital1VOgaxQ= Date: Sat, 28 Nov 2026 19:12:03 -0800 From: Andrew Morton To: Qian Xiao Cc: Matthew Wilcox , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Krystian Kaniewski Subject: Re: [PATCH v3] xarray: fix index jumping backwards in xas_find_marked() Message-Id: <20261128191203.6d8a42b8a55809048367f903@linux-foundation.org> In-Reply-To: <20261127222110.3755894-1-heyheyco@gmail.com> References: <20261126190847.3064508-1-heyheyco@gmail.com> <20261127222110.3755894-1-heyheyco@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 27 Nov 2026 14:21:09 -0800 Qian Xiao wrote: > xas_find() keeps xa_index when a lookup starts inside a multi-index > entry stored in a non-leaf node, and aligns xa_offset with that index > before advancing. xas_find_marked() still does neither. > > Walking from a sibling slot to the canonical slot calls > xas_move_index(), so a start index such as 127 becomes 0. After the > cursor has been walked, xa_offset can also stay on the canonical slot > while xa_index is inside a later slot of the same entry. The next > xas_find_marked() then recomputes xa_index from the stale offset. If > the entry is split, the call returns a marked entry below the index > already reached. xas_find() returns the following entry in the same > situation. > > Resolve the sibling without moving xa_index. Before advancing a cursor > that has already been walked, set xa_offset from xa_index the same way > xas_find() does. xas_next_marked() uses that path when the offset and > index disagree, as xas_next_entry() already does. xas_pause() aligns > xa_offset before its existing calculation, so the resume index stays at > the end of the entry. > > If the tree changes while a sibling is being resolved, do not descend > into a node that does not contain xa_index, and do not move xa_index > backwards. Compare the next marked slot with get_offset() instead of > recomputing xa_index with a 32-bit shift. Return XA_RETRY_ENTRY. > xa_find_after() handles that retry before xas_sibling(), so a rewind > that then retries restarts the walk. Callers that use xas_retry() > restart from the same index. What is the relationship between this and Krystian's identically-named patch? https://lore.kernel.org/20260904121301.200049-1-krystianmkaniewski@gmail.com > The userspace XArray test suite passed. > The kernel was not built. Well that isn't encouraging :(