Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2986409imu; Mon, 17 Dec 2018 11:07:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ut9kdWDJEGwDmsNDrBIQB7jKineNSP5YvbDr0GelvWvTuxnSmax3j4XBXyhes4STixSUJq X-Received: by 2002:a17:902:a58a:: with SMTP id az10mr14016297plb.10.1545073672371; Mon, 17 Dec 2018 11:07:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545073672; cv=none; d=google.com; s=arc-20160816; b=KdCf7E1Z/wzA+4cbz4QzogYtTuH8Q53htTu/1chkjMxXkSwi+RteH4C37X/gcZe4/Z oADSf4FdrI8mXEiD4N/I3d7paDBS6pV3u7rhU4B5d7ONl34o27x6R+kTvBdwoivM14Oz ftiz/EUqorcUzN/Sgj43swlItmcPn+crGDtLiLoDnfsUBeO1G7SWjnZTW0d+0d6bkg/E leOFjdr/BS29C14Z9QmbA5uLw290j34nORUqowpURlmuKv+vcEzJ1chalvEdvtIehN9D 4Jo+Zhley6wXkSm9PIlqi7JVbLGS9L/95s5A3Cao1uRjL9243x4RRVFzDBuhiTADfifK W/4g== 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=35uV+yWP08Qrfy0/zOZNAmcYLF7hPNS45RwY8wJJV/c=; b=u52ekZtNVQkPXCMY9nADmkPRSLU7wRsHz2KZ+//b5SDQQ4nb/4E09ZBYSmCuN2g3xQ vepKSQx4tsLlD4bzVDG8/k+IOiUg4BXJD/CQfsUB3hm7H7BLUgp7Mc5KjeIMdLeSF7S0 ChBgP2sUCbJfeXeIbS6yh0V2J98uaapN7V+HgUBLL+3JObNFw/f4UKsSG0HIiE2molKI 6sUMsOmZiDDqCScENHqmimA9lUB34X2gwfPk2jIlfdIe6dE3Wst690827dhP62IXNgEw +KRWXvpx/gIiF/kMWGKI2o9tPq174l+hEp82DASbdrfIfoqQ1Ua8CoiXvAuRRSxxCBiX PD8Q== 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 i96si11458554plb.188.2018.12.17.11.07.36; Mon, 17 Dec 2018 11:07:52 -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 S1733274AbeLQP1o (ORCPT + 99 others); Mon, 17 Dec 2018 10:27:44 -0500 Received: from mx2.suse.de ([195.135.220.15]:60458 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727738AbeLQP1o (ORCPT ); Mon, 17 Dec 2018 10:27:44 -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 0D996ACD3; Mon, 17 Dec 2018 15:27:42 +0000 (UTC) Date: Mon, 17 Dec 2018 16:27:41 +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, Jessica Yu Subject: Re: [PATCH v14 07/11] livepatch: Add atomic replace Message-ID: <20181217152741.2i2trzjk5rmofgc3@pathway.suse.cz> References: <20181129094431.7801-1-pmladek@suse.com> <20181129094431.7801-8-pmladek@suse.com> <20181213225528.ies3kxjjtzl6dmd3@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181213225528.ies3kxjjtzl6dmd3@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 16:55:28, Josh Poimboeuf wrote: > On Thu, Nov 29, 2018 at 10:44:27AM +0100, Petr Mladek wrote: > > @@ -415,6 +449,124 @@ static struct attribute *klp_patch_attrs[] = { > > NULL > > }; > > > > +/* > > + * Dynamically allocated objects and functions. > > + */ > > I don't think this comment is needed. > > > +static void klp_free_object_dynamic(struct klp_object *obj) > > +{ > > + kfree(obj->name); > > + kfree(obj); > > +} > > @@ -456,6 +620,8 @@ static void klp_free_funcs(struct klp_object *obj) > > if (func->kobj_alive) { > > func->kobj_alive = false; > > kobject_put(&func->kobj); > > + } else if (func->nop) { > > + klp_free_func_nop(func); > > This removes 'func' from the list, so it needs to do a 'safe' list > iteration. Good catch! Well, note that the 'safe' list iterators were added by the very next patch anyway. This is why I never triggered a problem with this. > > +void klp_discard_replaced_patches(struct klp_patch *new_patch) > > +{ > > + struct klp_patch *old_patch, *tmp_patch; > > + > > + list_for_each_entry_safe(old_patch, tmp_patch, &klp_patches, list) { > > + if (old_patch == new_patch) > > + return; > > + > > + old_patch->enabled = false; > > + klp_unpatch_objects(old_patch); > > + klp_free_patch_start(old_patch); > > + schedule_work(&old_patch->free_work); > > + } > > This doesn't need the "safe" list iteration because it doesn't remove > the patch from the list. It does need the 'safe' list. klp_free_patch_start() removes the patch from the list. > Side note, it would probably be useful to have a klp_for_each_patch() > helper. Will do. Best Regards, Petr