From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 C4498346795 for ; Thu, 19 Mar 2026 14:15:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773929708; cv=none; b=dttAc3jgmALOYdYakQR+QxzbU08+iV0ohyeOj/htNLPnRYzCgEKmquS93wKok0y1vBWBOC3+5V2451bLncYyobnfJtejFTMPpkStMYlsUYMdrOMBGePakUG/cU8B8WuLx7nT5+5WTijuC7E4gTxoHpqUwgSim8yvypF9mj53qIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773929708; c=relaxed/simple; bh=NyDpUefiCSPlWWRvqq9xaW+D4++bPDPn7h6B882GkbU=; h=From:In-Reply-To:References:To:Cc:Subject:MIME-Version: Content-Type:Date:Message-ID; b=P5S5TZ4Hgq2N2+w8A2DG3WkCT7yEu8USMmiAqY9FuTLOhWr05M6kYToRqhwuztUqPuXap48tn0mZpQXzMHhyU+G0rIrV7gB55XOXbFK7WfETpYQWFZ2BpdLDrjNbMQuoYE2w6sAGOH61VuLYFUAPRTZxdrR2OpYoQE0wBPJwxBk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Z9AX3vRm; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Z9AX3vRm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773929706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zyi3ZJIo6Bn9fSHFWfOQ7dVlLfssMZ57KTQjpeLHHX8=; b=Z9AX3vRmhuW6ihB3U0YEsth4VODFCAbqIFzcuZyuddzFvMY0P68OwDE1IOiy4ChkdWxwhm l6FRzrTyyavb7DcvdHhtdJZbAB+bKBjzhNgLwl1Wb3O44yttGNkUTO3kOGOKAAS6EPrA85 bemj+kjk78WpVDA+tQv18tDlw7OZcX0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-17-BGgfKXSHNb2NbcloDPCg_w-1; Thu, 19 Mar 2026 10:15:03 -0400 X-MC-Unique: BGgfKXSHNb2NbcloDPCg_w-1 X-Mimecast-MFC-AGG-ID: BGgfKXSHNb2NbcloDPCg_w_1773929702 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 256211955D8B; Thu, 19 Mar 2026 14:15:02 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.45.224.65]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5FDE01800351; Thu, 19 Mar 2026 14:15:00 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20260318204515.26931-1-objecting@objecting.org> References: <20260318204515.26931-1-objecting@objecting.org> To: Josh Law Cc: dhowells@redhat.com, Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] lib/assoc_array: fix stale nr_leaves_on_tree after gc Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4186138.1773929698.1@warthog.procyon.org.uk> Date: Thu, 19 Mar 2026 14:14:58 +0000 Message-ID: <4186139.1773929698@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Josh Law wrote: > 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. This just moves the window. The count is then inconsistent before the new root becomes visible. Note that there's no guarantee that nr_leaves_on_tree is stable if you're not locking against modification. Further, if you look in: Documentation/core-api/assoc_array.rst there's no mention of nr_leaves_on_tree being part of the API. Unfortunately, C doesn't allow me to put in a private: marker as C++ does. Note that neither assoc_array_iterate() nor assoc_array_find() make reference to the value. Are you actually seeing a problem stemming from this? David