lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <TYCP286MB2323ACFB89E58BE6A05232C1CA529@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM>
Date:   Mon, 26 Sep 2022 23:01:18 +0800
From:   Dawei Li <set_pte_at@...look.com>
To:     colyli@...e.de, kent.overstreet@...il.com
Cc:     linux-bcache@...r.kernel.org, linux-kernel@...r.kernel.org,
        Dawei Li <set_pte_at@...look.com>
Subject: [PATCH] bcache: improve race performance of closure debug by rcu

Closure debug system implements a closure list which is shared between
readers and writers, and a spinlock protecting the concurrency access
on it, which means that all readers and writers are mutual-exclusive,
which brings overhead to performance.

A rcu-based lock is introduced to solve the problem.

Signed-off-by: Dawei Li <set_pte_at@...look.com>
---
 drivers/md/bcache/closure.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c
index d8d9394a6beb..b019d6338589 100644
--- a/drivers/md/bcache/closure.c
+++ b/drivers/md/bcache/closure.c
@@ -10,6 +10,7 @@
 #include <linux/module.h>
 #include <linux/seq_file.h>
 #include <linux/sched/debug.h>
+#include <linux/rculist.h>
 
 #include "closure.h"
 
@@ -141,7 +142,7 @@ void closure_debug_create(struct closure *cl)
 	cl->magic = CLOSURE_MAGIC_ALIVE;
 
 	spin_lock_irqsave(&closure_list_lock, flags);
-	list_add(&cl->all, &closure_list);
+	list_add_rcu(&cl->all, &closure_list);
 	spin_unlock_irqrestore(&closure_list_lock, flags);
 }
 
@@ -153,7 +154,7 @@ void closure_debug_destroy(struct closure *cl)
 	cl->magic = CLOSURE_MAGIC_DEAD;
 
 	spin_lock_irqsave(&closure_list_lock, flags);
-	list_del(&cl->all);
+	list_del_rcu(&cl->all);
 	spin_unlock_irqrestore(&closure_list_lock, flags);
 }
 
@@ -163,9 +164,9 @@ static int debug_show(struct seq_file *f, void *data)
 {
 	struct closure *cl;
 
-	spin_lock_irq(&closure_list_lock);
+	rcu_read_lock();
 
-	list_for_each_entry(cl, &closure_list, all) {
+	list_for_each_entry_rcu(cl, &closure_list, all) {
 		int r = atomic_read(&cl->remaining);
 
 		seq_printf(f, "%p: %pS -> %pS p %p r %i ",
@@ -184,7 +185,8 @@ static int debug_show(struct seq_file *f, void *data)
 		seq_printf(f, "\n");
 	}
 
-	spin_unlock_irq(&closure_list_lock);
+	rcu_read_unlock();
+
 	return 0;
 }
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ