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 X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_NEOMUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2546C43219 for ; Thu, 2 May 2019 08:51:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 959442089E for ; Thu, 2 May 2019 08:51:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726512AbfEBIv3 (ORCPT ); Thu, 2 May 2019 04:51:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:36198 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726011AbfEBIv2 (ORCPT ); Thu, 2 May 2019 04:51:28 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9339AAF3E; Thu, 2 May 2019 08:51:27 +0000 (UTC) Date: Thu, 2 May 2019 10:51:27 +0200 From: Petr Mladek To: "Tobin C. Harding" Cc: Greg Kroah-Hartman , "Tobin C. Harding" , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , "Rafael J. Wysocki" , Joe Lawrence , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 5/5] livepatch: Do not manually track kobject initialization Message-ID: <20190502085127.5kiuxdey2fmrx4kr@pathway.suse.cz> References: <20190502023142.20139-1-tobin@kernel.org> <20190502023142.20139-6-tobin@kernel.org> <20190502071232.GB16247@kroah.com> <20190502073044.bfzugymrncnaajxe@pathway.suse.cz> <20190502083127.GC18363@eros.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190502083127.GC18363@eros.localdomain> User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2019-05-02 18:31:27, Tobin C. Harding wrote: > On Thu, May 02, 2019 at 09:30:44AM +0200, Petr Mladek wrote: > > On Thu 2019-05-02 09:12:32, Greg Kroah-Hartman wrote: > > > On Thu, May 02, 2019 at 12:31:42PM +1000, Tobin C. Harding wrote: > > > > Currently we use custom logic to track kobject initialization. Recently > > > > a predicate function was added to the kobject API so we now no longer > > > > need to do this. > > > > > > > > Use kobject API to check for initialized state of kobjects instead of > > > > using custom logic to track state. > > > > > > > > Signed-off-by: Tobin C. Harding > > > > --- > > > > include/linux/livepatch.h | 6 ------ > > > > kernel/livepatch/core.c | 18 +++++------------- > > > > 2 files changed, 5 insertions(+), 19 deletions(-) > > > > > > > > @@ -626,7 +626,7 @@ static void __klp_free_objects(struct klp_patch *patch, bool nops_only) > > > > list_del(&obj->node); > > > > > > > > /* Might be called from klp_init_patch() error path. */ > > > > - if (obj->kobj_added) { > > > > + if (kobject_is_initialized(&obj->kobj)) { > > > > kobject_put(&obj->kobj); > > > > } else if (obj->dynamic) { > > > > klp_free_object_dynamic(obj); > > > > > > Same here, let's not be lazy. > > > > > > The code should "know" if the kobject has been initialized or not > > > because it is the entity that asked for it to be initialized. Don't add > > > extra logic to the kobject core (like the patch before this did) just > > > because this one subsystem wanted to only write 1 "cleanup" function. > > > > We use kobject for a mix of statically and dynamically defined > > structures[*]. And we misunderstood the behavior of kobject_init(). > > > > Anyway, the right solution is to call kobject_init() > > already in klp_init_patch_early() for the statically > > defined structures and in klp_alloc*() for the dynamically > > allocated ones. Then we could simply call kobject_put() > > every time. > > > > Tobin, this goes deeper into the livepatching code that > > you probably expected. Do you want to do the above > > suggested change or should I prepare the patch? > > I'd love for you to handle this one Petr, I'd say its a net gain > time wise that way since if I do it you'll have to review it too > carefully anyways. > > So that will mean patch #1 and #5 of this series are dropped and handed > off to you (thanks). Patch #2 and #3 Greg said he will take. Patch #4 > is not needed. That's a win in my books :) Sound like a great plan. I am going to work on the patch for the livepatching code. Anyway, thanks a lot for your patches. It is a big relief to realize that we could remove some hacks and do it clearly, modulo the static structures ;-) Best Regards, Petr