From nobody Tue Apr 7 01:19:00 2026 Received: from mail-yx1-f52.google.com (mail-yx1-f52.google.com [74.125.224.52]) (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 D68E915B998 for ; Tue, 17 Mar 2026 02:50:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773715857; cv=none; b=mCMl1ZdtJ0pOkcR3sIV5+njXnWpzi2B/yDgpT3c6Ea7uey0ypbrfU4sJWRf1r+kz5AALMpGjvOT2ELoqzU3b4hY8Skj0HWyEJht2+uarj+qttH7CuPZvVKuNmIk8jWL3Y3m2racikqG5RcAGDffYA0dzRr9v24KxZpSIwxJxUX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773715857; c=relaxed/simple; bh=Ev5NOOaLCTI0R2tSGGS3VlAUiQ39CSjOS/qrd80m92E=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cwGPl8aT+jhhdIhCEstt+1ZOnbon8mi6fX+WxATJPVISTj4hAzrIRkU2mo+79Ne3r/NDJYUDVpBUjqcIVW1WywrbgGzqFmXsmVRfwAWfCdE6H/6VpkSe8qTd6NHsmVnNLDKxbos1HG4UPTKR55toPoW9qS2igfV9lRDG2py4rSE= ARC-Authentication-Results: i=1; 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=Zznyh+69; arc=none smtp.client-ip=74.125.224.52 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="Zznyh+69" Received: by mail-yx1-f52.google.com with SMTP id 956f58d0204a3-64acd19e1dfso4951892d50.0 for ; Mon, 16 Mar 2026 19:50:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1773715855; x=1774320655; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=lSH13KJcmbIwWK3JLHjAk43mNZH52hkh+lGVSi7g5tY=; b=Zznyh+69cZVnbacReyCeZENb+dQTEqRAV30iHUfyklR7ZkfcD9MCbEdAoZpNBhuxjP bS3+9gYHvgM+/ZwwTrvmLhrZQsIkaZKGjj0LyEiU6ItvZ4CcBqe4UnYaIu+tcah50Kqv 8IYD0AdQUAdHJILEWbuPnf1EQX0lBQ6Y3se6mz9R6RQCn7P36W2PaEJEJUpjgJ9dKxnn N4/PqXPyXCgla0LqEtHJreHec2mq4ItF510EUuNoMLwJs5pqRx4v/puCD3H0dDUu0Q7s lHx+tIJfPJtrB8TQHr6EWzUU8Mw5Je/Sf4pQIpYH5MlAQy3K3e4cJ4yayxUqUFLq+A0Y 4gkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773715855; x=1774320655; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=lSH13KJcmbIwWK3JLHjAk43mNZH52hkh+lGVSi7g5tY=; b=gUUzpJqfze4WzF8R7D63aCIxN195aW9x/BhPTloO2GFEncfOk8R+zLwjdKVfl7OtD5 qu8RaqLQBLVJcKIdUvynjOrFcNEqehfkMeseSaB80mbM31EyyAsn/LimKDM810h+9q+6 Z60U53P5A7AMxJNSKw3WuH78UnjBuUdFTkJtrs2qFRh7L+kCiDUAICjBBm1EdoJ3gX54 jwSP16w/AP32Mb2NJF4SvO54ejuKWyUgqKqofmwEEGiNK6kHq49WqcpDz7RrhuIxkbo6 w1+HMZQ4o5MuA2PojWYs9QOUVQYSqxxalFMPxDbY2742F/F57gqudEz4BCjJAgTAA4tb kBjw== X-Forwarded-Encrypted: i=1; AJvYcCVhdeGWbTAGpbeFSFp/9LxmmEhiVQ2p1Rr8uUR8xE1fcoNEUhiqi8ww7XR+ex93asCYAdNGieWzobXJ24Q=@vger.kernel.org X-Gm-Message-State: AOJu0YxdK9gylS9UQApEtr4oDh6+1nJDRoXsw4QTYKUhHjZiC7o6MsMC nDUSy+iJRAlKk5mNUohyIf8T20zvqs/FRmjMpAm2bWzZ5qOAxJkDk61kYKesqLuUSX0= X-Gm-Gg: ATEYQzxQI/9KLGnKUIxxw7O8Q5rT4QhDbxWrEl1s1z7byEkUi/Xy00yQkSGA/R/AZRE HC+XYy94HsGflSZe8os30R9dpH9r7qFOEYv+2zuPQu+jEs17cLXjNKmo5yKrKessQUX/xOETNo3 K/1pF3mHTg2Of+C10zZsXvTrmHPV7P5t12bi2ALSn5MvFSUqdHmBDelMguaSotJiPl2RbUoUBgL MqWWldO1HzRoCVAxVya9hubjFki1H6JvqcJoQHNyHwCFLQiIJhwe4MvmXa+HlY2lzXGTeATp2kF wweP0aYIDQsOjZnAlRST1p10z1Bys7oA7hXw1DNslB47GfK/uLD81+Vb7NiQZ7LA0GRyvRcEdi9 eiFcTeT8wXO/T7jY8vBKEjbXw9HdoR8amS5ySBj12TpOR+nEz2MXTlnKqYS6/39RjdJtQW8lt0Q ioBbNd9Ah2+1sLcDy7+DMYXVXxwiqDYpImd2LCHL9GceNrM743xKxmTFIVRuz0fDlz2K8NSSQoj ZT5284hfPqtayTEc0QD5sLq/ZUAZ5jjpf5TZkZ8/MPTguZGMw== X-Received: by 2002:a05:690c:288:b0:797:4722:f8a7 with SMTP id 00721157ae682-79a1c26723bmr151441587b3.61.1773715854973; Mon, 16 Mar 2026 19:50:54 -0700 (PDT) Received: from soleen.c.googlers.com.com (57.233.150.34.bc.googleusercontent.com. [34.150.233.57]) by smtp.gmail.com with ESMTPSA id 00721157ae682-79a5a866c85sm14951757b3.35.2026.03.16.19.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2026 19:50:54 -0700 (PDT) From: Pasha Tatashin To: pasha.tatashin@soleen.com, rppt@kernel.org, pratyush@kernel.org, linux-kernel@vger.kernel.org, dmatlack@google.com, akpm@linux-foundation.org, linux-mm@kvack.org Subject: [PATCH 1/6] liveupdate: Protect file handler list with rwsem Date: Mon, 16 Mar 2026 22:50:44 -0400 Message-ID: <20260317025049.494931-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.53.0.851.ga537e3e6e9-goog In-Reply-To: <20260317025049.494931-1-pasha.tatashin@soleen.com> References: <20260317025049.494931-1-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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Because liveupdate file handlers will eventually no longer hold a module reference when registered, we must ensure that the access to the handler list is protected against concurrent module unloading. Signed-off-by: Pasha Tatashin --- kernel/liveupdate/luo_file.c | 61 +++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index 5acee4174bf0..6a0ae29c6a24 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -112,6 +112,7 @@ #include #include "luo_internal.h" =20 +static DECLARE_RWSEM(luo_file_handler_lock); static LIST_HEAD(luo_file_handler_list); =20 /* 2 4K pages, give space for 128 files per file_set */ @@ -277,10 +278,12 @@ int luo_preserve_file(struct luo_file_set *file_set, = u64 token, int fd) goto err_fput; =20 err =3D -ENOENT; - list_private_for_each_entry(fh, &luo_file_handler_list, list) { - if (fh->ops->can_preserve(fh, file)) { - err =3D 0; - break; + scoped_guard(rwsem_read, &luo_file_handler_lock) { + list_private_for_each_entry(fh, &luo_file_handler_list, list) { + if (fh->ops->can_preserve(fh, file)) { + err =3D 0; + break; + } } } =20 @@ -777,10 +780,12 @@ int luo_file_deserialize(struct luo_file_set *file_se= t, bool handler_found =3D false; struct luo_file *luo_file; =20 - list_private_for_each_entry(fh, &luo_file_handler_list, list) { - if (!strcmp(fh->compatible, file_ser[i].compatible)) { - handler_found =3D true; - break; + scoped_guard(rwsem_read, &luo_file_handler_lock) { + list_private_for_each_entry(fh, &luo_file_handler_list, list) { + if (!strcmp(fh->compatible, file_ser[i].compatible)) { + handler_found =3D true; + break; + } } } =20 @@ -850,25 +855,27 @@ int liveupdate_register_file_handler(struct liveupdat= e_file_handler *fh) if (!luo_session_quiesce()) return -EBUSY; =20 - /* Check for duplicate compatible strings */ - list_private_for_each_entry(fh_iter, &luo_file_handler_list, list) { - if (!strcmp(fh_iter->compatible, fh->compatible)) { - pr_err("File handler registration failed: Compatible string '%s' alread= y registered.\n", - fh->compatible); - err =3D -EEXIST; + scoped_guard(rwsem_write, &luo_file_handler_lock) { + /* Check for duplicate compatible strings */ + list_private_for_each_entry(fh_iter, &luo_file_handler_list, list) { + if (!strcmp(fh_iter->compatible, fh->compatible)) { + pr_err("File handler registration failed: Compatible string '%s' alrea= dy registered.\n", + fh->compatible); + err =3D -EEXIST; + goto err_resume; + } + } + + /* Pin the module implementing the handler */ + if (!try_module_get(fh->ops->owner)) { + err =3D -EAGAIN; goto err_resume; } - } =20 - /* Pin the module implementing the handler */ - if (!try_module_get(fh->ops->owner)) { - err =3D -EAGAIN; - goto err_resume; + INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, flb_list)); + INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, list)); + list_add_tail(&ACCESS_PRIVATE(fh, list), &luo_file_handler_list); } - - INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, flb_list)); - INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, list)); - list_add_tail(&ACCESS_PRIVATE(fh, list), &luo_file_handler_list); luo_session_resume(); =20 liveupdate_test_register(fh); @@ -909,10 +916,12 @@ int liveupdate_unregister_file_handler(struct liveupd= ate_file_handler *fh) if (!luo_session_quiesce()) goto err_register; =20 - if (!list_empty(&ACCESS_PRIVATE(fh, flb_list))) - goto err_resume; + scoped_guard(rwsem_write, &luo_file_handler_lock) { + if (!list_empty(&ACCESS_PRIVATE(fh, flb_list))) + goto err_resume; =20 - list_del(&ACCESS_PRIVATE(fh, list)); + list_del(&ACCESS_PRIVATE(fh, list)); + } module_put(fh->ops->owner); luo_session_resume(); =20 --=20 2.53.0.851.ga537e3e6e9-goog From nobody Tue Apr 7 01:19:00 2026 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (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 DCA792BEFEE for ; Tue, 17 Mar 2026 02:50:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773715858; cv=none; b=M+gFWn/AKkGjxVQyE1LdRKHB5XgBWdf72T/AZSpN/rCac43iruJKXmjehv53Uug6EPHDj3ofVRBoMpOuszqc14WicBWitJDD2fSBB1RNJvn8xkqLb6966WfJJOjsU8sdMBIF85tUks7t12OBRtx/cjCxrhK12i8Wt5hUmQyTrjo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773715858; c=relaxed/simple; bh=wJhLhkPnFixEl7Kib5viyl1tW+lOTiNSaZw/tXvxEcU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rPfT3duPNVlbwGkApxsaGtOIR6Zu+kLx7NXd0Eqd5vHUgg5TWS70YQ/G4VUAlJ/BgjSPsMfRce6UsYBeW5OO1VUMIwzThLVzjlflA0ZVX1+/iwsh0kNuge9ldzta1jd9BhegU1/S8DLnzrAqWcifOOaSaLfOUshoQO7REK0P5Qc= ARC-Authentication-Results: i=1; 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=Ahr5xTQe; arc=none smtp.client-ip=209.85.128.176 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="Ahr5xTQe" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-798374d0f44so4813277b3.0 for ; Mon, 16 Mar 2026 19:50:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1773715856; x=1774320656; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=YtIBMXQB5r0gT6fB7kIdzkfYk2CIFHQnbepfnHEfiSo=; b=Ahr5xTQeQp6IuaBeyE/f51i9jzxF2lXmFgxJmmtfW6wVOE4Aim8ZGInHRo9qou23k5 5yP5wrk/aYDMAuWcWctIyzTudHzoX6EaVTAm+qIcVAZihO5cvtv8cPBzWQLxz+0Gllsf Xv/A/Ff3uPtFrckBsrdVZUQcv0aRnYxDS0pgDrlz0N03dcq3yaCxDOt0QOfEIA5R985I FEH+dQE3W0BgCcdlX9I8i9asTDv4m4osUsOTUDO4i/PcSRnKijYTQ7inUSg8clcmNz1O ve0JlBOUQb/7sdyi1FxHHju0LKT93qsZXpt/Wi1KX6Nb1FqQ/caqK9tUk1GFHl1lbLF7 jzZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773715856; x=1774320656; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=YtIBMXQB5r0gT6fB7kIdzkfYk2CIFHQnbepfnHEfiSo=; b=MAyYXNGaqFTd/Shyp69ptCMEc7JFvS3E3YDik6AnFwSZpRlCHBoHYwiazT3b3wKg1c jhA54e0MNxOleROCwPIOtwcbxkxqHnEssxF6sz84rEyFYhCb0Gx2APr2HW7GIoYi5Yc3 I1hGLhz33ssMM7c2KtdBfMQXc78oYaK0mz91UDz/jt/e2Mj5d5pZBY8XacX5dkgpkmzO 5AQY6Dz3o/NDQcHYiz4mGtEJd6nEvMCvjqBV97315u9rWUPLoSZSHihu2420tvlBmrRe b2jaGDJIQpeg2Jkx7vEIlOX9o9j1sd8jOgqe5Bjfs8+BJZgf6dHTQ0Sp+6wHCzsZGpHK gsUQ== X-Forwarded-Encrypted: i=1; AJvYcCXscXVhg0xwlUk+iYe/qpJ4Xx2SltVzlZhePwPLqIbzZep9xaaUG/RPpQbv0yrwo6gtUbmxadY8VRdEHak=@vger.kernel.org X-Gm-Message-State: AOJu0YxqjWeEI66dQr27DtTm5Qh5AIY46y7GdeBQfSgnsWG7gQxHFk6E BIUP8rIbo4+WKDPvrOxvGXSeYvQJkDRcr9nr1K4iobAbzb+H5dvrgxZg/XQBc3InS/782I6gzsu wy89W X-Gm-Gg: ATEYQzwKxfV5WgBO2RewdzglSOoCnqPtoCQHpz8r9Ag/qO15Kd4jMnvv7ic/2p0JZD0 4KwCnakCcEQXdbVOKqBWWqwY3iXCHSQxjC1q+UMOjaInCjIHNVvshGh9KadW1vOy6wcn4iquD4X ilh1uf8Exc2ZBKb20TUHhy8TsSrgvSIWaDFwECEYBtdCkhOtlyE5FdYdtI8UlyJ1cvldzW757gn 2TuAiS1fBAR8U4YUenxxvHKkSj8lxqc1vI3DqRaG/dSOJpAbZHt8O4fUvPrG40aoPNKIDUdUyQ6 1JdbReahPfOx+cFdSqSn1pu3v4jRG/XHkCPXZGIgwip/wkHGRZFnp7SKrmxQ7ObLXkdU1ujPMoc Qvu0ZNISdU8apuoSdpWFaHCMPIn35Q5ZWnxRMHXkiga4IvmFi2N3UaHk7dhIVRQ+P06On5lQbkw 4N7AqYXrNEjf9U6S06MaMOOPsDPEDaIh5VdJ+zb3cGMp2QBLwxayPbKWCzID2ZxukNP0xif33K+ MBZ7H78z6VcSWOPlzeQht6axLfcXPczwBL/Z9kNFy0X4Elv2g== X-Received: by 2002:a05:690c:67c7:b0:796:335a:895 with SMTP id 00721157ae682-79a61789c43mr17250767b3.6.1773715855932; Mon, 16 Mar 2026 19:50:55 -0700 (PDT) Received: from soleen.c.googlers.com.com (57.233.150.34.bc.googleusercontent.com. [34.150.233.57]) by smtp.gmail.com with ESMTPSA id 00721157ae682-79a5a866c85sm14951757b3.35.2026.03.16.19.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2026 19:50:55 -0700 (PDT) From: Pasha Tatashin To: pasha.tatashin@soleen.com, rppt@kernel.org, pratyush@kernel.org, linux-kernel@vger.kernel.org, dmatlack@google.com, akpm@linux-foundation.org, linux-mm@kvack.org Subject: [PATCH 2/6] liveupdate: Protect FLB lists with rwsem Date: Mon, 16 Mar 2026 22:50:45 -0400 Message-ID: <20260317025049.494931-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.53.0.851.ga537e3e6e9-goog In-Reply-To: <20260317025049.494931-1-pasha.tatashin@soleen.com> References: <20260317025049.494931-1-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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Because liveupdate FLB objects will soon drop their persistent module references when registered, list traversals must be protected against concurrent module unloading. Introduce two read-write semaphores to provide this protection: 1. A global luo_flb_lock protects the global registry of FLBs. 2. A per-handler flb_lock protects the handler's specific list of FLB dependencies. Read locks are used during concurrent list traversals (e.g., during preservation and serialization). Write locks are taken during registration and unregistration. When both locks are required, the global luo_flb_lock is strictly acquired before the per-handler flb_lock to prevent deadlocks. Signed-off-by: Pasha Tatashin --- include/linux/liveupdate.h | 3 +++ kernel/liveupdate/luo_flb.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/liveupdate.h b/include/linux/liveupdate.h index dd11fdc76a5f..8394fb2d8774 100644 --- a/include/linux/liveupdate.h +++ b/include/linux/liveupdate.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include =20 @@ -107,6 +108,8 @@ struct liveupdate_file_handler { struct list_head __private list; /* A list of FLB dependencies. */ struct list_head __private flb_list; + /* Protects flb_list */ + struct rw_semaphore __private flb_lock; }; =20 /** diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index f52e8114837e..91910d806d1d 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include "luo_internal.h" @@ -70,6 +71,7 @@ struct luo_flb_global { long count; }; =20 +static DECLARE_RWSEM(luo_flb_lock); static struct luo_flb_global luo_flb_global =3D { .list =3D LIST_HEAD_INIT(luo_flb_global.list), }; @@ -240,6 +242,8 @@ int luo_flb_file_preserve(struct liveupdate_file_handle= r *fh) struct luo_flb_link *iter; int err =3D 0; =20 + guard(rwsem_read)(&ACCESS_PRIVATE(fh, flb_lock)); + list_for_each_entry(iter, flb_list, list) { err =3D luo_flb_file_preserve_one(iter->flb); if (err) @@ -272,6 +276,8 @@ void luo_flb_file_unpreserve(struct liveupdate_file_han= dler *fh) struct list_head *flb_list =3D &ACCESS_PRIVATE(fh, flb_list); struct luo_flb_link *iter; =20 + guard(rwsem_read)(&ACCESS_PRIVATE(fh, flb_lock)); + list_for_each_entry_reverse(iter, flb_list, list) luo_flb_file_unpreserve_one(iter->flb); } @@ -292,6 +298,8 @@ void luo_flb_file_finish(struct liveupdate_file_handler= *fh) struct list_head *flb_list =3D &ACCESS_PRIVATE(fh, flb_list); struct luo_flb_link *iter; =20 + guard(rwsem_read)(&ACCESS_PRIVATE(fh, flb_lock)); + list_for_each_entry_reverse(iter, flb_list, list) luo_flb_file_finish_one(iter->flb); } @@ -355,6 +363,9 @@ int liveupdate_register_flb(struct liveupdate_file_hand= ler *fh, if (!luo_session_quiesce()) return -EBUSY; =20 + guard(rwsem_write)(&luo_flb_lock); + guard(rwsem_write)(&ACCESS_PRIVATE(fh, flb_lock)); + /* Check that this FLB is not already linked to this file handler */ err =3D -EEXIST; list_for_each_entry(iter, flb_list, list) { @@ -444,6 +455,9 @@ int liveupdate_unregister_flb(struct liveupdate_file_ha= ndler *fh, if (!luo_session_quiesce()) return -EBUSY; =20 + guard(rwsem_write)(&luo_flb_lock); + guard(rwsem_write)(&ACCESS_PRIVATE(fh, flb_lock)); + /* Find and remove the link from the file handler's list */ list_for_each_entry(iter, flb_list, list) { if (iter->flb =3D=3D flb) { @@ -638,6 +652,8 @@ void luo_flb_serialize(void) struct liveupdate_flb *gflb; int i =3D 0; =20 + guard(rwsem_read)(&luo_flb_lock); + list_private_for_each_entry(gflb, &luo_flb_global.list, private.list) { struct luo_flb_private *private =3D luo_flb_get_private(gflb); =20 --=20 2.53.0.851.ga537e3e6e9-goog From nobody Tue Apr 7 01:19:00 2026 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (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 4D3F5330B38 for ; Tue, 17 Mar 2026 02:50:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773715859; cv=none; b=hh67uv32NT3QhKeKNe3Vqs1MiWJCx6ln5OxkeRuYVX7I4BKuBP/OUBGgtBeMzDm2Cv80w2BfpF88zG8AYoUJhIIa9fsLGDbPKhbI8ASg9MoumJgE4WUWoAyzt/HJUzf0r3H7WpVYq3jF+xIaKbvYIKppmWp6flaKwEA+sdsIqeY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773715859; c=relaxed/simple; bh=r+QHGddt69BM3WLDmYj12zmbHERYjwjaQwEttoEZ4Qw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LxbbUEbwIXvBYKQFzl6KkwKclO9NrkbVtzU/Za/TBteLkqjz1CGuWWI+8wA6K6uOu3tpKPOe8FEh0f0qe4Bx4sttl1UFPJ/s6uPAMMSYEwi98s2702/bHdI1c30DrIVXU7W11V9jn4GnDadUNcDI81cEJEbtDQZFy9zwtOUb/Io= ARC-Authentication-Results: i=1; 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=RiI2TaRu; arc=none smtp.client-ip=209.85.128.175 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="RiI2TaRu" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-793fdbb8d3aso52389917b3.3 for ; Mon, 16 Mar 2026 19:50:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1773715857; x=1774320657; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=kZn4gLBXu3j1qaebpHUHA9zxqcEZY+fBddtxI5ASzdM=; b=RiI2TaRuf3DobUJeiq65atMB3VRCLpUcWWsnCnHUuCA7h4oXZbKUewwtMKn6aAKIwi 9LykTJdOWkGKQK7YPMtAXQEQQPQE12Fy7My0wDICzHquNsYEB894Cx14QiPNEYEke5Yj xN65KjcVPl47rWzIWjx9QONb6Tyy5x7uiXn5JGYwPx1L/VDcF31e7f26RHfosPgKjSIj kwjb17j6zlKW+//h4rAwZE38w4+XqaFXVbEr2cyF8HAtbkUREvLdJ2Qdw10UcUlQiJ0l tsFTE8DAoJ4vcJEqMT+znhUErnxXDJOzLHM4OyeKe4INXtCeyJrjG1X2zwqCM26qNKKP 8Ivg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773715857; x=1774320657; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=kZn4gLBXu3j1qaebpHUHA9zxqcEZY+fBddtxI5ASzdM=; b=gxBlJUH98o+DuwIXiwySAdvCevcO+vdBPVt4dQFTpNZFBfMEUr6Zy5VcEDskN7c5ut PsEhw/gHck0BrglAWOz241X1c1eaRUXAZrB/pwzmxUwWuT0x7cqG/Pb+OCkiSQ/WufRp 1p7tBJ71GZ/PVCzF2bJRrK0aHz9jSA1e8sMc1tFDv2JjIeh8IuxQMvIEyG45eghKeIuI 0p5e2QEN9QNzWpdYexppIFqArq2Nh8Rsz53TM+mXps3aBv2PNFA0GFHtSIiCRceM2H8v S/XhNwYMnO33eMrKYRs4gWlWghdZdmWXXk6KVbWDtLAgoXwRJSH75XBoEKlT1nVOUBzC ZFyA== X-Forwarded-Encrypted: i=1; AJvYcCUzneB8Nnc73QyDIhTkbEHELpwa5Uqz6qLZNaTdcnhgd71/mu/E0K5sJ+lAaCP//QUMytqiIhkX5DKxMa0=@vger.kernel.org X-Gm-Message-State: AOJu0YwXs8jzlBrXoV2/1tvVOJH6Xz9NeUuCz9pl2jMIT2fRkGswhUJv XMmqabRfqnhBDsukeE+SJEzKnKylUrVpCVRj7VHWmMQxSBZMlU6AjQf/B4RS2d+LI54= X-Gm-Gg: ATEYQzyCrBQrpRyomd/446wptAP9GuxF0vSRy7AU8aL7Tm4YLfca60pNUIadc0yGUWZ HToxedE6JcvT8qY81NCPiOh3v1/YBSTKk/WvzthyQxP2wtOu6PYIPVtj5pqjFSB0G00JvrVCrPE esIpe+YO+1WvQw6eAKfPIibRQVRpj7ljN+bEbo+DgJpJaJC4HdONy5r2wdr5vHX1HK1LB5Gc3SO 9xD3s/cR/MrT773hKg3I3zAiI5qfE1hHIa5yBxGHJg5qQg+SRU6r43EqUGk6i860D0PpszE+zF6 DzqwLrq4EMX9i7MplfSPegZ8KOfzpj87kvnUxLwo4UAUr9hxkfjmt530FN7dY4EyjsPpg8MJV9S LknPZ9P0AQhx7JNTem7eqlbL3z+w9V7DZBxYmhWK1EYUMX0n+rnJw4u7ZX61PFE6Te0DCcpKduk NN49Dm+1u6RZotoUTA6HbGePL8l/VXpRlcDRL9CxV4ku9uNqL0ikep+BMvni17iZN1wZuPq679B +rZvaEE1/IdJh8ltowmOagRCweEEQCHingSAynF5jz44EHQ8A== X-Received: by 2002:a05:690c:6891:b0:79a:3d7f:e8e0 with SMTP id 00721157ae682-79a3d7ffc32mr86614677b3.19.1773715857192; Mon, 16 Mar 2026 19:50:57 -0700 (PDT) Received: from soleen.c.googlers.com.com (57.233.150.34.bc.googleusercontent.com. [34.150.233.57]) by smtp.gmail.com with ESMTPSA id 00721157ae682-79a5a866c85sm14951757b3.35.2026.03.16.19.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2026 19:50:56 -0700 (PDT) From: Pasha Tatashin To: pasha.tatashin@soleen.com, rppt@kernel.org, pratyush@kernel.org, linux-kernel@vger.kernel.org, dmatlack@google.com, akpm@linux-foundation.org, linux-mm@kvack.org Subject: [PATCH 3/6] liveupdate: Defer file handler module refcounting to active sessions Date: Mon, 16 Mar 2026 22:50:46 -0400 Message-ID: <20260317025049.494931-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.53.0.851.ga537e3e6e9-goog In-Reply-To: <20260317025049.494931-1-pasha.tatashin@soleen.com> References: <20260317025049.494931-1-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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Stop pinning modules indefinitely upon file handler registration. Instead, dynamically increment the module reference count only when a live update session actively uses the file handler (e.g., during preservation or deserialization), and release it when the session ends. This allows modules providing live update handlers to be gracefully unloaded when no live update is in progress. Signed-off-by: Pasha Tatashin --- kernel/liveupdate/luo_file.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index 6a0ae29c6a24..6b2b49cb375e 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -253,6 +253,7 @@ static bool luo_token_is_used(struct luo_file_set *file= _set, u64 token) * -ENOSPC if the file_set is full. * -ENOENT if no compatible handler is found. * -ENOMEM on memory allocation failure. + * -ENODEV if the file handler's module is unloading. * Other erros might be returned by .preserve(). */ int luo_preserve_file(struct luo_file_set *file_set, u64 token, int fd) @@ -281,7 +282,10 @@ int luo_preserve_file(struct luo_file_set *file_set, u= 64 token, int fd) scoped_guard(rwsem_read, &luo_file_handler_lock) { list_private_for_each_entry(fh, &luo_file_handler_list, list) { if (fh->ops->can_preserve(fh, file)) { - err =3D 0; + if (try_module_get(fh->ops->owner)) + err =3D 0; + else + err =3D -ENODEV; break; } } @@ -293,7 +297,7 @@ int luo_preserve_file(struct luo_file_set *file_set, u6= 4 token, int fd) =20 err =3D luo_flb_file_preserve(fh); if (err) - goto err_free_files_mem; + goto err_module_put; =20 luo_file =3D kzalloc_obj(*luo_file); if (!luo_file) { @@ -323,6 +327,8 @@ int luo_preserve_file(struct luo_file_set *file_set, u6= 4 token, int fd) kfree(luo_file); err_flb_unpreserve: luo_flb_file_unpreserve(fh); +err_module_put: + module_put(fh->ops->owner); err_free_files_mem: luo_free_files_mem(file_set); err_fput: @@ -365,6 +371,7 @@ void luo_file_unpreserve_files(struct luo_file_set *fil= e_set) args.private_data =3D luo_file->private_data; luo_file->fh->ops->unpreserve(&args); luo_flb_file_unpreserve(luo_file->fh); + module_put(luo_file->fh->ops->owner); =20 list_del(&luo_file->list); file_set->count--; @@ -649,6 +656,7 @@ static void luo_file_finish_one(struct luo_file_set *fi= le_set, =20 luo_file->fh->ops->finish(&args); luo_flb_file_finish(luo_file->fh); + module_put(luo_file->fh->ops->owner); } =20 /** @@ -783,7 +791,8 @@ int luo_file_deserialize(struct luo_file_set *file_set, scoped_guard(rwsem_read, &luo_file_handler_lock) { list_private_for_each_entry(fh, &luo_file_handler_list, list) { if (!strcmp(fh->compatible, file_ser[i].compatible)) { - handler_found =3D true; + if (try_module_get(fh->ops->owner)) + handler_found =3D true; break; } } @@ -796,8 +805,10 @@ int luo_file_deserialize(struct luo_file_set *file_set, } =20 luo_file =3D kzalloc_obj(*luo_file); - if (!luo_file) + if (!luo_file) { + module_put(fh->ops->owner); return -ENOMEM; + } =20 luo_file->fh =3D fh; luo_file->file =3D NULL; @@ -873,6 +884,7 @@ int liveupdate_register_file_handler(struct liveupdate_= file_handler *fh) } =20 INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, flb_list)); + init_rwsem(&ACCESS_PRIVATE(fh, flb_lock)); INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, list)); list_add_tail(&ACCESS_PRIVATE(fh, list), &luo_file_handler_list); } @@ -922,7 +934,6 @@ int liveupdate_unregister_file_handler(struct liveupdat= e_file_handler *fh) =20 list_del(&ACCESS_PRIVATE(fh, list)); } - module_put(fh->ops->owner); luo_session_resume(); =20 return 0; --=20 2.53.0.851.ga537e3e6e9-goog From nobody Tue Apr 7 01:19:01 2026 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (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 74B052C11CF for ; Tue, 17 Mar 2026 02:50:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773715860; cv=none; b=ihCfoDJfOmZK4Ly2f4vf80jZDIONt9tnU4DEUooJiW+N53gspuIZY5l766dgi084NCcRenLTbsCC5ytErj935BSzX3D56cP/3l9NK023UO0pZPx0X3zw4FzvmE2gwdlEJq+TUA57Q6NEoFfftDiChLv+f4CFmPulbN0qIwadxBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773715860; c=relaxed/simple; bh=YKrvu+8KUko9GyvP4ENDHu+v4QBuGSrJspIEh3Z6nUU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TWB8aYzl/UVpn1L6gyuAW3zk9hpmal5GYa1pGFsVbrIlRau2OKq6/0Wkab/ZXLCi+Ph8EVsFHz5Ei8FxYLZ1H4VvqFmU3Z6qb68dpHQXfB5WmwjFw2/8dni8riSX7bFvIKgv3EXHb2hfyA5SqSAm0fLv+mWKrCVIRSILrU/bfHE= ARC-Authentication-Results: i=1; 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=GT1D+Zcm; arc=none smtp.client-ip=209.85.128.176 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="GT1D+Zcm" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-7927261a3acso42067317b3.0 for ; Mon, 16 Mar 2026 19:50:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1773715858; x=1774320658; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PjOdhUZ1Sfc2pBNZkzIv/+F2L8hy1jAjYMY22sGDTyM=; b=GT1D+Zcm4kgCtQrN8a6pCE1RaN3M023FYAAkG5u6rBLOjE4yHNHq+HdSvA17QzzvWj EhJiaTmvLWWmYEogyJZPvdzAA4qU12u5+A0RAE5JfV74K7CfiJcEAn8lPhGRlIdL06tL YcekFbJv88bInwAyv/5oFsPWUQdcKqlKIGVW31TrEFo9BkrAG2o9MY8TWPvC4rymYxIq 9Tg7y9KTKSPxMruMsCL4TM1fVLhvyN9WxAfBgH+e52BhwhXRRoWcfPjFF67N0VDDVGyN nQ1sONh+d2TqRw2mNGNl5HsQjnbZ5RaCmfuo/qlOxsMJoRvsXUImaCIBBkmm8Jd/VanW sR7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773715858; x=1774320658; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=PjOdhUZ1Sfc2pBNZkzIv/+F2L8hy1jAjYMY22sGDTyM=; b=AVk1KfTC4jPdez3Em3mm0KLSVwDfDe5yxjbxxgKCIMqENySWlmDZUA0v6EZDy8HkNW fSXOKbvwbbunvErWD1DBSxZYDFFV07/KffCOr8B6iF2/XwPhv34GgzA0Zb05fT0EIipA fvQ0s/QYQxdyE3v1FE9CZ+7C5N9SjU367jz9p98uxX4t9vsUXspq+DyKwTXsCDTMJFO9 18ceiv7ViSicdE40OrOKJTjV5h7eWCJtp2/PvAMUwSGAmIMFHm/b9XHhbKfp7KQVeaV4 wXi+CWvjc1J8MRnce2CWC9EArFpwDGeBy244VHvVR0q5/yA89xQ6ZgMFtNycWPoNCiIQ DUOQ== X-Forwarded-Encrypted: i=1; AJvYcCXOwYvhd/jlFmjGQiGclcyiDAyxPdWEcFxzTsQSX2HC4D8158wj/rtmQYvXjWRmGzWumdcSO/Wvenjtjnw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx0NpR6duSaMIeQoFckKnqI6wu1nNZOYeuMAKiaG+AlxgnKhMSX /2c26i2dZd0gJ1ZhCilpUfVV0toTy+yqOMO7H25ej7XA4Wr/H+S29x7MK3EnwkEPcSM= X-Gm-Gg: ATEYQzwXgzmeV7ENyDqqf7MY8FdnvfiTTAjRrXyKbaidpE2N0ltNdYmbfpMaqnl8owt 3Gbr92YuqYXzE6eVgpDq7fsg+7lGpd+aYJkpV91+WP/I1Ok0rmHF1A+engd+K1km6NMXd5SUvP7 b6XmkTduKrht+yyytKM5VfDkOFkh3WGF3lnO6lOOPpYYln0uzQ8cBPDd2BwL4Lvv96KG3qG/uFf 4HT0jaZhKO88+M7gZ+tmdrq5jWV4hi7zOKCYiENlZiXrTMVugvOw9/dbw1pB62qkBfXtmZU9zMJ UxBGCCtSaWA0KYyXon5dyw0lk/y9q7S5EhgmGXlo5FSVAjoCNkALoDdT1oj655jPlLOpRBI7cvm SDefcWJsjE9UvakzEVidYYlkkzN/YUO1hE7BI2Y4iChuRv77d/xEWjZ1LrLkItuUmApeTdkHqBL vkqbLcB/9E3EwxGyzOYGa3AhBhfwoK3k2lqzo/jCnHgI1Ju8ijj7SldMV52vlzCG/YIVcNQm7Y2 eUnHn9Xg/VgU9YxXaJzomp6uggtuK0J0BpEYow+bvQZ3k8bqw== X-Received: by 2002:a05:690c:660d:b0:79a:51df:6a0a with SMTP id 00721157ae682-79a51dfb37dmr49247187b3.60.1773715858519; Mon, 16 Mar 2026 19:50:58 -0700 (PDT) Received: from soleen.c.googlers.com.com (57.233.150.34.bc.googleusercontent.com. [34.150.233.57]) by smtp.gmail.com with ESMTPSA id 00721157ae682-79a5a866c85sm14951757b3.35.2026.03.16.19.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2026 19:50:57 -0700 (PDT) From: Pasha Tatashin To: pasha.tatashin@soleen.com, rppt@kernel.org, pratyush@kernel.org, linux-kernel@vger.kernel.org, dmatlack@google.com, akpm@linux-foundation.org, linux-mm@kvack.org Subject: [PATCH 4/6] liveupdate: Defer FLB module refcounting to active sessions Date: Mon, 16 Mar 2026 22:50:47 -0400 Message-ID: <20260317025049.494931-5-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.53.0.851.ga537e3e6e9-goog In-Reply-To: <20260317025049.494931-1-pasha.tatashin@soleen.com> References: <20260317025049.494931-1-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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Stop pinning modules indefinitely upon FLB registration. Instead, dynamically take a module reference when the FLB is actively used in a session (e.g., during preserve and retrieve) and release it when the session concludes. This allows modules providing FLB operations to be cleanly unloaded when not in active use by the live update orchestrator. Signed-off-by: Pasha Tatashin --- kernel/liveupdate/luo_flb.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index 91910d806d1d..daa852abdedd 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -112,10 +112,15 @@ static int luo_flb_file_preserve_one(struct liveupdat= e_flb *flb) struct liveupdate_flb_op_args args =3D {0}; int err; =20 + if (!try_module_get(flb->ops->owner)) + return -ENODEV; + args.flb =3D flb; err =3D flb->ops->preserve(&args); - if (err) + if (err) { + module_put(flb->ops->owner); return err; + } private->outgoing.data =3D args.data; private->outgoing.obj =3D args.obj; } @@ -143,6 +148,7 @@ static void luo_flb_file_unpreserve_one(struct liveupda= te_flb *flb) =20 private->outgoing.data =3D 0; private->outgoing.obj =3D NULL; + module_put(flb->ops->owner); } } } @@ -178,12 +184,17 @@ static int luo_flb_retrieve_one(struct liveupdate_flb= *flb) if (!found) return -ENOENT; =20 + if (!try_module_get(flb->ops->owner)) + return -ENODEV; + args.flb =3D flb; args.data =3D private->incoming.data; =20 err =3D flb->ops->retrieve(&args); - if (err) + if (err) { + module_put(flb->ops->owner); return err; + } =20 private->incoming.obj =3D args.obj; private->incoming.retrieved =3D true; @@ -217,6 +228,7 @@ static void luo_flb_file_finish_one(struct liveupdate_f= lb *flb) private->incoming.data =3D 0; private->incoming.obj =3D NULL; private->incoming.finished =3D true; + module_put(flb->ops->owner); } } } @@ -394,11 +406,6 @@ int liveupdate_register_flb(struct liveupdate_file_han= dler *fh, goto err_resume; } =20 - if (!try_module_get(flb->ops->owner)) { - err =3D -EAGAIN; - goto err_resume; - } - list_add_tail(&private->list, &luo_flb_global.list); luo_flb_global.count++; } @@ -479,7 +486,6 @@ int liveupdate_unregister_flb(struct liveupdate_file_ha= ndler *fh, if (!private->users) { list_del_init(&private->list); luo_flb_global.count--; - module_put(flb->ops->owner); } =20 luo_session_resume(); @@ -506,7 +512,8 @@ int liveupdate_unregister_flb(struct liveupdate_file_ha= ndler *fh, * * Return: 0 on success, or a negative errno on failure. -ENODATA means no * incoming FLB data, -ENOENT means specific flb not found in the incoming - * data, and -EOPNOTSUPP when live update is disabled or not configured. + * data, -ENODEV if the FLB's module is unloading, and -EOPNOTSUPP when + * live update is disabled or not configured. */ int liveupdate_flb_get_incoming(struct liveupdate_flb *flb, void **objp) { --=20 2.53.0.851.ga537e3e6e9-goog From nobody Tue Apr 7 01:19:01 2026 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) (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 BC76834CFBD for ; Tue, 17 Mar 2026 02:51:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773715862; cv=none; b=hr1CUQNuS0o6JzRzd2O1PjrdAzZYiL3Rn//DbUA9cCMqEFeW5FzkO9d68JNX/a/q3+qFNq3HK47sVIayMqLKVtv0ELaUiPGQpGnEiN4q/bjyRxuk9WPLWD6ktCxX3mQ67FXQ6vdF9iZoVYPjBRrWOHq3u0XSKFtD3bWY4KCaFN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773715862; c=relaxed/simple; bh=vS7QcUz0WEMkqtEepJCwXdIhd/NFaUveowsZh47nX+s=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S4fdCx6jb8V/iGFcsjDuXVmcW1yJedb3C8tJotfGHUwhYazBuvgr8gJD/FldonEOxj9r5kHDOG2kFk9F+BDTvIKJbIHXAdftGnknUCW27pdewwVHGHh88PdeVaQhTAdBwK4hmXOOi7AGoVNHoO/XJtCX4pT+DNAceGAPGhr580o= ARC-Authentication-Results: i=1; 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=fE/i7cxG; arc=none smtp.client-ip=209.85.128.169 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="fE/i7cxG" Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-79a46260385so18167777b3.3 for ; Mon, 16 Mar 2026 19:51:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1773715860; x=1774320660; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=DDyewP1AZHpe5wDxr4egwn4qSBkMsagV6JEmGWYwO1o=; b=fE/i7cxGY8UT9KI3CN/IcYqfcm+MNzFTbaMfhOz0099vmHo2qDiFpnjpWr5z8z0Y9p it//d3BXoymUMTsBaW6Ykw5vaKCnYCr9l9yFwWZRwCoPZ0uEIfkV6Gp5YkibUC+rjvD+ zFzeJToqgUIU7/siswBQI3tCVUAVIBooF6ZnCFQSeK3XCj5ixUjTDS6dtRD4I54pDGec VLbBcHrJNDD03MRd+RHiS/C98R4GxqSQ8JNs7gdLgyvMs4YVTOwke4Scy+bK0NWtfCCu GijHAKODuuVuwWIb2nYDre3b1aT/ExmyerTzUOgOMJU8F1p2j4HzRyk6X7C8KFEbOk08 0IYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773715860; x=1774320660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=DDyewP1AZHpe5wDxr4egwn4qSBkMsagV6JEmGWYwO1o=; b=gppaUNFxPNrdzfSGJYxY4c7cwvj+1ccMsd2zwe4+tXwafZL+l/it1PVFgnh/A+zRYQ FRwtGJry5jRQ266ht8RyOG5RwuEpuZflmjNU1Wh0zTIq+qYFQAiUMzg94awlaQhXvXuM 5m1A09uhP3LL9MwlvsIuHsdY2h09SU8oOPXq+aWo5y90/xeWQKN10PhK5MoWsRlYF5ZT Sxf6bDGlOpiAwAD5U6ENU0cJ/0lhTKAmaC9tGYFywLLXPLwUIMF0NIpoQV9gFP5LZKFL +ZB21pYHwjH2dzq/j7+KAnJMVs8AuMmCqd0eSOIL4FGqkIRytWaxL5xLAiWmx7xLnqls /DxQ== X-Forwarded-Encrypted: i=1; AJvYcCU75BJYHFKk4H8lpj4iwGfLcZXEab/0EcdMQPmZ+Pnk+VMgZFSFF8MSpbDJ3KBRQlFM1gEUhHXTFqyt9TQ=@vger.kernel.org X-Gm-Message-State: AOJu0Ywt/MWi9aj2zFKj18Xqup+09R3NNxpDgySTnsVQUH5s12z5Vq+2 VPJcx+OW1b9VA9OeifJEne+goN0Sw8bCQVLAM5NMl/6u+LoQWI/Wt0KJwaHCeo39okg= X-Gm-Gg: ATEYQzz/lPiS+I8HthDv9fe9w3sr1mh3VkmGjAbC2w/CzVkqBhSyCmm8R1A0qaM62fR +zr2I30EZZKrpICz53t/Ldb2VTMjyIUUjTLiqQAyiQb85wRix88xvgg6A7w9/zTIPnEjT/JBVwz 8LD9lzj8QBZ83tUCDtoIBgQJALJa1qBTS+zqumV4PB3IgvRsyV7rvmQwYfW8wvsQjJC1jVQ+i2g y6kWs4mtbqlPjFQDtR9Jh7LD2tkL7/ryeowspiAclAilpwKi4MjAbSYJAbHbFzxfgMTG9IrRuCN jEAKkJHyK2D4N+IGWw7HFNKzTl6WXV9lpCV1DWITV1crIIRYxcmOraouYgtXQ433ZMPY6zbCu6y gZr4G5bqy/TKeQJf/EM6fjH65fecOTXeS4x6nwLYwUIlxVUl11NbeyEtfWgZVbQKH6cjDMrKD9v /dNU/bXCIBI3yGabcIVVSDS2JBI+q00ncIqhALAVlVv9l3txokZEGxAxGrGcK5K8CLQjB3G7r8V tna/YDpXl0TaEfJbxqRwdgJjgKcbiLPZ/OIwNqwNeQlFMtJkQ== X-Received: by 2002:a05:690c:6d10:b0:797:d386:44c9 with SMTP id 00721157ae682-79a1c17b181mr153296457b3.32.1773715859783; Mon, 16 Mar 2026 19:50:59 -0700 (PDT) Received: from soleen.c.googlers.com.com (57.233.150.34.bc.googleusercontent.com. [34.150.233.57]) by smtp.gmail.com with ESMTPSA id 00721157ae682-79a5a866c85sm14951757b3.35.2026.03.16.19.50.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2026 19:50:58 -0700 (PDT) From: Pasha Tatashin To: pasha.tatashin@soleen.com, rppt@kernel.org, pratyush@kernel.org, linux-kernel@vger.kernel.org, dmatlack@google.com, akpm@linux-foundation.org, linux-mm@kvack.org Subject: [PATCH 5/6] liveupdate: Make unregister functions return void Date: Mon, 16 Mar 2026 22:50:48 -0400 Message-ID: <20260317025049.494931-6-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.53.0.851.ga537e3e6e9-goog In-Reply-To: <20260317025049.494931-1-pasha.tatashin@soleen.com> References: <20260317025049.494931-1-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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Change liveupdate_unregister_file_handler and liveupdate_unregister_flb to return void instead of an error code. If they fail to unregister due to dangling references, print a warning instead of aborting. As pointed out by Jason Gunthorpe and Alex Williamson, returning an error from a "destroy" or unregister function during a module unload is a poor API choice since the unload cannot be stopped at that point. Signed-off-by: Pasha Tatashin --- include/linux/liveupdate.h | 13 ++++++------ kernel/liveupdate/luo_file.c | 27 +++++++++++------------- kernel/liveupdate/luo_flb.c | 40 ++++++++++-------------------------- lib/tests/liveupdate.c | 8 ++------ 4 files changed, 31 insertions(+), 57 deletions(-) diff --git a/include/linux/liveupdate.h b/include/linux/liveupdate.h index 8394fb2d8774..293df26b9e7f 100644 --- a/include/linux/liveupdate.h +++ b/include/linux/liveupdate.h @@ -231,12 +231,12 @@ bool liveupdate_enabled(void); int liveupdate_reboot(void); =20 int liveupdate_register_file_handler(struct liveupdate_file_handler *fh); -int liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh); +void liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh= ); =20 int liveupdate_register_flb(struct liveupdate_file_handler *fh, struct liveupdate_flb *flb); -int liveupdate_unregister_flb(struct liveupdate_file_handler *fh, - struct liveupdate_flb *flb); +void liveupdate_unregister_flb(struct liveupdate_file_handler *fh, + struct liveupdate_flb *flb); =20 int liveupdate_flb_get_incoming(struct liveupdate_flb *flb, void **objp); int liveupdate_flb_get_outgoing(struct liveupdate_flb *flb, void **objp); @@ -258,9 +258,8 @@ static inline int liveupdate_register_file_handler(stru= ct liveupdate_file_handle return -EOPNOTSUPP; } =20 -static inline int liveupdate_unregister_file_handler(struct liveupdate_fil= e_handler *fh) +static inline void liveupdate_unregister_file_handler(struct liveupdate_fi= le_handler *fh) { - return -EOPNOTSUPP; } =20 static inline int liveupdate_register_flb(struct liveupdate_file_handler *= fh, @@ -269,8 +268,8 @@ static inline int liveupdate_register_flb(struct liveup= date_file_handler *fh, return -EOPNOTSUPP; } =20 -static inline int liveupdate_unregister_flb(struct liveupdate_file_handler= *fh, - struct liveupdate_flb *flb) +static inline void liveupdate_unregister_flb(struct liveupdate_file_handle= r *fh, + struct liveupdate_flb *flb) { return -EOPNOTSUPP; } diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index 6b2b49cb375e..0fe2f8be8bd1 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -907,21 +907,17 @@ int liveupdate_register_file_handler(struct liveupdat= e_file_handler *fh) * reverses the operations of liveupdate_register_file_handler(). * * It ensures safe removal by checking that: - * No live update session is currently in progress. * No FLB registered with this file handler. * * If the unregistration fails, the internal test state is reverted. * - * Return: 0 Success. -EOPNOTSUPP when live update is not enabled. -EBUSY = A live - * update is in progress, can't quiesce live update or FLB is registred wi= th - * this file handler. */ -int liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh) +void liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh) { - int err =3D -EBUSY; + bool is_empty; =20 if (!liveupdate_enabled()) - return -EOPNOTSUPP; + return; =20 liveupdate_test_unregister(fh); =20 @@ -929,18 +925,19 @@ int liveupdate_unregister_file_handler(struct liveupd= ate_file_handler *fh) goto err_register; =20 scoped_guard(rwsem_write, &luo_file_handler_lock) { - if (!list_empty(&ACCESS_PRIVATE(fh, flb_list))) - goto err_resume; - - list_del(&ACCESS_PRIVATE(fh, list)); + is_empty =3D list_empty(&ACCESS_PRIVATE(fh, flb_list)); + if (is_empty) + list_del(&ACCESS_PRIVATE(fh, list)); } luo_session_resume(); =20 - return 0; + if (!is_empty) { + pr_warn("Failed to unregister file handler '%s': FLB list not empty\n", + fh->compatible); + liveupdate_test_register(fh); + } + return; =20 -err_resume: - luo_session_resume(); err_register: liveupdate_test_register(fh); - return err; } diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index daa852abdedd..23fa6e0c6083 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -436,31 +436,17 @@ int liveupdate_register_flb(struct liveupdate_file_ha= ndler *fh, * the FLB is removed from the global registry and the reference to its * owner module (acquired during registration) is released. * - * Context: This function ensures the session is quiesced (no active FDs - * being created) during the update. It is typically called from a - * subsystem's module exit function. - * Return: 0 on success. - * -EOPNOTSUPP if live update is disabled. - * -EBUSY if the live update session is active and cannot be quies= ced. - * -ENOENT if the FLB was not found in the file handler's list. */ -int liveupdate_unregister_flb(struct liveupdate_file_handler *fh, - struct liveupdate_flb *flb) +void liveupdate_unregister_flb(struct liveupdate_file_handler *fh, + struct liveupdate_flb *flb) { struct luo_flb_private *private =3D luo_flb_get_private(flb); struct list_head *flb_list =3D &ACCESS_PRIVATE(fh, flb_list); struct luo_flb_link *iter; - int err =3D -ENOENT; + bool found =3D false; =20 if (!liveupdate_enabled()) - return -EOPNOTSUPP; - - /* - * Ensure the system is quiescent (no active sessions). - * This acts as a global lock for unregistration. - */ - if (!luo_session_quiesce()) - return -EBUSY; + return; =20 guard(rwsem_write)(&luo_flb_lock); guard(rwsem_write)(&ACCESS_PRIVATE(fh, flb_lock)); @@ -470,15 +456,19 @@ int liveupdate_unregister_flb(struct liveupdate_file_= handler *fh, if (iter->flb =3D=3D flb) { list_del(&iter->list); kfree(iter); - err =3D 0; + found =3D true; break; } } =20 - if (err) - goto err_resume; + if (!found) { + pr_warn("Failed to unregister FLB '%s': not found in file handler '%s'\n= ", + flb->compatible, fh->compatible); + return; + } =20 private->users--; + /* * If this is the last file-handler with which we are registred, remove * from the global list, and relese module reference. @@ -487,14 +477,6 @@ int liveupdate_unregister_flb(struct liveupdate_file_h= andler *fh, list_del_init(&private->list); luo_flb_global.count--; } - - luo_session_resume(); - - return 0; - -err_resume: - luo_session_resume(); - return err; } =20 /** diff --git a/lib/tests/liveupdate.c b/lib/tests/liveupdate.c index 496d6ef91a30..5b6abf779f87 100644 --- a/lib/tests/liveupdate.c +++ b/lib/tests/liveupdate.c @@ -137,16 +137,12 @@ void liveupdate_test_register(struct liveupdate_file_= handler *fh) =20 void liveupdate_test_unregister(struct liveupdate_file_handler *fh) { - int err, i; + int i; =20 for (i =3D 0; i < TEST_NFLBS; i++) { struct liveupdate_flb *flb =3D &test_flbs[i]; =20 - err =3D liveupdate_unregister_flb(fh, flb); - if (err) { - pr_err("Failed to unregister %s %pe\n", - flb->compatible, ERR_PTR(err)); - } + liveupdate_unregister_flb(fh, flb); } =20 pr_info("Unregistered %d FLBs from file handler: [%s]\n", --=20 2.53.0.851.ga537e3e6e9-goog From nobody Tue Apr 7 01:19:01 2026 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (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 B1F0E346E41 for ; Tue, 17 Mar 2026 02:51:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773715863; cv=none; b=STdw1lRZbL80+t4iApQLd/Z68aCpWvpItUi76hGGa7Ev+q1OdJeS7gW85l9+FsMFR5AsqGcbi11KOmbGod8MDLixf0C3JnqtQxaoloKdfVy9cHFtOnb1H8BNAb97lXNKmv8AT70ngIPhbRbMaKYN1QejaPGIqVPiEL2POycYbk4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773715863; c=relaxed/simple; bh=NivFBiGu31RZfVCjzxekBJ87+FNJ54DJ542JKdteQdM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T/KzTXktF31/GW3qgAStI+yDlNb2QdJsJVuRIkTQRVHd1IsQhLJ0wByZKuUuh5vbufBCpJfrpPT3WS6Dv77eLEe/k6p0bojvH0IqDrfZoA+b5o5T8/MI5Fx0x/Ecuu3IM4YpJS/TLQhNmCoxGv0EgTzZNmCErV5XKoSQCSRB334= ARC-Authentication-Results: i=1; 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=ATV8+/z5; arc=none smtp.client-ip=209.85.128.178 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="ATV8+/z5" Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-78fc4425b6bso50556027b3.1 for ; Mon, 16 Mar 2026 19:51:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1773715861; x=1774320661; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=sd93Vtcs6nWwoXw9KS21SuDl6vnDZo9LwpKtI+MCpyM=; b=ATV8+/z54mbhnW0OyAwHfydw4VVnnv2DvRYFRKlDIryab1b49dFH8yPAWHCNXOH7vp MH0XiLxbyB598QqmlPofIaXx1qcVPNtt8h+HWxjxrRayOgxVLE2WT23on/Ac8ZjCx30h rSTxUjDa/jL5A/+/4D01TnZOAMsaGUhJRVVTPUevqJ3feRN/wnq8BR80ADZIkC6Nu3OU lm2ATOYGU9V9HvqNDUSzCQf2+viPIkfz33ae3g3NfuvN5yGxOzsfRKQokWVo2l0C8iM9 fohu3sFwroh/B3phUtTqRf9ffgpHZq0H6vXNW7h8lQxKMCnjzXhzh3Q8uXPpKx28Ggan pYVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773715861; x=1774320661; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=sd93Vtcs6nWwoXw9KS21SuDl6vnDZo9LwpKtI+MCpyM=; b=U7jlCb2Z6XU6vnDLAmB0YUoVo6YpE+VfzHix/VYQxl6WrDeOyueUIDtiuvWglyqOnu ROFzJIRUYbWQjGs2FR5ipeYuuGYSlN/7Lto5ZNdDnGmhODLap0YjmMsj8Yc4c+kG3nsc IrMsWveF8hd6amsbzPQu3oFGTHAMs54HfWND32jcY5l68g43Alhv7lIqOsNFRHFPguGK xcziLtRWL2aYvW0JzAib8HXIhVLLakjrtl6fRVZRLkLO0Dn6bR6AYz2Wyq/U3XToZhyK 9nzbRXxryPBpnb4SkGgJX1xrnmwgAg1hXwotsL4hMYmO6xf3lJHYhSECpRDXzsgDquoT hKeA== X-Forwarded-Encrypted: i=1; AJvYcCV1ZZwiMtgktTWck+hQEOQ3uH/DC2aeo77DbFRhE8NWjjqa+sTUjIUN9BsFG1i6ix4w6Y2BzANUSF97mqY=@vger.kernel.org X-Gm-Message-State: AOJu0YysC7OVt40IWMEJrg5RITHbwlTEzsdxNSPUMoExhvPtUDBZunfX IUizvBmtOyQLIGBibTIKoqJwikUvcdfBUaKVDZ3HNFQ93OsMKOXBPa3Bc32fLookXpc= X-Gm-Gg: ATEYQzw63nWczmA55wjLEn4L8Q2X/l96C/024QSFIDvMQZ22PBJIqIxi0fUeP0budGD nSNvMhFNg0WI9duynd64+hY5g0r13157EiLBwjI/Curd/lbXVF4yWmRPfC0HosvqX0JepemhWWc H467VOnHt1mTDxxFNMOLkEzt/X8j48hXCBOK0r5XvgN3xHzqaasIrYxfYFpQcvB+bOI8HDyDg/0 DYQuVdWLS2jCzxwjA6j8AssNJKdz67dPzGJY4DWDJozj1vET7jiToWj8paJkNtZYH4yeQVkVdrD WFXJT8tq4ZuZtDSnmWWCDHauKqV5c8bsvRe5191/x+smkWopzVTukc6v3N/p5QueyONH88BKCJm Dt7kurr5jB4kQk1crwosunXwyvpX5ee9dtnXSdJqdBqStCUj++z3WAaTRn0RW6b4dCXy7zwA2IU Cbz9xQwgCRGX9a43Ixbaz/MFPulNTPBS9RF7zm4H39176Qp0MCv82WCDL46B9y+a7HsGIkviXS3 OwFtYkstGXU1vAICI1+0UrTaDbaLHl2xPXob9AGFFmLRfYDRXvnLV6L3CHm X-Received: by 2002:a05:690c:84:b0:799:3e:8239 with SMTP id 00721157ae682-79a1c071df6mr154381937b3.6.1773715860747; Mon, 16 Mar 2026 19:51:00 -0700 (PDT) Received: from soleen.c.googlers.com.com (57.233.150.34.bc.googleusercontent.com. [34.150.233.57]) by smtp.gmail.com with ESMTPSA id 00721157ae682-79a5a866c85sm14951757b3.35.2026.03.16.19.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2026 19:51:00 -0700 (PDT) From: Pasha Tatashin To: pasha.tatashin@soleen.com, rppt@kernel.org, pratyush@kernel.org, linux-kernel@vger.kernel.org, dmatlack@google.com, akpm@linux-foundation.org, linux-mm@kvack.org Subject: [PATCH 6/6] liveupdate: Remove luo_session_quiesce() Date: Mon, 16 Mar 2026 22:50:49 -0400 Message-ID: <20260317025049.494931-7-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.53.0.851.ga537e3e6e9-goog In-Reply-To: <20260317025049.494931-1-pasha.tatashin@soleen.com> References: <20260317025049.494931-1-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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that module references properly handle the usage of file handlers and FLBs during active sessions, we can safely remove the luo_session_quiesce() and luo_session_resume() mechanism. Signed-off-by: Pasha Tatashin --- kernel/liveupdate/luo_file.c | 31 +++------------------- kernel/liveupdate/luo_flb.c | 31 +++++----------------- kernel/liveupdate/luo_internal.h | 2 -- kernel/liveupdate/luo_session.c | 44 -------------------------------- 4 files changed, 9 insertions(+), 99 deletions(-) diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index 0fe2f8be8bd1..bfa0b4868746 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -847,7 +847,6 @@ void luo_file_set_destroy(struct luo_file_set *file_set) int liveupdate_register_file_handler(struct liveupdate_file_handler *fh) { struct liveupdate_file_handler *fh_iter; - int err; =20 if (!liveupdate_enabled()) return -EOPNOTSUPP; @@ -858,45 +857,29 @@ int liveupdate_register_file_handler(struct liveupdat= e_file_handler *fh) return -EINVAL; } =20 - /* - * Ensure the system is quiescent (no active sessions). - * This prevents registering new handlers while sessions are active or - * while deserialization is in progress. - */ - if (!luo_session_quiesce()) - return -EBUSY; - scoped_guard(rwsem_write, &luo_file_handler_lock) { /* Check for duplicate compatible strings */ list_private_for_each_entry(fh_iter, &luo_file_handler_list, list) { if (!strcmp(fh_iter->compatible, fh->compatible)) { pr_err("File handler registration failed: Compatible string '%s' alrea= dy registered.\n", fh->compatible); - err =3D -EEXIST; - goto err_resume; + return -EEXIST; } } =20 /* Pin the module implementing the handler */ - if (!try_module_get(fh->ops->owner)) { - err =3D -EAGAIN; - goto err_resume; - } + if (!try_module_get(fh->ops->owner)) + return -EAGAIN; =20 INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, flb_list)); init_rwsem(&ACCESS_PRIVATE(fh, flb_lock)); INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, list)); list_add_tail(&ACCESS_PRIVATE(fh, list), &luo_file_handler_list); } - luo_session_resume(); =20 liveupdate_test_register(fh); =20 return 0; - -err_resume: - luo_session_resume(); - return err; } =20 /** @@ -921,23 +904,15 @@ void liveupdate_unregister_file_handler(struct liveup= date_file_handler *fh) =20 liveupdate_test_unregister(fh); =20 - if (!luo_session_quiesce()) - goto err_register; - scoped_guard(rwsem_write, &luo_file_handler_lock) { is_empty =3D list_empty(&ACCESS_PRIVATE(fh, flb_list)); if (is_empty) list_del(&ACCESS_PRIVATE(fh, list)); } - luo_session_resume(); =20 if (!is_empty) { pr_warn("Failed to unregister file handler '%s': FLB list not empty\n", fh->compatible); liveupdate_test_register(fh); } - return; - -err_register: - liveupdate_test_register(fh); } diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index 23fa6e0c6083..8810595c672d 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -346,7 +346,6 @@ int liveupdate_register_flb(struct liveupdate_file_hand= ler *fh, struct luo_flb_link *link __free(kfree) =3D NULL; struct liveupdate_flb *gflb; struct luo_flb_link *iter; - int err; =20 if (!liveupdate_enabled()) return -EOPNOTSUPP; @@ -367,22 +366,13 @@ int liveupdate_register_flb(struct liveupdate_file_ha= ndler *fh, if (!link) return -ENOMEM; =20 - /* - * Ensure the system is quiescent (no active sessions). - * This acts as a global lock for registration: no other thread can - * be in this section, and no sessions can be creating/using FDs. - */ - if (!luo_session_quiesce()) - return -EBUSY; - guard(rwsem_write)(&luo_flb_lock); guard(rwsem_write)(&ACCESS_PRIVATE(fh, flb_lock)); =20 /* Check that this FLB is not already linked to this file handler */ - err =3D -EEXIST; list_for_each_entry(iter, flb_list, list) { if (iter->flb =3D=3D flb) - goto err_resume; + return -EEXIST; } =20 /* @@ -390,20 +380,16 @@ int liveupdate_register_flb(struct liveupdate_file_ha= ndler *fh, * is registered */ if (!private->users) { - if (WARN_ON(!list_empty(&private->list))) { - err =3D -EINVAL; - goto err_resume; - } + if (WARN_ON(!list_empty(&private->list))) + return -EINVAL; =20 - if (luo_flb_global.count =3D=3D LUO_FLB_MAX) { - err =3D -ENOSPC; - goto err_resume; - } + if (luo_flb_global.count =3D=3D LUO_FLB_MAX) + return -ENOSPC; =20 /* Check that compatible string is unique in global list */ list_private_for_each_entry(gflb, &luo_flb_global.list, private.list) { if (!strcmp(gflb->compatible, flb->compatible)) - goto err_resume; + return -EEXIST; } =20 list_add_tail(&private->list, &luo_flb_global.list); @@ -414,13 +400,8 @@ int liveupdate_register_flb(struct liveupdate_file_han= dler *fh, private->users++; link->flb =3D flb; list_add_tail(&no_free_ptr(link)->list, flb_list); - luo_session_resume(); =20 return 0; - -err_resume: - luo_session_resume(); - return err; } =20 /** diff --git a/kernel/liveupdate/luo_internal.h b/kernel/liveupdate/luo_inter= nal.h index 8083d8739b09..ec949f91c8c1 100644 --- a/kernel/liveupdate/luo_internal.h +++ b/kernel/liveupdate/luo_internal.h @@ -83,8 +83,6 @@ int __init luo_session_setup_outgoing(void *fdt); int __init luo_session_setup_incoming(void *fdt); int luo_session_serialize(void); int luo_session_deserialize(void); -bool luo_session_quiesce(void); -void luo_session_resume(void); =20 int luo_preserve_file(struct luo_file_set *file_set, u64 token, int fd); void luo_file_unpreserve_files(struct luo_file_set *file_set); diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_sessio= n.c index 783677295640..067ffb54c36a 100644 --- a/kernel/liveupdate/luo_session.c +++ b/kernel/liveupdate/luo_session.c @@ -600,47 +600,3 @@ int luo_session_serialize(void) =20 return err; } - -/** - * luo_session_quiesce - Ensure no active sessions exist and lock session = lists. - * - * Acquires exclusive write locks on both incoming and outgoing session li= sts. - * It then validates no sessions exist in either list. - * - * This mechanism is used during file handler un/registration to ensure th= at no - * sessions are currently using the handler, and no new sessions can be cr= eated - * while un/registration is in progress. - * - * This prevents registering new handlers while sessions are active or - * while deserialization is in progress. - * - * Return: - * true - System is quiescent (0 sessions) and locked. - * false - Active sessions exist. The locks are released internally. - */ -bool luo_session_quiesce(void) -{ - down_write(&luo_session_global.incoming.rwsem); - down_write(&luo_session_global.outgoing.rwsem); - - if (luo_session_global.incoming.count || - luo_session_global.outgoing.count) { - up_write(&luo_session_global.outgoing.rwsem); - up_write(&luo_session_global.incoming.rwsem); - return false; - } - - return true; -} - -/** - * luo_session_resume - Unlock session lists and resume normal activity. - * - * Releases the exclusive locks acquired by a successful call to - * luo_session_quiesce(). - */ -void luo_session_resume(void) -{ - up_write(&luo_session_global.outgoing.rwsem); - up_write(&luo_session_global.incoming.rwsem); -} --=20 2.53.0.851.ga537e3e6e9-goog