From nobody Tue Apr 7 02:56:17 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