Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp454904ybl; Thu, 23 Jan 2020 01:41:26 -0800 (PST) X-Google-Smtp-Source: APXvYqybi9/R9++NY5A7uRdqOBvCdeYsiteg4We8tqT4ZRYYcXK7ZhoJZj+/S8ZCDbww35NlHKQs X-Received: by 2002:a9d:634e:: with SMTP id y14mr11091229otk.162.1579772486217; Thu, 23 Jan 2020 01:41:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579772486; cv=none; d=google.com; s=arc-20160816; b=Uck1IWDvL25XPNg+1KgyPwo2iqOahjvAhPhnrKQcHfmL0+75NdRfOMiL/vKjV/4m/z wkufH+fFhzoiS+gfr5UMct7g/Uj1k5i5y0v3zMd27z6Euo8CBKDBvF+poguP3SVBOqsv T/yGiT4s+RXLoX+ucDEav9fGBzx+/EwjWVfsxcy4y4DzKUko2DJQ7Q14OJlDlxPy9Dak BmswDxOW7EJvbFkf5kFm/pk6ZE8qG+zApuysy1hFNh7LyINsyc41vYXdtrpTR4mbman5 EeS6N1MOM65cyGnxbW/fcwoCwPBpm0aWFMo4XM5Ln6MCAFUZZT0egBpB8f4+rUEs5OKN AMGA== 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:dkim-signature; bh=md0ZAk3FQElHi7XKV64Hv8xf0dK+/8lwA6XrQZmfofk=; b=r/PTyMUUR+yhc3fUpnwMSaaoHzFJ/3+HOVhFMhmvGWxCEZxRBH6VV4BoxXO38bvCi4 /IGd7JyEbkz+U3UYYu021Wu3mNfAOI4WzH19wpai3lXjfOOyFzHppi/3SpdiPbDYHEml jDqTpKJCjdkxIBUGS8FYs6R9IGebBvdEAOJQXg6GyKOx/kF3XbsqT4LUNuszhLqyp+MX G65FPaT1QYp7n2knY5cO6JD7meWXM7/vmu/dx041FkPat0BwdcmnL95fh1SAZw54m0ru 0TO+I2XLQoNlHe38Zc8Au8LT6QDa64H8b9jQI24IanVb0IAPe9+/kM89r7iBVErJgXmF F2QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=G5E6yCVW; 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 u25si876099otg.170.2020.01.23.01.41.12; Thu, 23 Jan 2020 01:41:26 -0800 (PST) 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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=G5E6yCVW; 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 S1726205AbgAWJjL (ORCPT + 99 others); Thu, 23 Jan 2020 04:39:11 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:53970 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726026AbgAWJjL (ORCPT ); Thu, 23 Jan 2020 04:39:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=md0ZAk3FQElHi7XKV64Hv8xf0dK+/8lwA6XrQZmfofk=; b=G5E6yCVWS3GRTr6UKlwVnV6af qCnyJhNhT8PUON1JNDidqpblUj1Fn++0bPz8/SfRDfSe3Xp9WrQN673jD4O14VPhL6cniwYnjbKam CPpH2oEjhHv1IKSlmC8zSvG6zjzJTHSW/85N/xc6v2gPZVj6ijzGEFf3daci6NPYXU5z4g4KPFhhW nVunhbWNVSPwdTyd56xWu8x4MfbHYCbZb+VvUqOhpdeQoxxDvvcVXq/zTItkK2PYKH/SN40UVXZmc y9kCP5QA+tFinoR7Q/LB7mlyzTGi+9VuAdbHbOt+UcVlnpiIVec3H/mtamQGiWeHPKK/RCSNDek8B LXGatyHHg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iuYx8-0003iU-Tx; Thu, 23 Jan 2020 09:39:08 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 29A463042BC; Thu, 23 Jan 2020 10:37:25 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 264782B713024; Thu, 23 Jan 2020 10:39:05 +0100 (CET) Date: Thu, 23 Jan 2020 10:39:05 +0100 From: Peter Zijlstra To: Qian Cai Cc: Marco Elver , Will Deacon , mingo@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] locking/osq_lock: fix a data race in osq_wait_next Message-ID: <20200123093905.GU14914@hirez.programming.kicks-ass.net> References: <20200122165938.GA16974@willie-the-truck> <20200122223851.GA45602@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 22, 2020 at 06:54:43PM -0500, Qian Cai wrote: > diff --git a/kernel/locking/osq_lock.c b/kernel/locking/osq_lock.c > index 1f7734949ac8..832e87966dcf 100644 > --- a/kernel/locking/osq_lock.c > +++ b/kernel/locking/osq_lock.c > @@ -75,7 +75,7 @@ osq_wait_next(struct optimistic_spin_queue *lock, > * wait for either @lock to point to us, through its Step-B, or > * wait for a new @node->next from its Step-C. > */ > - if (node->next) { > + if (READ_ONCE(node->next)) { > next = xchg(&node->next, NULL); > if (next) > break; This could possibly trigger the warning, but is a false positive. The above doesn't fix anything in that even if that load is shattered the code will function correctly -- it checks for any !0 value, any byte composite that is !0 is sufficient. This is in fact something KCSAN compiler infrastructure could deduce.