From nobody Thu Apr 2 18:49:25 2026 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (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 ACA7B372ECB for ; Fri, 27 Mar 2026 03:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582430; cv=none; b=LcZ21Y1DB9FKDzwWRORtRpob6TAeC/aN8C1axRYeID08jD3juRViftIHAH07B9TPns598k0/jqwVtF+iD7OglpsP9G1PiYRGTyoOdz2e3827uzlvlIEkfIjMT+e/fbKPtBHC1fOJagnKpdCwZXs8H19xrWaU46ctxDuIJfF9ShU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582430; c=relaxed/simple; bh=WcC2Hz9QVrMKjrTl+widwmdAWiHB/PEv+vASN7Q3Lwc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dK5Yv82bdVtiZH6upZDbLvaiZF3u9Czf8fCi0IzSP9Sv6PL1myBxsK6deed99JNVqUg2sYsDWT68bhUNgCxsrVjm13mxjw7eo5py7585TsAa/jDjs+ftNgflR0y2krpWEHDJN/Q+Obx4agFu7veTE7SFS7pFmtky5nFVQQhslGw= 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=JL0trVau; arc=none smtp.client-ip=209.85.219.42 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="JL0trVau" Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-89a000f5adeso24218866d6.3 for ; Thu, 26 Mar 2026 20:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582428; x=1775187228; 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=aADyeHO5XJu6ZrJPxM1LwlVH9QhmzTzIomzhTiemGHY=; b=JL0trVauCMkLusvwvcHJQqpdO/K1BXY29zRZq6SXu9PsSB1/fPOXUa5b4yTJTXhOrr 7kaDrtYOzotE2MRsTYPu+Ltw593ApkytH+oliKaoFgg2Esb+yCCzV3cBrEyUGxi5Rpb8 uzrSCJR03icO6AGu2rGrcUUgamflADG8sATbx+f2QDG595ar49LzbeLMOKsGDrGkQ/pf oWif9ShKKRVUXxSKcYuabVFKb5ghMa6cw32o/fORBSBfoylgjVmvbBYN2zcT1dpuDwpk AzZE5oJriUroR0cjU+akSET/vWAkdYi+2nJ8A1lwFbXR5IK3hQeAG4qIpeaa7TQMLw1K rovA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582428; x=1775187228; 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=aADyeHO5XJu6ZrJPxM1LwlVH9QhmzTzIomzhTiemGHY=; b=TDyJ0t5LmsPpheL/lPMlAu6NT1tLKVbykK6A8le8yrLr7+qhT3OpNbYp5NXeaCvzkV K6qwMI2h4dveUpDP8v5hOq3qow4TE3idTGyvd9CwrEvEQv5Jc0hLzCqB3OdQHKqOc+Wt zGbuR2ffFFWpYok5EXt4UDYO9bT0vS4gQNFgEyuZXwynF6chRdkR1JJDS2f23P10DcJb lGVibzki4X9otpTcYjh/0mXSWetklXeruWaAhSHTUzFD+1RH1zrqqO988z+q44/fM7ez FRuOx8iqz1px3qZMfInK0u1q7bYwsmx2eJWjQyBh678GHNGmeGpCXzum+nLbK6AwfxWZ glyA== X-Forwarded-Encrypted: i=1; AJvYcCVjngUZ/v6InW8xc81BCzggDZNSCCHqM7dsldxJk3erxciJkOwDo6u0OWNGmxeKz10MmZUw795JwYLCLok=@vger.kernel.org X-Gm-Message-State: AOJu0YycqjmMVgfGh8QTiMpBL8vncbSGIvgpt7QTTl8RkXcHRQjT+aOM NCkWolhbPodPHcJnzB1vTDBacLBOscCoMfA30Aay6xAP/BFzj2047YkDraxCB4rHNWU= X-Gm-Gg: ATEYQzznoUNaZhopWzj8xeLlYkk9+BTczgqZTpwX9kIp4emet4B/Ai6uaWlIE/QaZgw SRqPC/bzvFTAadsxG8JVuwia5POATloBuYtXevRekWTMgjrdmW+zd4SYgXEfgAN/BiFCnCgVsOE sF0TfjvhpQTzmshpLmUi5IrQcGDzgkukinkf9KFrbi2HWLq+gDQF1nGesFZVfQDavzgis4CimKb t9liIKEzIXc1O6hvDrkWS55z753XKXV7fXH42ec3MFUTK5qXKqt+p3ck/mo4OGFY9GIYdJx8H65 wXAlMTlZXksIgMWSSaPPrUBDxFkN5WHGRqLq5gE4L1dNasSWLvMpz0vnUbWVcB5lqhYsGm215Pm /UjKCCHUlW6dhB39hp9/vWRFDxy8yIKGCmf7GD+I6yYs6nHv285eybyiK3E02xAAq48AXXGWsjr e9xnIXls9YURnnIB1fwbEMR10hRAd9mrTAFx9lg9Qejc0YYQN4rwgP9oicSyqn0Jw6UQ== X-Received: by 2002:a05:6214:4842:b0:89c:c685:f52d with SMTP id 6a1803df08f44-89ce8d2fb33mr10795416d6.15.1774582427783; Thu, 26 Mar 2026 20:33:47 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89cd5a22711sm46519186d6.27.2026.03.26.20.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:47 -0700 (PDT) From: Pasha Tatashin To: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: [PATCH v3 10/10] liveupdate: Defer file handler module refcounting to active sessions Date: Fri, 27 Mar 2026 03:33:34 +0000 Message-ID: <20260327033335.696621-11-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327033335.696621-1-pasha.tatashin@soleen.com> References: <20260327033335.696621-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 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index 761e8f7cfc82..619465358798 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -280,7 +280,8 @@ int luo_preserve_file(struct luo_file_set *file_set, u6= 4 token, int fd) down_read(&luo_register_rwlock); 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; break; } } @@ -292,7 +293,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) { @@ -322,6 +323,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: @@ -364,6 +367,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--; @@ -648,6 +652,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 /** @@ -782,7 +787,8 @@ int luo_file_deserialize(struct luo_file_set *file_set, down_read(&luo_register_rwlock); 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 +802,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; @@ -858,12 +866,6 @@ int liveupdate_register_file_handler(struct liveupdate= _file_handler *fh) } } =20 - /* Pin the module implementing the handler */ - if (!try_module_get(fh->ops->owner)) { - err =3D -EAGAIN; - goto err_unlock; - } - 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); @@ -893,6 +895,4 @@ void liveupdate_unregister_file_handler(struct liveupda= te_file_handler *fh) guard(rwsem_write)(&luo_register_rwlock); luo_flb_unregister_all(fh); list_del(&ACCESS_PRIVATE(fh, list)); - - module_put(fh->ops->owner); } --=20 2.43.0