From nobody Thu Apr 2 18:49:26 2026 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.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 35FD536E477 for ; Fri, 27 Mar 2026 03:33:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582424; cv=none; b=jJJTBo524deLpkhsinFUFIVoBBZB3RqCm1nY65Tg0V9ct0CNYIv/BFb1oVuChE3iH09srDD1E6Fa6txW1oj2EXGPQelXT1gS7TwIjlkauo+J3cslN9VohYVJO+ysIN8/Kxo7YMlPJBRnsZwXyYvn9YTp48/+L3I6vzZpHntfWdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582424; c=relaxed/simple; bh=hDYmhOCkLcuzTi8Vf3GuI5IG6D2POfCXw86QraXoLyo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y4lEFZkGSpuJA/r5TldUY/wkblLtecEMnn88bKUOVVJUpO80qweiEhxi8B6Ed/tVCNCCQCmJwTVCQKioJ+ZJWvd0mVQ4JD4lRFzoMq7wp2/yM7Opy28TRxfKQngaEY7DcubPgrn1339CV8tWorUSeTxw0e8/4LScRttH8cmTfAk= 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=JLS+czog; arc=none smtp.client-ip=209.85.222.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="JLS+czog" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-8c6f21c2d81so155604585a.2 for ; Thu, 26 Mar 2026 20:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582422; x=1775187222; 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=6Iybl7pyAga8N/3JgGk4Dm4BTbHSRib3nIqdcUgoEHA=; b=JLS+czogmWBet57oDk0Pkzb5/OR8SSGfLizKTEnYnYaq8tud08a/J1CuOdUHkvDEqW qu1ZDBNQqlG9sXSLIhw+mIYlj/bC7OzmN/E4cKgO47xp3cjYOiBf7o7WeVO7BPljLysC A78Qea4RQg22N9ak7kOTVBtP8x+Nm8VZQr363vv5gqLs+XqDWdl3ktVxFXyrvTffdlLd 6HTxUnEHMO1O7vL34Xz7mZUcGmOxbNPUvBU8rn4J2AY7MYvmu3f/SoWLkNhIhuO91wkZ QekxPIQgdxQkNNnOo2t0w1cISTOa7CtxgUhLzSi/ZrEpONzVd9DAcU80dhWg2cHYfxHw fPCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582422; x=1775187222; 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=6Iybl7pyAga8N/3JgGk4Dm4BTbHSRib3nIqdcUgoEHA=; b=dtWPmXYV+wbycbkuV5nzG8saAPZAwrKUlxSywOqpLGAj3YhrlcrzIDXVh2rxXA3qdo r3ve1/Tsu/ebTEa62Bd2yEAVDPRfeLtR74b+iEkPY5wLcvP4Q1be6PbnbHnDhhgTijA0 LxUgcYF77U1MIAyv2BP3oS0QogcahwVDthOHzSJmYB7k/pwPk63o5GR7XMgIm8U9kDUr UN9oPq/mk67HtJQJsAFuX25sPlFAJqchX80myy320yku4e4GWhxV9qryeKlKfaC5Hc+Z GcImC1gkGW7uTF/oJQE/nqurMPnPqhB/bAwxGB7YOwI5gwKHL17f57zeIBGG627T+b+0 FXMg== X-Forwarded-Encrypted: i=1; AJvYcCVCSGvowZQR70o7phdMBpIh/61tS9thDKzDbP9LrgT82XozBn27WWJlW3pu+sSSDHemLI81ShpngsSIGeI=@vger.kernel.org X-Gm-Message-State: AOJu0YzibEdS6sMRHLWOwWpFnf5WniIw9eRA/LX+gRl2rFP43BhP7YyI guRwauBzjsSiIFrx6JzhyXWW/6LgLXjV1e9lcAm3BtJ4KhQaF/q3XI1a3++4JZJ8nKY= X-Gm-Gg: ATEYQzzxVYOImkniiGoa193Fj5wF9dex3DVPGzckUsh8jgouZST++3ggnahevI/mJ3R /CqGffSK+IIol4umkR0VOTYfpZthR1OIMb8hu/wJo/Mz25qu395Q2/f5/aKvOVfu5PEZ/7XFatx 9BjOjCQW1GL6cocoE8jmhyfMnvflzG40vhkqhFpj0VIoXMhrHg1Pnb6jPHtoyU2CAnwNkixpNIv IJjetsB2tUAqpoXyZjHIPIo0DLlUZtcaaangYUvrTg3gjiQNawGrrajDSTPvU0vlqDqswp9ZHRd RHd0LY8Cc4Cs1vPmbr8OhBuvb6FdIWouphOpv+qZIC1lN8io/U2J3ZnnXoxsxleB/5pHIXiLZ93 fIRIDja/Ts7YAAc+Eg5YHEIJbf8Y3X8ZDsC9fIbVf1nsDzY5ufyLVe17tfrg01EPo+DZvfSaz6z u+ZSOUxpe+/CBzOpFisykJcQRuE2aZ0Fjo0N+qn+IAcRMuZ6F728BPciz+UJqkpuKGqA== X-Received: by 2002:ac8:7d4b:0:b0:509:26f4:64e9 with SMTP id d75a77b69052e-50ba3994b30mr12539711cf.51.1774582422102; Thu, 26 Mar 2026 20:33:42 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:41 -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 05/10] liveupdate: Defer FLB module refcounting to active sessions Date: Fri, 27 Mar 2026 03:33:29 +0000 Message-ID: <20260327033335.696621-6-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 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 Reviewed-by: Pratyush Yadav (Google) Reviewed-by: Samiullah Khawaja --- 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 3c91d0008eb1..ce28ce9b113e 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -115,10 +115,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; } @@ -146,6 +151,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); } } } @@ -181,12 +187,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; @@ -237,6 +248,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); } } } @@ -412,11 +424,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++; } @@ -493,12 +500,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 up_write(&luo_register_rwlock); @@ -527,7 +533,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.43.0