From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rik van Riel Subject: Re: Preemptable Ticket Spinlock Date: Mon, 22 Apr 2013 19:13:48 -0400 Message-ID: <5175C42C.1030901@redhat.com> References: <51745650.9050204@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Jiannan Ouyang , LKML , Raghavendra K T , Peter Zijlstra , Avi Kivity , Gleb Natapov , Ingo Molnar , Marcelo Tosatti , Srikar , "H. Peter Anvin" , "Nikunj A. Dadhania" , KVM , Thomas Gleixner , Chegu Vinod , "Andrew M. Theurer" , Srivatsa Vaddagiri , Andrew Jones , Karen Noel To: Andi Kleen Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 04/22/2013 05:56 PM, Andi Kleen wrote: > Rik van Riel writes: >> >> If we always incremented the ticket number by 2 (instead of 1), then >> we could use the lower bit of the ticket number as the spinlock. > > Spinning on a single bit is very inefficient, as you need to do > try lock in a loop which is very unfriendly to the MESI state protocol. > It's much better to have at least three states and allow > spinning-while-reading-only. > > This is typically very visible on systems with >2S. Absolutely, the spinning should be read-only, until the CPU sees that the desired bit is clear. MESI-friendly spinning is essential. -- All rights reversed