Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752011AbbETBwS (ORCPT ); Tue, 19 May 2015 21:52:18 -0400 Received: from mail-wg0-f53.google.com ([74.125.82.53]:34205 "EHLO mail-wg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751126AbbETBwQ (ORCPT ); Tue, 19 May 2015 21:52:16 -0400 Date: Wed, 20 May 2015 09:51:43 +0800 From: Minfei Huang To: Jiri Kosina Cc: Jiri Slaby , live-patching@vger.kernel.org, jpoimboe@redhat.com, sjenning@redhat.com, vojtech@suse.cz, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] livepatch: introduce patch/func-walking helpers Message-ID: <20150520015143.GA38414@dhcp-128-78.nay.redhat.com> References: <1432029679-9763-1-git-send-email-jslaby@suse.cz> <1432029679-9763-2-git-send-email-jslaby@suse.cz> <20150519122724.GA37748@dhcp-128-78.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2594 Lines: 74 On 05/19/15 at 11:58P, Jiri Kosina wrote: > On Tue, 19 May 2015, Minfei Huang wrote: > > > > klp_for_each_object and klp_for_each_func are now used all over the > > > code. One need not think what is the proper condition to check in the > > > for loop now. > > > > > > Signed-off-by: Jiri Slaby > > > --- > > > include/linux/livepatch.h | 6 ++++++ > > > kernel/livepatch/core.c | 18 +++++++++--------- > > > 2 files changed, 15 insertions(+), 9 deletions(-) > > > > > > diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h > > > index fe45f2f02c8d..31db7a05dd36 100644 > > > --- a/include/linux/livepatch.h > > > +++ b/include/linux/livepatch.h > > > @@ -805,7 +805,7 @@ static int klp_init_patch(struct klp_patch *patch) > > > if (ret) > > > goto unlock; > > > > > > - for (obj = patch->objs; obj->funcs; obj++) { > > > + klp_for_each_object(patch, obj) { > > > ret = klp_init_object(patch, obj); > > > if (ret) > > > goto free; > > > @@ -960,7 +960,7 @@ static int klp_module_notify(struct notifier_block *nb, unsigned long action, > > > mod->klp_alive = false; > > > > > > list_for_each_entry(patch, &klp_patches, list) { > > > - for (obj = patch->objs; obj->funcs; obj++) { > > > + klp_for_each_object(patch, obj) { > > > > The code is more clearly to use "if", instead of the loop, although we will take > > more than one line than previous, since we will always get the first function > > from the object. > > I have absolutely no idea what you are trying to say here, sorry. Could > you please try to rephrase your review comment? > Sure. Sorry for confuse you with my comment. Following is the livepatch code. list_for_each_entry(patch, &klp_patches, list) { for (obj = patch->objs; obj->funcs; obj++) { ---------------------------------- We get the fisrt object from the patch, then we break the loop. The code is more clearly to use "if", instead of the loop. ---------------------------------- if (!klp_is_module(obj) || strcmp(obj->name, mod->name)) continue; if (action == MODULE_STATE_COMING) { obj->mod = mod; klp_module_notify_coming(patch, obj); } else /* MODULE_STATE_GOING */ klp_module_notify_going(patch, obj); break; ---------------------------------- Here we break the loop. ---------------------------------- } } Thanks Minfei -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/