From: Nicolai Stange <nstange@suse.de>
To: Joe Lawrence <joe.lawrence@redhat.com>
Cc: Petr Mladek <pmladek@suse.com>, Nicolai Stange <nstange@suse.de>,
live-patching@vger.kernel.org, linux-kernel@vger.kernel.org,
Josh Poimboeuf <jpoimboe@redhat.com>,
Jessica Yu <jeyu@redhat.com>, Jiri Kosina <jikos@kernel.org>,
Miroslav Benes <mbenes@suse.cz>
Subject: Re: [PATCH v4] livepatch: introduce shadow variable API
Date: Fri, 18 Aug 2017 16:46:41 +0200 [thread overview]
Message-ID: <87378pgcha.fsf@suse.de> (raw)
In-Reply-To: <5f769d8c-f539-ebdc-359b-ef42dc7c019b@redhat.com> (Joe Lawrence's message of "Fri, 18 Aug 2017 10:19:54 -0400")
Joe Lawrence <joe.lawrence@redhat.com> writes:
> On 08/18/2017 10:04 AM, Petr Mladek wrote:
>> On Fri 2017-08-18 15:44:29, Nicolai Stange wrote:
>>> Joe Lawrence <joe.lawrence@redhat.com> writes:
>>>
>>> <snip>
>>>> +
>>>> +/**
>>>> + * klp_shadow_get() - retrieve a shadow variable data pointer
>>>> + * @obj: pointer to parent object
>>>> + * @id: data identifier
>>>> + *
>>>> + * Return: the shadow variable data element, NULL on failure.
>>>> + */
>>>> +void *klp_shadow_get(void *obj, unsigned long id)
>>>> +{
>>>> + struct klp_shadow *shadow;
>>>> +
>>>> + rcu_read_lock();
>>>> +
>>>> + hash_for_each_possible_rcu(klp_shadow_hash, shadow, node,
>>>> + (unsigned long)obj) {
>>>> +
>>>> + if (klp_shadow_match(shadow, obj, id)) {
>>>> + rcu_read_unlock();
>>>> + return shadow->data;
>>>
>>> I had to think a moment about what protects shadow from getting freed by
>>> a concurrent detach after that rcu_read_unlock(). Then I noticed that if
>>> obj and the livepatch are alive, then so is shadow, because there
>>> obviously hasn't been any reason to detach it.
>>>
>>> So maybe it would be nice to have an additional comment at
>>> klp_shadow_detach() that it's the API user's responsibility not to use a
>>> shadow instance after detaching it...
>
> Nicolai, I can add something like "This function releases the memory for
> this shadow variable instance, callers should stop referencing it
> accordingly." Similar text for klp_shadow_detach_all().
Perfect, thanks!
>> Good point. In fact, it might make sense to rename the functions:
>>
>> attach -> create
>> detach -> destroy
>>
>> The name detach suggests that the variable is just not connected to
>> the parent object but that it is still accessible/usable.
>
> FWIW, kpatch calls them "kpatch_shadow_alloc" and "kpatch_shadow_free".
> Now that it's clear that we're not going separate shadow variable
> allocation from hash table insertion, going back to alloc/create and
> destroy/free is fine w/me.
--
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
prev parent reply other threads:[~2017-08-18 14:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-14 20:02 [PATCH v4] livepatch: shadow variables Joe Lawrence
2017-08-14 20:02 ` [PATCH v4] livepatch: introduce shadow variable API Joe Lawrence
2017-08-15 13:59 ` Josh Poimboeuf
2017-08-16 12:43 ` Miroslav Benes
2017-08-16 13:40 ` Joe Lawrence
2017-08-31 12:45 ` Miroslav Benes
2017-08-17 14:05 ` Petr Mladek
2017-08-17 16:01 ` Joe Lawrence
2017-08-17 16:28 ` Josh Poimboeuf
2017-08-18 9:42 ` Petr Mladek
2017-08-18 19:04 ` Josh Poimboeuf
2017-08-18 13:46 ` Joe Lawrence
2017-08-18 16:18 ` Petr Mladek
2017-08-18 20:25 ` Joe Lawrence
2017-08-21 11:24 ` Petr Mladek
2017-08-18 13:44 ` Nicolai Stange
2017-08-18 14:04 ` Petr Mladek
2017-08-18 14:19 ` Joe Lawrence
2017-08-18 14:46 ` Nicolai Stange [this message]
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=87378pgcha.fsf@suse.de \
--to=nstange@suse.de \
--cc=jeyu@redhat.com \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.