Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5445066ybi; Wed, 12 Jun 2019 02:36:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWnIhAVLKXPhPkvEQWH5u1tesLNrmBrxG7hLg1R2GcBuSKAiq4JMVDkMumZ/UlFnkRvFyX X-Received: by 2002:a63:2206:: with SMTP id i6mr22241826pgi.349.1560332216263; Wed, 12 Jun 2019 02:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560332216; cv=none; d=google.com; s=arc-20160816; b=sREXFCIrwHqv7T5+1ryaP4jwuL4dyCGcpG7gWcIuQiBIRRzBl+pD/HkYCdCxefEiaD 80iwIqnYkY37u6c3xK+cGV48r51jYjdEz7U9gaqOzZigiipWiMl1CvDZNjyj/2Kgamz/ 76JD5ZZNxFeaBvghI0ldYcammvNu6I0bucuPhGvrNm4TcRXqFFQWzDun3y7AzEGurg6E t0DPixxt13SowkO9V/w/0Nkbxwi32ug3cPdliBsinnGv+BpsOfcWv8/hTl23PGAeJs4Z jmi6iSAL5Dfat4NYjv8tXI0sSA+H30Pm7rqGDSNHzQ/8pPFAwOw/R7tnJhWK9E7kFEYu WFdg== 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=CiLuE/WMSMkRy09k6UM0zfghMEgtU3AZQZR919ql4rg=; b=soRgn8ZAHOnOmRB7KxaKAAjhJps3CTS+kHGZLdDIkFLMY0M1ZNxxBs94KbWwlOTGYu 2m1bldGdLKfvZ1IqblkrQRGTe/tKv9yAZdgJS3tCcYtCwtWEy2aerzG94TyRA8gGmfaC OSgx2b8H9DDmRhbSQvLIcvjfYzM0epCuQyM6o31FZNKB4zn5Tt8pD+I1F61ThnJnsNN7 60iQOv0rl4KQYEDHz/ABv4Vj6ZnESEL4uHwbbuJVSLFKiQ0u6y7eq/ww/JLzDZAPUPlk 03+V+lT7SHHqKU5V9S6Xg9KYdcLRy215fKJwUIlwsoXiNRQADXxJfg3Uv5/L5ZW1AFQO lXXg== 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 l11si15421470plb.414.2019.06.12.02.36.40; Wed, 12 Jun 2019 02:36:56 -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 S2437226AbfFLJcC (ORCPT + 99 others); Wed, 12 Jun 2019 05:32:02 -0400 Received: from foss.arm.com ([217.140.110.172]:48454 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436605AbfFLJcC (ORCPT ); Wed, 12 Jun 2019 05:32:02 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A427028; Wed, 12 Jun 2019 02:32:01 -0700 (PDT) Received: from brain-police (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C6C563F246; Wed, 12 Jun 2019 02:31:59 -0700 (PDT) Date: Wed, 12 Jun 2019 10:31:53 +0100 From: Will Deacon To: Jayachandran Chandrasekharan Nair Cc: Ard Biesheuvel , "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: <20190612093151.GA11554@brain-police> References: <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> <20190522160417.GF7876@fuggles.cambridge.arm.com> <20190612040933.GA18848@dc5-eodlnx05.marvell.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190612040933.GA18848@dc5-eodlnx05.marvell.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi JC, On Wed, Jun 12, 2019 at 04:10:20AM +0000, Jayachandran Chandrasekharan Nair wrote: > On Wed, May 22, 2019 at 05:04:17PM +0100, Will Deacon wrote: > > 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: > > > > 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. > > Now that the lockref change is mainline, I think we need to take another > look at this patch. Before we get too involved with this, I really don't want to start a trend of "let's try to rewrite all code using cmpxchg() in Linux because of TX2". At some point, the hardware needs to play ball. However... Ard's refcount patch was about moving the overflow check out-of-line. A side-effect of this, is that we avoid the cmpxchg() operation from many of the operations (atomic_add_unless() disappears), and it's /this/ which helps you. So there may well be a middle ground where we avoid the complexity of the out-of-line {over,under}flow handling but do the saturation post-atomic inline. I was hoping we could use LDMIN/LDMAX to maintain the semantics of REFCOUNT_FULL, but now that I think about it I can't see how we could keep the arithmetic atomic in that case. Hmm. Whatever we do, I prefer to keep REFCOUNT_FULL the default option for arm64, so if we can't keep the semantics when we remove the cmpxchg, you'll need to opt into this at config time. Will