Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp259406lqg; Fri, 1 Mar 2024 04:39:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVQFVKeflJ6L4QDqisfwhqh8ELaPcnRGSh9H84kx66+vN8hv/yI8qtTTwyKaIPmnAS3RpYZpkgodpwXkrAxFZJM78sW/IXMOCGXUtxgAw== X-Google-Smtp-Source: AGHT+IFiPiNPQi/85lHoGl6FC5MP2EUxDBMKFXVntROVM1nG+7blgPWuFAcDZohhT/IXaPPXVY95 X-Received: by 2002:a17:906:4acb:b0:a3f:384a:73ab with SMTP id u11-20020a1709064acb00b00a3f384a73abmr1044702ejt.71.1709296743315; Fri, 01 Mar 2024 04:39:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709296743; cv=pass; d=google.com; s=arc-20160816; b=JmwmWg15Roih8+QA+9VxVRKK/5YhDiCNSoNktJ0bselYDQsXAb3zBMn5Cv9fkXOp+d WyMEirx9nrYILFdv7mDCpakcPpHJPnsRs+AQOHNfqhd17AuPM/WpXbGzyoyzEKGmoFqd ZJhIsoEcwzrWj4NjYlZuhM8lfTJvIshmNtz3sY3880L1+ogMa2G4o7pl5MZp2NTtiSsZ Ecq+fwDBH6YMy3SAdHRh2aiqoigO5fU+xwaQz/nIZUDS/tsfl3hNXvZ9YJeXAXN71s6g 2R9MwaUAehBeTPU+ORvbQVltPcqO4/TzWdz3/7girt9oAcwr9s0UULNB7Rp3SYDmsR6m SuGA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=xvQzYqM2/IhbJhv4vYl/ejMCNx3rv85KanRhSSdY2Vw=; fh=otbSJrICWqyYBlvP3fCZCBRnYKDwJVRGzwQL6nrD14w=; b=t53a71KGL0ch0zMfNbFkvI2gZ1M2v6FLKXKpbiuMsAeOxH3CRll8Y0tsfIiLuzz66T NMEQNOhL6rwotj9a4l+KB/BMPvJ1tlMHYBhCzDWBwVUSAKR9EY6LFUNxmvD01NCdpPQj AlxYhGK61nH3icTwivWgFnNf1oR7TXutINZvITswATi0xafBjooXSaPO6OUikgKBbTVP ol9qjWWvx2Rfp+dFQEqje5mU2vo38IhK0sjVggcaV7I+ivhfUIEG2dGtKV+z64LuR4UB 7ppS8l67d9L+QzUbjceV0YoGBpOBYFTu4oehjmHRGucep+6J0SnTYT9jWHvfZviijTVn Zvvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WioeGyKY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-88405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88405-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bk10-20020a170907360a00b00a442389d4a1si1398904ejc.542.2024.03.01.04.39.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 04:39:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WioeGyKY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-88405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88405-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0EA3B1F2634C for ; Fri, 1 Mar 2024 12:39:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B290320B3E; Fri, 1 Mar 2024 12:38:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="WioeGyKY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wTU3GIET" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CF8A3FB83; Fri, 1 Mar 2024 12:38:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709296732; cv=none; b=Q1dDW7qcBbEv+eqD49msYCjey2v0w4qPQe3lgPLgijErkW85LpDprlp4wFW6FZkdLSVrGv5WH2D0tEGb1CEP3XrGcV+jEqLCxsWBOto2g5GePvECA5fWjade8fyar0y8XGRDRJgAnddyo5I9OKi/PkQPETfPrxC1dDUy+9JjmhQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709296732; c=relaxed/simple; bh=3hJsk2U/SNP5TG0kNRfPTL8kuultS+lkSu1yYxZDFPo=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=tf/y93prroe0NLH9zAIVXS/BjiBK8cdQZOLwMUn3SZYKUN01u2aXE96L04lC0zX+lxuR6Vz6nhJJzYouyU2xGtSkFBU7QyBd28tv5wPb1Hcu0yK/PpxV+RKQw3dME/1gE0PFYVJh28Px3CCU2yLTt3zsojqFEAOcNSUTdHOgFvY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=WioeGyKY; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=wTU3GIET; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Fri, 01 Mar 2024 12:38:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1709296729; 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=xvQzYqM2/IhbJhv4vYl/ejMCNx3rv85KanRhSSdY2Vw=; b=WioeGyKYM8+RPOfuVZrYSQjLCIpy4/cL9B8AepgepOY8yoP45TZa01Rh6lfWhx+psiyXct 3s4vT3KAScyR+Bd0Mmo9xO4d86Vb89aELDC5J7LZCwgwZs9KYMGnmXZeOsNMo14Bturu17 wgpQmvtQv5wjzRkCLdDpUpfVtly0u+txgJnR/aYscU3GsQLTR3pg5/tsghmcLqSaDHFs0g zQS8lHCpMeH4y0F6ppGC4n5bLwpi9+OmbgMl3SBPz8NMPaIRj9DVX3k8l8c7YMNZToy+EI 6UF0XY1jG2v1EFcCfW82nbHBabUU2LeYDrJ33wf50XRryaQM00Cwahk4G8pVig== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1709296729; 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=xvQzYqM2/IhbJhv4vYl/ejMCNx3rv85KanRhSSdY2Vw=; b=wTU3GIETyNUfwdSFShM5R7G+7ZdX0zz7UqQizds7t1fe9Al92WfYsnTJdK9V3ycUIEPLcE uA0GxNj4gFWW3hDw== From: "tip-bot2 for Uros Bizjak" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] locking/rtmutex: Use try_cmpxchg_relaxed() in mark_rt_mutex_waiters() Cc: Uros Bizjak , Ingo Molnar , Peter Zijlstra , Waiman Long , Will Deacon , Thomas Gleixner , Linus Torvalds , "Paul E. McKenney" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240124104953.612063-1-ubizjak@gmail.com> References: <20240124104953.612063-1-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170929672826.398.6495674800219372460.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the locking/core branch of tip: Commit-ID: ce3576ebd62d99f79c1dc98824e2ef6d6ab68434 Gitweb: https://git.kernel.org/tip/ce3576ebd62d99f79c1dc98824e2ef6d6ab68434 Author: Uros Bizjak AuthorDate: Wed, 24 Jan 2024 11:49:53 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 01 Mar 2024 13:02:05 +01:00 locking/rtmutex: Use try_cmpxchg_relaxed() in mark_rt_mutex_waiters() Use try_cmpxchg() instead of cmpxchg(*ptr, old, new) == old. The x86 CMPXCHG instruction returns success in the ZF flag, so this change saves a compare after CMPXCHG (and related move instruction in front of CMPXCHG). Also, try_cmpxchg() implicitly assigns old *ptr value to "old" when CMPXCHG fails. There is no need to re-read the value in the loop. Note that the value from *ptr should be read using READ_ONCE() to prevent the compiler from merging, refetching or reordering the read. No functional change intended. Signed-off-by: Uros Bizjak Signed-off-by: Ingo Molnar Cc: Peter Zijlstra Cc: Waiman Long Cc: Will Deacon Cc: Thomas Gleixner Cc: Linus Torvalds Cc: Paul E. McKenney Link: https://lore.kernel.org/r/20240124104953.612063-1-ubizjak@gmail.com --- kernel/locking/rtmutex.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 4a10e8c..88d08ee 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -237,12 +237,13 @@ static __always_inline bool rt_mutex_cmpxchg_release(struct rt_mutex_base *lock, */ static __always_inline void mark_rt_mutex_waiters(struct rt_mutex_base *lock) { - unsigned long owner, *p = (unsigned long *) &lock->owner; + unsigned long *p = (unsigned long *) &lock->owner; + unsigned long owner, new; + owner = READ_ONCE(*p); do { - owner = *p; - } while (cmpxchg_relaxed(p, owner, - owner | RT_MUTEX_HAS_WAITERS) != owner); + new = owner | RT_MUTEX_HAS_WAITERS; + } while (!try_cmpxchg_relaxed(p, &owner, new)); /* * The cmpxchg loop above is relaxed to avoid back-to-back ACQUIRE