From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751322AbcFNGMF (ORCPT ); Tue, 14 Jun 2016 02:12:05 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:4101 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751153AbcFNGMD (ORCPT ); Tue, 14 Jun 2016 02:12:03 -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: Tue, 14 Jun 2016 14:11:48 +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: Will Deacon CC: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, 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> <20160608092244.GA27029@arm.com> In-Reply-To: <20160608092244.GA27029@arm.com> 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: 16061406-0048-0000-0000-0000019254FB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16061406-0049-0000-0000-000045EF2F96 Message-Id: <575FA024.7060608@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-06-14_03:,, 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-1606140068 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016年06月08日 17:22, Will Deacon wrote: > On Thu, Jun 02, 2016 at 06:09:08PM +0800, Pan Xinhui wrote: >> strcut __qrwlock has different layout in big endian machine. we need set >> the __qrwlock->wmode to NULL, and the address is not &lock->cnts in big >> endian machine. >> >> Do as what read unlock does. we are lucky that the __qrwlock->wmode's >> val is _QW_LOCKED. > > Doesn't this have wider implications for the qrwlocks, for example: > > while ((cnts & _QW_WMASK) == _QW_LOCKED) { ... } > > would actually end up looking at the wrong field of the lock? > I does not clearly understand your idea. :( the condition in the while() is always true from the view of current code. BUT if __qrwlock has same layout on the two endian machine, the while() will end up. :) > Shouldn't we just remove the #ifdef __LITTLE_ENDIAN stuff from __qrwlock, > given that all the struct members are u8? > No. that makes codes complex. for example struct __qrwlock lock; WRITE_ONCE(lock->wmode, _QW_WAITING); if (atomic_(&lock->cnts) == _QW_WAITING) { do_something(); } IF you remove the #ifdef __LITTLE_ENDIAN stuff from __qrwlock. codes above obviously will break. And we already have such code. thanks xinhui > Will >