[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170720202309.rzwfzazpzyb4doco@treble>
Date: Thu, 20 Jul 2017 15:23:09 -0500
From: Josh Poimboeuf <jpoimboe@...hat.com>
To: Joe Lawrence <joe.lawrence@...hat.com>
Cc: Miroslav Benes <mbenes@...e.cz>, live-patching@...r.kernel.org,
linux-kernel@...r.kernel.org, Jessica Yu <jeyu@...hat.com>,
Jiri Kosina <jikos@...nel.org>, Petr Mladek <pmladek@...e.com>
Subject: Re: [PATCH v2 1/2] livepatch: introduce shadow variable API
On Thu, Jul 20, 2017 at 11:48:41AM -0400, Joe Lawrence wrote:
> On a related note, if we keep the allocations and memcpy, how about I
> shift around the attach/get calls like so:
>
> __klp_shadow_attach
> set shadow variable member values
> memcpy
> add to hash
>
> klp_shadow_attach
> alloc new shadow var
> lock
> call __klp_shadow_attach with new alloc
> unlock
>
> klp_shadow_get_or_attach
> be optimistic, call klp_shadow_get (if found, return it)
> be pessimistic, alloc new shadow var
> lock
> call klp_shadow_get again
> if unlikely found
> kfree unneeded alloc
> else
> call __klp_shadow_attach with new alloc
> unlock
> return whichever shadow var we used
>
> This way both calls can accept gfp_flags that may sleep, with the only
> downside that klp_shadow_get_or_attach may allocate an unnecessary
> shadow variable in the unlikely case that it's found on the second
> klp_shadow_get attempt (under the lock). No more clunky "bool lock"
> flag either. :)
Sounds good to me!
--
Josh
Powered by blists - more mailing lists