Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp706715ybm; Wed, 22 May 2019 10:08:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0n2ofytSmK5FdX1EY8PZP4mSpK5LOPtJ/Au1v+FRCHe487fwI7+PV9KrjkG4+4dS/z2ke X-Received: by 2002:a65:5c89:: with SMTP id a9mr92011032pgt.334.1558544907129; Wed, 22 May 2019 10:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558544907; cv=none; d=google.com; s=arc-20160816; b=bQJsZSUNoWLQO7GGZQEk8PSqkl1X0knvFMPFh7xgpXptYgH7kV5pbTxyz6C7k8eKkv 553eoWGLthfQDM2xJOviDgokOFOugNYvR80XarHXLSJYpTgkqRf+fUrN7SYJO3AxCW01 +8mslCPaw2nszvQmJbqIsZ75jqmViwmD+9JY8IeghznVVe6f+YMR9bKpo+uT86bAB7W+ olXNkZuuTVCTWja74Lxf60p7iPAK/8mPyv2veSML/mmy3LmpFlMENbTAGbUmT/ymzjZn lMfwwl80WphqtYPpq2FQb7wDottIDsmh82uS+U6zwTkfQ2jL270TO62KbHXZqeStwIvY AH0A== 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; bh=7f7gRQuJjOF6QO4fOq05i4KKB+qpMCP1y7xU17q6XvA=; b=WvafYDmUMgd3S3gW3Myt8owk24/ZCZB08mWby+mr1XRJZSjkEeavpht/lo0+5GhbZe IhUpNl3SThU4+yCpR0LWigRFzWscCEVQrDw/XJeffo6atI78xFz/MvpoxRT7H6x85fu+ fKCXR3403/uArnQRv4OE4lqiTscAsDbnNALwdefLY3rZuIcRWHC7MMaknmdBB0LrmxCL i9cEL3RzCNxurFMIQ/mCwBLN2sZ7T9IwycGu+xudM2J9E2Kk04ppm79caoRkwGE4nQuJ BE1GP/kA0ry7LNkMJEiSXnbcxvAgbk+SvDtxT9x83MmcRKfESMzH9GqG15bDGkyNjLA0 wZzg== ARC-Authentication-Results: i=1; mx.google.com; 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 i11si6086784plt.92.2019.05.22.10.08.10; Wed, 22 May 2019 10:08:27 -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; 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 S1729857AbfEVQEW (ORCPT + 99 others); Wed, 22 May 2019 12:04:22 -0400 Received: from foss.arm.com ([217.140.101.70]:54496 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728466AbfEVQEV (ORCPT ); Wed, 22 May 2019 12:04:21 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5E97B341; Wed, 22 May 2019 09:04:21 -0700 (PDT) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 035BE3F718; Wed, 22 May 2019 09:04:19 -0700 (PDT) Date: Wed, 22 May 2019 17:04:17 +0100 From: Will Deacon To: Ard Biesheuvel Cc: Jayachandran Chandrasekharan Nair , "catalin.marinas@arm.com" , Jan Glauber , Linus Torvalds , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [RFC] Disable lockref on arm64 Message-ID: <20190522160417.GF7876@fuggles.cambridge.arm.com> References: <20190429145159.GA29076@hc> <20190502082741.GE13955@hc> <20190502231858.GB13168@dc5-eodlnx05.marvell.com> <20190506061100.GA8465@dc5-eodlnx05.marvell.com> <20190506181039.GA2875@brain-police> <20190518042424.GA28517@dc5-eodlnx05.marvell.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1+86 (6f28e57d73f2) () Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 18, 2019 at 12:00:34PM +0200, Ard Biesheuvel wrote: > On Sat, 18 May 2019 at 06:25, Jayachandran Chandrasekharan Nair > wrote: > > > > On Mon, May 06, 2019 at 07:10:40PM +0100, Will Deacon wrote: > > > On Mon, May 06, 2019 at 06:13:12AM +0000, Jayachandran Chandrasekharan Nair wrote: > > > > Perhaps someone from ARM can chime in here how the cas/yield combo > > > > is expected to work when there is contention. ThunderX2 does not > > > > do much with the yield, but I don't expect any ARM implementation > > > > to treat YIELD as a hint not to yield, but to get/keep exclusive > > > > access to the last failed CAS location. > > > > > > Just picking up on this as "someone from ARM". > > > > > > The yield instruction in our implementation of cpu_relax() is *only* there > > > as a scheduling hint to QEMU so that it can treat it as an internal > > > scheduling hint and run some other thread; see 1baa82f48030 ("arm64: > > > Implement cpu_relax as yield"). We can't use WFE or WFI blindly here, as it > > > could be a long time before we see a wake-up event such as an interrupt. Our > > > implementation of smp_cond_load_acquire() is much better for that kind of > > > thing, but doesn't help at all for a contended CAS loop where the variable > > > is actually changing constantly. > > > > Looking thru the perf output of this case (open/close of a file from > > multiple CPUs), I see that refcount is a significant factor in most > > kernel configurations - and that too uses cmpxchg (without yield). > > x86 has an optimized inline version of refcount that helps > > significantly. Do you think this is worth looking at for arm64? > > > > I looked into this a while ago [0], but at the time, we decided to > stick with the generic implementation until we encountered a use case > that benefits from it. Worth a try, I suppose ... > > [0] https://lore.kernel.org/linux-arm-kernel/20170903101622.12093-1-ard.biesheuvel@linaro.org/ If JC can show that we benefit from this, it would be interesting to see if we can implement the refcount-full saturating arithmetic using the LDMIN/LDMAX instructions instead of the current cmpxchg() loops. Will