From: Minfei Huang <mnfhuang@gmail.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: Jiri Slaby <jslaby@suse.cz>,
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
Date: Wed, 20 May 2015 09:51:43 +0800 [thread overview]
Message-ID: <20150520015143.GA38414@dhcp-128-78.nay.redhat.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1505192357320.8186@pobox.suse.cz>
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 <jslaby@suse.cz>
> > > ---
> > > 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
next prev parent reply other threads:[~2015-05-20 1:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-19 10:01 [PATCH 1/2] livepatch: make kobject in klp_object statically allocated Jiri Slaby
2015-05-19 10:01 ` [PATCH 2/2] livepatch: introduce patch/func-walking helpers Jiri Slaby
2015-05-19 12:27 ` Minfei Huang
2015-05-19 21:58 ` Jiri Kosina
2015-05-20 1:51 ` Minfei Huang [this message]
2015-05-20 7:11 ` Jiri Slaby
2015-05-23 13:23 ` Minfei Huang
2015-05-19 14:22 ` Josh Poimboeuf
2015-05-19 21:59 ` Jiri Kosina
2015-05-19 14:21 ` [PATCH 1/2] livepatch: make kobject in klp_object statically allocated Josh Poimboeuf
2015-05-19 21:59 ` Jiri Kosina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150520015143.GA38414@dhcp-128-78.nay.redhat.com \
--to=mnfhuang@gmail.com \
--cc=jkosina@suse.cz \
--cc=jpoimboe@redhat.com \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=sjenning@redhat.com \
--cc=vojtech@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).