Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752182AbbBKKzK (ORCPT ); Wed, 11 Feb 2015 05:55:10 -0500 Received: from mail-wg0-f53.google.com ([74.125.82.53]:35985 "EHLO mail-wg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751418AbbBKKzI (ORCPT ); Wed, 11 Feb 2015 05:55:08 -0500 Message-ID: <54DB3509.5040300@suse.cz> Date: Wed, 11 Feb 2015 11:55:05 +0100 From: Jiri Slaby User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Josh Poimboeuf CC: Seth Jennings , Jiri Kosina , Vojtech Pavlik , Masami Hiramatsu , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 8/9] livepatch: allow patch modules to be removed References: <5a1f98566264a40895704d553e9acf8cfda0659c.1423499826.git.jpoimboe@redhat.com> <54DA55CA.3080408@suse.cz> <20150210195706.GB1118@treble.redhat.com> In-Reply-To: <20150210195706.GB1118@treble.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2013 Lines: 50 On 02/10/2015, 08:57 PM, Josh Poimboeuf wrote: > On Tue, Feb 10, 2015 at 08:02:34PM +0100, Jiri Slaby wrote: >> On 02/09/2015, 06:31 PM, Josh Poimboeuf wrote: >>> --- a/kernel/livepatch/core.c >>> +++ b/kernel/livepatch/core.c >> ... >>> @@ -497,10 +500,6 @@ static struct attribute *klp_patch_attrs[] = { >>> >>> static void klp_kobj_release_patch(struct kobject *kobj) >>> { >>> - /* >>> - * Once we have a consistency model we'll need to module_put() the >>> - * patch module here. See klp_register_patch() for more details. >>> - */ >> >> I deliberately let you write the note in there :). What happens when I >> leave some attribute in /sys open and you remove the module in the meantime? > > You're right, as was I the first time :-) > > The only problem is that it would be nice if we could call > klp_unregister_patch() from the patch module's exit function, so that > doing an rmmod on the patch module unregisters it. But if we put > module_put() in the patch release function, then we have a circular > dependency and we could never rmmod it. > > How about instead we do a klp_is_patch_registered() at the beginning of > all the attribute accessor functions? It's kind of ugly, but I can't > think of a better idea at the moment. Ugh, no :). You even have the kobject proper in the module which would be gone. However we can take inspiration in kgraft. I introduced a completion there and wait for it in rmmod. This completion is made complete in kobject's release. See: https://git.kernel.org/cgit/linux/kernel/git/jirislaby/kgraft.git/tree/kernel/kgraft_files.c?h=kgraft#n30 https://git.kernel.org/cgit/linux/kernel/git/jirislaby/kgraft.git/tree/kernel/kgraft_files.c?h=kgraft#n138 This should IMO work here too. regards, -- js suse labs -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/