lkml.org 
[lkml]   [2017]   [Jul]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2017-07-20 23:25    [W:3.244 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site