Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754191Ab3DVF4f (ORCPT ); Mon, 22 Apr 2013 01:56:35 -0400 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:48276 "EHLO e28smtp04.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752227Ab3DVF4e (ORCPT ); Mon, 22 Apr 2013 01:56:34 -0400 Message-ID: <5174D1D4.1080704@linux.vnet.ibm.com> Date: Mon, 22 Apr 2013 11:29:48 +0530 From: Raghavendra K T Organization: IBM User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121029 Thunderbird/16.0.2 MIME-Version: 1.0 To: Jiannan Ouyang CC: Rik van Riel , LKML , 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 Subject: Re: Preemptable Ticket Spinlock References: <51745650.9050204@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13042205-5564-0000-0000-000007997B6B Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1834 Lines: 53 On 04/22/2013 04:37 AM, Jiannan Ouyang wrote: > On Sun, Apr 21, 2013 at 5:12 PM, Rik van Riel wrote: >> Your algorithm is very clever, and very promising. >> >> However, it does increase the size of the struct spinlock, and adds >> an additional atomic operation to spin_unlock, neither of which I >> suspect are necessary. >> >> 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. >> >> If we do NOT run virtualized, we simply increment the ticket by 2 >> in spin_unlock, and the code can remain otherwise the same. >> >> If we do run virtualized, we take that spinlock after acquiring >> the ticket (or timing out), just like in your code. In the >> virtualized spin_unlock, we can then release the spinlock and >> increment the ticket in one operation: by simply increasing the >> ticket by 1. >> >> In other words, we should be able to keep the overhead of this >> to an absolute minimum, and keep spin_unlock to be always the >> same cost it is today. >> >> -- >> All rights reversed > > Hi Rik, > > Thanks for your feedback. > > Yes I agree with you > - increase the size of struct spinlock is unnecessary > - your idea of utilize the lower bit and save one atomic operation > from unlock is cool! > Yes, +1. it is indeed a cool idea. Thanks to Jeremy.. and as Rik already mentioned it would also prevent the side effects of increasing lock size. (It reminds my thought of encoding vcpuid in lock for pv spinlock) > I can come up with a updated patch soon. > > --Jiannan > > -- 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/