Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4029764ybl; Mon, 3 Feb 2020 11:09:56 -0800 (PST) X-Google-Smtp-Source: APXvYqwXpaGsLq8THnEOuKcBiZ3vAfLSyJeTUF3/0D7gUNQYB4Y9/eSY0hTIrIVUIG5WzqVV+V4e X-Received: by 2002:a9d:6c8d:: with SMTP id c13mr18725220otr.277.1580756996392; Mon, 03 Feb 2020 11:09:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580756996; cv=none; d=google.com; s=arc-20160816; b=ce58hynxlHTO+e4hPAj++sfWF1fwBzx25gh1MCKbo1lNFWKe+W9wepJ1HSa6ZzdBfF CGCFJfKXCOk7G80LDWU1wnk7AbZoS3oscI5H8EBqhrDWC25YSUuutrBZ3pgbjo8QpqvJ 7JfLPsSfyd+zhACRdC51AOVfQabcFNKXVw8WPl9h9rabUNHA6gGkxOK33U6WmVTb+GyM BtyM79zv9CpJywVMxbB+tQ+kcpGW1xuVyykjBDOHlu7olTUxR9k89iY+yz4geZU4pazn 9EqxXjDfPxckFNFzPoqdvOcdOgT8TzLZ3hTq8I8IJ3UoCCMsg7662Cricr87BCRxDKuQ MFqQ== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=qy/cuW6g75pQ8V0kFqIkByPxGQYcUqm2wEejFwmgt2U=; b=q6CUaeSr9rb/KjIqzOZ4ZxUPVSwV9CwQcs5asHpmJjGXckxFcaYGhzvOf+mG9GeY6h VF7hmUm04xgRbtpjxk8lZi6Rwpl3YEElZhYMlDWHUDmgiYIy6lcDRSVdsce0IWc7wDt9 EsnGkCYiHbUNHBmmJHeXVKox4lKwrteaTQR10fYf4VgbpGdmG2Wip1AG9WrBBBx7R2ZF B6Tz7UEX3zqHAaqZeGwF+FGCpGphkTYJCEHCj8m4qXU5yuyp8j7dl2owkV8YBaJuSQ2Y R1hmJmBVEO91GQ3Bp2V8GqHIT/ruwPrmUHBI7AwvBPtDO8H4/7F9qq/7yQVcNg4+v3C5 6+yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fbpMA9Nu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j65si9232566otc.308.2020.02.03.11.09.27; Mon, 03 Feb 2020 11:09:56 -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=pass header.i=@kernel.org header.s=default header.b=fbpMA9Nu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728422AbgBCR3t (ORCPT + 98 others); Mon, 3 Feb 2020 12:29:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:50230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727150AbgBCR3s (ORCPT ); Mon, 3 Feb 2020 12:29:48 -0500 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (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 099252051A; Mon, 3 Feb 2020 17:29:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580750988; bh=Uspm0bN82l4q/CZvMckAs1J5CnCFjKdej6OTbP0zbts=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=fbpMA9Nue+S3d9Ba/+scCcAj5pEpzNJwzr+RoQG2ur7DAvrDIdKCpOhxRU+hQZYUC aV5AYwSZ4M6Ypu5+tWqcOroXtYm8UP+gMi2yeRxmSBROrRqE8/Je+LMabuDFdewu+n 0HOCgBhB301RSRj/8I65l4ivCTXPJbCvxCiy/Q7Y= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id D7BCB3522718; Mon, 3 Feb 2020 09:29:47 -0800 (PST) Date: Mon, 3 Feb 2020 09:29:47 -0800 From: "Paul E. McKenney" To: Will Deacon Cc: David Laight , 'Eric Dumazet' , Peter Zijlstra , Thomas Gleixner , the arch/x86 maintainers , LKML , Marco Elver Subject: Re: Confused about hlist_unhashed_lockless() Message-ID: <20200203172947.GM2935@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200131164308.GA5175@willie-the-truck> <20200131184322.GA11457@worktop.programming.kicks-ass.net> <26258e70c35e4c108173a27317e64a0b@AcuMS.aculab.com> <20200203155839.GK2935@paulmck-ThinkPad-P72> <20200203160227.GA7274@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200203160227.GA7274@willie-the-truck> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 03, 2020 at 04:02:28PM +0000, Will Deacon wrote: > On Mon, Feb 03, 2020 at 07:58:39AM -0800, Paul E. McKenney wrote: > > On Mon, Feb 03, 2020 at 03:45:54PM +0000, David Laight wrote: > > > From: Eric Dumazet > > > > Sent: 31 January 2020 18:53 > > > > > > > > On Fri, Jan 31, 2020 at 10:48 AM Eric Dumazet wrote: > > > > > > > > > > > > > > This is nice, now with have data_race() > > > > > > > > > > Remember these patches were sent 2 months ago, at a time we were > > > > > trying to sort out things. > > > > > > > > > > data_race() was merged a few days ago. > > > > > > > > Well, actually data_race() is not there yet anyway. > > > > > > Shouldn't it be NO_DATA_RACE() ?? > > > > No, because you use data_race() when there really are data races, but you > > want KCSAN to ignore them. For example, diagnostic code that doesn't > > participate in the actual concurrency design and that doesn't run all > > that often might use data_race(). For another example, if a developer > > knew that data races existed, but that the compiler could not reasonably > > do anything untoward with those data races, that developer might well > > choose to use data_race() instead of READ_ONCE(). Especially if the > > access in question was on a fastpath where helpful compiler optimizations > > would be prohibited by use of READ_ONCE(). > > Yes, and in this particular case I think we can remove some WRITE_ONCE()s > from the non-RCU hlist code too (similarly for hlist_nulls). Quite possibly, but we should take them case by case. READ_ONCE() really does protect against some optimizations, while data_race() does not at all. But yes, in some cases you want to -avoid- using READ_ONCE() and WRITE_ONCE() so that KCSAN can do its job. For example, given a per-CPU variable that is only supposed to be accessed from the corresponding CPU except for reads by diagnostic code, you should have the main algorithm use plain C-language reads and writes, and have the diagnostic code use data_race(). This allows KCSAN to correctly flag bugs that access this per-CPU variable off-CPU while leaving the diagnostic code alone. Seem reasonable? Thanx, Paul