Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: cryptd - Use nested-BH locking for cryptd_cpu_queue

cryptd_queue::cryptd_cpu_queue is a per-CPU variable and relies on
disabled BH for its locking. Without per-CPU locking in
local_bh_disable() on PREEMPT_RT this data structure requires explicit
locking.

Add a local_lock_t to the struct cryptd_cpu_queue and use
local_lock_nested_bh() for locking. This change adds only lockdep
coverage and does not alter the functional behaviour for !PREEMPT_RT.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Sebastian Andrzej Siewior and committed by
Herbert Xu
590f8a67 d956692c

+6
+6
crypto/cryptd.c
··· 34 34 static struct workqueue_struct *cryptd_wq; 35 35 36 36 struct cryptd_cpu_queue { 37 + local_lock_t bh_lock; 37 38 struct crypto_queue queue; 38 39 struct work_struct work; 39 40 }; ··· 111 110 cpu_queue = per_cpu_ptr(queue->cpu_queue, cpu); 112 111 crypto_init_queue(&cpu_queue->queue, max_cpu_qlen); 113 112 INIT_WORK(&cpu_queue->work, cryptd_queue_worker); 113 + local_lock_init(&cpu_queue->bh_lock); 114 114 } 115 115 pr_info("cryptd: max_cpu_qlen set to %d\n", max_cpu_qlen); 116 116 return 0; ··· 137 135 refcount_t *refcnt; 138 136 139 137 local_bh_disable(); 138 + local_lock_nested_bh(&queue->cpu_queue->bh_lock); 140 139 cpu_queue = this_cpu_ptr(queue->cpu_queue); 141 140 err = crypto_enqueue_request(&cpu_queue->queue, request); 142 141 ··· 154 151 refcount_inc(refcnt); 155 152 156 153 out: 154 + local_unlock_nested_bh(&queue->cpu_queue->bh_lock); 157 155 local_bh_enable(); 158 156 159 157 return err; ··· 173 169 * Only handle one request at a time to avoid hogging crypto workqueue. 174 170 */ 175 171 local_bh_disable(); 172 + __local_lock_nested_bh(&cpu_queue->bh_lock); 176 173 backlog = crypto_get_backlog(&cpu_queue->queue); 177 174 req = crypto_dequeue_request(&cpu_queue->queue); 175 + __local_unlock_nested_bh(&cpu_queue->bh_lock); 178 176 local_bh_enable(); 179 177 180 178 if (!req)