Skip to contentSkip to conversation

security, keys: Optimize barrier usage for Rmw atomic bitops

PATCH In review Davidlohr Bueso 1 participant 2 messages Jan 29, 2020 – Mar 20, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 security, keys: Optimize barrier usage for Rmw atomic bitops

For both set and clear_bit, we can avoid the unnecessary barriers on non LL/SC architectures, such as x86. Instead, use the smp_mb__{before,after}_atomic() calls.

---
 security/keys/gc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/keys/gc.c +2 -2
index 671dd730ecfc..ce7b4c22e3c4 100644
@@ -102,7 +102,7 @@ void key_gc_keytype(struct key_type *ktype)
 
 	key_gc_dead_keytype = ktype;
 	set_bit(KEY_GC_REAPING_KEYTYPE, &key_gc_flags);
-	smp_mb();
+	smp_mb__after_atomic();
 	set_bit(KEY_GC_REAP_KEYTYPE, &key_gc_flags);
 
 	kdebug("schedule");
@@ -308,7 +308,7 @@ static void key_garbage_collector(struct work_struct *work)
 
 	if (unlikely(gc_state & KEY_GC_REAPING_DEAD_3)) {
 		kdebug("dead wake");
-		smp_mb();
+		smp_mb__before_atomic();
 		clear_bit(KEY_GC_REAPING_KEYTYPE, &key_gc_flags);
 		wake_up_bit(&key_gc_flags, KEY_GC_REAPING_KEYTYPE);
 	}
Signature · 1 line
2.16.4
#1 lore raw

ping?

Quoted 34 lines · Davidlohr Bueso

For both set and clear_bit, we can avoid the unnecessary barriers on non LL/SC architectures, such as x86. Instead, use the smp_mb__{before,after}_atomic() calls.

---
security/keys/gc.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
security/keys/gc.c +2 -2
index 671dd730ecfc..ce7b4c22e3c4 100644
@@ -102,7 +102,7 @@ void key_gc_keytype(struct key_type *ktype)
 
 	key_gc_dead_keytype = ktype;
 	set_bit(KEY_GC_REAPING_KEYTYPE, &key_gc_flags);
-	smp_mb();
+	smp_mb__after_atomic();
 	set_bit(KEY_GC_REAP_KEYTYPE, &key_gc_flags);
 
 	kdebug("schedule");
@@ -308,7 +308,7 @@ static void key_garbage_collector(struct work_struct *work)
 
 	if (unlikely(gc_state & KEY_GC_REAPING_DEAD_3)) {
 		kdebug("dead wake");
-		smp_mb();
+		smp_mb__before_atomic();
 		clear_bit(KEY_GC_REAPING_KEYTYPE, &key_gc_flags);
 		wake_up_bit(&key_gc_flags, KEY_GC_REAPING_KEYTYPE);
 	}
Signature · 1 line
2.16.4