From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8467E3A6B7A for ; Tue, 31 Mar 2026 10:38:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774953496; cv=none; b=uMELrYrjz3cpC8TF0XyKxSM11i8YCVJsbjp+rBnV6IKc/6thiZLYvQSOaorbfvnxCDGGm9vToqwy0HzJOJib1SHwCtsNduiu5HKGChLh7VnNO6LTatmvZ+Ja8GQERujhhu5VmAfI3Ozh9OH5rB7wjhyrO+Q10vc5Pm89Ioqzrck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774953496; c=relaxed/simple; bh=NJqJwlXRBGRb+UTLLKfcHb2qxyqwNaawxNGCqJYZQwk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=n9BLMMvo2k/KHeKAkqR9S2HO4cFu7TM5qEq9cR1j9PxyQevRotJrh0u7Zlj7skk74pyjug7dBEn+CXYFae5pAloGKzfJKVaWFAzJCR1cuqy5qD4ncOCNZBnXXezL3yvkP4VkdgQcLKTT/gGSf5WXrBAhs+bnnf5iSg6TDtovfho= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GDJCvsb5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GDJCvsb5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72EDBC19423; Tue, 31 Mar 2026 10:38:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774953496; bh=NJqJwlXRBGRb+UTLLKfcHb2qxyqwNaawxNGCqJYZQwk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=GDJCvsb59yNSCzj2fnsZ7US1xTmRV/TBed8SYWPpTWVcGQ2xxUj1YnDNzXxzPG8Z4 JTeqhvVnUdcjyNaZieLaCr09B12zYUzam2xNWtM0ES//rovy0Vpl9gkb8HZW2HTK8K lu6HPajYMyVyXqrK1w6VPI3zJqRUEYG4/ZWalaStA1p+urtYyduQw9g6B5+3s/HoQz XFhs1I8d+VI485wDpL0OLs0BT5JAwH/+z4s5Fj5/mc59cMJgqf/xxf1cfhGJ7FiGSh 1Ep2q2dttFz5a5M//OABnAcPG7F42bZKySMdudqlI1SgmPg+wEsmUlbgcQO0CVoBJE 5bKJ8klCoxhmA== From: Pratyush Yadav To: Pasha Tatashin Cc: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: Re: [PATCH v3 02/10] liveupdate: Synchronize lazy initialization of FLB private state In-Reply-To: <20260327033335.696621-3-pasha.tatashin@soleen.com> (Pasha Tatashin's message of "Fri, 27 Mar 2026 03:33:26 +0000") References: <20260327033335.696621-1-pasha.tatashin@soleen.com> <20260327033335.696621-3-pasha.tatashin@soleen.com> Date: Tue, 31 Mar 2026 10:38:12 +0000 Message-ID: <2vxzecl0i8rv.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Fri, Mar 27 2026, Pasha Tatashin wrote: > The luo_flb_get_private() function, which is responsible for lazily > initializing the private state of FLB objects, can be called > concurrently from multiple threads. This creates a data > race on the 'initialized' flag and can lead to multiple executions of > mutex_init() and INIT_LIST_HEAD() on the same memory. > > Introduce a static spinlock (luo_flb_init_lock) local to the function > to synchronize the initialization path. Use smp_load_acquire() and > smp_store_release() for memory ordering between the fast path and the > slow path. > > Signed-off-by: Pasha Tatashin Reviewed-by: Pratyush Yadav But... wouldn't it be a whole lot simpler if we introduce a DEFINE_LUO_FLB() and get rid of luo_flb_get_private() entirely: #define DEFINE_LUO_FLB(_name, _ops, _compatible) \ struct liveupdate_flb _name = { \ .ops = _ops, \ .compatible = _compatible, \ .private = { \ .list = LIST_HEAD_INIT(_name.private.list), \ .list = LIST_HEAD_INIT(_name.private.list), \ / ... }, \ } I can't get sparse to work so not sure if I need some special syntax to initialize stuff in .private, but I reckon we can get something working. [...] -- Regards, Pratyush Yadav