From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Joe Lawrence <joe.lawrence@redhat.com>
Cc: Petr Mladek <pmladek@suse.com>,
live-patching@vger.kernel.org, linux-kernel@vger.kernel.org,
Jessica Yu <jeyu@redhat.com>, Jiri Kosina <jikos@kernel.org>,
Miroslav Benes <mbenes@suse.cz>
Subject: Re: [PATCH v2 1/2] livepatch: introduce shadow variable API
Date: Mon, 24 Jul 2017 10:04:07 -0500 [thread overview]
Message-ID: <20170724150407.jyb33ux2f5iyetvq@treble> (raw)
In-Reply-To: <f903b90c-70a9-5e29-2f62-b409bc66cad7@redhat.com>
On Fri, Jul 21, 2017 at 09:55:59AM -0400, Joe Lawrence wrote:
> >>> I would do WARN() in klp_shadow_attach() when the variable
> >>> already existed are return NULL. Of course it might be inoncent
> >>> duplication. But it might mean that someone else is using another
> >>> variable of the same name but with different content. klp_shadow_get()
> >>> would then return the same variable for two different purposes.
> >>> Then the whole system might end like a glass on a stony floor.
> >>
> >> What do you think of expanding the API to include each the cases
> >> outlined above? Something like:
> >>
> >> 1 - klp_attach = allocate and add a unique <obj, id> to the hash,
> >> duplicates return NULL and a WARN
> >
> > Sounds good.
> >
> >> 2 - klp_get_or_attach = return <obj, id> if it already exists,
> >> otherwise allocate a new one
> >
> > Sounds good.
> >
> >> 3 - klp_get_or_update = update and return <obj, id> if it already
> >> exists, otherwise allocate a new one
> >
> > I am not sure where this behavior would make sense. See below.
> >
> >
> >> IMHO, I think cases 1 and 3 are most intuitive, so maybe case 2 should
> >> be dropped. Since you suggested adding klp_get_or_attach(), what do you
> >> think?
> >
> > I do not agree. Let's look at the example with the missing lock.
> > The patch adds the lock if it did not exist. Then the lock can
> > be used to synchronize all further operations.
> >
> > klp_get_or_update() would always replace the existing lock
> > with a freshly initialized one. We would loss the information
> > if it was locked or not.
>
> Ah good point, perhaps we have two situations here:
>
> A - A shadow variable that's pointing to some object, like a lock,
> where the original object is required. (Your example above.)
>
> B - A shadow variable that's storing the data itself. In other words,
> instead of attaching a pointer, the whole object was attached:
>
> void patched_function()
> {
> ...
> klp_get_or_attach(obj, id, &jiffies, sizeof(jiffies), ...)
> ...
>
> in which case the caller is only interested in pushing in the
> latest version of jiffies.
>
> For these I suggest klp_get_or_attach() for case A and
> klp_get_or_update() for case B.
klp_get_or_update() doesn't actually 'get', because even if it does, it
gets updated first. I think a more precise name would be
klp_update_or_attach().
--
Josh
next prev parent reply other threads:[~2017-07-24 15:04 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-28 15:37 [PATCH v2 0/2] livepatch: add shadow variable API Joe Lawrence
2017-06-28 15:37 ` [PATCH v2 1/2] livepatch: introduce " Joe Lawrence
2017-06-30 13:49 ` kbuild test robot
2017-07-07 18:05 ` Joe Lawrence
2017-07-14 0:41 ` Josh Poimboeuf
2017-07-17 15:35 ` Miroslav Benes
2017-07-18 13:00 ` Petr Mladek
2017-07-18 19:36 ` Joe Lawrence
2017-07-19 15:19 ` Petr Mladek
2017-07-19 18:50 ` Miroslav Benes
2017-07-17 15:29 ` Miroslav Benes
2017-07-18 20:21 ` Joe Lawrence
2017-07-19 2:28 ` Josh Poimboeuf
2017-07-19 19:01 ` Miroslav Benes
2017-07-20 14:45 ` Miroslav Benes
2017-07-20 15:48 ` Joe Lawrence
2017-07-20 20:23 ` Josh Poimboeuf
2017-07-21 8:42 ` Petr Mladek
2017-07-21 8:59 ` Miroslav Benes
2017-07-18 12:45 ` Petr Mladek
2017-07-20 20:30 ` Joe Lawrence
2017-07-21 9:12 ` Miroslav Benes
2017-07-21 9:27 ` Petr Mladek
2017-07-21 9:13 ` Petr Mladek
2017-07-21 13:55 ` Joe Lawrence
2017-07-24 15:04 ` Josh Poimboeuf [this message]
2017-06-28 15:37 ` [PATCH v2 2/2] livepatch: add shadow variable sample programs Joe Lawrence
2017-07-18 14:47 ` Petr Mladek
2017-07-18 19:15 ` Joe Lawrence
2017-07-19 14:44 ` Petr Mladek
2017-07-19 15:06 ` Petr Mladek
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=20170724150407.jyb33ux2f5iyetvq@treble \
--to=jpoimboe@redhat.com \
--cc=jeyu@redhat.com \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=pmladek@suse.com \
/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).