From: "David Laight" Subject: RE: sha512: make it work, undo percpu message schedule Date: Fri, 13 Jan 2012 11:45:53 -0000 Message-ID: References: <1326450942.2272.20.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT Cc: "Alexey Dobriyan" , , , , "Steffen Klassert" To: "Eric Dumazet" , "Herbert Xu" Return-path: Content-class: urn:content-classes:message In-Reply-To: <1326450942.2272.20.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC> Sender: netdev-owner@vger.kernel.org List-Id: linux-crypto.vger.kernel.org > Trying a dynamic memory allocation, and fallback on a single > pre-allocated bloc of memory, shared by all cpus, protected by a > spinlock ... > - > + 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); > > + > + 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? 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 David