Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6270818yba; Wed, 1 May 2019 09:04:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+dGSbfa2Uk+QtdYbGdjuhq+buUuwW6oc2TFv/HRbBHDoKBxcBydn3mIxqZ8xNUsnvT5pl X-Received: by 2002:a65:6202:: with SMTP id d2mr74751354pgv.176.1556726658746; Wed, 01 May 2019 09:04:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556726658; cv=none; d=google.com; s=arc-20160816; b=F+UDXrawOb8cJhPsUViu9PTWvY+4oOXLXFx6mlzaVdAc36rczs2n3Vpp1h1T2ePEFm 1WKtk9AgO9u5SeLaWOpQ5sOSvjfx2a0D2qlq24DGQJwxB9p9YZll0M/DfCKwRSydyd/7 6ecfJdunkGzXsRkSvfQ0vCCEQoB3YM2qFI/+F7J/gdFNeDNPp9BeOb7evKLbT3013Br6 r6YX1A3+2r6iaQuEr/EKUQbIVo7fV2Mvdng9ffkX5JFzk7/b77Yn8eRkWGmLiycJLPG8 NOO2uLTIcRRuJ9uc9Vnkby8I0JMHfVULiW8JCsF6VhSqpmekfZA5Hqt0bq/Y0y9FAWd9 kR6g== 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=6g2UPhOM/U74chEw2b6ClD8/NytAnrA3Ned+SIOB7b8=; b=D88Pq4NcbqLmgEp4W4j36Ymz4TQGhthPf7ZZ1LtzkPEQVlmkLuFCDw1ScNK2+hWJ11 k4ldjacRcMOLfOwg+FvL8fSSwP/uhdOM0aNHvPs60Cq6CX13M6unIKw7i5fTiFO2GywQ 6b8HO26DpXpK76jKk4/IMi89z4Pq2a1wSrVncdUb5PfAtppmijDcoCI0KG8TpZgg3YLH E91MSIub+JhKU3LqMoKpbHDuPtRk5HypWKsin3Ao00JGzVWzOvHofF7Rl6dinOEpgI37 mpzkERx89r2iVqNyumZ9rpTuUqodmCq42w94ZoqO+xJWo7GiZwQA/EOxiiXXVgfn7OKx YVfA== 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 18si5979865pfo.13.2019.05.01.09.04.01; Wed, 01 May 2019 09:04:18 -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 S1726725AbfEAQBp (ORCPT + 99 others); Wed, 1 May 2019 12:01:45 -0400 Received: from foss.arm.com ([217.140.101.70]:33208 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726434AbfEAQBp (ORCPT ); Wed, 1 May 2019 12:01:45 -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 D73FBA78; Wed, 1 May 2019 09:01:44 -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 719143F719; Wed, 1 May 2019 09:01:43 -0700 (PDT) Date: Wed, 1 May 2019 17:01:40 +0100 From: Will Deacon To: Jan Glauber Cc: "catalin.marinas@arm.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Jayachandran Chandrasekharan Nair , peterz@infradead.org, torvalds@linux-foundation.org Subject: Re: [RFC] Disable lockref on arm64 Message-ID: <20190501160140.GC28109@fuggles.cambridge.arm.com> References: <20190429145159.GA29076@hc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190429145159.GA29076@hc> 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 Hi Jan, [+Peter and Linus, since they enjoy this stuff] On Mon, Apr 29, 2019 at 02:52:11PM +0000, Jan Glauber wrote: > I've been looking into performance issues that were reported for several > test-cases, for instance an nginx benchmark. Could you share enough specifics here so that we can reproduce the issue locally, please? That would help us in our attempts to develop a fix without simply disabling the option for everybody else. > It turned out the issue we have on ThunderX2 is the file open-close sequence > with small read sizes. If the used files are opened read-only the > lockref code (enabled by ARCH_USE_CMPXCHG_LOCKREF) is used. > > The lockref CMPXCHG_LOOP uses an unbound (as long as the associated > spinlock isn't taken) while loop to change the lock count. This behaves > badly under heavy contention (~25x retries for one cmpxchg to succeed > with 28 threads operating on the same file). In case of a NUMA system > it also behaves badly as the access from the other socket is much slower. It's surprising that this hasn't been reported on x86. I suspect their implementation of cmpxchg is a little more forgiving under contention. > The fact that on ThunderX2 cpu_relax() turns only into one NOP > instruction doesn't help either. On Intel pause seems to block the thread > much longer, avoiding the heavy contention thereby. NOPing out the yield instruction seems like a poor choice for an SMT CPU such as TX2. That said, the yield was originally added to cpu_relax() as a scheduling hint for QEMU. > With the queued spinlocks implementation I can see a major improvement > when I disable lockref. A trivial open-close test-case improves by > factor 2 while system time is decreasing also 2x. Looking at kernel compile > and dbench numbers didn't show any regression with lockref disabled. > > Can we simply disable lockref? Is anyone else seeing this issue? Is there > an arm64 platform that actually implements yield? There are two issues with disabling lockref like this: 1. It's a compile-time thing, so systems that would benefit from the code are unfairly penalised. 2. You're optimising for the contended case at the cost of the uncontended case, which should actually be the common case as well. Now, nobody expects contended CAS to scale well, so the middle ground probably involves backing off to the lock under contention, a bit like an optimistic trylock(). Unfortunately, that will need some tuning, hence my initial request for a reproducer. Cheers, Will