RE: sha512: make it work, undo percpu message schedule
From: Eric Dumazet <hidden>
Date: 2012-01-13 12:35:28
Also in:
linux-crypto
From: Eric Dumazet <hidden>
Date: 2012-01-13 12:35:28
Also in:
linux-crypto
Le vendredi 13 janvier 2012 à 11:45 +0000, David Laight a écrit :
quoted
Trying a dynamic memory allocation, and fallback on a single pre-allocated bloc of memory, shared by all cpus, protected by a spinlock...quoted
- + static u64 msg_schedule[80]; + static DEFINE_SPINLOCK(msg_schedule_lock); int i; - u64 *W = get_cpu_var(msg_schedule); + u64 *W = kzalloc(sizeof(msg_schedule), GFP_ATOMIC |__GFP_NOWARN);quoted
+ + if (!W) { + spin_lock_bh(&msg_schedule_lock); + W = msg_schedule; + }If this code can be called from an ISR is the kmalloc() call safe?
Yes, obviously, kmalloc() is IRQ safe.
If the above is safe, wouldn't it be better to: 1) try to use the static buffer 2) try to kalloc() a buffer 3) spinwait for the static buffer to be free
No idea of what you mean, and why you think its better. kmalloc() propably can give us a block already hot in cpu cache.