summaryrefslogtreecommitdiff
path: root/kernel/jump_label.c
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2017-08-01 23:58:50 +0200
committerIngo Molnar <mingo@kernel.org>2017-08-10 12:28:57 +0200
commitd0646a6f5533226ceb7620c20717286d3a372794 (patch)
tree2d9b9aa221931072cb170625404c999a11bb7e23 /kernel/jump_label.c
parentbe040bea9085a9c2b1700c9e60888777baeb96d5 (diff)
jump_label: Add RELEASE barrier after text changes
In the unlikely case text modification does not fully order things, add some extra ordering of our own to ensure we only enabled the fast path after all text is visible. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Jason Baron <jbaron@akamai.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/jump_label.c')
-rw-r--r--kernel/jump_label.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 833eecae825e..f2ea678c269f 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -108,7 +108,11 @@ void static_key_slow_inc(struct static_key *key)
if (atomic_read(&key->enabled) == 0) {
atomic_set(&key->enabled, -1);
jump_label_update(key);
- atomic_set(&key->enabled, 1);
+ /*
+ * Ensure that if the above cmpxchg loop observes our positive
+ * value, it must also observe all the text changes.
+ */
+ atomic_set_release(&key->enabled, 1);
} else {
atomic_inc(&key->enabled);
}
@@ -130,7 +134,10 @@ void static_key_enable(struct static_key *key)
if (atomic_read(&key->enabled) == 0) {
atomic_set(&key->enabled, -1);
jump_label_update(key);
- atomic_set(&key->enabled, 1);
+ /*
+ * See static_key_slow_inc().
+ */
+ atomic_set_release(&key->enabled, 1);
}
jump_label_unlock();
cpus_read_unlock();