From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795890458; b=KLBLM/n9XSFnKir+B7RLHQUNHcxSDm7LU06Uwg8wh6Pk7l+k7cACEl9GxmCpEoqMJZRX P5Z/leJU0smHbpQH9k8qFg66qDk8ByrDVZX3RzgH5abnkqBXgeuF0ZNlsC0OPXYvTEnt8 5JAvTNngWFq4/I+Y4OotVblPkOIG9ui0XjiwFea5Xl8ix5lW8FrZ3eUhCmZsY5bsYLkX0 U8SF26LRG6RI29mw+bdl4ImYFEewG/kk4+0YQod7FLx+dvyAu4BAPsjDWOSweBcwluWeQ PCfJrx28QdPm/NbdXbV7dJ1wmCVW/p+uVQQ4BMQT1UhQw8bDURCkC5nSe8/bJYz/IOQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795890458; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:Message-ID:In-Reply-To:References:From:Subject:To:Cc: MIME-Version:Content-Type:Content-Disposition:User-Agent; bh=herPMHPokgx3q7klLpgUehruDwzqYgIa/ATg6qpJFmw=; b=HKv3DhzHCz94YsRtlSUdrhjJJSVHK3upgx812H6Pf0ZWB/pkH9rZJjOC5ZUrob8bI1Tv sdPPMmuqtjf+rHaA22HcLtKWviErm7X6hQRTiLRh2AfJQPyvoWKVMJTUaudlnEvzdw7nL Vse5aKfiuI3UJ4xM7kCCtVdGPEcP+RZVHeKotnTnJfbJRVwptj/IvC3v2ZVHRNBizVljY VUE0dH7rM0Zvfoy1pG/2FCb1pnO2cTuGgF7nWPloCF1bszYxoTv17+4Fc/1vFqUwl3m2A bPZ3L0y0XukMRSirsQNtysQNPCVywn5EoUKnyh3x6FlsTCVGyQDIzqybGnCDApfreDg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chrisdown.name; spf=pass smtp.mailfrom=chrisdown.name; dkim=pass header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=gCgQyTR6; arc=none smtp.remote-ip=74.125.224.43 Received: from mail-yx1-f43.google.com (mail-yx1-f43.google.com [74.125.224.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F04B4606A684 for ; Sat, 28 Nov 2026 18:27:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F04B4606A684 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=gCgQyTR6 Received: by mail-yx1-f43.google.com with SMTP id 956f58d0204a3-677d35fd1d2so9246798d50.1 for ; Sat, 28 Nov 2026 10:27:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1795890456; x=1796495256; darn=vger.kernel.org; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:references:in-reply-to:message-id:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=herPMHPokgx3q7klLpgUehruDwzqYgIa/ATg6qpJFmw=; b=gCgQyTR6dymSBDJRNM68W3cC7kXangemHSHvErQL4AjEBXUtQXQSWIni6rnvqfHf2G 9Fg2MiBsvsz522bBrOriztf2wXov7PSBgHBorVhbYRIieL/8eRI+qqssj9rpS11NKUaU S1XE5RWLm+qetLk/fNaNXX47S7OypfaHOWALU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795890456; x=1796495256; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:references:in-reply-to:message-id:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=herPMHPokgx3q7klLpgUehruDwzqYgIa/ATg6qpJFmw=; b=Df7e0dYGHdOd1GBXR+0hbpy4AjtBPQ8A9ISoBGq5dr1vDk4mk961v/LZAFaeDmkSgZ sqbNrxR4CjSgWVlEXBo6Z+8p00xXtsVnDQ8xH7dSmzth3NETHEHo6gSUBttzhR4tK4Tv wIuEyqIKuVIbkOd9N7HETT5RIo7h+KeA5kWUW47wE4EzBc1hUU4K5JjptUlypFwmXdui 6ka7LErsZ54sfo+ftCFku4gdig1efcWkugWATiAkZnwCqjeE+SsUPaAKS1P2AQ77yfCR WTYuIYT6VugFTJuyy4PhTzZWkRvGDPYOu63dlasrUhEUn+5Lo03Pp2GIyvFDfvRtqr63 kvkQ== X-Forwarded-Encrypted: i=1; AL+hErHrhNDg/MGFOTOvlHRk4WS0/XTEae6HVmY5HKPAhthHoG4q3xR4d55pd/uHbmMKwyFK2XExyFDoJSSdXcM=@vger.kernel.org X-Gm-Message-State: APuU4Z/s/ZK5DLbCtGb1VSrYAG4rdxaMbHEi/HPPVOO6+tizAHO7pIQH Pfzqwckm9TYV50q1MpACiFO2nBSfX/UhM9j3hP+pCek5EhmajtBjo3OvD/VxryC8WDQ= X-Gm-Gg: AZFdTZc4SEhwUq/HY1i+7HpzDyU0RiccS7Fc/gcXXLsa2bukKDa8EX0i+ckeNcKQDBx qW+XC8PYWkomg8W5TdCQrPFfd6wJ3AdivOOJsIcQY8UdFaFNsB24wpVRrssduw7tlz5jr+ZPqck ThhSbnhv+FX7o9zv0iKejkxqpQZwj7u2wu5TUafT90/eT5tk+b8ETQgSEkxnEhsjqqOyV9SsDlV 1Xy0JKFaanuqOYm2f3wsU35StbtEBI5V7PDFyIUOPeTz6BGSjRYptxYfTcK6egCMQ5P0Sype025 rA9M02oY3+JLbW111k5TVbPzJSGPOS8lvU+ay+GYcyKjdyjWG7rbDI8FGLKBXDAJIC+WqDem4il 2Z9ueYm164pTr0nWOeW0bCZe1zB2TfvTyDOX5cjatmWLxmWr06TsIJPtj/OIQ62sTHuuvgGdq3h yQ2FsPeOrroc+usn+DoXfR6qBMNW1BR1YiZtItBjQJoaAwGvKLbGygnvToL/6q77RxMlDVHvR+H ySr7RlCH/wbVcXemfqYcQhmUfsLbfXbtAMbBBbdMedfAJYHo08mUBLTZOnpHAQAcAnU5xe5Rkwv FTR22wW/Z5N7qoSdZPzGJPCsU1wUMl53J9mJBkk4avfFrp0aaQgYBECBfdh00xRZAhAlMhA69D3 1Te6rwt1oIZEYzFi71mv7BBr0YaHZyW7k8bHMsE/mtO654qWNNZLdJjgTPpcCIOY0bN6ZJKCpab +AV/g80trOv5X7Zu9c1cLDA6ee/iI1QVrrCj/Fy7fWaOZAAbmw8jm7py7us+Ox2eFXn0/LgcOBC o7h1G0yAOVFNU/uRwyKL50= X-Received: by 2002:a05:690e:438d:b0:67d:a676:262c with SMTP id 956f58d0204a3-67df45165b1mr5810763d50.98.1795890456040; Sat, 28 Nov 2026 10:27:36 -0800 (PST) Received: from [172.20.0.3] (c-73-207-185-9.hsd1.ga.comcast.net. [73.207.185.9]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67df330acc4sm12841529d50.4.2026.11.28.10.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 10:27:34 -0800 (PST) Date: Sat, 28 Nov 2026 10:27:33 -0800 Message-ID: <796edd4ceaa5cf5a28403dab816c04c47754c4df.1795857773.git.chris@chrisdown.name> In-Reply-To: References: From: Chris Down Subject: [PATCH v2 2/7] liveupdate: Make failed retrieves distinguishable from dropped files To: Pasha Tatashin , Mike Rapoport , Pratyush Yadav Cc: Alexander Graf , Baoquan He , Jonathan Corbet , Shuah Khan , kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-team@meta.com, Breno Leitao , sashiko-bot@kernel.org X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/2.4.3 (cc9e3943) (2026-10-09) At Meta, we want to use live update to upgrade hypervisors in place and preserve service fd stores across systemctl kexec. Our kernel rollout stops automatically when host health checks fail. We need it to stop if the new kernel can't give back state that a VMM or service handed over. We also want to track files that userspace never asks for. Today the process that tries a retrieve sees its error, but a fleet collector can't see that error or tell whether a session went unclaimed. Opening /dev/liveupdate to check would itself trigger deserialisation on the first open and can get in the way of the real restorer because the device is exclusive-open. The collector polls procfs and sysfs, so it needs a result it can read after the event. Let's expose the incoming deserialisation state and aggregate session and file counts under /sys/class/misc/liveupdate/incoming/. A collector can stop the rollout on state=failed or files_failed > 0, and track files that were dropped or are still held. The session owner already knows which VM or service it belongs to, so there is no need to expose session names. Signed-off-by: Chris Down --- .../ABI/testing/sysfs-class-misc-liveupdate | 44 ++++++++++++++++ Documentation/userspace-api/liveupdate.rst | 7 +++ MAINTAINERS | 1 + kernel/liveupdate/luo_core.c | 50 +++++++++++++++++++ kernel/liveupdate/luo_file.c | 16 +++++- kernel/liveupdate/luo_internal.h | 34 +++++++++++++ kernel/liveupdate/luo_session.c | 6 +++ 7 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-class-misc-liveupdate diff --git a/Documentation/ABI/testing/sysfs-class-misc-liveupdate b/Documentation/ABI/testing/sysfs-class-misc-liveupdate new file mode 100644 index 000000000000..25e3b49d7aeb --- /dev/null +++ b/Documentation/ABI/testing/sysfs-class-misc-liveupdate @@ -0,0 +1,44 @@ +What: /sys/class/misc/liveupdate/incoming/ +Date: Nov 2026 +Contact: kexec@lists.infradead.org +Description: + Incoming Live Update Orchestrator (LUO) state and counters. + Present when live update is enabled. Each attribute is read + independently. +Users: system monitoring + +What: /sys/class/misc/liveupdate/incoming/state +Date: Nov 2026 +Contact: kexec@lists.infradead.org +Description: read only + Status of incoming LUO sessions: + + "none" No sessions were handed over. + "pending" Deserialization has not finished. It + starts on the first open of /dev/liveupdate. + "deserialized" The sessions can be retrieved. + "failed" Deserialization failed. Opening + /dev/liveupdate returns -EIO. +Users: system monitoring + +What: /sys/class/misc/liveupdate/incoming/sessions +What: /sys/class/misc/liveupdate/incoming/files +Date: Nov 2026 +Contact: kexec@lists.infradead.org +Description: read only + Number of sessions deserialized and number of files in + those sessions, respectively. Counts can be partial while + state is "pending" or after it changes to "failed". +Users: system monitoring + +What: /sys/class/misc/liveupdate/incoming/files_retrieved +What: /sys/class/misc/liveupdate/incoming/files_failed +What: /sys/class/misc/liveupdate/incoming/files_dropped +Date: Nov 2026 +Contact: kexec@lists.infradead.org +Description: read only + Number of successful retrieves, permanent retrieve failures, + and files discarded at session finish without a recorded + retrieve outcome, respectively. Retrieves and failures are + counted when they occur. +Users: system monitoring diff --git a/Documentation/userspace-api/liveupdate.rst b/Documentation/userspace-api/liveupdate.rst index cdd74627ab75..39bbb91d0dd4 100644 --- a/Documentation/userspace-api/liveupdate.rst +++ b/Documentation/userspace-api/liveupdate.rst @@ -45,6 +45,13 @@ For details, see: - `sd_pid_notify_with_fds(3) `_ +Monitoring +========== + +Read ``/sys/class/misc/liveupdate/incoming/`` to monitor incoming +sessions and file retrievals without opening ``/dev/liveupdate``. +See Documentation/ABI/testing/sysfs-class-misc-liveupdate for the sysfs ABI. + See Also ======== diff --git a/MAINTAINERS b/MAINTAINERS index a946fbbd74f0..5c74e7dfcdc0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15524,6 +15524,7 @@ L: kexec@lists.infradead.org L: linux-kernel@vger.kernel.org S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux.git +F: Documentation/ABI/testing/sysfs-class-misc-liveupdate F: Documentation/core-api/liveupdate.rst F: Documentation/mm/memfd_preservation.rst F: Documentation/userspace-api/liveupdate.rst diff --git a/kernel/liveupdate/luo_core.c b/kernel/liveupdate/luo_core.c index 1b2bda22902d..ba174e9aae03 100644 --- a/kernel/liveupdate/luo_core.c +++ b/kernel/liveupdate/luo_core.c @@ -75,6 +75,8 @@ static struct { */ DECLARE_RWSEM(luo_register_rwlock); +struct luo_incoming_stats luo_incoming_stats; + static int __init early_liveupdate_param(char *buf) { return kstrtobool(buf, &luo_global.enabled); @@ -423,11 +425,59 @@ static const struct file_operations luo_fops = { .unlocked_ioctl = luo_ioctl, }; +static const char * const luo_incoming_state_names[] = { + [LUO_INCOMING_NONE] = "none", + [LUO_INCOMING_PENDING] = "pending", + [LUO_INCOMING_DESERIALIZED] = "deserialized", + [LUO_INCOMING_FAILED] = "failed", +}; + +static ssize_t state_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + enum luo_incoming_state state = READ_ONCE(luo_incoming_stats.state); + + return sysfs_emit(buf, "%s\n", luo_incoming_state_names[state]); +} +static DEVICE_ATTR_RO(state); + +#define LUO_INCOMING_ATTR_RO(_name) \ +static ssize_t _name##_show(struct device *dev, \ + struct device_attribute *attr, char *buf) \ +{ \ + return sysfs_emit(buf, "%ld\n", \ + atomic_long_read(&luo_incoming_stats._name)); \ +} \ +static DEVICE_ATTR_RO(_name) + +LUO_INCOMING_ATTR_RO(sessions); +LUO_INCOMING_ATTR_RO(files); +LUO_INCOMING_ATTR_RO(files_retrieved); +LUO_INCOMING_ATTR_RO(files_failed); +LUO_INCOMING_ATTR_RO(files_dropped); + +static struct attribute *luo_incoming_attrs[] = { + &dev_attr_state.attr, + &dev_attr_sessions.attr, + &dev_attr_files.attr, + &dev_attr_files_retrieved.attr, + &dev_attr_files_failed.attr, + &dev_attr_files_dropped.attr, + NULL +}; + +static const struct attribute_group luo_incoming_group = { + .name = "incoming", + .attrs = luo_incoming_attrs, +}; +__ATTRIBUTE_GROUPS(luo_incoming); + static struct luo_device_state luo_dev = { .miscdev = { .minor = MISC_DYNAMIC_MINOR, .name = "liveupdate", .fops = &luo_fops, + .groups = luo_incoming_groups, }, .in_use = ATOMIC_INIT(0), }; diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index 9bda37b0dc4f..f8eee426d0bc 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -545,6 +545,16 @@ void luo_file_unfreeze(struct luo_file_set *file_set, memset(file_set_ser, 0, sizeof(*file_set_ser)); } +/* Record the first retrieve result. A negative status is permanent. */ +static void luo_file_set_retrieve_status(struct luo_file *luo_file, int status) +{ + luo_file->retrieve_status = status; + if (status > 0) + atomic_long_inc(&luo_incoming_stats.files_retrieved); + else + atomic_long_inc(&luo_incoming_stats.files_failed); +} + /** * luo_retrieve_file - Restores a preserved file from a file_set by its token. * @file_set: The file_set from which to retrieve the file. @@ -613,7 +623,7 @@ int luo_retrieve_file(struct luo_file_set *file_set, u64 token, err = luo_file->fh->ops->retrieve(&args); if (err) { /* Keep the error code for later use. */ - luo_file->retrieve_status = err; + luo_file_set_retrieve_status(luo_file, err); return err; } @@ -627,7 +637,7 @@ int luo_retrieve_file(struct luo_file_set *file_set, u64 token, luo_file->file, GFP_KERNEL)); *filep = luo_file->file; - luo_file->retrieve_status = 1; + luo_file_set_retrieve_status(luo_file, 1); return 0; } @@ -724,6 +734,8 @@ int luo_file_finish(struct luo_file_set *file_set) struct luo_file, list); luo_file_finish_one(file_set, luo_file); + if (!luo_file->retrieve_status) + atomic_long_inc(&luo_incoming_stats.files_dropped); if (luo_file->file) { xa_erase(&luo_preserved_files, diff --git a/kernel/liveupdate/luo_internal.h b/kernel/liveupdate/luo_internal.h index dac6644bfb18..504963fc9898 100644 --- a/kernel/liveupdate/luo_internal.h +++ b/kernel/liveupdate/luo_internal.h @@ -77,6 +77,40 @@ struct luo_session { extern struct rw_semaphore luo_register_rwlock; +/** + * enum luo_incoming_state - Deserialization state of incoming sessions + * @LUO_INCOMING_NONE: No incoming sessions. + * @LUO_INCOMING_PENDING: Deserialization has not finished. + * @LUO_INCOMING_DESERIALIZED: Sessions are ready to retrieve. + * @LUO_INCOMING_FAILED: Deserialization failed. + */ +enum luo_incoming_state { + LUO_INCOMING_NONE, + LUO_INCOMING_PENDING, + LUO_INCOMING_DESERIALIZED, + LUO_INCOMING_FAILED, +}; + +/** + * struct luo_incoming_stats - Incoming session and file counters + * @state: Deserialization state. + * @sessions: Sessions deserialized. + * @files: Files in deserialized sessions. + * @files_retrieved: Files retrieved. + * @files_failed: Permanent retrieve failures. + * @files_dropped: Files discarded without a retrieve outcome. + */ +struct luo_incoming_stats { + enum luo_incoming_state state; + atomic_long_t sessions; + atomic_long_t files; + atomic_long_t files_retrieved; + atomic_long_t files_failed; + atomic_long_t files_dropped; +}; + +extern struct luo_incoming_stats luo_incoming_stats; + static inline struct liveupdate_session *luo_session_from_file_set(struct luo_file_set *file_set) { struct luo_session *session; diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_session.c index f1b86f701238..88959cc5bb8b 100644 --- a/kernel/liveupdate/luo_session.c +++ b/kernel/liveupdate/luo_session.c @@ -547,6 +547,7 @@ int __init luo_session_setup_incoming(u64 sessions_pa) return err; sh->active = true; + luo_incoming_stats.state = LUO_INCOMING_PENDING; return 0; } @@ -581,6 +582,9 @@ static int luo_session_deserialize_one(struct luo_session_header *sh, return err; } + atomic_long_inc(&luo_incoming_stats.sessions); + atomic_long_add(session->file_set.count, &luo_incoming_stats.files); + return 0; } @@ -624,12 +628,14 @@ int luo_session_deserialize(void) } kho_block_set_destroy(&sh->block_set); + WRITE_ONCE(luo_incoming_stats.state, LUO_INCOMING_DESERIALIZED); return 0; save_err: kho_block_set_destroy(&sh->block_set); saved_err = err; + WRITE_ONCE(luo_incoming_stats.state, LUO_INCOMING_FAILED); return err; } -- 2.56.1