Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2792636imu; Mon, 17 Dec 2018 07:56:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/UspGYHQBGiS6ubPrq4sX/7jC5X4wn46DlIPcGlVq2a6X4AeDvvWfsYNgt13dzoH399LHP0 X-Received: by 2002:a63:2849:: with SMTP id o70mr12346344pgo.155.1545062186774; Mon, 17 Dec 2018 07:56:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545062186; cv=none; d=google.com; s=arc-20160816; b=Q4JzZmEpxc8huJ2fUe4CBrN6TlwVIi6XPxnyRhrM3LBdwAJvpC+JOcBew1QD+GZrso e7kXcAXx6QY5R2mHijAVjw8tru478IwqqACsG/4gmTMiyMBMLyHsdznwiCAr+FXiBCmL eGV9i9LnI/JEAPNEEgIE6gm3azkVm49k3m6i3cKohPe9W7VplT545N9HW3HaZJyA0x7c zbfxi8rt5lq2Ze/l2iztCWryT+Sz4feqdIVcoLfzOcLxOAt2+TEwuYSNm2Q9sOmjE0Th bx6wQFhE6YJM7xBwKvNpTwdtRpYQW0MgmJSOHBCO+OeLrajE6J0vUZTDmuI2zbDsldtc cIgQ== 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=5YTkDNsnMkOguY/NG3KJ2MOMyix45g0voW2piZ3Ej9s=; b=dQ08vEd1em2xnDujP9OfIAPcOIApv7Yv0/CvsuzkmCUocnq/3xxYqN24KdEMKpoeZH xwxe4O8xY4WxJhBWUSsXbRu2G0RPvIoAwFEChPV4Rirnd4CNGXuwUgZx+kMz4l+zjCws l3lDqgqRtIYr3GGtRCa7YLYqR1Q1LH4OIK9KsKBuKr8B1cXRp081Uldrg45s+g5Ws8zv HpP9S843IZkrEXs17s0HUfEu6+d4kJ9L2NtArIvzk7wulW4WNR2LsWxcUSw4voArUpgk seW/Tpn8KOa8JfF+favnSok8djtW2K3e6c4gVbwqpOG8Mllfs96R+dGOTisQG+x4cTqh b/jg== 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 r18si11404125pgb.491.2018.12.17.07.56.11; Mon, 17 Dec 2018 07:56:26 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387951AbeLQPy4 (ORCPT + 99 others); Mon, 17 Dec 2018 10:54:56 -0500 Received: from mx2.suse.de ([195.135.220.15]:37162 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387737AbeLQPyz (ORCPT ); Mon, 17 Dec 2018 10:54:55 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B71AFACE5; Mon, 17 Dec 2018 15:54:53 +0000 (UTC) Date: Mon, 17 Dec 2018 16:54:53 +0100 From: Petr Mladek To: Josh Poimboeuf Cc: Jiri Kosina , Miroslav Benes , Jason Baron , Joe Lawrence , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v14 08/11] livepatch: Remove Nop structures when unused Message-ID: <20181217155453.nr34ooxmriik2cln@pathway.suse.cz> References: <20181129094431.7801-1-pmladek@suse.com> <20181129094431.7801-9-pmladek@suse.com> <20181213230045.2xgi2pyewkjbou22@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181213230045.2xgi2pyewkjbou22@treble> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2018-12-13 17:00:45, Josh Poimboeuf wrote: > On Thu, Nov 29, 2018 at 10:44:28AM +0100, Petr Mladek wrote: > > +static void __klp_free_funcs(struct klp_object *obj, bool free_all) > > { > > - struct klp_func *func; > > + struct klp_func *func, *tmp_func; > > + > > + klp_for_each_func_safe(obj, func, tmp_func) { > > + if (!free_all && !func->nop) > > + continue; > > I suspect that changing 'free_all" to 'nops_only' (and inverting the > condition) would make the code more readable. > > And a similar suggestion for __klp_free_objects(). I am not super happy with the negative check as well. The problem is that in __klp_free_objects() it would look like: if (nops_only && !obj->dynamic) continue; By other words, "free_all" works better with both "nops" and "dynamic". That said, I do not mind about it. Tell me what you prefer and I'll change it. > > + > > + /* > > + * Avoid double free. It would be tricky to wait for kobject > > + * callbacks when only NOPs are handled. > > + */ > > + list_del(&func->node); > > I've read this comment several times but I still have no idea how it > relates to the code :-) I wrote this comment when I was lost in thoughts how to make freeing safe. Especially I wondered whether we would need to wait until the structures are freed. You are right that this is needed to remove the freed nops/dynamic structures in general. I will remove the comment. Best Regards, Petr