Re: [PATCH v5 1/5] jump_label: Prevent key->enabled int overflow
From: Peter Zijlstra
Date: Wed Nov 23 2022 - 05:22:17 EST
On Tue, Nov 22, 2022 at 06:55:30PM +0000, Dmitry Safonov wrote:
> key->enabled is indeed a ref-counter as it's documented in multiple
> places: top comment in jump_label.h, Documentation/staging/static-keys.rst,
> etc.
> +/***
> + * static_key_fast_inc_not_negative - 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.
> + *
> + * Returns true if the increment was done.
> + */
One more thing; it might be useful to point out that unlike refcount_t
this thing does not saturate but will fail to increment on overflow.