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 E2576C5B543 for ; Wed, 4 Jun 2025 16:30:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DFA16B05B6; Wed, 4 Jun 2025 12:30:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 690086B05B9; Wed, 4 Jun 2025 12:30:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57F666B05B6; Wed, 4 Jun 2025 12:30:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 35BD46B05B3 for ; Wed, 4 Jun 2025 12:30:20 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CC7DDEF01E for ; Wed, 4 Jun 2025 16:30:19 +0000 (UTC) X-FDA: 83518255758.23.0F9295B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 00470C0008 for ; Wed, 4 Jun 2025 16:30:17 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LX3EfVya; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of pratyush@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=pratyush@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749054618; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GbPTqs5Qg/sIhyZ8T6mbeojEuwWpXLCm8VQtuIssIXA=; b=f7x9Oq+wmcZghH/c+V3pj8CIGWxhSAObWVlaSRf6jN0pW674bgrpUV2fpmMM/BkHJONFJL rE/BTzTsJwhyKxAWfD1xt5CoTJQl6Jaq/wbwnE2R4NrEqs3bQl3LdKH9Ky3++sUHzMQqYX DB7Onk/X7xsZ0/XfOPQPSSv4ckKXfL0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749054618; a=rsa-sha256; cv=none; b=jVzzZx41dSeoquEFuRieZunmz7jjO46vMjh/g2k/FU1DVqQUfY1PXYshc08el7vUl6MCzj zNIDOvRsFP770ueUlOk5pUgezzeWa29D08fPfWZAiVbPjzPhVTMtIsP8CVqJSSu9cxT9CJ 968ZerS8JJl2EiKoW9+5RkOY3Mu/i4U= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LX3EfVya; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of pratyush@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=pratyush@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EF1C85C10FB; Wed, 4 Jun 2025 16:27:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98FC8C4CEE4; Wed, 4 Jun 2025 16:30:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749054616; bh=1Dkfld7z7Nz/jU3LSfpdgyvyWJ0WOr284arW7DyFew4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=LX3EfVyaLIfpmPLwRexknSU0TIIK28XO7r0RXp96qDPl8vwqunyVvHzvdu7yKQ/w/ ux+Mpd3pS3CC6t2zHvMRibzNivZNuP5TJWYptRmWPSTeBxaD7cHPImZFtu2ZZbGXUQ 0EXLq3db7FtfNheso90cWfC1hY35rcEoW5/LeDroePH+N5dq3xd9ECyaykBANnnyDX WLSNcAqLWbZmvJwB84YEgvrMjyla9/b59NSKpLiYbDK7mATzwdbyf50lyasPXLGtLn t9SMREzpOgrkiOoXNbjwptAiehjhoFVC7/0suH3ZzB6OM12ZzSizJzetUKFDHT6vNK GX8Vc8AhBn5oA== From: Pratyush Yadav To: Pasha Tatashin Cc: pratyush@kernel.org, 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 Subject: Re: [RFC v2 06/16] luo: luo_subsystems: add subsystem registration In-Reply-To: <20250515182322.117840-7-pasha.tatashin@soleen.com> References: <20250515182322.117840-1-pasha.tatashin@soleen.com> <20250515182322.117840-7-pasha.tatashin@soleen.com> Date: Wed, 04 Jun 2025 18:30:07 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 00470C0008 X-Stat-Signature: exd3km13y83h3by8is1r8uyfbne3ti8b X-Rspam-User: X-HE-Tag: 1749054617-822945 X-HE-Meta: U2FsdGVkX19AA+lRaHoxW3qXvx3qCB8KAA2bq1e8cdSx3aqGBXMOcRkcPgNlZEHIIGm6xBTrUnAG8fzCAyz7F5kto1aVJUqgeEvnuJO9VOAy2NaSDxex6YTjlmHBKCEv+LnaLUSWhQKeBdUyOH65Vs+P7ZoHP2kkxlEvr8lUVxZ0QZyJNbpR7bYduJtp8aEuozVloKTrqiQ5qoBHK+j9NCouxd72SEii4s3dJgw0E0CCBzdPlpelD+R2if8vksIUm7m4hsM6/Lq2vKn5jMNrSd9pzqapWw3kmrnEQOHtaSFhRDMGNMj1IzEV43zwGRe/kbww18B7qvD7SlHWByRkimtwhwOpR8eieacTD8qrPaGw79AC54FcQaosDy6mR+8RA9QFTMDxgpxc6R5Bv5poc1FoWrZuyMCuqwcnkSu/dNgmwfgs/fFZzIw3ePhGznFFZlWQtRrc/SOAm0+3Ule6vWHv56kohZBUDUS0LQLw74p/bpYav2TwryKbHCFKM60Ns7sJ9BrDkKbTPZsYiN1Zc5e4aO+mS3KYP94B+cL891it0630Dcky5x5v74Xz3/NP2LQvKYKIl5sOnzpJp7tqg1S5OT7xoo2FM1/0zUR4umFh2vikDHVopf05atB+4cd30TiUTGCDGzkzsVcRvVXPPQmD0Cfs4oKj8y+iwL9tkxhZNJaBSFxG1g0/d5nDHDSdRXcUPLfHRq+ojPu9GebVvTldrrFfh9OWzKGvPwZwymaLhcUsp2swJnUilt5Rwmhd78ThRQqqYBUoR7SDm0afmEMzqJy4II1AR1vnhjag4LdiQDqm2kz7MtOWiwMoW2fDkCppmCBAahESKSPZGAY+Ux8eOCSM0wektByH06fE2s0TA9IZpXuyoL2HH1sM00dDRI82T3lC1wYpQVHKNhT5xxjtRBkRXLyWH5pSb4XBveYUPaYt1Wd8OnTWn90xR+COISfvDsdh8Vjd59NtJB7 +CX5yqJs epFm2Exqr8XHMl7lkmKCu9UftCPeON+zHp0zRz9ZJIhv12np/93srYtzJcrWv/Hyas3774AVRTZ3r68HHiLLrMuBB7pAmEcC8MTu7FL5ELF3D7hV0xmLbjqhW5b6OZ75+GwJaVLHpWBYVwoD7QK/rhNtmumQoLhOHbo93k6fa42NWmlzbi5D1kBJkgoKxdwzyTzE8Tl/7js9cyb91mcU3fXLwEZIWBIq6cvciiI2Y08Q0sdBmqVHnP4/wG3eRrhZvXMc09pUXkNuFFLz3FICm5wXejNsdJMnycHA95OMdtL+VWqUVwPm6sL78hTyGjP5ExS+IENLTOgkQArXjj3i/NuNiFEwwY6FiCK9X 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 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 process > 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 handler from > + * LUO > + * @h: Pointer to the same liveupdate_subsystem structure that was used during > + * registration. > + * > + * Unregisters a previously registered subsystem handler. Typically called > + * during module exit or subsystem teardown. LUO removes the structure from its > + * internal list; the caller is responsible for any necessary memory cleanup > + * 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 registration list. > + * -EBUSY if LUO is not in the NORMAL state. > + */ > +int liveupdate_unregister_subsystem(struct liveupdate_subsystem *h) > +{ > + struct liveupdate_subsystem *iter; > + bool found = false; > + int ret = 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 == h) { > + found = 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(). > + break; > + } > + } > + > + if (found) { > + list_del_init(&h->list); > + } else { > + pr_warn("Subsystem handler '%s' not found for unregistration.\n", > + h->name); > + ret = -ENOENT; > + } > + > + mutex_unlock(&luo_subsystem_list_mutex); > + luo_state_read_exit(); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(liveupdate_unregister_subsystem); [...] -- Regards, Pratyush Yadav