From nobody Mon Apr 6 16:45:33 2026 Received: from sender-of-o58.zoho.eu (sender-of-o58.zoho.eu [136.143.169.58]) (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 D46D91A073F for ; Wed, 18 Mar 2026 20:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.169.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773866729; cv=pass; b=Zxer+GnW1vZeNoSiQfa/j72kGhCqQiB1YgUTTCu6B2rIiU8HXl94Fl8Kzvj9n2D2zxraKIkgS44JkWO7+NOpqsu37bJZy7lnyZ0njhDwRAU/+FIYkhI2NpuWgcZvbOUSX6jh1DpLBTBF9S2Xk1S7M/IcDEdKbyP+w0DdyrDrz6s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773866729; c=relaxed/simple; bh=smcHeb0hqulVxcQDHdkCV6GEDMY9lpJHk3GnSY26cUg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=bkrVFzpIYgUs7O05sntbxh7Z0YDgssVVULrY0mbYUmJxNh9xzlnrdTdVgRS6ro8fWs7ZXHCalEOAE96whsT0a5pGrfOFmstSR6ERZbnYa/nmOZdt+Ql9lt5zP4VbxgwKY4ivLnA7ADbXejZw7qpNNkBqBQZPPhdtpAZJYN910wI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org; spf=pass smtp.mailfrom=objecting.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b=nlXxtcK9; arc=pass smtp.client-ip=136.143.169.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=objecting.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b="nlXxtcK9" ARC-Seal: i=1; a=rsa-sha256; t=1773866721; cv=none; d=zohomail.eu; s=zohoarc; b=axDAKQIb0UdEVsYbZsNxEWHRWQlL2Alz6B7qQPxbzHff7PUgssNpjB13pemfvGYkmQgC0tq+VoIOP/Aiv0jPL1dm3EbVdSt3/OF0op9wclgxGVR2uJI710MhytrXcAB0NxFF/1dA89MZz1WAxrTyqwtvrD0ZvWVklj0QyPYoZRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1773866721; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=cDDrHZmeHHqRrmzH89IdWsWKUGjDjWe1P08PleTf/sk=; b=c9bNkgnmmUgWD0pjC+8v/OVFF2j8cOBID90YTEzFQeOUBpLa3Psmf1DqJ6T55x7Mygt5x3SFDuRH9Cu4IyipqXOSgsKRSPF1pfGRYW6z4gcXm2SaKcfcKtp2C87MpzArz/zWBb19Y71TgEq42SvUQiaWfq/7gt0GNUgMZJApsBg= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=objecting.org; spf=pass smtp.mailfrom=objecting@objecting.org; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1773866721; s=zmail; d=objecting.org; i=objecting@objecting.org; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=cDDrHZmeHHqRrmzH89IdWsWKUGjDjWe1P08PleTf/sk=; b=nlXxtcK9qapM105LBypZAmrREFb+G3l2Y4EnmKmCxtEXx+owkv9NLXo2EkPiE3Vm IktGjJu7g+P1A2aco3cIeFRdg1ynwi/gzQXygFS5E63AjUzV6Zvn8aoNDuPg41fcUDy shEEFHGxkjyzehC9+CU8bR23PnGmBMz6KxKTglxI= Received: by mx.zoho.eu with SMTPS id 1773866719463899.3352012979726; Wed, 18 Mar 2026 21:45:19 +0100 (CET) From: Josh Law To: Andrew Morton Cc: David Howells , linux-kernel@vger.kernel.org, Josh Law Subject: [PATCH v2] lib/assoc_array: fix stale nr_leaves_on_tree after gc Date: Wed, 18 Mar 2026 20:45:15 +0000 Message-Id: <20260318204515.26931-1-objecting@objecting.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" In assoc_array_gc(), assoc_array_apply_edit() publishes the new tree root before nr_leaves_on_tree is updated, creating a window where the tree is visible with a stale leaf count. Move the nr_leaves_on_tree assignment before assoc_array_apply_edit() so the count is consistent when the new root becomes visible. Signed-off-by: Josh Law --- lib/assoc_array.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/assoc_array.c b/lib/assoc_array.c index bcc6e0a013eb..0752fd44e066 100644 --- a/lib/assoc_array.c +++ b/lib/assoc_array.c @@ -1711,8 +1711,8 @@ int assoc_array_gc(struct assoc_array *array, =20 gc_complete: edit->set[0].to =3D new_root; - assoc_array_apply_edit(edit); array->nr_leaves_on_tree =3D nr_leaves_on_tree; + assoc_array_apply_edit(edit); return 0; =20 enomem: --=20 2.34.1