Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752009Ab3DUVNc (ORCPT ); Sun, 21 Apr 2013 17:13:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24361 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751693Ab3DUVNa (ORCPT ); Sun, 21 Apr 2013 17:13:30 -0400 Message-ID: <51745650.9050204@redhat.com> Date: Sun, 21 Apr 2013 17:12:48 -0400 From: Rik van Riel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130402 Thunderbird/17.0.5 MIME-Version: 1.0 To: Jiannan Ouyang CC: 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 , Gleb Natapov , Karen Noel Subject: Re: Preemptable Ticket Spinlock References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2304 Lines: 53 On 04/20/2013 06:12 PM, Jiannan Ouyang wrote: > Hello Everyone, > > I recently came up with a spinlock algorithm that can adapt to > preemption, which you may be interested in. The intuition is to > downgrade a fair lock to an unfair lock automatically upon preemption, > and preserve the fairness otherwise. It is a guest side optimization, > and can be used as a complementary technique to host side optimizations > like co-scheduling and Pause-Loop Exiting. > > In my experiments, it improves VM performance by 5:32X on average, when > running on a non paravirtual VMM, and by 7:91X when running on a VMM > that supports a paravirtual locking interface (using a pv preemptable > ticket spinlock), when executing a set of microbenchmarks as well as a > realistic e-commerce benchmark. > > A detailed algorithm description can be found in my VEE 2013 paper, > Preemptable Ticket Spinlocks: Improving Consolidated Performance in the > Cloud > Jiannan Ouyang, John R. Lange > ouyang,jacklange@cs.pitt.edu > University of Pittsburgh > http://people.cs.pitt.edu/~ouyang/files/publication/preemptable_lock-ouyang-vee13.pdf 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 -- 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/