From nobody Mon Apr 6 19:59:50 2026 Received: from mail-yx1-f49.google.com (mail-yx1-f49.google.com [74.125.224.49]) (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 396FF3DBD6D for ; Wed, 18 Mar 2026 14:17:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773843424; cv=none; b=g09borlcg0TLdmvNz1bQ3V6bx5louofCDJkeryYBcIie6HkhQdVQZ7grt+Rcfu+dU8TOXCXSbFILCft53+XRGIWwduamagjLg/CxTDdrYR9y7xKJsF90Ne3xDCd0+D6IhnSztx04e0KKIDKphX2vTiHJ5I12Cp3FX8tPWxMswRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773843424; c=relaxed/simple; bh=iR8I+/StaBXxEZV0NdnOtDjxL5dTWNF5Ps57FdSsCf8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r72LoXG8kGlKy20VryiWZJl9Oku6/22ihxloKEU3odFy9oJd2Pa7EDO6j4f4x6U8vBExWmNFgeQmb3KMV7Ad9HoutkL6usOnNUd2c11aNHGVRjR9ufNSRMepdzqpHzXRbpVMAprJ9dGLE737Gv8aDUIp2ouAlgftEJidr5Ti6vM= 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=PEDVKODJ; arc=none smtp.client-ip=74.125.224.49 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="PEDVKODJ" Received: by mail-yx1-f49.google.com with SMTP id 956f58d0204a3-64ad79dfb7cso7562556d50.2 for ; Wed, 18 Mar 2026 07:17:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1773843421; x=1774448221; 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=r+VqvYB4/DwM+CB2Xe5IvCpNGUCzC20aSBPm99ZSf4E=; b=PEDVKODJxMOzBF1PASES2Z3Ar7l8jPctmuyc4myFzdn/pX9s1WOHplMMN0f/m0yyou yO/gVMu7S4GfDKJYnQpqhT+M20dsUk7JmZqgK46+pVMYjpeXPvowmMDMSuihQ0E4mYux 77kZHB+G+o/iXrv4rIu4qh4HxMNNV4Kg/iFoks0ukVaZzIPVTq64NKz4/kAeaIE05+fV YNlmnA37QqR7mBpVYBrE+DQtz9dnvtTJ/a5yLpT3yDzWzmnvqJM7rPhFbH521OWFuRky z5fbNL3dRJpOjSVUiwDYtCCYfiLqWmI5JPnMMfqpU3wKxmIMyt6GinC/AHXTGj+K93Q/ rEPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773843421; x=1774448221; 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=r+VqvYB4/DwM+CB2Xe5IvCpNGUCzC20aSBPm99ZSf4E=; b=V6uCHHL+u/qg+lfPtm5NRa/JOr66IhAHL3FOzs3JveXYyrbBSw7Xxh4LA4rX9Rmo9f hqqVCPS35HpmNyhDJfMyyx3dKe84MbU+QC+keAqjgqzi/9RsT+Lh129suIX00eYedYD+ G1f7FJIddqPkxF297eoPc61D6BTgKyo73j8P7rkaMqFYqcTZdDw8Mi/r0oO9kEn3cJyp rbT5VZjANbjx6KiPv/iHQTDGKiwpTQ5sRYyAmxxtCqeO0Sve9g+JAKDMbmaKMttnS5g8 ovipL0jUC1w7URUyjLYNYrd805gh9izdwZuvmnoOvXWXYW7Rc+vxc5aif8MqAtZUBdZF 6FtA== X-Forwarded-Encrypted: i=1; AJvYcCUueBxLQGBzgtjjaRmYs3N8SBEQpFmvqmD6z8aTUguxJR2wAiXiFdnEeqinvRMvwhV9RWtWmHtvBJCUvNE=@vger.kernel.org X-Gm-Message-State: AOJu0YwTjoe9wMfg3Q9cZgOSL56Q2yhfu91fRtSnrG2JYIsCYFYVuKan VzqX1Y+ql88/rU2eayvBqcu3N6A/2SpaG6OVBvhVLizdLUUiObkAK2hxXcadckHI99c= X-Gm-Gg: ATEYQzwEm5fXKnGAvOEd2NtKkVnDD2EFJb38wXRYgVAgOXgZnfxx7f7uMBrwG9IkkRu DTiLps2pbqRKX8pLG526zKa5mOh0YAWhga06a9ms7W9b9/d00dkK5FCdBKqw8gQiPpyJnFTsHWe JODZ354mVqCdhMvALwi2omDoRZ2/r5AL7t9f3Ok+9na9rVpcEbqKF/Ai22PMAuvN5YwVv26svor QBeGsc/xl9DZMI/geLh+XYRVc2EZqWWUyM+e1PDlmSU9QTVh4nZA9/eCF8iNuB3mcARWEaAMHex 8LCVP2rwar0Q0e5N+hOhLpoQ3nA6izd12MHzetjCMW40wfcVrDiSMP9Olcal/+SLCTpG66i2oZE EpYyyVJ9bsAZPyIz24Y1E8tuLhz1mrYxAvU3MqRd3WBCSydM/rVTGfLS98x6atjHQjG1TRg5cYS H4w4sAje+qwNQDI8IUYBgEj/PupSz2DRwM1b8FP7y6CHzmsvOkQhEWTaGHqnG8Y5DtwSf0GNWXc NpYnk9MdumnnhDBSlKzmJklRuEqkaatlb455dTCl2Utpo9uuw== X-Received: by 2002:a05:690e:4466:b0:64a:e799:1d92 with SMTP id 956f58d0204a3-64e916017c1mr2847774d50.61.1773843420339; Wed, 18 Mar 2026 07:17: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 956f58d0204a3-64e91be0e91sm1672028d50.15.2026.03.18.07.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2026 07:16:59 -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 Subject: [PATCH v2 4/8] liveupdate: Defer FLB module refcounting to active sessions Date: Wed, 18 Mar 2026 10:16:42 -0400 Message-ID: <20260318141637.1870220-14-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.53.0.851.ga537e3e6e9-goog In-Reply-To: <20260318141637.1870220-10-pasha.tatashin@soleen.com> References: <20260318141637.1870220-10-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3373; i=pasha.tatashin@soleen.com; h=from:subject; bh=iR8I+/StaBXxEZV0NdnOtDjxL5dTWNF5Ps57FdSsCf8=; b=owEBbQKS/ZANAwAKAbt3KEzbc3reAcsmYgBpurPLbaFvSonT8zodhVCWfmkfgUrhZ5neWD5Yl lk0n7d4NhSJAjMEAAEKAB0WIQRBMaqT7LRvGvB/NmK7dyhM23N63gUCabqzywAKCRC7dyhM23N6 3vfYEACHkJvJO9RYAfuX2GirFrKaaIB1vkyXHVlN0h/nFzPddsyK5i19XDsQTcvXCge6ahu3UTH QG8HNKcbZjJvx7aDk7SPLi/2X8jNZInKJMQN7qOQJpByfZlf/7EFZkPHlhYp58nXtiHhatYpfiM 1ijBMgNWE7matlz77/Wtwl9Ui2Nm3W/qO/cGQZlOXcS7bDpvv7eJYvtHKwc45M/SUB8j9ZElMMT kab0YWyftiMI2k5iV53LW1maimBM2EqWBDHHzwEFc/q7lX+2aEuZ4U/6dJgO8PfaB8VEVQS6B+U DUKqln4zzhSZmv5w4h8fYJA1lIsYQ2HW5CexIApQwlwC0bsFY+N+FrkFlzgMHTN+YuHiijvSMyx 1p/1y6B6icDeXAdqL2cOJxfiIlS/QqmyuScGvYXzOTvtEzI5fLc/FVAQCVOA+3WWv+VXPqMik8K yGMGAkGLyLMAVhaU+yPZfmYwVJa+28qAv/mmu6s5VTiqKwENAYH3b/y++dUjr0be30fGrs7Pyt3 RQ6HEVxKRgNN0bK8Odx6Z81L5oYtb9gxXR6ZQiJvvEX9hhDo08K22fuT1fBx75a9C/iYz9ZfV3X TEBKUim3pjj6/SLjNedVct0R0tJsvT0hef9EGDz+wj6t5ceKKI7UTNLu+99dPhkBHwNXdh+n2yn CoT+ZEqbfukS3Rw== X-Developer-Key: i=pasha.tatashin@soleen.com; a=openpgp; fpr=CAAAB722DD22A081F0D49F35633A6A993D43B569 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 | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index 91910d806d1d..98336cd23aa5 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++; } @@ -474,12 +481,11 @@ int liveupdate_unregister_flb(struct liveupdate_file_= handler *fh, private->users--; /* * If this is the last file-handler with which we are registred, remove - * from the global list, and relese module reference. + * from the global list. */ 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