Commit-ID: d0646a6f5533226ceb7620c20717286d3a372794 Gitweb: http://git.kernel.org/tip/d0646a6f5533226ceb7620c20717286d3a372794 Author: Peter Zijlstra <peterz@xxxxxxxxxxxxx> AuthorDate: Tue, 1 Aug 2017 23:58:50 +0200 Committer: Ingo Molnar <mingo@xxxxxxxxxx> CommitDate: Thu, 10 Aug 2017 12:28:57 +0200 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@xxxxxxxxxxxxx> Cc: Jason Baron <jbaron@xxxxxxxxxx> Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx> --- kernel/jump_label.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/jump_label.c b/kernel/jump_label.c index 833eeca..f2ea678 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(); -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
![]() |