Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753437AbbBKShX (ORCPT ); Wed, 11 Feb 2015 13:37:23 -0500 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:37326 "EHLO e23smtp04.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753004AbbBKShV (ORCPT ); Wed, 11 Feb 2015 13:37:21 -0500 Message-ID: <54DBA199.8070708@linux.vnet.ibm.com> Date: Thu, 12 Feb 2015 00:08:17 +0530 From: Raghavendra K T Organization: IBM User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Oleg Nesterov CC: Linus Torvalds , Jeremy Fitzhardinge , Sasha Levin , Davidlohr Bueso , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Peter Anvin , Konrad Rzeszutek Wilk , Paolo Bonzini , Paul McKenney , Waiman Long , Dave Jones , the arch/x86 maintainers , Paul Gortmaker , Andi Kleen , Jason Wang , Linux Kernel Mailing List , KVM list , virtualization , xen-devel@lists.xenproject.org, Rik van Riel , Christian Borntraeger , Andrew Morton , Andrey Ryabinin Subject: Re: [PATCH] x86 spinlock: Fix memory corruption on completing completions References: <1423234148-13886-1-git-send-email-raghavendra.kt@linux.vnet.ibm.com> <54D7D19B.1000103@goop.org> <54D87F1E.9060307@linux.vnet.ibm.com> <20150209120227.GT21418@twins.programming.kicks-ass.net> <54D9CFC7.5020007@linux.vnet.ibm.com> <20150210132634.GA30380@redhat.com> <54DB384A.2050305@linux.vnet.ibm.com> <20150211173838.GB28689@redhat.com> In-Reply-To: <20150211173838.GB28689@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15021118-0013-0000-0000-000000CDCA52 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1643 Lines: 50 On 02/11/2015 11:08 PM, Oleg Nesterov wrote: > On 02/11, Raghavendra K T wrote: >> >> On 02/10/2015 06:56 PM, Oleg Nesterov wrote: >> >>> In this case __ticket_check_and_clear_slowpath() really needs to cmpxchg >>> the whole .head_tail. Plus obviously more boring changes. This needs a >>> separate patch even _if_ this can work. >> >> Correct, but apart from this, before doing xadd in unlock, >> we would have to make sure lsb bit is cleared so that we can live with 1 >> bit overflow to tail which is unused. now either or both of head,tail >> lsb bit may be set after unlock. > > Sorry, can't understand... could you spell? > > If TICKET_SLOWPATH_FLAG lives in .head arch_spin_unlock() could simply do > > head = xadd(&lock->tickets.head, TICKET_LOCK_INC); > > if (head & TICKET_SLOWPATH_FLAG) > __ticket_unlock_kick(head); > > so it can't overflow to .tail? > You are right. I totally forgot we can get rid of tail operations :) > > And we we do this, probably it makes sense to add something like > > bool tickets_equal(__ticket_t one, __ticket_t two) > { > return (one ^ two) & ~TICKET_SLOWPATH_FLAG; > } > Very nice idea. I was tired of ~TICKET_SLOWPATH_FLAG usage all over in the current (complex :)) implementation. These two suggestions helps alot. > and change kvm_lock_spinning() to use tickets_equal(tickets.head, want), plus > it can have more users in asm/spinlock.h. -- 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/