From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753397AbcFFEsj (ORCPT ); Mon, 6 Jun 2016 00:48:39 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59931 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750945AbcFFEsh (ORCPT ); Mon, 6 Jun 2016 00:48:37 -0400 Message-Id: <201606060448.u564mYGP013434@mx0a-001b2d01.pphosted.com> X-IBM-Helo: d28dlp01.in.ibm.com X-IBM-MailFrom: xinhui.pan@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Date: Mon, 06 Jun 2016 12:48:16 +0800 From: xinhui User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Peter Zijlstra , Waiman Long CC: linux-kernel@vger.kernel.org, mingo@redhat.com Subject: Re: [PATCH] locking/qspinlock: Use this_cpu_ptr instead of this_cpu_dec References: <1464947330-3568-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> <5751F48A.6090508@hpe.com> <20160603213549.GB3710@twins.programming.kicks-ass.net> In-Reply-To: <20160603213549.GB3710@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16060604-0052-0000-0000-0000026F0910 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16060604-0053-0000-0000-00000CB24DB8 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-06-06_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=8 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606060059 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016年06月04日 05:35, Peter Zijlstra wrote: > 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. > yes, ppc will do some check when restore irq flags. it's really heavy. and yes, such change cause more instructions to be issued. there is a RELOC_HIDE macro in this_cpu_ptr and gcc can't do optimization. How about ICC. I once used ICC when I was in intel but i forgot the result. > It does; I think he wants __this_cpu_dec() instead, but the Changelog > needs improvement to explain why that is ok. > oh, great. __this_cpu_dec() is fine. thanks no any irq flags save/restore again. :) thanks xinhui