Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751121AbVJFPyp (ORCPT ); Thu, 6 Oct 2005 11:54:45 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751120AbVJFPyp (ORCPT ); Thu, 6 Oct 2005 11:54:45 -0400 Received: from gw1.cosmosbay.com ([62.23.185.226]:60055 "EHLO gw1.cosmosbay.com") by vger.kernel.org with ESMTP id S1751122AbVJFPyo (ORCPT ); Thu, 6 Oct 2005 11:54:44 -0400 Message-ID: <43454886.6010608@cosmosbay.com> Date: Thu, 06 Oct 2005 17:53:42 +0200 From: Eric Dumazet User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: fr, en MIME-Version: 1.0 To: Hugh Dickins CC: Linus Torvalds , Kirill Korotaev , Ingo Molnar , linux-kernel@vger.kernel.org, Andrew Morton , xemul@sw.ru, Andrey Savochkin , st@sw.ru Subject: Re: SMP syncronization on AMD processors (broken?) References: <434520FF.8050100@sw.ru> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.6 (gw1.cosmosbay.com [172.16.8.80]); Thu, 06 Oct 2005 17:53:41 +0200 (CEST) Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1328 Lines: 50 Hugh Dickins a ?crit : > On Thu, 6 Oct 2005, Linus Torvalds wrote: > >>If you want to notify another CPU that you want the spinlock, then you >>need to set the "flag" variable _outside_ of the spinlock. >> >>Spinlocks are not fair, not by a long shot. They never have been, and they >>never will. Fairness would be extremely expensive indeed. > > > That reminds me: ought cond_resched_lock to be doing something more? > > int cond_resched_lock(spinlock_t *lock) > { > int ret = 0; > > if (need_lockbreak(lock)) { > spin_unlock(lock); > cpu_relax(); > ret = 1; > spin_lock(lock); > } > - Isnt it funny that some bugs can spot other bugs ? :) break_lock should be declared atomic_t and used like that : void __lockfunc _##op##_lock(locktype##_t *lock) { preempt_disable(); for (;;) { if (likely(_raw_##op##_trylock(lock))) break; preempt_enable(); atomic_inc(&(lock)->break_lock); while (!op##_can_lock(lock)) cpu_relax(); preempt_disable(); atomic_dec(&(lock)->break_lock); } } Eric - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/