From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932972AbcFCVf5 (ORCPT ); Fri, 3 Jun 2016 17:35:57 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:52828 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752448AbcFCVf4 (ORCPT ); Fri, 3 Jun 2016 17:35:56 -0400 Date: Fri, 3 Jun 2016 23:35:49 +0200 From: Peter Zijlstra To: Waiman Long Cc: Pan Xinhui , linux-kernel@vger.kernel.org, mingo@redhat.com Subject: Re: [PATCH] locking/qspinlock: Use this_cpu_ptr instead of this_cpu_dec Message-ID: <20160603213549.GB3710@twins.programming.kicks-ass.net> References: <1464947330-3568-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> <5751F48A.6090508@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5751F48A.6090508@hpe.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 03, 2016 at 05:20:10PM -0400, Waiman Long wrote: > On 06/03/2016 05:48 AM, Pan Xinhui wrote: > >queued_spin_lock_slowpath should not worry about interrupt change > >node->count by accident because ->count is inc and dec when we > >enter/leave queued_spin_lock_slowpath. > > > >So this_cpu_dec() does some no point things here, lets use this_cpu_ptr > >for a small optimization. > > > >Signed-off-by: Pan Xinhui > >--- > > kernel/locking/qspinlock.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > >diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c > >index 99f31e4..2b4daac 100644 > >--- a/kernel/locking/qspinlock.c > >+++ b/kernel/locking/qspinlock.c > >@@ -492,7 +492,7 @@ release: > > /* > > * release the node > > */ > >- this_cpu_dec(mcs_nodes[0].count); > >+ this_cpu_ptr(&mcs_nodes[0])->count--; > > } > > EXPORT_SYMBOL(queued_spin_lock_slowpath); > > > > Is this going to generate better code for PPC? For x86, I think it will > cause more instruction to be issued. It does; I think he wants __this_cpu_dec() instead, but the Changelog needs improvement to explain why that is ok.