From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DC87C5B543 for ; Sun, 8 Jun 2025 00:04:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 784F56B0088; Sat, 7 Jun 2025 20:04:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 735986B0089; Sat, 7 Jun 2025 20:04:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6245B6B008A; Sat, 7 Jun 2025 20:04:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 436266B0088 for ; Sat, 7 Jun 2025 20:04:42 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B90591CF65F for ; Sun, 8 Jun 2025 00:04:41 +0000 (UTC) X-FDA: 83530287162.18.D7808BF Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) by imf05.hostedemail.com (Postfix) with ESMTP id E19E1100002 for ; Sun, 8 Jun 2025 00:04:39 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=a5jAKjI2; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf05.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.175 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749341079; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zp/D6Nx8BfMiScISjeIblyGMtACHkzJtCPjT0UaHWyY=; b=To245utMJGPuP4NP8IxufPHEiUzGbqGmhkUFU6BxZ1pEowulRpufZQmA74VdBhRKZ4Ey4c uXTJPPvF9IB7/TLwmN6FezDXP4oKzcRTxegK9bZfigbvmfEGqeir8+vb9G2EY+1wLkTv+x vZaG2fCLMNVTswqWvwAFS1mhbPDp2UE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=a5jAKjI2; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf05.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.175 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749341080; a=rsa-sha256; cv=none; b=tnwQJBlBKzbcXuGp7I2V0ovP6gRVToZYzPlZrnp8KNxmAmI47CB0Pg0yTdnWvjK2LghlVM HBztgak5vsLt1h1dzLeTtNX6N2p1mrD8uBueG1dVOLgcB526w0L+g0ntf8cHQo5okaJFHj FSWa2iNIO/qTd4R3IuRK1yGyind6imY= Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-4a58e0b26c4so51702521cf.3 for ; Sat, 07 Jun 2025 17:04:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1749341079; x=1749945879; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zp/D6Nx8BfMiScISjeIblyGMtACHkzJtCPjT0UaHWyY=; b=a5jAKjI2dvzEp6Za2vzzV4eIaOcND1jTCzX7svWYpl4UftHZ3JTFNwITnQHs3Ehhpb ns7iOx9iLdzb8DiRp7DBihijL2fdF4zJaXhDGN01EO892bR9fDfJZ61tmYFGMIbr9ONc 73VeFUSaNpDtS28q5kOLrsKV8WoZ0KWIHle3nl7gwMhZRcfcXeASDix9nkDzB9f0x/fY FeuSuMYmh9glQkt9I8U5XZ5ERoQ7UiuU2mi3V3jCEV4Hym7A1AoaEtwVQFbcFIwmn1PE ds7ayXy6S8DSGW4myBv49utZj9FOmID5aUk+5g+5+3vuDYwKyIjJtjRAbIobauY68AXR PnCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749341079; x=1749945879; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zp/D6Nx8BfMiScISjeIblyGMtACHkzJtCPjT0UaHWyY=; b=dvisuaNAb0X5KI6xuAOkHASnrH0eFg8r5l8wVmwJw+vibkTJJvyEzgJ4/mSVT8/oR6 R9XDyrEapVrqwLvSEBS5mn3MyM7ao+6iGOSNL4Os9nFA/7t1bVW1BvEPWtC/70OHPfBj gEeew8nbjGd+GAC+9IgkMz4hmInvlqMzFyLgvNyCK2nLtWY89UMxMjDExDrI6BdGtAfw zNKAbqs3txtevK5NTe4N/5Rbj0o3zW8vN11RRhogDro1WuUIQ7yDVIsySBMsLe87ghMv iypBGKRQYToYcdt8EBOf3imEsxaP9S3z1aVtkPgUney+SoVNjQFYHxNyQRvwWN0dVKra YLLw== X-Forwarded-Encrypted: i=1; AJvYcCU62tOPrEc9inL0XH4wOE1Z1JqNF3rSRk5E4/SfFY0Is9FZLF5vYzvB/fSD9F0LDvVh0n+NkUo/FQ==@kvack.org X-Gm-Message-State: AOJu0Yz+G50KudBuxm7tgpAo5FnakphrXRXW5LGUil0WSQW455/Yx9IY jBtbKALCTj5UZba8tFKCU5LvqhAiP6TtatJnh+l/+wgEMlRMMBsJKDAlIWR9iAloFjKEdW2OGVD 65XP8szPIYe0p4cR7RfGrmzCoygO9OFoS1RM1KoWzTQ== X-Gm-Gg: ASbGncseBHDM2+bHHZ8OoHOKf6NWyOTSC1z2BiDHXsaEp7Ye+Ui+pHHcPM0j7pBDWYE LqwTiwdHw9fcxd0aa4fI/I9KTRNhFK8P7kPHVy/BnDghJw9dqtIj9j4rMQ/jgpK/+MKEBYnMD7T /YsO3aOJZTjgXlzHiziC/SY5BUy68MYIII12gQf4qo X-Google-Smtp-Source: AGHT+IEHyFkt2x/bEAiQ5dSYS8a+nTEZ4nXGxUXv1xBh/B/nln1ArBefBSOd6jxdD7aTJ5evdbG2kp9u/gDYdQ8Odpo= X-Received: by 2002:a05:622a:1b0b:b0:4a3:800d:2a9a with SMTP id d75a77b69052e-4a5b9a0498fmr129085641cf.6.1749341078791; Sat, 07 Jun 2025 17:04:38 -0700 (PDT) MIME-Version: 1.0 References: <20250515182322.117840-1-pasha.tatashin@soleen.com> <20250515182322.117840-7-pasha.tatashin@soleen.com> In-Reply-To: From: Pasha Tatashin Date: Sat, 7 Jun 2025 20:04:00 -0400 X-Gm-Features: AX0GCFuiagbyWhs5WKRlcCrzhjgoTlRaZx67U0f0XBer66fayKl3tu7mrARjDcI Message-ID: Subject: Re: [RFC v2 06/16] luo: luo_subsystems: add subsystem registration To: Pratyush Yadav Cc: jasonmiu@google.com, graf@amazon.com, changyuanl@google.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, zhangguopeng@kylinos.cn, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: E19E1100002 X-Stat-Signature: nxo7c9k3c1w9euzyz79iou5eg1w7swac X-Rspam-User: X-HE-Tag: 1749341079-116201 X-HE-Meta: U2FsdGVkX1+xxUgdLpERaKKNC3FV2nU25DS300QC+AnmhgAzaljzO9S1Hub7EiyUFEeorCjXoKW3LdcdP9YJ6XgxSJUgXNYMsPK9bd6jDlNwJ8y3aruxH7v9bjisBRrtyu9cwvG+qgF2+7mjYpCw6hptrBtFE0zP0L1jheamiv2usftU6QLjl45myXRHj5NPGfwgib5LArmOE62LzuPU0r9yQHy02C9JKeKyauCnFLvRyXmrTr1RXmCsNOI3Q1vvDGBwxQU7lmd8pzo6pgAI7oQx3RuL4LBf1sOrTWt6P8IemiFiD+qKszTTP6QqxuNHV0gWUr9UvuXGvp1eL4nT7JbcKZJYxaD9uy7x3Avog1rQkW/WuTuKOIZbOypKHjky+4XeEbV2v1L6jyIjhmaIP7pR5YXoVhWpiV+4+YOPV0eGo9ievlsWuVefHWhGIRnRJc1VdSfg5qghD+C5YOKhkimNbl7tCdQqfMbrkeouIxYQfzzoUNwpg0Q79p+UU/C6uGBY6E9y8lfGQhS3yWjZLuODxU2vuuaMOzT2zRRf0eko1BQzjdAwaRKHwPEUZ8CyKZBDzQaI9czF6tbxuewCGrmA7SwcUA8paNInr9ItmyGmoIQq8cbwt0E8A3oYDdPqjhwJLJEAqoEYwIrqv903lBpzoS7xQYb6D9bFwz3R4scoQ1BZd1ewy4uGm31xwVM7urnPPyIHpWdQuQ8riV2/b7jl2Hvzq1CqfuztMR1olTU8N32jh+ID56OLIX0cQaAghV6qujyu4/SHLjaMw5iNc85WqOl87iV27MxDce9dUhoMgetbkEN3/dsMd4tO0bVwo24M4ZpAeSvMQ4EC1qZW5W7ZL+AWl8eln2mzVXFpRQImKaVHRKBQ7cRPuzJM3J4fMQZj5dlIBswPPY6U6Fr02n397a2UxNSPNPgNrOU6GoDkzOzsUaTkSMFMSpvINTv1ThOERCgmYkBmxS3ddnC jUcwCGOB Cg/9B1cqA1wZurUO/N5B92GvijAKgvAAOEL7wfc7V2NCbUCfLTeU222Za1ytColyB5rA4Li49Gnp5L1mR1Iccs23pB94yY17Nz1eOXmllRiwR+VpMgCI9zSUE8yX1FxaWUZ/uKbmGFW+w/eAQY4+Ir5i4b3tZzUq4XeF/wV+QZs47f2qkEEB/6yowoCYgPt0TBKzIYUZGxDxDrWKsiH1ESHUjXYGHEPD5Y2bYoynKFuwUs6lhzD1ewqdI1mm/v+jM/VTyzZMbaDlqzaEZ8tiJMwGxhth3jzvvvWVJDqsGnPtK8H6Io3s0JYDRWRWyW78+9ySqSGKILiBr5Iqp83HuDn4HrcamzqbxDS6SnRYNQ8ancjmaz4WAGkTQkXtQYQ97HSMy7+Ndjg9bgBLFNvQofjE3h73TxjqWSceaU3rtBIoVNTEHF9iNPPYAnOu/mEu1fQuJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Jun 4, 2025 at 12:30=E2=80=AFPM Pratyush Yadav wrote: > > On Thu, May 15 2025, Pasha Tatashin wrote: > > > Introduce the framework for kernel subsystems (e.g., KVM, IOMMU, device > > drivers) to register with LUO and participate in the live update proces= s > > via callbacks. > > > > Subsystem Registration: > > - Defines struct liveupdate_subsystem in linux/liveupdate.h, > > which subsystems use to provide their name and optional callbacks > > (prepare, freeze, cancel, finish). The callbacks accept > > a u64 *data intended for passing state/handles. > > - Exports liveupdate_register_subsystem() and > > liveupdate_unregister_subsystem() API functions. > > - Adds drivers/misc/liveupdate/luo_subsystems.c to manage a list > > of registered subsystems. > > Registration/unregistration is restricted to > > specific LUO states (NORMAL/UPDATED). > > > > Callback Framework: > > - The main luo_core.c state transition functions > > now delegate to new luo_do_subsystems_*_calls() functions > > defined in luo_subsystems.c. > > - These new functions are intended to iterate through the registered > > subsystems and invoke their corresponding callbacks. > > > > FDT Integration: > > - Adds a /subsystems subnode within the main LUO FDT created in > > luo_core.c. This node has its own compatibility string > > (subsystems-v1). > > - luo_subsystems_fdt_setup() populates this node by adding a > > property for each registered subsystem, using the subsystem's > > name. > > Currently, these properties are initialized with a placeholder > > u64 value (0). > > - luo_subsystems_startup() is called from luo_core.c on boot to > > find and validate the /subsystems node in the FDT received via > > KHO. It panics if the node is missing or incompatible. > > - Adds a stub API function liveupdate_get_subsystem_data() intended > > for subsystems to retrieve their persisted u64 data from the FDT > > in the new kernel. > > > > Signed-off-by: Pasha Tatashin > [...] > > +/** > > + * liveupdate_unregister_subsystem - Unregister a kernel subsystem han= dler from > > + * LUO > > + * @h: Pointer to the same liveupdate_subsystem structure that was use= d during > > + * registration. > > + * > > + * Unregisters a previously registered subsystem handler. Typically ca= lled > > + * during module exit or subsystem teardown. LUO removes the structure= from its > > + * internal list; the caller is responsible for any necessary memory c= leanup > > + * of the structure itself. > > + * > > + * Return: 0 on success, negative error code otherwise. > > + * -EINVAL if h is NULL. > > + * -ENOENT if the specified handler @h is not found in the registratio= n list. > > + * -EBUSY if LUO is not in the NORMAL state. > > + */ > > +int liveupdate_unregister_subsystem(struct liveupdate_subsystem *h) > > +{ > > + struct liveupdate_subsystem *iter; > > + bool found =3D false; > > + int ret =3D 0; > > + > > + luo_state_read_enter(); > > + if (!liveupdate_state_normal() && !liveupdate_state_updated()) { > > + luo_state_read_exit(); > > + return -EBUSY; > > + } > > + > > + mutex_lock(&luo_subsystem_list_mutex); > > + list_for_each_entry(iter, &luo_subsystems_list, list) { > > + if (iter =3D=3D h) { > > + found =3D true; > > Nit: you don't actually need the found variable. You can do the same > check that list_for_each_entry() uses, which is to call > list_entry_is_head(). True, but for readability, 'found' makes more sense here. I do not like using iterator outside of the loop, and also if (list_entry_is_head(iter, &luo_subsystems_list, list) {} harder to understand, and would require a comment, instead of simple: if (found) {} > > > + break; > > + } > > + } > > + > > + if (found) { > > + list_del_init(&h->list); > > + } else { > > + pr_warn("Subsystem handler '%s' not found for unregistrat= ion.\n", > > + h->name); > > + ret =3D -ENOENT; > > + } > > + > > + mutex_unlock(&luo_subsystem_list_mutex); > > + luo_state_read_exit(); > > + > > + return ret; > > +} > > +EXPORT_SYMBOL_GPL(liveupdate_unregister_subsystem); > [...] > > -- > Regards, > Pratyush Yadav