Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3149200pxb; Sat, 9 Oct 2021 03:10:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV0C3k78ZvNSCjLb7v1SZdgjROADoF0HG9jpDuqZoYcxu4IUeKmzff5iJsheiN6tBo4B37 X-Received: by 2002:a17:906:39d8:: with SMTP id i24mr10831252eje.49.1633774230473; Sat, 09 Oct 2021 03:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633774230; cv=none; d=google.com; s=arc-20160816; b=sJz/2nKerfbgx31DXhXMuqGTd6dGh7dIKcG5k+EWVko1ms+KSpAU7JlQy4kocNiZ84 U3x3pf3Ihw/6H3xieDBU1d4BtSHEuCuZzw2Nzsf/OpXxcAFyzgu7l+ZyPfGfbTeTiCIr t2ptqD/sSY0PUVjRRF/nKCe6TJIp/6pBMFRrbtkezuk+Xr4bfjGM8edq1Jn+yEvwz7gL AgrtAPq8VwUXwG9ByzHYSFaXmjhzDSKtfnrun1GuBrsSaPFDLnk09WPdsFGQNKBAzWnc LrKIvMU8tTUsk2n16SGm2pc79IM0M7XT4VNPhmN/mAz8kC01fI4R4i6rTFuCWUyg/9GV hgVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=g3pCBjl2e8Da4p/V5bnaKUuPbwpFUMahEuvVM8sY/DQ=; b=HMgWsuyK29lmDBc6s4WINM0IeesXOuuhS96vUWRrn2kbPYUpEFvyegJIDbWOUkw9b7 +Ps6p6rX/Q0CCuCdYypvexj7FFk2jnUPmqEAPmNPRTPs3W2D2/yLCplyU6MST13Eaqc0 XwJT5eJ/nJmhVaX8beC39IgtoKYM2PXRKHNBR1dEHDnrocPXd/uA8k+cov1fA5UcGeTv R1NKXCSwJGaBq59Z6+D5zp09D6KIzKN+Yh2SwFpVa86i3OmHee7Oxf8ZxRtp3JZd6frq PBIrLfWtqyGFrWI3LMIBc1Uyka0PbyrcFAfQJSRrZxLjFWZZy9DfRWtXXeLUc4xibQjr el8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JWvu76gd; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=oUt1K8Hk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si3167211eds.72.2021.10.09.03.10.03; Sat, 09 Oct 2021 03:10:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JWvu76gd; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=oUt1K8Hk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244753AbhJIKJ7 (ORCPT + 99 others); Sat, 9 Oct 2021 06:09:59 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:49538 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244657AbhJIKJR (ORCPT ); Sat, 9 Oct 2021 06:09:17 -0400 Date: Sat, 09 Oct 2021 10:07:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1633774040; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g3pCBjl2e8Da4p/V5bnaKUuPbwpFUMahEuvVM8sY/DQ=; b=JWvu76gdJK4gakbpZXUsiXssoLjGVFF68PWDzVDaz+bvWmiIjCu8+/rZIQiwFuIwxSelYH QDxsfEHwOs2HAi+0A9k+V5KlX5dcRjSH5G5JIsrwAkvxh6NninVQOg7LYqa93yNUanmfoq +hOqUxrngflxDDozIV7TvyCLiyVI5ue+cp76hkXI/on+bQlFuKxc9D5BnDIz/LhNlnKMz4 zko9ZhKNpTH2fgwuQrqGUsIGBifR9YyDmlxJwivZWL9JvOR7wUFlo7QovKd0EvpAQniUEm hiHaXYstA3G7yJ2gJVL2npE+acokJ1HOb3x/AbEHsjUPoWJ0yynPNBnidC5T3Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1633774040; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g3pCBjl2e8Da4p/V5bnaKUuPbwpFUMahEuvVM8sY/DQ=; b=oUt1K8HkA3xxfbv3X0XycH3RojsFD3JBVyND763c59RhE1NYAR9spqB0kdyWQlzdgV23D1 XoaxaLLdS5tarWCQ== From: "tip-bot2 for Davidlohr Bueso" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] locking/rwbase: Optimize rwbase_read_trylock Cc: Davidlohr Bueso , "Peter Zijlstra (Intel)" , Waiman Long , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210920052031.54220-2-dave@stgolabs.net> References: <20210920052031.54220-2-dave@stgolabs.net> MIME-Version: 1.0 Message-ID: <163377403924.25758.18240935726439029694.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the locking/core branch of tip: Commit-ID: c78416d122243c92992a1d1063f17ddd0bc80e6c Gitweb: https://git.kernel.org/tip/c78416d122243c92992a1d1063f17ddd0bc80e6c Author: Davidlohr Bueso AuthorDate: Sun, 19 Sep 2021 22:20:30 -07:00 Committer: Peter Zijlstra CommitterDate: Thu, 07 Oct 2021 13:51:07 +02:00 locking/rwbase: Optimize rwbase_read_trylock Instead of a full barrier around the Rmw insn, micro-optimize for weakly ordered archs such that we only provide the required ACQUIRE semantics when taking the read lock. Signed-off-by: Davidlohr Bueso Signed-off-by: Peter Zijlstra (Intel) Acked-by: Waiman Long Link: https://lkml.kernel.org/r/20210920052031.54220-2-dave@stgolabs.net --- kernel/locking/rwbase_rt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/locking/rwbase_rt.c b/kernel/locking/rwbase_rt.c index 15c8110..6fd3162 100644 --- a/kernel/locking/rwbase_rt.c +++ b/kernel/locking/rwbase_rt.c @@ -59,8 +59,7 @@ static __always_inline int rwbase_read_trylock(struct rwbase_rt *rwb) * set. */ for (r = atomic_read(&rwb->readers); r < 0;) { - /* Fully-ordered if cmpxchg() succeeds, provides ACQUIRE */ - if (likely(atomic_try_cmpxchg(&rwb->readers, &r, r + 1))) + if (likely(atomic_try_cmpxchg_acquire(&rwb->readers, &r, r + 1))) return 1; } return 0; @@ -187,7 +186,7 @@ static inline void __rwbase_write_unlock(struct rwbase_rt *rwb, int bias, /* * _release() is needed in case that reader is in fast path, pairing - * with atomic_try_cmpxchg() in rwbase_read_trylock(), provides RELEASE + * with atomic_try_cmpxchg_acquire() in rwbase_read_trylock(). */ (void)atomic_add_return_release(READER_BIAS - bias, &rwb->readers); raw_spin_unlock_irqrestore(&rtm->wait_lock, flags);