From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751545AbcFCHWV (ORCPT ); Fri, 3 Jun 2016 03:22:21 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54241 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751091AbcFCHWT (ORCPT ); Fri, 3 Jun 2016 03:22:19 -0400 X-IBM-Helo: d23dlp02.au.ibm.com X-IBM-MailFrom: xinhui.pan@linux.vnet.ibm.com X-IBM-RcptTo: linux-arch@vger.kernel.org;linux-kernel@vger.kernel.org Date: Fri, 03 Jun 2016 15:20:53 +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 CC: Arnd Bergmann , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, waiman.long@hp.com Subject: Re: [PATCH] locking/qrwlock: fix write unlock issue in big endian References: <1464862148-5672-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> <4399273.0kije2Qdx5@wuerfel> <575011FD.4070109@linux.vnet.ibm.com> <20160602111505.GB3190@twins.programming.kicks-ass.net> In-Reply-To: <20160602111505.GB3190@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: 16060307-0048-0000-0000-0000018DC64D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16060307-0049-0000-0000-000045DE390F Message-Id: <57512FD5.5020301@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-06-03_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606030082 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016年06月02日 19:15, Peter Zijlstra wrote: > On Thu, Jun 02, 2016 at 07:01:17PM +0800, xinhui wrote: >> >> On 2016年06月02日 18:44, Arnd Bergmann wrote: >>> On Thursday, June 2, 2016 6:09:08 PM CEST Pan Xinhui wrote: >>>> diff --git a/include/asm-generic/qrwlock.h b/include/asm-generic/qrwlock.h >>>> index 54a8e65..eadd7a3 100644 >>>> --- a/include/asm-generic/qrwlock.h >>>> +++ b/include/asm-generic/qrwlock.h >>>> @@ -139,7 +139,7 @@ static inline void queued_read_unlock(struct qrwlock *lock) >>>> */ >>>> static inline void queued_write_unlock(struct qrwlock *lock) >>>> { >>>> - smp_store_release((u8 *)&lock->cnts, 0); >>>> + (void)atomic_sub_return_release(_QW_LOCKED, &lock->cnts); >>>> } >>> >>> Isn't this more expensive than the existing version? >>> >> yes, a little more expensive than the existing version > > Think 20+ cycles worse. > >> But does this is generic code, I am not sure how it will impact the performance on other archs. > > As always, you get to audit users of stuff you change. And here you're > lucky, there's only 1. > yes, and hope there will be 2 :) >> If you like >> we calculate the correct address to set to NULL >> say, >> static inline void queued_write_unlock(struct qrwlock *lock) >> { >> u8 *wl = lock; >> >> #ifdef __BIG_ENDIAN >> wl += 3; >> #endif >> smp_store_release(wl, 0); >> >> } > > No, that's horrible. Either lift __qrwlock into qrwlock_types.h or do > what qspinlock does. And looking at that, we could make agree. > queued_spin_unlock() use the atomic_sub_return_relaxed() thing too I > suppose, that generates slightly better code. > thanks for your suggestion. I can have a try in queued_spin_unlock().