Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2020686ybk; Mon, 11 May 2020 09:56:34 -0700 (PDT) X-Google-Smtp-Source: APiQypJg361qMHccX8seAqEhuREd3Y39J4qrx+jnEdNlpyCLeR79U5q/PcLc9TrmPtkXyJmvVWa8 X-Received: by 2002:a17:906:1a06:: with SMTP id i6mr13960401ejf.90.1589216194225; Mon, 11 May 2020 09:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589216194; cv=none; d=google.com; s=arc-20160816; b=BXL1ZpMt3jmLiXMwlXwvXzW1djpOFC6cWo5W7XW5SiUk/MnZ9JiAUGHjR7WbNl1L2V CJe4tXhcWwQeeIFKVpQRv+TFo9ulzTnmW14gMHJPlFI00YDRNxlJgPRoYcpEDqSa0b9q J8bTkC5kr3dDn5kV08xyyb8d94sxSNV4+sHrq60mvp8hJC5usCSNOrRo7Cv+4RDpIRMi znpHrd8qG08oy7YK6L6GQnQG3jqwoJ9Ik8JspcwVTJcmSk+xv+7cLaJmkTlbX/Kwj9YR efho3R94BLr16v4bnF2n9JJ6E3XrhmaqafxyMKHUJcKHvgXt052JxBGSkb0R8zw2mv5X rSqQ== 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=HL3vLrv3jx5EJ53FA5NJzpgycmq7G6IkJK0zLJaCZbE=; b=yepPq1fdb+8IzUMDbK5BsEjXpEh6XQE/eHtc5HV9WMCUa6fq0h3iSpPJ7KH3UZrHPr B3YtOwwzX5tebchw6Ow7UKf2sn2JsBM8PKrz3+Ob6PTFB5VqAIx6WWnLvJSMfkizq+s3 qeXSus8HX4ZaHNyTxOimEoG2No1uyALtDdhuvOPaNk9V2btGTRptr+tesApx7UcZANvW q6fZEpSzoRokorlozhapGUYswyNQAqNHipIWVQkgfZWZwT/wuZYJUWf9gilB4RWo6Iiw xQyIGg7qsYla2Y/NzF5t3JCeKb29qTOV0q2++qwcaGtS+obPgxyAsXilSAbH7pld4AJS iFvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RE1b8HCS; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si6466563edm.343.2020.05.11.09.56.10; Mon, 11 May 2020 09:56:34 -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=@kernel.org header.s=default header.b=RE1b8HCS; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730215AbgEKQyq (ORCPT + 99 others); Mon, 11 May 2020 12:54:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:35360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728556AbgEKQyq (ORCPT ); Mon, 11 May 2020 12:54:46 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1426C206D7; Mon, 11 May 2020 16:54:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589216086; bh=+cmhZ7rQWxtakkUxWzeTlbXAzXea4SDhu3uYx57iTHQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RE1b8HCSu0+7YpG60Tc9Bb0jmlk6yhVnexlAMOxMKr9XGmpifIMZopnGPqxq1fMFb nnRleX6q+9Yr/VnHQqpSdnoC8FLbrkvW+6elJMXsxhpzjY7JKtBrwrHy7Pvtq70Jbl qNA2SH6Yb3eZZEz4KrdpVzJE+9UlZf1HnWLgwm8k= Date: Mon, 11 May 2020 17:54:42 +0100 From: Will Deacon To: Qian Cai Cc: "Paul E. McKenney" , Elver Marco , LKML , Ingo Molnar , "Peter Zijlstra (Intel)" Subject: Re: [PATCH -next v2] locking/osq_lock: annotate a data race in osq_lock Message-ID: <20200511165441.GB23081@willie-the-truck> References: <20200511155812.GB22270@willie-the-truck> 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 Mon, May 11, 2020 at 12:44:26PM -0400, Qian Cai wrote: > > > > On May 11, 2020, at 11:58 AM, Will Deacon wrote: > > > > I'm fine with the data_race() placement, but I don't find the comment > > very helpful. We assign the result of a READ_ONCE() to 'prev' in the > > loop, so I don't think that the cpu_relax() is really relevant. > > > > The reason we don't need READ_ONCE() here is because if we race with > > the writer then either we'll go round the loop again after accidentally > > thinking prev->next != node, or we'll erroneously attempt the cmpxchg() > > because we thought they were equal and that will fail. > > > > Make sense? > > I think the significant concern from the previous reviews was if compilers > could prove that prev->next == node was always true because it had no > knowledge of the concurrency, and then took out the whole if statement > away resulting in an infinite loop. Hmm, I don't see how it can remove the cmpxchg(). Do you have a link to that discussion, please? Will