Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754399AbbBLARF (ORCPT ); Wed, 11 Feb 2015 19:17:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54993 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752614AbbBLARE (ORCPT ); Wed, 11 Feb 2015 19:17:04 -0500 Date: Thu, 12 Feb 2015 13:16:49 +1300 From: Jesper Dangaard Brouer To: Christoph Lameter Cc: akpm@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, penberg@kernel.org, iamjoonsoo@lge.com, brouer@redhat.com Subject: Re: [PATCH 2/3] slub: Support for array operations Message-ID: <20150212131649.59b70f71@redhat.com> In-Reply-To: References: <20150210194804.288708936@linux.com> <20150210194811.902155759@linux.com> <20150211174817.44cc5562@redhat.com> <20150212104316.2d5c32ea@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1873 Lines: 51 On Wed, 11 Feb 2015 16:06:50 -0600 (CST) Christoph Lameter 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/