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 DDA2A318B9C for ; Wed, 15 Apr 2026 15:18:38 +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=1776266318; cv=none; b=rMih+f6P54tHowTVV6ism+k03k+q8bIpllF4KFtIyO7OtTT/sElZ2nfCcakvggkwi4U/jG8Ew4nrJ95LF87KyRtG7M0BJG8LBP7Z95NV2GyGsay6r7bWLVzJWx/5TywGG/SkJvQAVc3DEkm5+Cpy7q0mYl5j22tFJtN/WDHk6VQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776266318; c=relaxed/simple; bh=spPodaQQ2KV5AGi/Zab2Sit6wY9oszgJNiSDRnTy6So=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cRqxZsofE02hnsWQ5fW7KxH4i4Ye8JeiZhSHLUvA6tuJZGHlqd6khp8+LFyqiCXZzWX190mVLqV8kfw+8oZygfkjWPqpzmqip1E9SHUOAwJRafyWJ2uwGNu8T+AG17EylqGZ5VzYoPAJ0DjET1aNq5VM0q+06wK7ZfbHpqIYncg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Cy0BooHy; 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="Cy0BooHy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6E3BC19424; Wed, 15 Apr 2026 15:18:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776266318; bh=spPodaQQ2KV5AGi/Zab2Sit6wY9oszgJNiSDRnTy6So=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Cy0BooHyYzKBkujHE/ZEtWBSkQhdVdHrxKUGWYpuC29q7sjnOi69xrIbcQBMZku6q rgDgHOGZ6RXC8r7X27Zs3tvqGedq7T0iPVdt8sDJZ2piEuGzQmzy52Z8eiD6xAfQ9I F9xDe05kOkU/+jaCk1nJa4DufC5KxHTOtUuv2uu/4lupouDSlRn2OhzauVYsejZGL5 feIBvRa/mVLQ7IBMNzdqATVD6LkBVVJ874MmZIN62yTplT4yE4Wco2yWWBMLZqv9lJ oRyX1p169xSn+Qkh2/t6TagQuonKq/hR3h6GlRZXp+7X1YZXjBfzG9vx3CU0uZbaEc +IBNv/cGUMi9g== Date: Wed, 15 Apr 2026 18:18:33 +0300 From: Mike Rapoport To: Pasha Tatashin Cc: 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 v4 02/11] liveupdate: Synchronize lazy initialization of FLB private state Message-ID: References: <20260413185127.128180-1-pasha.tatashin@soleen.com> <20260413185127.128180-3-pasha.tatashin@soleen.com> 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-Disposition: inline In-Reply-To: <20260413185127.128180-3-pasha.tatashin@soleen.com> On Mon, Apr 13, 2026 at 06:51:18PM +0000, 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 (Google) Reviewed-by: Mike Rapoport (Microsoft) > --- > kernel/liveupdate/luo_flb.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c > index f52e8114837e..cf4a8f854c83 100644 > --- a/kernel/liveupdate/luo_flb.c > +++ b/kernel/liveupdate/luo_flb.c > @@ -89,13 +89,18 @@ struct luo_flb_link { > static struct luo_flb_private *luo_flb_get_private(struct liveupdate_flb *flb) > { > struct luo_flb_private *private = &ACCESS_PRIVATE(flb, private); > + static DEFINE_SPINLOCK(luo_flb_init_lock); > > + if (smp_load_acquire(&private->initialized)) > + return private; > + > + guard(spinlock)(&luo_flb_init_lock); > if (!private->initialized) { > mutex_init(&private->incoming.lock); > mutex_init(&private->outgoing.lock); > INIT_LIST_HEAD(&private->list); > private->users = 0; > - private->initialized = true; > + smp_store_release(&private->initialized, true); > } > > return private; > -- > 2.43.0 > -- Sincerely yours, Mike.