lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 07 Oct 2015 23:00:39 +0200
From:	Daniel Borkmann <daniel@...earbox.net>
To:	Alexei Starovoitov <ast@...mgrid.com>, davem@...emloft.net
CC:	hannes@...essinduktion.org, netdev@...r.kernel.org
Subject: Re: [PATCH net-next 2/5] once: make helper generic for calling function
 once

On 10/07/2015 06:16 PM, Alexei Starovoitov wrote:
> On 10/7/15 6:43 AM, Daniel Borkmann wrote:
>> From: Hannes Frederic Sowa<hannes@...essinduktion.org>
>>
>> Make the get_random_once() helper generic enough, so that functions
>> in general would only be called once, where one user of this is then
>> net_get_random_once().
>>
>> The only implementation specific call is to get_random_bytes(), all
>> the rest of this *_once() facility would be duplicated among different
>> subsystems otherwise. The new do_once() helper will be used by prandom()
>> later on, but might also be useful for other scenarios as well where a
>> one-time initialization in often-called, possibly fast-path code could
>> occur.
>>
>> Signed-off-by: Hannes Frederic Sowa<hannes@...essinduktion.org>
>> Signed-off-by: Daniel Borkmann<daniel@...earbox.net>
>> ---
>>   include/linux/once.h | 25 ++++++++++++++++++-------
>>   lib/once.c           | 34 +++++++++++++++++++++-------------
>>   2 files changed, 39 insertions(+), 20 deletions(-)
>
> looking at the patch 1 the once.c file name really looked out of place,
> but this patch makes it fit. Interesting helper, though
> get_random_once_kvec() and kvec are not pretty, since they take extra
> stack and being inited even when static_key is disabled.
> Instead is it possible to split do_once into two parts then
> your macro can have varags and kvec/extra_helper can be removed like:
> #define do_once(func, ...)                      \
>   ({                                             \
>          bool ___ret = false;                    \
>          static bool ___done = false;            \
>          static struct static_key ___once_key =  \
>                  STATIC_KEY_INIT_TRUE;           \
>          if (static_key_true(&___once_key)) {    \
>                  __do_once_lock(&___done);       \
>                  func(##__VA_ARGS__);            \
>                  __do_once_unlock(&_done, &___once_key);\
>          } \
>          ___ret;                                 \
>   })

Thanks, good point, I do like it! After reworking this, the outcome of
the new DO_ONCE() is a bit different than above. I'll send out v2 very
soon to show the code result.

Thanks,
Daniel
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ