From nobody Tue Dec 2 00:25:56 2025 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (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 8981732AAB8 for ; Tue, 25 Nov 2025 16:59:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764089975; cv=none; b=NwdtxF6tCUI6Cphogwa1ja6Ib60srX9t5sTU9Tu80tu7jqJFPeVu1lA8C5yrFQiBHVR1bmECw8sSKdP8RRDe/4zWd9PIYcrKOCRo7mtLMsOdmmi1rFGjBjX0d8Jzjd9QPxYOETsk6G8McFBQyZkjlDC0D1hNxE92QSyCyyGgpMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764089975; c=relaxed/simple; bh=Cgp78p6MJr5ikWgAbD441bmUNWaMvB9QxQCFESAbYw0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J/BLN67zJl9LeW61X/3J8lFI7GrUKR2A4/SmNJoV7cSSVfNoaiIkn2HY4kFCTfysd0M7RL5sJfPjB/XAUbqv3vXfV6rJaqmaYtiCqwQzp3ZNpFQWh3IogC5Ph8g14xYxRGUXmipTislG+rKRXAAeUpOORtcE+llri4mfIQbAdVA= 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=RZN45G2w; arc=none smtp.client-ip=209.85.128.180 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="RZN45G2w" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-7895017c722so54441427b3.2 for ; Tue, 25 Nov 2025 08:59:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1764089972; x=1764694772; 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=yx9quZG9gLF2dl0IKuMBsHxvDi//DiVhoRUqED9zxDI=; b=RZN45G2wbDuSV0HRp6JijJQd/3rGnFubrD45DMPC3tre2NkFVEESsBIeAFhFooL0MT o1ZVVNXOb47qOMZc+Exxpti8Ougo1j3zr1hgKEMP5fE/+ToSFLciJxk2z4OWuc1jt09B oZ4VDa7J1t71IiDxa7oDEVPLN+geY+ViV5IL49YQGlJ9FUVIATdKexbFn75GUSHK9Ct/ 91UGUM0Zqq3g7HG1TkhX1AuR8kiMwudG1DND+Au5tYlddVZYpkJdxdyZMG+uo0530UxL BBkekJaVLAr7A5jsJzkB/KoJ9JkBShDkuxmJOSW90kXWPO5h+g6Vu1+Ezmzeexclc8Zc CNfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764089972; x=1764694772; 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=yx9quZG9gLF2dl0IKuMBsHxvDi//DiVhoRUqED9zxDI=; b=WGk4ckFZGYkTD/C1rzuY8fuyKgGGW1P+kCkrRU8U51YW2ZGvoKl1MKg6xIWNSRICU9 BIec/sYGNSQeJnrH9EgfHt1+2XDsqzqZgdAdreZVbId4cYEd9JMA0xYI5okZyQt7t4hT vpaoMbCsX56xT2j+wUnQTvTCVAr3kdTAisYjK5iUr//XLcB4/1E85g+yLKtQcN1YJ/Y1 R6sYYVGCiH2GxA6qNPOgwgzwsSMQuH22BNvrV6CvELxYyDLf+67Z9jrh2slua/Xuwa/s mvYyrQKniFFw/H1/D/t2TKKjX7bA/UBEuaoOgn3pWdlKEF6kNZAkgUmqu4btbHXaQg7N RPZg== X-Forwarded-Encrypted: i=1; AJvYcCXE9xjji8/J1c7YoDrHvpvpwmElMCYu1rqYFH4Xw8ANJOHXOx2aNaD0uXYKLo5F1YwryxdAT3d4A2H8ZAc=@vger.kernel.org X-Gm-Message-State: AOJu0YxrZykPBCE7CV+hFg/XxbY4sTYYa9NtBHe9kbCcolJscQthKSB9 NnrQ6zubPXxmksUxzDpnuaCOqxCTO37xsfXhEAevl5LsfM1x2zh0OcWi5mX1D2OpX+Y= X-Gm-Gg: ASbGncv39SD2A2ISAbbzjzKZXycxFoazokYkwa40qOW6BI07h0KG+H4dYLeieksIYdu kI7LOCvOGrayi+SkKQ02OwDvOAfZfHUqfEsXnBH6pb3/XV6+7S/DInLU9zYPYF92/5JNWJsG54S Zm00SDqXwuje7p5c4S3PexTct1PTOQmcLZTzrb7jmVcYlREYImpp1D3gOQWLBwRXSMCoHYc3MeI CjfCJ+ysrlP9PGLRinDVud88BTEZQNSfVHsNrIMDpx/oc/mC4+E3nlOSrG6ilN319sKg3FMmQ/j MWpE44CbN8F3jwEOOTKp5xdjgPuzhdrw5ct05j+fsDdWiWdNIwdVu6uTkY65YnCJZAKesEdq3Kc ll1N+7+shaIMyvS9wXr1AJGKe8yCCyqzhRlvsGJaAjk+L+W55A99zmBXaPzJSKAkIuKLb9PjoMg IEng9dS6oNrsnRBHANb9OcO87IfIPaRHXStuiWvivOG+L/59QQEEN8JobSpqRpN4C5 X-Google-Smtp-Source: AGHT+IEW6KgCKYwZ7XEqOpbUcHlowFzPqPsBiqMYeBlVaw8DURiXeYQOxuH5IPmz+1TT/Eb1rS/paQ== X-Received: by 2002:a05:690c:338f:b0:788:737:4830 with SMTP id 00721157ae682-78ab6fce723mr28091657b3.66.1764089972519; Tue, 25 Nov 2025 08:59:32 -0800 (PST) Received: from soleen.c.googlers.com.com (182.221.85.34.bc.googleusercontent.com. [34.85.221.182]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78a798a5518sm57284357b3.14.2025.11.25.08.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Nov 2025 08:59:32 -0800 (PST) From: Pasha Tatashin To: pratyush@kernel.org, jasonmiu@google.com, graf@amazon.com, pasha.tatashin@soleen.com, rppt@kernel.org, dmatlack@google.com, rientjes@google.com, corbet@lwn.net, rdunlap@infradead.org, ilpo.jarvinen@linux.intel.com, kanie@linux.alibaba.com, ojeda@kernel.org, aliceryhl@google.com, masahiroy@kernel.org, akpm@linux-foundation.org, tj@kernel.org, yoann.congal@smile.fr, mmaurer@google.com, roman.gushchin@linux.dev, chenridong@huawei.com, axboe@kernel.dk, mark.rutland@arm.com, jannh@google.com, vincent.guittot@linaro.org, hannes@cmpxchg.org, dan.j.williams@intel.com, david@redhat.com, joel.granados@kernel.org, rostedt@goodmis.org, anna.schumaker@oracle.com, song@kernel.org, linux@weissschuh.net, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, gregkh@linuxfoundation.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, rafael@kernel.org, dakr@kernel.org, bartosz.golaszewski@linaro.org, cw00.choi@samsung.com, myungjoo.ham@samsung.com, yesanishhere@gmail.com, Jonathan.Cameron@huawei.com, quic_zijuhu@quicinc.com, aleksander.lobakin@intel.com, ira.weiny@intel.com, andriy.shevchenko@linux.intel.com, leon@kernel.org, lukas@wunner.de, bhelgaas@google.com, wagi@kernel.org, djeffery@redhat.com, stuart.w.hayes@gmail.com, ptyadav@amazon.de, lennart@poettering.net, brauner@kernel.org, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, saeedm@nvidia.com, ajayachandra@nvidia.com, jgg@nvidia.com, parav@nvidia.com, leonro@nvidia.com, witu@nvidia.com, hughd@google.com, skhawaja@google.com, chrisl@kernel.org Subject: [PATCH v8 13/18] liveupdate: luo_file: add private argument to store runtime state Date: Tue, 25 Nov 2025 11:58:43 -0500 Message-ID: <20251125165850.3389713-14-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.52.0.460.gd25c4c69ec-goog In-Reply-To: <20251125165850.3389713-1-pasha.tatashin@soleen.com> References: <20251125165850.3389713-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" From: Pratyush Yadav Currently file handlers only get the serialized_data field to store their state. This field has a pointer to the serialized state of the file, and it becomes a part of LUO file's serialized state. File handlers can also need some runtime state to track information that shouldn't make it in the serialized data. One such example is a vmalloc pointer. While kho_preserve_vmalloc() preserves the memory backing a vmalloc allocation, it does not store the original vmap pointer, since that has no use being passed to the next kernel. The pointer is needed to free the memory in case the file is unpreserved. Provide a private field in struct luo_file and pass it to all the callbacks. The field's can be set by preserve, and must be freed by unpreserve. Signed-off-by: Pratyush Yadav Co-developed-by: Pasha Tatashin Signed-off-by: Pasha Tatashin Reviewed-by: Mike Rapoport (Microsoft) --- include/linux/liveupdate.h | 5 +++++ kernel/liveupdate/luo_file.c | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/liveupdate.h b/include/linux/liveupdate.h index 122ad8f16ff9..a7f6ee5b6771 100644 --- a/include/linux/liveupdate.h +++ b/include/linux/liveupdate.h @@ -27,6 +27,10 @@ struct file; * this to the file being operated on. * @serialized_data: The opaque u64 handle, preserve/prepare/freeze may u= pdate * this field. + * @private_data: Private data for the file used to hold runtime state= that + * is not preserved. Set by the handler's .preserve() + * callback, and must be freed in the handler's + * .unpreserve() callback. * * This structure bundles all parameters for the file operation callbacks. * The 'data' and 'file' fields are used for both input and output. @@ -36,6 +40,7 @@ struct liveupdate_file_op_args { bool retrieved; struct file *file; u64 serialized_data; + void *private_data; }; =20 /** diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index e9727cb1275a..ddff87917b21 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -129,6 +129,10 @@ static LIST_HEAD(luo_file_handler_list); * This handle is passed back to the handler's .freeze(), * .retrieve(), and .finish() callbacks, allowing it to tr= ack * and update its serialized state across phases. + * @private_data: Pointer to the private data for the file used to hold r= untime + * state that is not preserved. Set by the handler's .pres= erve() + * callback, and must be freed in the handler's .unpreserv= e() + * callback. * @retrieved: A flag indicating whether a user/kernel in the new kern= el has * successfully called retrieve() on this file. This preve= nts * multiple retrieval attempts. @@ -155,6 +159,7 @@ struct luo_file { struct liveupdate_file_handler *fh; struct file *file; u64 serialized_data; + void *private_data; bool retrieved; struct mutex mutex; struct list_head list; @@ -298,6 +303,7 @@ int luo_preserve_file(struct luo_file_set *file_set, u6= 4 token, int fd) goto err_kfree; =20 luo_file->serialized_data =3D args.serialized_data; + luo_file->private_data =3D args.private_data; list_add_tail(&luo_file->list, &file_set->files_list); file_set->count++; =20 @@ -344,6 +350,7 @@ void luo_file_unpreserve_files(struct luo_file_set *fil= e_set) args.handler =3D luo_file->fh; args.file =3D luo_file->file; args.serialized_data =3D luo_file->serialized_data; + args.private_data =3D luo_file->private_data; luo_file->fh->ops->unpreserve(&args); =20 list_del(&luo_file->list); @@ -370,6 +377,7 @@ static int luo_file_freeze_one(struct luo_file_set *fil= e_set, args.handler =3D luo_file->fh; args.file =3D luo_file->file; args.serialized_data =3D luo_file->serialized_data; + args.private_data =3D luo_file->private_data; =20 err =3D luo_file->fh->ops->freeze(&args); if (!err) @@ -390,6 +398,7 @@ static void luo_file_unfreeze_one(struct luo_file_set *= file_set, args.handler =3D luo_file->fh; args.file =3D luo_file->file; args.serialized_data =3D luo_file->serialized_data; + args.private_data =3D luo_file->private_data; =20 luo_file->fh->ops->unfreeze(&args); } --=20 2.52.0.460.gd25c4c69ec-goog