Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2929902rwb; Fri, 16 Dec 2022 08:08:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf5nLUslmNsxPV1IprOFGwXIyn8Y3QDZasUw5L/6egy6bGQq7Kl/UmxeEKlRNXIRQyENO1dW X-Received: by 2002:a17:906:2993:b0:7c0:f7b0:95d3 with SMTP id x19-20020a170906299300b007c0f7b095d3mr25477290eje.36.1671206934357; Fri, 16 Dec 2022 08:08:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671206934; cv=none; d=google.com; s=arc-20160816; b=JfpSuke7UtfiS+Jx5CeYy7X0VEiw7p6cr1aBf5mXIkl2cAbNH7sfL0/52HpRZ2ueAR 3GhhuehJP23UKIvMjqf+Uc+XGilQHhFVWjwyAc8EJBtcHUoPQByas/eEn0y0gfmvZhUy 3wGBcOpHdLqsga4NyoG/raRvHCp8BqyY1P3uk+5hXnmcrdly/JhflMm2FkeV+iGtXYIV Mbb2s42cNOMbQd3gW5LfJLhHlfQo+6h7jao4AwkwmWSIwEqVzuNgKl3AXaq5RN8+8mQs F1cow3VHfClxwTGZC0BJvyCnPBIRmOve8Hz+T5Me9Y0nhwUNm9+zfdJFtaAlbT8z0TOZ h82A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=PibLVIS0eAdq8ZPh/htC3ak6Mjp0rOztfykOjP2k8Kk=; b=bijT6CtxDBfCi0doNbn9eE1D0JVXAg6rRk5ogVeG02ib1IgASu48RSFODxky3g148B mKuea1afc6E9ouoNUueZZ4vQdaMCifkeQ81lQzoh4+HbyVvFnqBjxvXFhGyc6bhGA42f lsChIzY+hppNBkIdRoyPPxE3dBBpzmctLvoeG1DwpQir562grV2YwMRh85JoY6JdrL1c KMU7VyYNjxeWfguj7NaNH7RAvT40JwcgxAj8DueQJ8EXzISVo7frheC1ZlXV4nLF4LOO iyp1pa2oPuwYAaVZTPWJebMyJiS77dCfk8OobzV2qDQXuHUQ5KXtjIB20G26bsGA9ybG YuQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JQO9cSRJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa10-20020a1709076d0a00b007a7fc67c880si3153430ejc.71.2022.12.16.08.08.38; Fri, 16 Dec 2022 08:08:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JQO9cSRJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231924AbiLPP6p (ORCPT + 68 others); Fri, 16 Dec 2022 10:58:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231609AbiLPP6V (ORCPT ); Fri, 16 Dec 2022 10:58:21 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CEDA6DCCF; Fri, 16 Dec 2022 07:58:11 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AD9CB62166; Fri, 16 Dec 2022 15:58:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0862EC433EF; Fri, 16 Dec 2022 15:58:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671206290; bh=Hwl7jph0tUeSs3x14knC3ALms+GSrlpG4Qg8RqqGh4c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JQO9cSRJpvu2dcIlJ4yg/aMix6YvsEDExgowcKYb6pVxMOO33Q2y+ml6SUYvizbLp 19Vb3+EXD0ENq1kzG5P18IVWKWWZVGxD2CuJ2QibpjqRPkSZQ14QP75McqVSDTa6it JVO+C1vOjVpR3HN35ypWQ12bjA0b1HUd/55/azTLN0WvsbOf+qCwzXIjTMPdLiJ7ME f7ptXxtkd0eoUy39p7enGm7kOQk5ThFMg7a3KeA9CX0l9IW0IQD6oUbETUyUNAs5by 7eX03ec5RuVS1/X+fU7rJy1B5OJ8DTxHmt8RAsx+kb3aGu8nIEt+Go2VHz+Oautod+ OSAzKfd3nuO5A== Date: Fri, 16 Dec 2022 15:58:04 +0000 From: Will Deacon To: Mel Gorman Cc: Sebastian Andrzej Siewior , Peter Zijlstra , Jan Kara , Thomas Gleixner , Ingo Molnar , Waiman Long , Boqun Feng , Pierre Gondois , Steven Rostedt , Catalin Marinas , Davidlohr Bueso , LKML , Linux-RT Subject: Re: [PATCH] rtmutex: Add acquire semantics for rtmutex lock acquisition Message-ID: <20221216155803.GB8949@willie-the-truck> References: <20221202100223.6mevpbl7i6x5udfd@techsingularity.net> <20221202150158.xzgovoy7wuic6vvk@techsingularity.net> <20221216111412.GA8666@willie-the-truck> <20221216135548.itw2xrqbvuldk35y@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221216135548.itw2xrqbvuldk35y@techsingularity.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey Mel, On Fri, Dec 16, 2022 at 01:55:48PM +0000, Mel Gorman wrote: > On Fri, Dec 16, 2022 at 11:14:12AM +0000, Will Deacon wrote: > > > diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c > > > index 35212f260148..af0dbe4d5e97 100644 > > > --- a/kernel/locking/rtmutex.c > > > +++ b/kernel/locking/rtmutex.c > > > @@ -238,6 +238,13 @@ static __always_inline void mark_rt_mutex_waiters(struct rt_mutex_base *lock) > > > owner = *p; > > > } while (cmpxchg_relaxed(p, owner, > > > owner | RT_MUTEX_HAS_WAITERS) != owner); > > > + > > > + /* > > > + * The cmpxchg loop above is relaxed to avoid back-to-back ACQUIRE > > > + * operations in the event of contention. Ensure the successful > > > + * cmpxchg is visible. > > > + */ > > > + smp_mb__after_atomic(); > > > > Could we use smp_acquire__after_ctrl_dep() instead? > > > > It's might be sufficient but it's not as obviously correct. It lacks an > obvious pairing that is definitely correct but the control dependency > combined with the smp_acquire__after_ctrl_dep *should* be sufficient > against the lock fast path based on the available documentation. However, > I was unable to convince myself that this is definitely correct on all CPUs. I'm reasonably confident (insofar as you can be confident about any of this) that it will work, and on arm64 it will result in a slightly cheaper instruction being emitted. However, I just chimed in because you asked for my opinion so I'm absolutely fine with whichever direction you prefer to take! > Given that arm64 was trivial to crash on PREEMPT_RT before the patch > (hackbench pipes also triggers the same problem), I'm reluctant to try and > be too clever particularly as I didn't have a reproducer for a problem in > this specific path. If someone can demonstrate a reasonable case where > smp_mb__after_atomic() is too heavy and document that it can be safely > relaxed then great. At least if that relaxing is wrong, there will be a > bisection point between the fix and the reintroduction of damage. I guess bigeasy can give the weaker barrier a try if he has the time, but otherwise we can leave the change as-is. Cheers, Will