From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932611AbcFBLCX (ORCPT ); Thu, 2 Jun 2016 07:02:23 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:19693 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932565AbcFBLCV (ORCPT ); Thu, 2 Jun 2016 07:02:21 -0400 X-IBM-Helo: d23dlp01.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: Thu, 02 Jun 2016 19:01:17 +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: Arnd Bergmann CC: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, waiman.long@hp.com, peterz@infradead.org 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> In-Reply-To: <4399273.0kije2Qdx5@wuerfel> 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: 16060211-0052-0000-0000-0000019C6809 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16060211-0053-0000-0000-0000061C9A42 Message-Id: <575011FD.4070109@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-06-02_05:,, 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-1606020122 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 But does this is generic code, I am not sure how it will impact the performance on other archs. 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); } > Arnd >