Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp16903pxv; Wed, 21 Jul 2021 14:11:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnDitTHlnTZ9Q+7UjBVsJMOD84pG4496D3rH1pr4u4h0IvT86bHxjhrFRqasJQ2XNIK5nc X-Received: by 2002:a92:8e41:: with SMTP id k1mr14669611ilh.276.1626901888408; Wed, 21 Jul 2021 14:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626901888; cv=none; d=google.com; s=arc-20160816; b=g0jfB0gMwBQZaEUArQ4O/c2sI83HOkzNkhRH/ScNocynoi0ciZ37vdPuLjy1BH3FlY 7z7wlN/T6aqn9hhxGSAblLEud2cnBBQQz7xLkkWt7KHJGko2/OutiiFzKlrlLr31QkBE yAKQAQw7OYZXICtVtfrLz6Dy/EJ8dPW2yVE/skQLvyux6UsT6QDKS8mZ3OxbATU7igoy niNdAb2RIuG87Z5Qr/VeBx4rVdCDKJxx1kKzIJ9TNqNy4bzmZtdZtZaBwJNGmo7C4QVT t/qgmsR3qvm464+g3WNnkQ+OJ1gUSRMOPsZgS0BV/NqCj9I2Bnebkp/GFiqhUuO2B2ho +AaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Jt9gtkzHHk35ZmXRmTZSgvTw+liznR4QxB2738UX6Mk=; b=S195z6zrLUx74AXhGul2vAPp3ahEBcLsCF+wZdbsvOsXmVhDNDcAQlOI/7uzn8YlWJ E926eEuXA2sVMqGjESccXbX07jJt0ULF7mn/67npUen5lBMwO2/2iq7HchW5FTOeu0uu vHE/OCHVlC69J4HX6JMHKbRQvq9+tI1gkrlAgguFjslYnidnif91nLYu//CEOwLD4fnX 9ZK6x1ESKfNHR3E3CCVhZ6uCu//j/WwZjujr7d3it11u5deJwGZz2HTs2q/+LVDt/o9D u3w40/wa9wdd4CJRdkIRWwrrquK1rAwtRdlVQN5jhMRHPevgYD+tl+DBpZlnKHo+s0w6 BPZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c4Zlh6Ju; 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 z14si20853492ilu.89.2021.07.21.14.11.13; Wed, 21 Jul 2021 14:11:28 -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=k20201202 header.b=c4Zlh6Ju; 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 S229994AbhGUU3h (ORCPT + 99 others); Wed, 21 Jul 2021 16:29:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:36742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbhGUU33 (ORCPT ); Wed, 21 Jul 2021 16:29:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 421DE61222; Wed, 21 Jul 2021 21:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626901805; bh=en754w73iFqTn89Z6AhHNd60Ce4arYxw9aIjHkrE69E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c4Zlh6JurAtz9AhlNdCGTi6AfqUYPMmN9j9MovAScPSW8OxO3v95wsNVzNU7oJzJO l6r8Bmf49Bg4iB2SQkYmOyoHD+boLQH8cRwwcCjgLXuy0hSlisQIc9b8cAeE+Rh/wp vlIL/RPvZn1XDVicv+/rgMmyctMulQ/hTEbkqI0fM8w/8B1pBQHz7DCLz/n/A4jWSo ibp0AWw3z7BcDhXp40J/DFTeQyeZmEmbxpVlFnG3cdrRytLkXd8B5yCN+9cu1vxMTL btckhySf3apIZ53v+5zH/rMaebAaPpk9Ello2GfU/WJYEGjt5vTEEKD+4N4ZUZ67c4 FIv2s2bdpn1LA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 127345C0A03; Wed, 21 Jul 2021 14:10:05 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org Cc: stern@rowland.harvard.edu, parri.andrea@gmail.com, will@kernel.org, peterz@infradead.org, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, akiyks@gmail.com, Manfred Spraul , "Paul E . McKenney" Subject: [PATCH memory-model 3/4] tools/memory-model: Heuristics using data_race() must handle all values Date: Wed, 21 Jul 2021 14:10:02 -0700 Message-Id: <20210721211003.869892-3-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20210721210726.GA828672@paulmck-ThinkPad-P17-Gen-1> References: <20210721210726.GA828672@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Manfred Spraul Data loaded for use by some sorts of heuristics can tolerate the occasional erroneous value. In this case the loads may use data_race() to give the compiler full freedom to optimize while also informing KCSAN of the intent. However, for this to work, the heuristic needs to be able to tolerate any erroneous value that could possibly arise. This commit therefore adds a paragraph spelling this out. Signed-off-by: Manfred Spraul Signed-off-by: Paul E. McKenney --- tools/memory-model/Documentation/access-marking.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/memory-model/Documentation/access-marking.txt b/tools/memory-model/Documentation/access-marking.txt index be7d507997cf8..fe4ad6d12d24c 100644 --- a/tools/memory-model/Documentation/access-marking.txt +++ b/tools/memory-model/Documentation/access-marking.txt @@ -126,6 +126,11 @@ consistent errors, which in turn are quite capable of breaking heuristics. Therefore use of data_race() should be limited to cases where some other code (such as a barrier() call) will force the occasional reload. +Note that this use case requires that the heuristic be able to handle +any possible error. In contrast, if the heuristics might be fatally +confused by one or more of the possible erroneous values, use READ_ONCE() +instead of data_race(). + In theory, plain C-language loads can also be used for this use case. However, in practice this will have the disadvantage of causing KCSAN to generate false positives because KCSAN will have no way of knowing -- 2.31.1.189.g2e36527f23