File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -162,22 +162,24 @@ bool static_key_slow_inc_cpuslocked(struct static_key *key)
162
162
if (static_key_fast_inc_not_disabled (key ))
163
163
return true;
164
164
165
- jump_label_lock ( );
166
- if ( atomic_read ( & key -> enabled ) == 0 ) {
167
- atomic_set ( & key -> enabled , -1 );
165
+ guard ( mutex )( & jump_label_mutex );
166
+ /* Try to mark it as 'enabling in progress. */
167
+ if (! atomic_cmpxchg ( & key -> enabled , 0 , -1 )) {
168
168
jump_label_update (key );
169
169
/*
170
- * Ensure that if the above cmpxchg loop observes our positive
171
- * value, it must also observe all the text changes.
170
+ * Ensure that when static_key_fast_inc_not_disabled() or
171
+ * static_key_slow_try_dec() observe the positive value,
172
+ * they must also observe all the text changes.
172
173
*/
173
174
atomic_set_release (& key -> enabled , 1 );
174
175
} else {
175
- if (WARN_ON_ONCE (!static_key_fast_inc_not_disabled (key ))) {
176
- jump_label_unlock ();
176
+ /*
177
+ * While holding the mutex this should never observe
178
+ * anything else than a value >= 1 and succeed
179
+ */
180
+ if (WARN_ON_ONCE (!static_key_fast_inc_not_disabled (key )))
177
181
return false;
178
- }
179
182
}
180
- jump_label_unlock ();
181
183
return true;
182
184
}
183
185
You can’t perform that action at this time.
0 commit comments