linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [rfc 4.16-rt patch] crypto: cryptd - serialize RT request enqueue/dequeue with a local lock
@ 2018-07-11 15:19 Mike Galbraith
  2018-07-26 16:58 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Galbraith @ 2018-07-11 15:19 UTC (permalink / raw)
  To: linux-rt-users; +Cc: Sebastian Andrzej Siewior, Thomas Gleixner, Steven Rostedt

Note: patch is the result of code inspection...

cryptod disables preemption to provide request enqueue/dequeue exclusion,
use a LOCAL_IRQ_LOCK to do the same for RT, keeping preemption enabled.

Signed-off-by: Mike Galbraith <efault@gmx.de>
---
 crypto/cryptd.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -31,10 +31,12 @@
 #include <linux/scatterlist.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/locallock.h>
 
 static unsigned int cryptd_max_cpu_qlen = 1000;
 module_param(cryptd_max_cpu_qlen, uint, 0);
 MODULE_PARM_DESC(cryptd_max_cpu_qlen, "Set cryptd Max queue depth");
+static DEFINE_LOCAL_IRQ_LOCK(cryptod_request_lock);
 
 struct cryptd_cpu_queue {
 	struct crypto_queue queue;
@@ -141,7 +143,7 @@ static int cryptd_enqueue_request(struct
 	struct cryptd_cpu_queue *cpu_queue;
 	atomic_t *refcnt;
 
-	cpu = get_cpu();
+	cpu = local_lock_cpu(cryptod_request_lock);
 	cpu_queue = this_cpu_ptr(queue->cpu_queue);
 	err = crypto_enqueue_request(&cpu_queue->queue, request);
 
@@ -158,7 +160,7 @@ static int cryptd_enqueue_request(struct
 	atomic_inc(refcnt);
 
 out_put_cpu:
-	put_cpu();
+	local_unlock_cpu(cryptod_request_lock);
 
 	return err;
 }
@@ -179,10 +181,10 @@ static void cryptd_queue_worker(struct w
 	 * cryptd_enqueue_request() being accessed from software interrupts.
 	 */
 	local_bh_disable();
-	preempt_disable();
+	local_lock(cryptod_request_lock);
 	backlog = crypto_get_backlog(&cpu_queue->queue);
 	req = crypto_dequeue_request(&cpu_queue->queue);
-	preempt_enable();
+	local_unlock(cryptod_request_lock);
 	local_bh_enable();
 
 	if (!req)

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

end of thread, other threads:[~2018-07-26 19:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-11 15:19 [rfc 4.16-rt patch] crypto: cryptd - serialize RT request enqueue/dequeue with a local lock Mike Galbraith
2018-07-26 16:58 ` Sebastian Andrzej Siewior
2018-07-26 18:03   ` Mike Galbraith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).