From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752714AbdHNPBO convert rfc822-to-8bit (ORCPT ); Mon, 14 Aug 2017 11:01:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51874 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751569AbdHNPBN (ORCPT ); Mon, 14 Aug 2017 11:01:13 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E8FE4128287 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=longman@redhat.com Subject: Re: [RESEND PATCH v5] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs To: Will Deacon , Peter Zijlstra Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Pan Xinhui , Boqun Feng , Andrea Parri References: <1495633108-12818-1-git-send-email-longman@redhat.com> <20170810115034.ie65wfxepiq6noew@hirez.programming.kicks-ass.net> <945c28c3-5779-c8c8-13bb-40477abd1f0e@redhat.com> <20170810161524.2wzocpcxrliy7nt6@hirez.programming.kicks-ass.net> <7cb318a8-d5b9-0019-a537-1720fc5222cc@redhat.com> <73daa6e6-537e-b0ce-e1e0-7afa75334509@redhat.com> <20170811090601.2owslxi4lgv3kond@hirez.programming.kicks-ass.net> <20170814120121.GA24249@arm.com> From: Waiman Long Organization: Red Hat Message-ID: Date: Mon, 14 Aug 2017 11:01:10 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20170814120121.GA24249@arm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 14 Aug 2017 15:01:13 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/14/2017 08:01 AM, Will Deacon wrote: > On Fri, Aug 11, 2017 at 11:06:01AM +0200, Peter Zijlstra wrote: >> On Thu, Aug 10, 2017 at 02:18:30PM -0400, Waiman Long wrote: >>> On 08/10/2017 12:22 PM, Waiman Long wrote: >>>> On 08/10/2017 12:15 PM, Peter Zijlstra wrote: >>>>> Might as well do an explicit: >>>>> >>>>> smp_mb__before_atomic() >>>>> cmpxchg_relaxed() >>>>> smp_mb__after_atomic() >>>>> >>>>> I suppose and not introduce new primitives. >>> I think we don't need smp_mb__after_atomic(). The read has to be fully >>> ordered, but the write part may not need it as the control dependency of >>> the old value should guard against incorrect action. Right? >> You'd think that, but IIRC there was something funny about using the SC >> return flag for control dependencies. Will? > Yeah, that's right, you can't use the STXR status flag to create control > dependencies. > > Will Actually, the code sequence that I plan to use are: smp_mb__before_atomic(); if (cmpxchg_relaxed(&pn->state, vcpu_halted, vcpu_hashed) != vcpu_halted) return; WRITE_ONCE(l->locked, _Q_SLOW_VAL); (void)pv_hash(lock, pn); I am planning to use the comparison of the returned value (pn->state) again vcpu_halted as the control dependency. I don't see how the status flag of STXR is affecting this. Cheers, Longman