On Wed, 11 Feb 2015 16:06:50 -0600 (CST) Christoph Lameter <cl@xxxxxxxxx> wrote: > On Thu, 12 Feb 2015, Jesper Dangaard Brouer wrote: > > > > > This is quite an expensive lock with irqsave. [...] > > > We can require that interrupt are off when the functions are called. Then > > > we can avoid the "save" part? > > > > Yes, we could also do so with an "_irqoff" variant of the func call, > > but given we are defining the API we can just require this from the > > start. > > Allright. Lets do that then. Okay. Some measurements to guide this choice. Measured on my laptop CPU i7-2620M CPU @ 2.70GHz: * 12.775 ns - "clean" spin_lock_unlock * 21.099 ns - irqsave variant spinlock * 22.808 ns - "manual" irqsave before spin_lock * 14.618 ns - "manual" local_irq_disable + spin_lock Reproducible via my github repo: https://github.com/netoptimizer/prototype-kernel/blob/master/kernel/lib/time_bench_sample.c The clean spin_lock_unlock is 8.324 ns faster than irqsave variant. The irqsave variant is actually faster than expected, as the measurement of an isolated local_irq_save_restore were 13.256 ns. The difference to the "manual" irqsave is only 1.709 ns, which is approx the cost of an extra function call. If one can use the non-flags-save version of local_irq_disable, then one can save 6.481 ns (on this specific CPU and kernel config 3.17.8-200.fc20.x86_64). -- Best regards, Jesper Dangaard Brouer MSc.CS, Sr. Network Kernel Developer at Red Hat Author of http://www.iptv-analyzer.org LinkedIn: http://www.linkedin.com/in/brouer https://github.com/netoptimizer/prototype-kernel/commit/1471ac60 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>