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 23FB4606A322 for ; Fri, 4 Dec 2026 01:26:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZfyfItPe Received: by kanga.kvack.org (Postfix) id 285626B05B2; Thu, 3 Dec 2026 20:26:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 235776B05B3; Thu, 3 Dec 2026 20:26:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 124426B05B4; Thu, 3 Dec 2026 20:26:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 961496B05B2 for ; Thu, 3 Dec 2026 20:26:32 -0500 (EST) Received: from smtpin18.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 11274A023A for ; Fri, 4 Dec 2026 01:26:32 +0000 (UTC) X-FDA: 85504560624.18.DF42934 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf17.hostedemail.com (Postfix) with ESMTP id 6B70E40005 for ; Fri, 4 Dec 2026 01:26:30 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=ZfyfItPe; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796347590; b=nl3Gy1vXaH2H0vT58RknE0+qFC8l6Q5KKEN0PnkKf2A1SUUS8wptwcYXQxEZ9CYcFGG86P CMjGLWDjdgefbPZnmUab6CKS9QR7VYMMRivWfWI8+bwxkWzS5AuOYby10PP904L5TbMt8G YraY8n1nBL2ecNnpB3o95MaxQF40Weo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796347590; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fhnbycIfPsQh9s5t9h2MVferKodsrhAZzw6m40aTgao=; b=bRGrxbfTfb/wTDMFVc1TK0Oy0gL0FvO7jNcd3bO5VnDt5BTClcuVSqClcEEovgBaCgHWEc zAZhiJMTCpyhH0pk4diPzmAHxZpmDFxV5BRTUUq3HYFSjuSmwiC7ARD+Tnd50VdPIyXQkI ATFrGGQRoXnc+0+Pyhl4N46lN+5DSiE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=ZfyfItPe; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 65B3360D8B; Fri, 4 Dec 2026 01:26:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F29B51F000CE; Fri, 4 Dec 2026 01:26:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796347589; bh=fhnbycIfPsQh9s5t9h2MVferKodsrhAZzw6m40aTgao=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ZfyfItPeix6LA+LOnUGofzvK9gc4KgNsVulYsJlrpLo+Gy+mRsYLjDKaGoirAPLJw +HBJZJI0aWgSmJeireFDjdYZJJzroTUg6c4pt6QptPX2XP/qMN1NnsmA3U0U9BOiGP 9u+brnCoxgRMU4zqtEFjJrzQmyCIoEXlSd6mm963WgTuFZsEVngCSOR4ll1mCqqYck 5XUK3a8ebiaRfQtX+g38LJdkUNYaGP557A5VX+A+1WWOM+wO1SXCPpUKRy2qCG7wRL wzPKNU5A0sfSG/uw5Uw36zcMUiIT+nU7F+isVP0ot+h4ob9uT4O1GTC4a6e0WUIC1f yjSNUupVqIY8g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 3/3] xarray: keep advancing after a concurrent sibling store Reply-To: sashiko-reviews@lists.linux.dev To: "Andrew Morton" , "Matthew Wilcox" Cc: linux-mm@kvack.org, "Qian Xiao" In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 01:26:28 +0000 X-Rspamd-Queue-Id: 6B70E40005 X-Stat-Signature: sdxh48px5dtqjq1rm1o3ghqc5ttfuyz4 X-Rspam-User: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Rspamd-Server: rspam08 X-HE-Tag: 1796347590-288443 X-HE-Meta: U2FsdGVkX1/ZGrMmgKFRDWa2QZAum+cJa32EnegO3chO9sbSrHFwyHMNvNGLrGn0X4rNld3DqbF2fQO+rfG+jy+bcytbQSNNX/0KZ52Id2Ok659eCN6FRUK3bSvEoq2xG3QQR09aCJyZy0bGHmT3SYg7kz5LrH25iiElq7DQkNoqi27VRxpENXQx9BRM29QBcK6Rfph34D1+eV9Bog9TIAfwspYGw++HAkvWo4TQaACfyMKvaoyecQWckfQYMRJ+bVvVydzAUv6i2CHycY9DXDkbivA4J1wdI+72VF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VgUxx7PHWjQaTh2c2/Q+mJ2LsSPJHer5F8JsBWR8yZKufj8t88Gwzwnv65LrrD99jEVqk1pPBk9YdpTzVNQPaOn1rVSRRof/JmLW4q9PXnWMWB700qioGsYUQ5BNTHMkWSzxMeivPwqolXjBRF69aY3xKDa2jDLA4wmTVxvjQaweqTAcWLS+VzSvcOFvTcIozTNjcsVQE/oCKmPO7FHuUnJ+qyrm5Kz73hnBIPIJIw9CevrpDWNpKb2URzP91FgJcoLu7AxsSZybBdyP6oQq8c+xqt6TnNXkRqf9vxbVGNMyzbvS1pcA6hMSdIP7i/MUIc0BC3EtQchSojqa552v/GsSi95ypxTdevjLNgc0OeV7CjLMLf/FRiKtcQJNc0HmFkDC0Ko+ZtAGN6OFiWQKyd4wxH6Os1ooCzri2FuOtBNZzkyQjSlCjbaeDoMCCk/lteVFjpycMCxcdp8Udcy0SxzazKluMAqt/lwZEhZHKgRhbCFMNLlYy85Q27zoo553tJBhmmgyBzQpd54k2bR4tmeKc= 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 X-Archived-By: Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] xarray: backward sibling resolution in xas_find_marked() on NULL or ascent - [Medium] xarray: in-place split in xas_find_marked() returns entry below xa_index -- commit 08b16eb70e7809f38ed1e7cbcf213a6ffa30db6a Author: Andrew Morton xarray: keep advancing after a concurrent sibling store This commit sets advance to true when xas_find_marked() encounters a sibling entry at its selected slot so the next iteration searches past that slot instead of resolving it backwards to a lower canonical slot. Link: https://lore.kernel.org/r/20261127222110.3755894-1-heyheyco@gmail.com > diff --git a/lib/xarray.c b/lib/xarray.c > index 5b68f41480610..7c820bd145186 100644 > --- a/lib/xarray.c > +++ b/lib/xarray.c > @@ -1544,8 +1544,10 @@ void *xas_find_marked(struct xa_state *xas, unsign= ed long max, xa_mark_t mark) > entry =3D xa_entry(xas->xa, xas->xa_node, xas->xa_offset); > if (!entry && !(xa_track_free(xas->xa) && mark =3D=3D XA_FREE_MARK)) > continue; > - if (xa_is_sibling(entry)) > + if (xa_is_sibling(entry)) { > + advance =3D true; > continue; > + } [Severity: Medium] Can xas_find_marked() still resolve xas->xa_offset backwards behind xas->xa_index when a selected slot is concurrently cleared to NULL before becoming a sibling, or when ascending from a finished child node? When xas_find_chunk() selects a later slot at offset > xas->xa_offset, it sets advance =3D false and moves xas->xa_index to offset. If the reader then sees !entry and takes the continue above, advance remains false on the next iteration: CPU0 (reader) CPU1 (writer) xas_find_marked() offset =3D xas_find_chunk(...) advance =3D false xas_move_index(xas, offset) xas->xa_offset =3D offset /* replaces offset with multi-index */ /* entry covering canon..offset */ rcu_assign_pointer(slot[offset], NULL) entry =3D xa_entry(..., offset) if (!entry && ...) continue; /* advance =3D=3D false */ rcu_assign_pointer(slot[offset], xa_mk_sibling(canon)) /* mark set on canon */ if (!advance) xas->xa_offset =3D canon offset =3D xas_find_chunk(...) /* returns canon =3D=3D xas->xa_offset = */ return entry; <-- returns canon with xa_offset < xa_ind= ex Because xas_find_chunk(xas, false, mark) starts at canon and returns offset =3D=3D xas->xa_offset, the offset > xas->xa_offset block and its XA_RETRY_ENTRY check are bypassed. The same backward resolution happens when finishing a child node (xas->xa_offset =3D=3D XA_CHUNK_SIZE): the loop sets xas->xa_offset =3D xas->xa_node->offset + 1, ascends to xa_parent(), and sets advance =3D false after xas->xa_index has already moved to child->offset + 1, so a concurrent multi-index store in the parent node covering canon..child->offset + 1 is resolved backwards to canon <=3D child->offset. Lockless RCU callers can then receive an entry already passed, or xa_find_after() can mistake a later entry for a sibling via xas_sibling() and skip it. > if (!xa_is_node(entry)) > return entry; > if (xas->xa_offset !=3D get_offset(xas->xa_index, xas->xa_node)) [Severity: Medium] If a marked multi-index entry is concurrently split in place into smaller marked entries in the same node, can returning non-node entries before the xas->xa_offset !=3D get_offset(xas->xa_index, xas->xa_node) check return an entry below xas->xa_index? CPU0 (reader, xa_index at slot 2) CPU1 (writer) xas_find_marked() if (!advance) /* slot 2 is sibling of 0 */ xas->xa_offset =3D 0 xas_split() /* splits slots 0..3 in place into */ /* marked entries E0..E3 */ offset =3D xas_find_chunk(...) /* returns 0 =3D=3D xas->xa_offset */ entry =3D xa_entry(..., 0) /* loads E0 */ if (!xa_is_node(entry)) return entry; <-- returns E0 at slot 0 < xa_index Because E0 is not an xa_node, xas_find_marked() returns before reaching the xas->xa_offset !=3D get_offset(xas->xa_index, xas->xa_node) check. The caller receives E0 below its starting index with xas->xa_offset =3D 0 and xas->xa_index at slot 2, and the next advance jumps to get_offset(xas->xa_index, xas->xa_node) + 1 (slot 3), skipping the marked split entry E2 at slot 2. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/b0bf98a720f546f69ae= 25ce7a9ebf702.0@linux-foundation.org?part=3D3