From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2AC739C627 for ; Fri, 3 Apr 2026 10:17:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775211438; cv=none; b=ccu/6A/KAF8esgjyauEKrNJR25ihDQ/K1Aol1+1CRe5eXk6dTy0oRonNlgcpwd9S+6GQl6dMZJpUFIVQnK297NOyJJc3Nt1wBJGLUMrorWGsRfu/kR64zpIxylbkd7hX7EX8F05FCehlSHdgwEuT4mGExit5DvLZmB/REUkNFvE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775211438; c=relaxed/simple; bh=XHL8TaSjsnHgKt+DxB5y+u9IjO2D1o2h4k+YjvwDOp0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=rf/wnA5wuv5achLApbCJ11RILoOnqWdl1Dsbm+zMohFd4nMd6m7CheBQxozb4IzzRNQFB470SOuFBDxZGv0QOrA/XjkMrUTD+DU2ISDOMKkPupO//p4IeFz2CK7iFEw9j7YkX3NcxhJKQfuphDr2KXzug2ReL9AZjROPsezzZzU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=okwIfj4P; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="okwIfj4P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 478FBC4CEF7; Fri, 3 Apr 2026 10:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775211438; bh=XHL8TaSjsnHgKt+DxB5y+u9IjO2D1o2h4k+YjvwDOp0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=okwIfj4PXWp0FtNFyJm/O1vTiBK5ex1H0qxKdjJfCdQ0DzVeAOTgDrFUNmjJue46M 6js9z4Gi942KjxxZSuJ9Q4f21WZiH9CxUp0BIgVOQXvbfQuuzVX2M/HMTwts5lYRs6 EUwQl1dKuj+xxeHpafmXiwprFo2N3mgP0SlRFbNJtmKnWY4BEyvE1SW3xI4QNt+yhn SfzRu3aXhvv8EMuhN12AWhHidZn5I9Q+8rC3SSaA88HYWBdjbumKPwG7YrF/y2aVBY NuF3jWEpTTHkdiLgdo+TyS3TSN561vygzK9LTRYP6Lo71JmWTaj5sSgkmUBHeo6/XG c+70RXX/zDSwQ== From: Pratyush Yadav To: Pasha Tatashin Cc: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: Re: [PATCH v3 07/10] liveupdate: Auto unregister FLBs on file handler unregistration In-Reply-To: <20260327033335.696621-8-pasha.tatashin@soleen.com> (Pasha Tatashin's message of "Fri, 27 Mar 2026 03:33:31 +0000") References: <20260327033335.696621-1-pasha.tatashin@soleen.com> <20260327033335.696621-8-pasha.tatashin@soleen.com> Date: Fri, 03 Apr 2026 10:17:14 +0000 Message-ID: <2vxzika8e4b9.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Fri, Mar 27 2026, Pasha Tatashin wrote: > To ensure that unregistration is always successful and doesn't leave > dangling resources, introduce auto-unregistration of FLBs: when a file > handler is unregistered, all FLBs associated with it are automatically > unregistered. > > Introduce a new helper luo_flb_unregister_all() which unregisters all > FLBs linked to the given file handler. > > Signed-off-by: Pasha Tatashin > --- > kernel/liveupdate/luo_file.c | 14 +----- > kernel/liveupdate/luo_flb.c | 84 ++++++++++++++++++++++---------- > kernel/liveupdate/luo_internal.h | 1 + > 3 files changed, 60 insertions(+), 39 deletions(-) > > diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c > index 439177c10723..80f4e3b796a6 100644 > --- a/kernel/liveupdate/luo_file.c > +++ b/kernel/liveupdate/luo_file.c > @@ -895,26 +895,16 @@ int liveupdate_register_file_handler(struct liveupdate_file_handler *fh) > */ > int liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh) > { > - int err = -EBUSY; > - > if (!liveupdate_enabled()) > return -EOPNOTSUPP; > > liveupdate_test_unregister(fh); > > - down_write(&luo_register_rwlock); > - if (!list_empty(&ACCESS_PRIVATE(fh, flb_list))) > - goto err_unlock; > - > + guard(rwsem_write)(&luo_register_rwlock); > + luo_flb_unregister_all(fh); > list_del(&ACCESS_PRIVATE(fh, list)); > - up_write(&luo_register_rwlock); > > module_put(fh->ops->owner); > > return 0; > - > -err_unlock: > - up_write(&luo_register_rwlock); > - liveupdate_test_register(fh); > - return err; > } > diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c > index ac6fa5b34b43..f8348138de70 100644 > --- a/kernel/liveupdate/luo_flb.c > +++ b/kernel/liveupdate/luo_flb.c > @@ -335,6 +335,62 @@ void luo_flb_file_finish(struct liveupdate_file_handler *fh) > luo_flb_file_finish_one(iter->flb); > } > > +static void luo_flb_unregister_one(struct liveupdate_file_handler *fh, > + struct liveupdate_flb *flb) > +{ > + struct luo_flb_private *private = luo_flb_get_private(flb); > + struct list_head *flb_list = &ACCESS_PRIVATE(fh, flb_list); > + struct luo_flb_link *iter; > + bool found = false; > + > + /* Find and remove the link from the file handler's list */ Nit: it would be nice to have a lockdep_assert_held_write() here to clearly show that the luo_register_rwlock must be held when modifying the list. I know that luo_flb_unregister_all() already has one, but in case we refactor later or add another caller. Other than this, Reviewed-by: Pratyush Yadav (Google) > + list_for_each_entry(iter, flb_list, list) { > + if (iter->flb == flb) { > + list_del(&iter->list); > + kfree(iter); > + found = true; > + break; > + } > + } > + [...] -- Regards, Pratyush Yadav