Linux-Security-Module Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] security, keys: Optimize barrier usage for Rmw atomic  bitops
@ 2020-01-29 18:06 Davidlohr Bueso
  2020-03-20 17:09 ` Davidlohr Bueso
  0 siblings, 1 reply; 2+ messages in thread
From: Davidlohr Bueso @ 2020-01-29 18:06 UTC (permalink / raw)
  To: dhowells; +Cc: linux-security-module, linux-kernel, dave, 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.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
 security/keys/gc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/keys/gc.c b/security/keys/gc.c
index 671dd730ecfc..ce7b4c22e3c4 100644
--- a/security/keys/gc.c
+++ b/security/keys/gc.c
@@ -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);
 	}
-- 
2.16.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] security, keys: Optimize barrier usage for Rmw atomic bitops
  2020-01-29 18:06 [PATCH] security, keys: Optimize barrier usage for Rmw atomic bitops Davidlohr Bueso
@ 2020-03-20 17:09 ` Davidlohr Bueso
  0 siblings, 0 replies; 2+ messages in thread
From: Davidlohr Bueso @ 2020-03-20 17:09 UTC (permalink / raw)
  To: dhowells; +Cc: linux-security-module, linux-kernel, Davidlohr Bueso

ping?

On Wed, 29 Jan 2020, Davidlohr Bueso wrote:

>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.
>
>Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
>---
> security/keys/gc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/security/keys/gc.c b/security/keys/gc.c
>index 671dd730ecfc..ce7b4c22e3c4 100644
>--- a/security/keys/gc.c
>+++ b/security/keys/gc.c
>@@ -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);
> 	}
>-- 
>2.16.4
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-29 18:06 [PATCH] security, keys: Optimize barrier usage for Rmw atomic bitops Davidlohr Bueso
2020-03-20 17:09 ` Davidlohr Bueso

Linux-Security-Module Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-security-module/0 linux-security-module/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-security-module linux-security-module/ https://lore.kernel.org/linux-security-module \
		linux-security-module@vger.kernel.org
	public-inbox-index linux-security-module

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-security-module


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git