Thread (8 messages) 8 messages, 3 authors, 2022-11-04

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

From: Dmitry Safonov <hidden>
Date: 2022-11-04 16:27:31
Also in: lkml

On 11/3/22 21:41, Peter Zijlstra wrote:
On Thu, Nov 03, 2022 at 09:25:22PM +0000, Dmitry Safonov wrote:
quoted
A helper to add another user for an existing enabled static key.
Utter lack of clue what for.
quoted
+/***
+ * 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help