From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965059AbVL2Idu (ORCPT ); Thu, 29 Dec 2005 03:33:50 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S965060AbVL2Idu (ORCPT ); Thu, 29 Dec 2005 03:33:50 -0500 Received: from mx2.mail.elte.hu ([157.181.151.9]:12739 "EHLO mx2.mail.elte.hu") by vger.kernel.org with ESMTP id S965059AbVL2Idu (ORCPT ); Thu, 29 Dec 2005 03:33:50 -0500 Date: Thu, 29 Dec 2005 09:33:33 +0100 From: Ingo Molnar To: Nicolas Pitre Cc: Arjan van de Ven , lkml Subject: Re: [patch 1/3] mutex subsystem: trylock Message-ID: <20051229083333.GA31003@elte.hu> References: <20051223161649.GA26830@elte.hu> <1135685158.2926.22.camel@laptopd505.fenrus.org> <20051227131501.GA29134@elte.hu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i X-ELTE-SpamScore: -1.9 X-ELTE-SpamLevel: X-ELTE-SpamCheck: no X-ELTE-SpamVersion: ELTE 2.0 X-ELTE-SpamCheck-Details: score=-1.9 required=5.9 tests=ALL_TRUSTED,AWL autolearn=no SpamAssassin version=3.0.3 -2.8 ALL_TRUSTED Did not pass through any untrusted hosts 0.9 AWL AWL: From: address is in the auto white-list X-ELTE-VirusStatus: clean Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org * Nicolas Pitre wrote: > > > > + * 1) if the exclusive store fails we fail, and > > > > + * > > > > + * 2) if the decremented value is not zero we don't even attempt the store. > > > > > > > > > btw I really think that 1) is wrong. trylock should do everything it > > > can to get the semaphore short of sleeping. Just because some > > > cacheline got written to (which might even be shared!) in the middle > > > of the atomic op is not a good enough reason to fail the trylock imho. > > > Going into the slowpath.. fine. But here it's a quality of > > > implementation issue; you COULD get the semaphore without sleeping (at > > > least probably, you'd have to retry to know for sure) but because > > > something wrote to the same cacheline as the lock... no. that's just > > > not good enough.. sorry. > > > > point. I solved this in my tree by calling the generic trylock if > > there's an __ex_flag failure in the ARMv6 case. Should be rare (and thus > > the call is under unlikely()), and should thus still enable the fast > > implementation. > > I'd solve it like this instead (on top of your latest patches): thanks, applied. > + "1: ldrex %0, [%3] \n" > + "subs %1, %0, #1 \n" > + "strexeq %2, %1, [%3] \n" > + "movlt %0, #0 \n" > + "cmpeq %2, #0 \n" > + "bgt 1b \n" so we are back to what is in essence a cmpxchg implementation? Ingo