Re: [PATCH v6 04/20] liveupdate: luo_session: add sessions support

From: Mike Rapoport
Date: Mon Nov 17 2025 - 16:13:22 EST


On Mon, Nov 17, 2025 at 10:09:28AM -0500, Pasha Tatashin wrote:
>
> > > + }
> > > +
> > > + for (int i = 0; i < sh->header_ser->count; i++) {
> > > + struct luo_session *session;
> > > +
> > > + session = luo_session_alloc(sh->ser[i].name);
> > > + if (IS_ERR(session)) {
> > > + pr_warn("Failed to allocate session [%s] during deserialization %pe\n",
> > > + sh->ser[i].name, session);
> > > + return PTR_ERR(session);
> > > + }
> >
> > The allocated sessions still need to be freed if an insert fails ;-)
>
> No. We have failed to deserialize, so anyways the machine will need to
> be rebooted by the user in order to release the preserved resources.
>
> This is something that Jason Gunthrope also mentioned regarding IOMMU:
> if something is not correct (i.e., if a session cannot finish for some
> reason), don't add complicated "undo" code that cleans up all
> resources. Instead, treat them as a memory leak and allow a reboot to
> perform the cleanup.
>
> While in this particular patch the clean-up looks simple, later in the
> series we are adding file deserialization to each session to this
> function. So, the clean-up will look like this: we would have to free
> the resources for each session we deserialized, and also free the
> resources for files that were deserialized for those sessions, only to
> still boot into a "maintenance" mode where bunch of resources are not
> accessible from which the machine would have to be rebooted to get
> back to a normal state. This code will never be tested, and never be
> used, so let's use reboot to solve this problem, where devices are
> going to be properly reset, and memory is going to be properly freed.

A part of this explanation should be a comment in the code.

--
Sincerely yours,
Mike.