Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5666330ybi; Tue, 4 Jun 2019 10:05:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWuEnx8ovWzmqQ1FNEPLLs0opcd5jmnlvS7Ddrwr3cMn7mvVJqPYkc91Xv0G7s+EHV08dJ X-Received: by 2002:a63:7ca:: with SMTP id 193mr19259703pgh.240.1559667925694; Tue, 04 Jun 2019 10:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559667925; cv=none; d=google.com; s=arc-20160816; b=AkNL6ZfFOZ1WltFbpA9jGq3Y6Rb3kGNbABKJboF5RcXvb/ukP7YABX9UWfJtHIeZMC jP3mC2CNAaeyrrVAveGRtY97ZQ8+mJyzfNZenC95uKoUy2S1F5JAJAVZZ7KS7jZMEGLo w8Hf81noTW1Um9IRKNjIfuzkqkllRjDkRwxYreP/2WGyQFgywbE+j9bBoITBYjvcZ1VU fH0MxFPEyuqb3wOTJSfRPydM/uOzz9mASEduKbLNC1f2EHSV8Umx/vweRoN4W/+Luiwg rQSD5a8i1JyiDt0aIYLpmFWpFcJ1C1r+kcn3Jj7brWh7XJHc4pv6pREqaBRaZp9kuJZK osOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cOmAcXP3xslB9SN+5584hLRHldJIouXYPbVgjk2nYSM=; b=HLc5WOH3Z+ZzmO3If/1uskeZtfdr3bUJE19G3M+joB4BhL9ya544021qQgFVUcyVRQ A/RasiaH6+AtvN+PD9zzYPg9LylXRjayn8vmQddePlLpLgJMdFu8K8u4U5V7VIYuzA6g LbGn3TxAlnBmE50as8HY0zwc6xdMOYxjBRu84GXpTHokMu/cOKe9gAq+IIu6uuvwLJfb +dGBHlR+Shpkd41zD3OITusnxwYtnzEvTjzikXcBoaR+CMFiAl1hoANFBIV4ZOzP7ABD lX2OUH4rVnGabFq6MP2ubwSBTzjJNTNxlx42kXZObeL99DK8aHq9VNYicxRNFwLeO4aG rVJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=iPXATZBt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10si22733319pjr.102.2019.06.04.10.05.08; Tue, 04 Jun 2019 10:05:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=iPXATZBt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727987AbfFDRCo (ORCPT + 99 others); Tue, 4 Jun 2019 13:02:44 -0400 Received: from merlin.infradead.org ([205.233.59.134]:40946 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727716AbfFDRCo (ORCPT ); Tue, 4 Jun 2019 13:02:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cOmAcXP3xslB9SN+5584hLRHldJIouXYPbVgjk2nYSM=; b=iPXATZBtcyo8M05+4EfxuLU+b mk10UIWmgoSKPjpOIFJx92Ro5KTGoGDRD2cHYYIXwj5ONEuphhuEINydK47JTVs8Wzw71hfn19MC7 JGHMuVBbd6AmmoHBxq5ZB6ZNL6fuZkwyHburri88Vbs8wJrfL5CuNwDBUfXT8tWUq7BkFHRSLeGNv IE+1IWJwOOAqwPMdGfWwcFpeCIOECFGQqgbsAC6kRoiebf9aOMkKwd9EOniVOijd14p1BOlE/xftP RzsPBhT15AButzFfThpFJFD3MQLX4DT8bVxDcnvInzRlPx1qdlJoOCF23F3vX7mLE3OriUii9bcaR 7yVJlD5cw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hYCpJ-0007Zn-5N; Tue, 04 Jun 2019 17:02:21 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A2C0220114D92; Tue, 4 Jun 2019 19:02:18 +0200 (CEST) Date: Tue, 4 Jun 2019 19:02:18 +0200 From: Peter Zijlstra To: Waiman Long Cc: Ingo Molnar , Will Deacon , Thomas Gleixner , Borislav Petkov , "H. Peter Anvin" , linux-kernel@vger.kernel.org, x86@kernel.org, Davidlohr Bueso , Linus Torvalds , Tim Chen , huang ying Subject: Re: [PATCH v8 17/19] locking/rwsem: Merge owner into count on x86-64 Message-ID: <20190604170218.GE3419@hirez.programming.kicks-ass.net> References: <20190520205918.22251-1-longman@redhat.com> <20190520205918.22251-18-longman@redhat.com> <20190604094537.GK3402@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 04, 2019 at 11:47:21AM -0400, Waiman Long wrote: > On 6/4/19 5:45 AM, Peter Zijlstra wrote: > > On Mon, May 20, 2019 at 04:59:16PM -0400, Waiman Long wrote: > >> With separate count and owner, there are timing windows where the two > >> values are inconsistent. That can cause problem when trying to figure > >> out the exact state of the rwsem. For instance, a RT task will stop > >> optimistic spinning if the lock is acquired by a writer but the owner > >> field isn't set yet. That can be solved by combining the count and > >> owner together in a single atomic value. > > I just realized we can use cmpxchg_double() here (where available of > > course). > > Does the 2 doubles need to be 128-bit aligned to use cmpxchg_double()? I > don't think we can guarantee that unless we explicitly set this alignment. It does :/ and yes, we'd need to play games with __align(2*sizeof(long)) and such.