From nobody Mon Apr 6 19:59:51 2026 Received: from mail-yx1-f42.google.com (mail-yx1-f42.google.com [74.125.224.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 A989A3DB65C for ; Wed, 18 Mar 2026 14:17:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773843422; cv=none; b=EqZaMrpjqbz79qyCAf/y5cDDpRnvJNR9vk3J1tHLFpnOyfNCknxhWEnERXY1jY3e4sqmBdK4RgtGVylw9PMXM8mPFhLJf9J6qho1HimQF7m2Wj5PywbIZiV5hYdAxTiMJj/pkUmpThSiJssIXtBzNjeeo4ydZuVHAoDTarimT0c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773843422; c=relaxed/simple; bh=Lffv2DnyZxO5nuM/8hkjo+xgENhHOwSyq1ggm1aLDpg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qFJZ61X0hRN8RhEnjxL9LrZQVIbz3c2dIsPnvUl5gXsc0JW0+TtPQZDHf+iWhk/+zwZz5ZTigyE+Tz+1bXGFh9CjdpnN3/9m4zOjtBOEvmrvjakq/kzWCa9+UabUyn+B6f93oRG3wK+gagwmGUR7Ohxbv6mVp0WR9E6UaVR5aSg= 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=BqljRrfk; arc=none smtp.client-ip=74.125.224.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="BqljRrfk" Received: by mail-yx1-f42.google.com with SMTP id 956f58d0204a3-64e8cdafeffso1474312d50.1 for ; Wed, 18 Mar 2026 07:17:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1773843420; x=1774448220; 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=ubd4lYK9V1coPSt+9iFoac0BiHxALbtZJdQokTSw3pM=; b=BqljRrfkVSRH6TXSDkmKmtdiHkgJy1LYnHcjtVQGonq0BDZHSGQL4jF/K3dfUiq7qC WHeeo1y7tnT+5u2IDFX/EOKFF7vwA82+w9i24PMK7jA/uvtKNlvdNmvetr5q8yxRmqGv +N+k+9+8XVkq9Kgl1a8eW7qeyKeHJUwTm9YDmCbTAfkKSE3Pz4VIGx7yWT+KK0roKlg3 zwiBs+8UAq2EVdFbOIjZkBjK0nCo1k3BpAyJiAMSto2YN+rH+YBbEcALAc3Bb3zIALB8 DKsqEqGyhRgMkuTgLhYLhb7TDfuWE2CKlOEC7DVok6Bjc2zJfAvSm3MQS6MAej9XBbUK Z+wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773843420; x=1774448220; 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=ubd4lYK9V1coPSt+9iFoac0BiHxALbtZJdQokTSw3pM=; b=PCiLteuY/4MZo2gJH10U6VsppPYBCqp1WqWERf5vfEXaqU7HQyD/ofvNQWPe7xw5lF 2z36BdJo+1bKPX58JImoQWZBgwcQ7EhbhQd77j3vzAZkD92TJvn1+GGjTmEaXIIafeYY 0wkPyh1SpsdrN3MBKDHPtMIauswsVrHar8UHgfwYbTUmFP/skHo+9XzCA4UT5TnkuTNV X4ek1kdCpVFsbQK1pPXJR7h5UVX00CblEJTKhn9wai4UKyVnGnYmC2XR397qQFBWzxbH viluqPm+kV2VLaP2CjovCrZxwmVBEbfeqztoQ1qCf5P2OJN4oMYxcakPhhuvhA7TJk93 zt6A== X-Forwarded-Encrypted: i=1; AJvYcCXvNvCVx1tl0nYwQVq11GtD/rk96SforyEFJn/D2T9ulIvpWkzyelSNgczgeUYfUCbRYYYZhL2HrPPyXc8=@vger.kernel.org X-Gm-Message-State: AOJu0YzMvTMGkifi8OkI1O4emimDZEy44ldtpQVgiDYAwUIgbEywxqpJ CKrwbTbyAMndhXzOjpMEMHleDe4S/YpHXgfk13+lSqxE3YLVU41Yn2oB2LIJ+HDwJLo= X-Gm-Gg: ATEYQzzrEIdOJXOY6e9RlIWb4snJv516ly8/MFeuQdvKwIRv0zUL8FaDRVzb3NADnu+ /mYAKXI8WPMixYfFLjKUNdHs6GX8x6xy0BKjZ69sSeVqz+2/N7c+lnZbtAl2Y2wS/m9r63tEdOc N4P7eEZ93yYjC5JX/0J3h1SnLHe5DjCh2qpXgtG0OnkO2fA5RFtncOQA/1vYqfTbfrXhIwOlQb3 Lz52/C3gHZDOR4CTjudRNyDmdFP3s3uFmgm1uyThEuaDUwVUaHQ8a36VpwR1HRUg+FmzPyg6YyU xPLkcPRaQtby8RepCm1mX1oB5p7B5BVlS+jj2sEV04Xyv0EBZUAv9qqbZWjqERiTVdqkPvp0JzZ uPfFPreUEAcC2v2BZwZ9uNmY6NW6F4H1vd5EE/j1PjuFKYnjfFPRiiU+h1jER2YkUAYoStIEtDU Y9QzzjY4/t4XltMLAWagXqHjmSKV07FxHzdx+xzwJiNVRJh+tqE6N5UOgBY7ANMV1M83qqSgIKD vshqa65fVXqdJePN2VVFZfhs0ysA/5Lp8U= X-Received: by 2002:a53:bd0b:0:b0:649:3875:9200 with SMTP id 956f58d0204a3-64e912ecefamr2553595d50.1.1773843419489; Wed, 18 Mar 2026 07:16: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 956f58d0204a3-64e91be0e91sm1672028d50.15.2026.03.18.07.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2026 07:16:58 -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 3/8] liveupdate: Remove file handler module refcounting Date: Wed, 18 Mar 2026 10:16:41 -0400 Message-ID: <20260318141637.1870220-13-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=3314; i=pasha.tatashin@soleen.com; h=from:subject; bh=Lffv2DnyZxO5nuM/8hkjo+xgENhHOwSyq1ggm1aLDpg=; b=owEBbQKS/ZANAwAKAbt3KEzbc3reAcsmYgBpurPKh1r+mZq+VPFRX+zQHHctHNNA9pcYeCPjk 6lF1jfleF2JAjMEAAEKAB0WIQRBMaqT7LRvGvB/NmK7dyhM23N63gUCabqzygAKCRC7dyhM23N6 3lTYEACVTFybupdvgSPfd2fCzSR3N2UrbQXZNHejUkbPthks8joN8TV/SNAo22lQP0aZtDZ4m1t O66zZScB9l1jmnV14XgYXm2Vx/oAhvCSKfuB7ilBXB5bc2hS+uwv/uUsfWYVAeiRsi853EpRU+7 3Ey8yY9NDR9WGk32UF2cDiysYUv+fcNvEi9P+8szI1T/l2IU+kb3l+Jo6Tdm+fxvKEJI0N5QVP4 6RM9u0WgPcVbMV2FvsUr5GxKM/UWYqBRwO0eEt/0VQtXFNLPj3t+nWwi8mI4Z2LRsuF5pM6H4Ce sdS/DygdtovOXW1QHA1K/1ULI+TN1VDBA1XL8AHZFdEmvIByLxYRAkqKGzcN7m3DMemmPn5ryur Kty3b35GCRVri/n9X8zwZd73XmAW6qCFay89lFkZ97O17OiFXr5IDtJS8rZNVxE3TlBF41BtgBu w3HgMpreZVak9Q1OcDQzFqYPaxa9Dx2Yf+sL7ulD6wcDtQhVnu3wI8PbaLJDE8inLs4jLs1iGAK mf0AGRrHmwEIi6ytkimFdbZgC8v+GKMdzcqQ5MCmFbOWrcAeXOel3d0LfxkmsH9Ef1UK86Se0rA Uc3LFyCq4vMH7SbFdGYq5VJHI9vDXz8Jf019zHgQOGh/6h3bs8ASlTHB91fa7XtPuhx411vJfy/ 77L6oexIIBV/uyA== X-Developer-Key: i=pasha.tatashin@soleen.com; a=openpgp; fpr=CAAAB722DD22A081F0D49F35633A6A993D43B569 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" File handlers do not need to pin modules indefinitely or during active live update sessions. The VFS 'struct file' pins the file handler's module via f_op->owner during active sessions, making dynamic reference counting unnecessary for handlers. When a file is preserved, the live update core obtains a 'struct file' via fdget(). As long as the file is kept open within the live update session, the module is pinned by the VFS and cannot be unloaded. Similarly, during deserialization, file handlers are matched based on the compatible string. Because the handler list is protected by luo_file_handler_lock, there is no race that requires dynamic module refcounting. Removing these module references ensures that modules implementing file handlers can be unloaded when no longer providing active files. Suggested-by: David Matlack Signed-off-by: Pasha Tatashin --- kernel/liveupdate/luo_file.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index 96fdd5790dcc..b124fd747841 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -836,7 +836,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; @@ -861,17 +860,11 @@ int liveupdate_register_file_handler(struct liveupdat= e_file_handler *fh) 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; + luo_session_resume(); + return -EEXIST; } } =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_rwsem(&ACCESS_PRIVATE(fh, flb_lock)); INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, list)); @@ -882,10 +875,6 @@ int liveupdate_register_file_handler(struct liveupdate= _file_handler *fh) liveupdate_test_register(fh); =20 return 0; - -err_resume: - luo_session_resume(); - return err; } =20 /** @@ -907,8 +896,6 @@ int liveupdate_register_file_handler(struct liveupdate_= file_handler *fh) */ int liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh) { - int err =3D -EBUSY; - if (!liveupdate_enabled()) return -EOPNOTSUPP; =20 @@ -918,19 +905,18 @@ 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; + if (!list_empty(&ACCESS_PRIVATE(fh, flb_list))) { + luo_session_resume(); + goto err_register; + } =20 list_del(&ACCESS_PRIVATE(fh, list)); } - module_put(fh->ops->owner); luo_session_resume(); =20 return 0; =20 -err_resume: - luo_session_resume(); err_register: liveupdate_test_register(fh); - return err; + return -EBUSY; } --=20 2.53.0.851.ga537e3e6e9-goog