Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6932906yba; Thu, 2 May 2019 00:43:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXGz1DIvlW38gIxKbvuZJ/tajTaVSJ0hl7jKVfSEYAqHN4a4tU2Ow2fo7m94zjRZiXP/Bx X-Received: by 2002:a17:902:6bc2:: with SMTP id m2mr2234343plt.194.1556783021465; Thu, 02 May 2019 00:43:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556783021; cv=none; d=google.com; s=arc-20160816; b=TQZC1G6HmkQMuQpQUhVPT2UlsSqeKZWXHU51t6x926etepJIlpEqC7gX9ZNG9dFj0s k3LSFuTl+XIo/Dr3FIQFKdjsK13tTLUfJB5YIKVYrN3tqhXF2xxw2E6/uwmdehzS3puh ZzELIos4dHXPKYuaPBOPcwbLivoZ67I4LkKXbSuFNsoW3NmHhXLDQ7XdUiYXePWHNnlf 68AEqWMwk9iUjc3gjAJA+gtPnv/gORmdmmSKNaNCExgBHo2GsHU9t9sDK48r7+Igf51n Jkf5pQkll6wZFmwygmpzNlf+rJKHJRZuHsNVNlxgCf8gclYRQHUEmIlzy4PY0G+2Z5xQ S2BQ== 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:dkim-signature; bh=X1reUAwV0aahuGMfoiS28eDvIH/HC8aEXxg1URI1rRA=; b=qCMM/e02QfCTfE5KtveqCaslovqtx2L8X7pkQSUWVRlITQJNJfeIdJdA5X7rUsH+b4 UU7AIIghxvki37qJH2pByP//w8IrePIDGTmGKYEmziTDdLpgEvpm06buuXP77/pEMgUT EVieEkMuZM7EnZHn6JjNCbk00zDtqNYzQqiRAMzzKI5ySdW4seYXa2dtFi7Qa7qiwPoS ShupQ9b29pec4jxDfJ+/PKoE24/0Ak5g5hxKJCpPZOho1nHIx9BjCKH054QEgHvZaEkJ 9ZxQpt4uponWlf+5nbD9mOXsvHKFRX//Dy6OMCU3FHpk8zo2uim3+sb+vZx1j3BFwmLO KVcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MMmPcHFJ; 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 y24si42545210plr.255.2019.05.02.00.43.26; Thu, 02 May 2019 00:43:41 -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; dkim=pass header.i=@kernel.org header.s=default header.b=MMmPcHFJ; 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 S1726310AbfEBHme (ORCPT + 99 others); Thu, 2 May 2019 03:42:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:49856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbfEBHmd (ORCPT ); Thu, 2 May 2019 03:42:33 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 803A820873; Thu, 2 May 2019 07:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556782953; bh=TTKkqMKRnS10zsZ6GIqwWKgzc1iZ0VEa/3aFdwJHGaA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MMmPcHFJ5qPEdNk1wLQ95fxfpyanD5o8FTZCmJhD7Ml76a8Z6H2fEJ3qiuGXwl2RA a+5/V6a/gxtms62G4dmua1GFV5CRZbSumjLWfdA1WDCmCQwg+uRWU7NQSQHJgbrql4 b4PTBSAx7/6Bb4cD4W50uBM2qGutKPgm3v7/4F5M= Date: Thu, 2 May 2019 09:42:30 +0200 From: Greg Kroah-Hartman To: Petr Mladek Cc: "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: <20190502074230.GA27847@kroah.com> References: <20190502023142.20139-1-tobin@kernel.org> <20190502023142.20139-6-tobin@kernel.org> <20190502071232.GB16247@kroah.com> <20190502073044.bfzugymrncnaajxe@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190502073044.bfzugymrncnaajxe@pathway.suse.cz> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). Eeek, no, a kobject should never be used for a static structure, that's just wrong. Well, almost wrong, ignore how the driver core itself does this in places :) thanks, greg k-h