From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE64C3F7A8B for ; Tue, 31 Mar 2026 16:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.208.51 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774975355; cv=pass; b=aPagyu4xmZ86cPtQ4dKfRJOHEZOT3cd4X24E9xJjYww6dS5pCailHHgDsbpwRKhbKyK5kg3IBwEl9ictq0MRQL+aRNAB/QkfK+0RqZYHnEeaCKVN2tEuifTIplUzNRBvE7xAQqr5tO/tJfL1aKq8LjThGAjqkinU3zt+PgzkEgg= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774975355; c=relaxed/simple; bh=q8nnxsi3S7awATC1M4GrHFy31TkfbDci1lXP5NjAPYE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=q8Pw/VSP2XXN+BjFuTkDFZn9ZIfj7rt9vTYRikM+MX9aHrhFDpbi7AA8Zd81g1D1tozs62OeUQ5jsl9Gi8g5NdA0RQ6dseZAboqOF67HxxR//hlZguCz8zA6Fgv3q6UCUYEjWs/qlWdnVWbEPVOmTFJxN8RCl9b7HICp80iSM2w= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b=d4aIrNWW; arc=pass smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="d4aIrNWW" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-66bd4e0560fso107516a12.0 for ; Tue, 31 Mar 2026 09:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774975352; cv=none; d=google.com; s=arc-20240605; b=MxnL5a2zkxaX69Vmb5WFp/ekq4InowCeIUwKgIbTk58eqJhjdp+s1xqkyd083ctXlJ co4mdRWY1dW0vzi/QvB9b4z+WYcEQtq/lAhGAMLZWgESWl4c+PwbsAx0rN8ET6MhBmX/ pKVMwgAcQWu3sfLyJVvpxIuHDSK8XJfOU3lrvzcOKLDEgAjxMl9ZV9bBm59FsfE9rm43 NoHx/hZeKtFhW6sG6aBqfPAVlcgfp/0PKqx7QBlOaK7ponKXVyMq2ZxHbKDqOk9a4rWZ 5aAmMvghZh+dclttpThL4EyPbyTld8lJaLouH2NVBf9xwmLTCmZKCAF4VPmyHUit9iXT Ntow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=OWXcgZxwCe/i5vmEyRuiCEIOs8zFNjOOEmunu4K6OG0=; fh=Su1yFrW88KAjCyy5R/2p12+J1VPQQp/KRiKlm7vDBMk=; b=b4FYd/AAnxv6EFifnJPb8bHQClcifWfDO1YtRxBG6Q1IDAMc1NLQv9f5k4v4ohl8br Tse9xeWzSnFa0iqWjgAqek44Rv1WEiqbfD9AYB0gNNuf55srC/wrroFMUm/dJnzH+fLD QlmLfO+UIUGveONUL1Z1vje5APUOO+5sGz6iawy4Yav7kTA//MM/9D/3emS7tDFimhC2 dW4NR5IeWCddYwDTPZyjYs92CPuuP7cExTUYKCheWQpOnzlbkpanVsn1gWNZTdTexd7B OzS1M46zsgDvfYK5owLjrUaIKDVDAUPC6vyg19qgFVKWd/Frp5dDL1FnVWnkMjkbweU2 PWTg==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774975352; x=1775580152; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OWXcgZxwCe/i5vmEyRuiCEIOs8zFNjOOEmunu4K6OG0=; b=d4aIrNWWQLLNI3FkmjLervjhDQUSBPtFiuXBGYqV22rrxYtEZSJzMIzxOPmMnpKGz4 yD+LsZ+GbLiteHb6ld6CX6qNpemZP4Gpqw8pXCrGXf9DaQZsodvGwPDvbJphfd1eUbZf 3ascDtfwD7O8KTdGkfn+KJBuAFJ367zJ73tsUFyoQAWkNCBTxaXjIeRh+Sz2qWN7SK4F kPo81HNV/AQ8Wsa+MdFcnThwfWmjfpkyjbPspe85XNUPYpyUyrbJvjPYR0ctvKrk/94K cf9eU/XVSV83oZ8OTPnN0ECzgsENn+2sOSpsZ9VEuUvTYm0VSCw6RzJXsr15FEtSAt7d fEzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774975352; x=1775580152; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=OWXcgZxwCe/i5vmEyRuiCEIOs8zFNjOOEmunu4K6OG0=; b=ZLV4T9mwn1wGxNNALwnkrSzgkTbflO62yxqYGKQOOGvZOGNwDn7qMFPKxjTpARelez 0A5Ggx4TELIRXTPa61IqMeKMqgGj4Y57gsOgH1O1OuXXGIT1KKktM66hG4wZoBntf3pO Il10Vqz5liWtUhOLwUoP8a8/Y31mgvSdIFjdvy/ESqyUH4Liq0Xav4JcqCLpOnCvn5Tz 50KpX4WxobtoMAWciMWWjLBE06q4qQ+pz7LVsUPtsahOIci8/Z8yZqwNUnyo4oXzRFOR evg/MA/IQbLkjcBN3vnX4DwR8AtZBEENb2HyDgh7xgUZXvnhOVcCBZxBBEtnGaYRj7gE tdRQ== X-Forwarded-Encrypted: i=1; AJvYcCXEhzFAHT+UUJfAvgeIvFuks22gs7y3OKF/hdGVSZu6TWiTDkHTRcluI+Ajge7IkvTfC9S6X8C6yrMnX0Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yws5ScE3GmRZDo2QIoKaXW2zk0R+nT3iLNNa07ILZz0Mz2ppgph dGgJ5HTsaPCK223f77a0ZDU1aEWGHdvPfNWVj910yOJsL44thnw2e1i4OVtFt7wk9gMfV/L67H/ 1/ValzjqBShZBolGAEL83m9xuwm0I7F0eJGqK644BFQ== X-Gm-Gg: ATEYQzz7epd+jwzwDrV5KAenRyUy8Arua7Ft9BMxpBqE0uI+aVJy4W6dbhI5eDJhE8w uAEFxpEDsphEev5bzSrqY6XJmNTArpx4X651mjWf+DOwBOvYligILyKkqKs/n/9Ac50sTuWPKVB Lw/1hwvdBJ2zWbNgAGC1yJUcBYB91A1QbgICYESz1d4avsSAd+qsmKfSYS7y4s0RPT057M2AeD8 PLbgx01E1B3nxUvPdbVwM9d4AEbtZoneCKDEQJ002cNqj/d8qEAQ0I4BAJD8rLPzfnmevysGHyk x7d+ROU8H4U7Raqh9mH3f5KZMT+oRi4W5NrXCA== X-Received: by 2002:a17:907:74e:b0:b97:b149:4e72 with SMTP id a640c23a62f3a-b9be88c4be8mr199825866b.28.1774975351482; Tue, 31 Mar 2026 09:42:31 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260327033335.696621-1-pasha.tatashin@soleen.com> <20260327033335.696621-3-pasha.tatashin@soleen.com> <2vxzecl0i8rv.fsf@kernel.org> In-Reply-To: <2vxzecl0i8rv.fsf@kernel.org> From: Pasha Tatashin Date: Tue, 31 Mar 2026 12:41:54 -0400 X-Gm-Features: AQROBzDDXSrXnDAF2LHX_tDmG-n3BYfL4GNehGeRWniM10iq-caP3N77QfA66TE Message-ID: Subject: Re: [PATCH v3 02/10] liveupdate: Synchronize lazy initialization of FLB private state To: Pratyush Yadav Cc: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dmatlack@google.com, skhawaja@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 31, 2026 at 6:38=E2=80=AFAM Pratyush Yadav wrote: > > 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 Thank you. > > 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: We are planning some updates to this code in the near future: 1. David Matlack will send a patch in the next version of VFIO LUO preservation series to add liveupdate_flb_put_incoming() so that caller can protect from race with release of the last FD release that will also release FLB. This change will increment FLB 'count' not only when FH uses it, but also when the object is being accessed. 2. After I plan to convert 'count' to use kref, and also decouble init and liveupdate_flb_get_incoming(), this will allow to access FLB object with interrupts disabled, as requested by Sami for the IOMMU work. I think, that while working on this 2nd change, we can also do some clean-ups if necessary. Pasha > > #define DEFINE_LUO_FLB(_name, _ops, _compatible) \ > struct liveupdate_flb _name =3D { = \ > .ops =3D _ops, = \ > .compatible =3D _compatible, = \ > .private =3D { = \ > .list =3D LIST_HEAD_INIT(_name.private.list), = \ > .list =3D 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 >