lkml.org 
[lkml]   [2020]   [Mar]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RESEND][PATCH v3 14/17] static_call: Add static_cond_call()
From
Date
On 24/03/2020 14.56, Peter Zijlstra wrote:
> Extend the static_call infrastructure to optimize the following common
> pattern:
>
> if (func_ptr)
> func_ptr(args...)
>

> +#define DEFINE_STATIC_COND_CALL(name, _func) \
> + DECLARE_STATIC_CALL(name, _func); \
> + struct static_call_key STATIC_CALL_NAME(name) = { \
> + .func = NULL, \
> + }
> +
> #define static_call(name) \
> ((typeof(STATIC_CALL_TRAMP(name))*)(STATIC_CALL_NAME(name).func))
>
> +#define static_cond_call(name) \
> + if (STATIC_CALL_NAME(name).func) \
> + ((typeof(STATIC_CALL_TRAMP(name))*)(STATIC_CALL_NAME(name).func))
> +

What, apart from fear of being ridiculed by kernel folks, prevents the
compiler from reloading STATIC_CALL_NAME(name).func ? IOW, doesn't this
want a READ_ONCE somewhere?

And please remind me, what is the consensus for sizeof(long) loads: does
static_call() need load-tearing protection or not?

Rasmus

\
 
 \ /
  Last update: 2020-03-27 00:39    [W:0.327 / U:15.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site