From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753464AbbAHHok (ORCPT ); Thu, 8 Jan 2015 02:44:40 -0500 Received: from LGEMRELSE6Q.lge.com ([156.147.1.121]:39342 "EHLO lgemrelse6q.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753051AbbAHHoj (ORCPT ); Thu, 8 Jan 2015 02:44:39 -0500 X-Original-SENDERIP: 10.177.222.153 X-Original-MAILFROM: iamjoonsoo.kim@lge.com Date: Thu, 8 Jan 2015 16:44:47 +0900 From: Joonsoo Kim To: Davidlohr Bueso Cc: Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jesper Dangaard Brouer , rostedt@goodmis.org, Thomas Gleixner Subject: Re: [PATCH 1/2] mm/slub: optimize alloc/free fastpath by removing preemption on/off Message-ID: <20150108074447.GA25453@js1304-P5Q-DELUXE> References: <1420421765-3209-1-git-send-email-iamjoonsoo.kim@lge.com> <1420513392.24290.2.camel@stgolabs.net> <20150106080948.GA18346@js1304-P5Q-DELUXE> <1420563737.24290.7.camel@stgolabs.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1420563737.24290.7.camel@stgolabs.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 06, 2015 at 09:02:17AM -0800, Davidlohr Bueso wrote: > On Tue, 2015-01-06 at 17:09 +0900, Joonsoo Kim wrote: > > On Mon, Jan 05, 2015 at 07:03:12PM -0800, Davidlohr Bueso wrote: > > > On Mon, 2015-01-05 at 10:36 +0900, Joonsoo Kim wrote: > > > > - preempt_disable(); > > > > - c = this_cpu_ptr(s->cpu_slab); > > > > + do { > > > > + tid = this_cpu_read(s->cpu_slab->tid); > > > > + c = this_cpu_ptr(s->cpu_slab); > > > > + } while (IS_ENABLED(CONFIG_PREEMPT) && unlikely(tid != c->tid)); > > > > + barrier(); > > > > > > I don't see the compiler reodering the object/page stores below, since c > > > is updated in the loop anyway. Is this really necessary (same goes for > > > slab_free)? The generated code by gcc 4.8 looks correct without it. > > > Additionally, the implied barriers for preemption control aren't really > > > the same semantics used here (if that is actually the reason why you are > > > using them). > > > > Hello, > > > > I'd like to use tid as a pivot so it should be fetched before fetching > > anything on c. Is it impossible even if !CONFIG_PREEMPT without > > barrier()? > > You'd need a smp_wmb() in between tid and c in the loop then, which > looks quite unpleasant. All in all disabling preemption isn't really > that expensive, and you should redo your performance number if you go > this way. This barrier() is not for read/write synchronization between cpus. All read/write operation to cpu_slab would happen on correct cpu in successful case. What I'd need to guarantee here is to prevent reordering between fetching operation for correctness of algorithm. In this case, barrier() seems enough to me. Am I wrong? Thanks.