From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B64C606A332 for ; Thu, 3 Dec 2026 01:06:49 +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=e1ibTI++ Received: by kanga.kvack.org (Postfix) id AB9636B00EF; Wed, 2 Dec 2026 20:06:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A6A3A6B05B1; Wed, 2 Dec 2026 20:06:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 983166B05B2; Wed, 2 Dec 2026 20:06:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7117B6B00EF for ; Wed, 2 Dec 2026 20:06:48 -0500 (EST) Received: from smtpin17.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay02.hostedemail.com (Postfix) with ESMTP id DEB4C12050A for ; Thu, 3 Dec 2026 01:06:47 +0000 (UTC) X-FDA: 85500882054.17.E0A1ADB Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf05.hostedemail.com (Postfix) with ESMTP id F38E610000A for ; Thu, 3 Dec 2026 01:06:45 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=e1ibTI++; dmarc=none; spf=pass (imf05.hostedemail.com: domain of akpm@linux-foundation.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796260006; b=x6CefbV7BCNOB8SQ6pANhMRXqciXmESzfvzJ6DjLgke02bOL7HO2ji/zs4d/Xjr7W2HG2C UBP0SysA5bjVACfCvonISBVeRL6tflQ4ReDD3vXaStFOjK4jQp2/4JFPK4jCpHhNwj87VK Wp6L7s/2sxBa0SV6IGZ04aL6X6gPFjI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796260006; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7XtWoIxKRGudumMFWLlctB0LO8dhnEb/FUElp17EvwA=; b=TgIQvxN5FzQ9BkzZOXRkXiyEcqIwj1VjTTAHdEMIkosjn0iVLTr/zlL8RtxkywHViL/IBw TgIfTs+BxglUjsY3iPYTNezJXKhSUk7trCeYBoUFKpJicn+1XSoq3Vrwo25pDqnTijsRyk s9+hc+JZKhFcXjv/dOlA2f9bBO/A4ng= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=e1ibTI++; dmarc=none; spf=pass (imf05.hostedemail.com: domain of akpm@linux-foundation.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 307DF41A76; Thu, 3 Dec 2026 01:06:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE8B41F000C1; Thu, 3 Dec 2026 01:06:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796260005; bh=7XtWoIxKRGudumMFWLlctB0LO8dhnEb/FUElp17EvwA=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=e1ibTI++QLIfDPFH/YjoTUCxH0BIbdbEU7giZMSPwzwuoR2LtnZb2BF7aFjJRGgQe mQ+F1jkNda3EP0q5ErY00F0SpR1eSMlOGyC2pPJxfYra4vUqUa5iSRzpGmI8RoMDW8 v23YmmUcmgdhO3+jC1YTw5MW8Lceu7x8FbviyVCs= Date: Wed, 2 Dec 2026 17:06:44 -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: <20261202170644.8b79f3de9e4e9c1df1b85e0f@linux-foundation.org> In-Reply-To: <20261129235255.848478-1-heyheyco@gmail.com> References: <20261124213424.2224554-1-heyheyco@gmail.com> <20261126190847.3064508-1-heyheyco@gmail.com> <20261127222110.3755894-1-heyheyco@gmail.com> <20261128191203.6d8a42b8a55809048367f903@linux-foundation.org> <20261129235255.848478-1-heyheyco@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Archived-By: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Stat-Signature: 8raweoxnwwx8dimnqoha5ct49wc6w9s5 X-Rspamd-Queue-Id: F38E610000A X-Rspamd-Server: rspam10 X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Rspam-User: X-HE-Tag: 1796260005-434405 X-HE-Meta: U2FsdGVkX1+a/artUDoRc6A/GbPfr2KIc2DCOS3leaWnxtv4K4hSbX92LiPATQUezy14ci7qcbTTAEkYsh3PS3uLpKf2YJ2xyiVFehhjB0TEmAGscBgvdmqq0vUUFwVIS+/KHzAaMa+wlBFVrT9G+KlafgwfEWHCVx8hN2DDWxI+iNQ+bTZ0M8oMWxgRj8SgJdxYmOt4nl8kYIcqRcNm2cus0HSv5gbD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EiyGtlSEbXKOr/BPs1dX44X68TURwzHa5P24YSxeBbnT22oF66M00TGkAduEILpsSWwQrFiVjNWEtzX5RAXRJfLJ865IhpONI6HlJpSOD6l4PtsRfnOO2v99UDuPrtvF58d5ySkhFZqKPUK2znUVTMQDj8rRYDcGfIy2rwctgbCl1RWx7mav4TQpdPbzW8vtPWNq/NsF15g== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Sun, 29 Nov 2026 15:52:55 -0800 Qian Xiao wrote: > On Sat, 28 Nov 2026 19:12:03 -0800 Andrew Morton wrote: > > What is the relationship between this and Krystian's identically-named > > patch? > > Thanks for taking a look. Krystian's patch is a4e667346a8d. It only > changes xas_find(). This is the same fix for xas_find_marked(), and it > doesn't touch xas_find(). > > > The kernel was not built. > > > > Well that isn't encouraging :( > > Fair point. I've since built an x86_64 defconfig vmlinux > successfully, without errors. The bug is legit and your patch (after fixing the Sashiko thing) fixes it. I'm struggling to figure out the userspace impact of the bug. It seems to be minor. afaict it's __folio_mark_dirty() -> set PAGECACHE_TAG_DIRTY WB_SYNC_ALL or tagged writeback -> transform PAGECACHE_TAG_DIRTY into PAGECACHE_TAG_TOWRITE writeback_iter() -> start IO on PAGECACHE_TAG_TOWRITE folios concurrent split -> uh oh, this makes the marked scan of mapping->i_pages move its xas.xa_index backwards. This can consume background writeback's page budget before it reaches later dirty folios. I could reproduce the backward jumping in test_xarray and in a kernel module scanning a real tmpfs page-cache XArray. The module set PAGECACHE_TAG_DIRTY itself - I couldn't reproduce the writeback-didn't-write-enough-stuff thing in actual testing. It turns out that there's more to the world than mm/, but Token Taxing Terrorist couldn't convincingly find any other xarray users which are impacted by this. DAX and memfd are "maybe, possibly". I've temporarily turned your patch into a series of three: 1: add the test 2: add your fix 3: add a (needed) -fix for the Sashiko thing I like to stage the test before the fix for simplifying the test-without/test-with testing. Shall scrunch everything together later. Sashiko -fix: --- a/lib/xarray.c~xarray-fix-index-jumping-backwards-in-xas_find_marked-fix +++ a/lib/xarray.c @@ -1544,8 +1544,10 @@ void *xas_find_marked(struct xa_state *x entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); if (!entry && !(xa_track_free(xas->xa) && mark == XA_FREE_MARK)) continue; - if (xa_is_sibling(entry)) + if (xa_is_sibling(entry)) { + advance = true; continue; + } if (!xa_is_node(entry)) return entry; if (xas->xa_offset != get_offset(xas->xa_index, xas->xa_node)) _