Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6981030yba; Thu, 2 May 2019 01:53:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwAi0jo4nm0vlelViNYLCfMLXTLgs0SJ7Inffi74UXWp9tYRZ9IsdTfKvtOXsWnjmnyeliM X-Received: by 2002:a62:3501:: with SMTP id c1mr2949960pfa.184.1556787207675; Thu, 02 May 2019 01:53:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556787207; cv=none; d=google.com; s=arc-20160816; b=C6FFb8KqI2gWSuKwBFVeAY6iPZudvglh6NZZGXRYoZuMG+dCIk0s7B6cGrwSdRG4IA fem9sHp9Nn4x6f0bYmjgjttN4sppqxrH71af5ZTGzfjWkKEheV3ZsQ9XPrUsntE9NVv1 bdrotEhwgK6YCWaQxKnhgh8RSWt1cukF6Ra2js4ySMaZJ/iv9tyYhYHDitiKaQ0Gdgke Flne3pVadHjMaAhwBP0k3oiPhR5eb0eAlTsVqarDxnTD53OAUTFhQLXpD5ROuea7Qy6R ChZdZhNCx6E6o8hxh55Pq3stm/BY7lOfg60+0l7wzrwLAKeGZDAit0A9j5+ShocFHyd5 kTVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Stv0FAKgMqehU5iKJdXjCb8OP+0iABQCmTDc77r/ht8=; b=qCOchKIFaxCZ4D5wJuhobIcUN5ZC5a5kJ1InmT4Yxk/JKMzVyUbFVsWclOFB96Jq1s 0+nzi3z6hvHEfeTOKVzbeBYG+4xjjimnr3aPU+SbW6CuVuJI4/d1qK1BUONo32byYsiR Ym9fIc9x/Ibct4G0VwKiuRTvPMM+iHqvwMtueBbqZg5CE8zU1XfQgcX0bNBOIJC7ulPM zY6od+I28APA8tUttRuic8x9NzMzUtq27tfqPma5KdC9s9cq8SiLUma1sCFQy1qQMhYL BBGRqFQbxDyr2RIzMdABYjn5eAK8tj+MVhhfyPxDQzju3yCnS0phpc3xBtnXQekjdxUH OimQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si41069441pgp.480.2019.05.02.01.53.10; Thu, 02 May 2019 01:53:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726497AbfEBIv3 (ORCPT + 99 others); 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