Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2859054rwb; Fri, 20 Jan 2023 08:12:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXv6MMEfGfIVDI7za2GDAmXFYF7/XJYmlUR6MP+fFyC9IHVMrQSCGd2T8SWnfpxaaZBEO8wc X-Received: by 2002:a17:906:c58:b0:78d:f456:1ed0 with SMTP id t24-20020a1709060c5800b0078df4561ed0mr29302344ejf.33.1674231122106; Fri, 20 Jan 2023 08:12:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674231122; cv=none; d=google.com; s=arc-20160816; b=qjwz3ORa7IJiqHHRZsWPyOWCbdUEZosP/FXVNCxIfBm0Vo3Ir8YrQKdQAAouq8yp81 GWNwfGHWhbFqB5amYweyJFgXOQzGCIHzod+4W7crqBEOo4r+WUdRWhkY2XEqoraGs/jP InwM1kp92X3gZwCONhBZyH6GoarA+k5X3Q9WSv+GgTpr7SYPPhwlh1W8JVbA636wjyLI 9LbPZIKZ5mw7gxrE7t214NRsPj4YRDbDLQof3uIKkXkGGrrs5frlEfo23FCVQ4pKxq2h JC/m23GcW0C9A/HzhzvBZNZ/9vpMbOQMfIs3suePI9ExthI/G0Y1aNFwoOvRxo/pgrls 4ANg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=flb/jOBpobT5YaEWeepMt4aZCcpp4XVzZ0X9x1uhANk=; b=E6Erk7E7NNLwp0sP5ooq14TlKH48dfQdip7CxIEMjTYbZ5g7WnYS+j6Y7np98rdIDn x3HMy0KDGHhluKUXwMCVKTOg3H5NDX8xY3KtsXTvOFvorZhEYHzOG4Psn5IBiFTvv7ks pshT89BxQJfMCj8DYLmSm+LxBmvm14OOmmSpTBKG2Bb0V24xGVTLiYgzguBK3yD+dBK3 PcdiUdLW9Po9/3MDjnvb8le8ybskeYKj2FeLo9qiJ3j/gS3l/6znZZ6kq60jHuoNEBSU Wu1YxUuKd7bL3CFEIiOwXAmzH6p6n8BS4TQyy7sg4aZcjDlvdhAxfO2TQF3TjPncjxb1 J9Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YTzNIkRB; 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 hr7-20020a1709073f8700b0086bfaaa9ee1si13307699ejc.198.2023.01.20.08.11.49; Fri, 20 Jan 2023 08:12:02 -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=YTzNIkRB; 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 S231618AbjATPzP (ORCPT + 50 others); Fri, 20 Jan 2023 10:55:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231687AbjATPzF (ORCPT ); Fri, 20 Jan 2023 10:55:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37F82707D8; Fri, 20 Jan 2023 07:54:45 -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 1551A61FDA; Fri, 20 Jan 2023 15:54:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C483C433D2; Fri, 20 Jan 2023 15:54:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674230079; bh=Lyzp89/oUt/Y+HS78U5nbaABso705ppG1wwrowaJd5k=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=YTzNIkRBatAMAnoFrKr6O9Jwkv2d6st4V+W1ZmWuVxiNC87cMqqtyzuJVuQLhRLtw cKGiFR7L6u/2Musmn3K/MvZQOXigdfi99RohHyjZ0lPUQvCjoIU30a8d7AmPQmjzXh z3ZIEhVxS/pNlQC72D2tLvOw2PV0BBNMHjNI2VlvsTYcADEAmL1m/rk5i/GTu00hGZ WFGLKP2xM1WzToGPlJhHpgVlv8PWfmV4G1wVLsteXbW17lyd2vOvYx8hy/QU/EJc7A 3QNBo6RxY08+fPmZ7HVrmOSYQSdV5WmdKMvVG1oJlJ8G1kK2u7fyQBkHy0ozLjYoGy 0bHMZbSjgQluQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 104335C0DFC; Fri, 20 Jan 2023 07:54:39 -0800 (PST) Date: Fri, 20 Jan 2023 07:54:39 -0800 From: "Paul E. McKenney" To: Arjan van de Ven Cc: Hernan Ponce de Leon , peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, akpm@osdl.org, tglx@linutronix.de, joel@joelfernandes.org, stern@rowland.harvard.edu, diogo.behrens@huawei.com, jonas.oberhauser@huawei.com, linux-kernel@vger.kernel.org, Hernan Ponce de Leon , stable@vger.kernel.org Subject: Re: [PATCH] Fix data race in mark_rt_mutex_waiters Message-ID: <20230120155439.GI2948950@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20230120135525.25561-1-hernan.poncedeleon@huaweicloud.com> <562c883b-b2c3-3a27-f045-97e7e3281e0b@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <562c883b-b2c3-3a27-f045-97e7e3281e0b@linux.intel.com> 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 On Fri, Jan 20, 2023 at 06:58:20AM -0800, Arjan van de Ven wrote: > On 1/20/2023 5:55 AM, Hernan Ponce de Leon wrote: > > From: Hernan Ponce de Leon > > > > > kernel/locking/rtmutex.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c > > index 010cf4e6d0b8..7ed9472edd48 100644 > > --- a/kernel/locking/rtmutex.c > > +++ b/kernel/locking/rtmutex.c > > @@ -235,7 +235,7 @@ static __always_inline void mark_rt_mutex_waiters(struct rt_mutex_base *lock) > > unsigned long owner, *p = (unsigned long *) &lock->owner; > > do { > > - owner = *p; > > + owner = READ_ONCE(*p); > > } while (cmpxchg_relaxed(p, owner, > > > I don't see how this makes any difference at all. > *p can be read a dozen times and it's fine; cmpxchg has barrier semantics for compilers afaics Doing so does suppress a KCSAN warning. You could also use data_race() if it turns out that the volatile semantics would prevent a valuable compiler optimization. Thanx, Paul