Re: [PATCH v2 1/3] jump_label: Add static_key_fast_inc()

Dmitry Safonov
2022-11-04T16:27:31Z

On 11/3/22 21:41, Peter Zijlstra wrote:
> On Thu, Nov 03, 2022 at 09:25:22PM +0000, Dmitry Safonov wrote:
>> A helper to add another user for an existing enabled static key.
>
> Utter lack of clue what for.
>
>> +/***
>> + * static_key_fast_inc - adds a user for a static key
>> + * @key: static key that must be already enabled
>> + *
>> + * The caller must make sure that the static key can't get disabled while
>> + * in this function. It doesn't patch jump labels, only adds a user to
>> + * an already enabled static key.
>> + */
>> +static inline void static_key_fast_inc(struct static_key *key)
>> +{
>> + STATIC_KEY_CHECK_USE(key);
>> + WARN_ON_ONCE(atomic_read(&key->enabled) < 1);
>> + atomic_inc(&key->enabled);
>> +}
>
> And no, that's racy as heck. We have things like atomic_inc_not_zero(),
> I suggest looking into it.

Thanks for the review, I'll look into that for v3.

Thanks,
Dmitry