Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2141326imu; Fri, 14 Dec 2018 06:27:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/XqcE2pMQ4imeBklWKrCVs7XkirukLA5q4onoRSxWTzxC0TG+g/y/22b9p72P1Md4oJcfV+ X-Received: by 2002:a63:ff62:: with SMTP id s34mr2920076pgk.325.1544797626048; Fri, 14 Dec 2018 06:27:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544797626; cv=none; d=google.com; s=arc-20160816; b=sySEhSuHtoM7BqePzdTV7sn+KxPuR5vlN7FGomEYTvYP6yU3jFW2iJDeqnUs9U5DF4 ehiKlDScf1AJfrO2Btq31TQrAHCoc1k7YRgGzACb7K9cHtrVOIRha3RB+U+KbD0xfTIH 317dJ4vuZW/xw30jXisssSdWks3jZ+6FRORgdeqGegtfPxOzD2vBzKAlPF98EKlLoA1p JCB85nnAVMfDjeyVbZlhHGSZoWSIGkwZkPfwe0J0WAqq73itDdTDm0vbH2OMbOXl/jrN gN41V2+THRjHSMn95nSzk03MXh9YwexfSgX0Xd1TmxcRZZ9uRMqrohL9Rh08OaKhgYC8 Iw/g== 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=HaadmDgx52lv9jI2s4TqQUwhASXwhbgmqsFR1MVPI3I=; b=nE0uHlhLu9VkQalxxR6DWMdbk+K8Bg/Z4THzv08yINl+nCW+AB9ZU7DovH6Sfo/sZd ojOJgkuHTgp3kwC4IUGxrZpCh4ZevRRTb3NaVntALTfw6xLPz6kNnebWwYrImqA+cB1Y Y3fWIVOmhTg9G6otxSnHwV98Nw309Se2fRT37+g6rQmIu2a+O6dae8ntIXerJQIsKpWH 1L/HewqKDrANxnuf0rsV6E3eUeQ1FlzINe5oVCgjHkWxcDxKwhyl4QihPT6B/GdhALA5 o94getyL+r8kdAeEVLkeseka/DC6Ui4tcX4AqwaRxjrtTSte1BZ/7Cn2hRaamzrqa+yR zKUQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e34si4049559pgb.80.2018.12.14.06.26.45; Fri, 14 Dec 2018 06:27:05 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730206AbeLNOXj (ORCPT + 99 others); Fri, 14 Dec 2018 09:23:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47694 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730001AbeLNOXj (ORCPT ); Fri, 14 Dec 2018 09:23:39 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC5AA307D914; Fri, 14 Dec 2018 14:23:38 +0000 (UTC) Received: from treble (ovpn-120-195.rdu2.redhat.com [10.10.120.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5464C5D6B3; Fri, 14 Dec 2018 14:23:35 +0000 (UTC) Date: Fri, 14 Dec 2018 08:23:33 -0600 From: Josh Poimboeuf To: Petr Mladek Cc: Jiri Kosina , Miroslav Benes , Jason Baron , Joe Lawrence , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Jessica Yu Subject: Re: [PATCH v14 03/11] livepatch: Consolidate klp_free functions Message-ID: <20181214142333.4uv6a44qspsxy6hb@treble> References: <20181129094431.7801-1-pmladek@suse.com> <20181129094431.7801-4-pmladek@suse.com> <20181213221037.qaxd5jswdrbv5oxz@treble> <20181214093201.otrr7irvigrhwlzu@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181214093201.otrr7irvigrhwlzu@pathway.suse.cz> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 14 Dec 2018 14:23:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 14, 2018 at 10:32:01AM +0100, Petr Mladek wrote: > On Thu 2018-12-13 16:10:37, Josh Poimboeuf wrote: > > On Thu, Nov 29, 2018 at 10:44:23AM +0100, Petr Mladek wrote: > > > +static void klp_free_funcs(struct klp_object *obj) > > > { > > > struct klp_func *func; > > > > > > - for (func = obj->funcs; func->old_name && func != limit; func++) > > > - kobject_put(&func->kobj); > > > + klp_for_each_func(obj, func) { > > > + /* Might be called from klp_init_patch() error path. */ > > > + if (func->kobj_alive) { > > > + func->kobj_alive = false; > > > + kobject_put(&func->kobj); > > > + } > > > > Why does it set 'kobj_alive' to false? The value will never be read > > again anyway, right? > > You are right. I'll remove it in v15. > > My intention was that it might signalize that the kobject is being > freed and eventually affect the behavior of sysfs-related callbacks. > But in reality, it should be handled by some per-patch flag instead > of a per-object one. > > > > Also, the name isn't quite right. The kobject is technically still > > alive here, and may even continue to be alive after the kobject_put(), > > if there's a sysfs reference to it somewhere. > > > > Maybe it should be called something like 'kobj_initialized' instead. > > Then it doesn't ever need to be set to false -- unless I'm missing > > something. > > This might cause confusion with kobj.state_initialized. This internal > kobject flag is set when the reference counter is initialized. But > it is true even before kobject_add() is called. > > We need a flag that signalizes that kobject_add() succeeded and we > can and must call kobject_put(). > > What about calling it 'kobj_added'? Sounds good to me. -- Josh