Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3794065ybl; Tue, 21 Jan 2020 07:10:01 -0800 (PST) X-Google-Smtp-Source: APXvYqx+hNpYH3nXpRb56pL8MIayy4F4+PXks7MDOsmYH/2irBQf5Jq6axDRh3MChYA77BGWnolP X-Received: by 2002:a9d:69ce:: with SMTP id v14mr4096008oto.248.1579619400747; Tue, 21 Jan 2020 07:10:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579619400; cv=none; d=google.com; s=arc-20160816; b=f1uh92eyGbVG2vhbxy5S+1mFjj/zsOQ+2gt8gB8fV8JUo2dUmahGlYIxWcjNP8I+ws ADBAzGiKNNpiOg9U0x+Md4oE21AHvlYmW9vbFFeeot7U1seHxHVnXHvwmnrEFg+g3m7+ oXNx+OsCpzLQ8f6TT8x1UgZ7lU0E5bxoEWKk44UVK8vJzRDnEvqJu2qxxLG9EBAFhT/+ 200xF59/mQfWO/fSM/PJQHAMTJnu/hQ6u+xUn06UmOEcVVvoFy6FYJaNPdHkgd68gz52 mpKJUt3zwV3oMzNR7VnHdURavcYrs4hdhSjh9wIBeRrmLNutwmyrMWHDguuvnpk6Jysv PZaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=sORnSh7V9XjzjlniDOWj1Q+C/fnBMkuk2ZbJfbkUnZI=; b=D9AJpopuCOMIWR7Q0XkqWOzML9cLm1bo0dGkUeadSceeor3hUvvJNp7DIrKSoqNuWg //6qT2C6gETlhn0mKoNZjtGDmgOsnU0uiSdpO05n+cMv6vRDngq3yhdo9T7kpLBvj4/Z 3UlmNUa79dB7xTSiEzxt8wqtIktvtxS1yOhuFl4id1vZIZu0ZxewBa+2DOfi589EvBEy 9k74ZiqcStxMIERcSMVoaeAEv8nqNJ1hXPHLm9v2ZyfHbHMIPnrEGeicJE6RG9XAQJut W9FYTOljE62oXxs79Z0CWDfjOif/tCb72M0Cru1q6vu7MaqiNVd8yxii0OHdba57NmDY oRbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uikBkA3X; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e20si18577577oig.199.2020.01.21.07.09.49; Tue, 21 Jan 2020 07:10:00 -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=@google.com header.s=20161025 header.b=uikBkA3X; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729130AbgAUPIK (ORCPT + 99 others); Tue, 21 Jan 2020 10:08:10 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:38830 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727255AbgAUPIJ (ORCPT ); Tue, 21 Jan 2020 10:08:09 -0500 Received: by mail-oi1-f196.google.com with SMTP id l9so2828142oii.5 for ; Tue, 21 Jan 2020 07:08:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sORnSh7V9XjzjlniDOWj1Q+C/fnBMkuk2ZbJfbkUnZI=; b=uikBkA3XWuiUqAuqjuD4vJoU7Y0e+UBkIRJrrJt781yThOkz0Dur1veCygtc716BPr QreYZDSWi32PCRuep2Q/nUHGfksWxONsfLhwa5oW5LKBZ//rt9rhu9fPW5YPNQ4pe1EJ Yd2t4fhwjY/dtnNM1e2CAsJU95sXeCsLb3xf4wPE+imOrpSoRXA3fQIOLyL/7Lp5BlLj wwsMuxMzT22zEvDFkYwU8/ynEkOJYjleOabMYL/KQ8HqfAMftMHcRHHD2TvGcbXOMC1/ 02ryIuVEN1fEMdb3kvjWAYzz53A9Brnd6uojhF/MAQpgH6zh3ROYx15IQNQily1Ghxmy WTzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sORnSh7V9XjzjlniDOWj1Q+C/fnBMkuk2ZbJfbkUnZI=; b=fbVLNnYyHOyJn+EA75SIfsgZVJPxADiQxjUIymc8A2vdajLzJdjyADE19GeK9OpWPm rrUwXSCSCacwnz364cYFk3EsvZ+8deZRor8ZtaRyGGupCYg/v1G6O/jW2bot9nkrvvj7 NVn9AnztaUAGhlzHlp34oJww05MOQHKrWt9M92LbBZyrrhXfalcTuqR4hxURjOlMicSH h1jRm2PqLFt0ThVJR9SXQWvNiIw7qhVxvI/PS6Qu38l2HA5PpCW11/ugtxRteEkObQQN tCMgVwOy1ujz5Ib60fvUIQl7ThOqVQWMzm4n09ap5o95kYvPPgTaN+es468ifXmbIjpB BvuQ== X-Gm-Message-State: APjAAAXCFGOiNKRlq4GC92C0MdUIYjWrN9TW+QiMdZiwgOWIVZR90MpV ZA6xIC73qz4OC8HXwqB0CjUgLoojc/KuEHBJUsuO0w== X-Received: by 2002:aca:2112:: with SMTP id 18mr3156833oiz.155.1579619288271; Tue, 21 Jan 2020 07:08:08 -0800 (PST) MIME-Version: 1.0 References: <20200120141927.114373-1-elver@google.com> <20200120141927.114373-3-elver@google.com> <20200120144048.GB14914@hirez.programming.kicks-ass.net> <20200120162725.GE2935@paulmck-ThinkPad-P72> <20200120165223.GC14914@hirez.programming.kicks-ass.net> <20200120202359.GF2935@paulmck-ThinkPad-P72> <20200121091501.GF14914@hirez.programming.kicks-ass.net> <20200121142109.GQ2935@paulmck-ThinkPad-P72> <20200121144716.GQ14879@hirez.programming.kicks-ass.net> In-Reply-To: <20200121144716.GQ14879@hirez.programming.kicks-ass.net> From: Marco Elver Date: Tue, 21 Jan 2020 16:07:56 +0100 Message-ID: Subject: Re: [PATCH 3/5] asm-generic, kcsan: Add KCSAN instrumentation for bitops To: Peter Zijlstra Cc: "Paul E. McKenney" , Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , kasan-dev , LKML , Mark Rutland , Will Deacon , Boqun Feng , Arnd Bergmann , Al Viro , christophe leroy , Daniel Axtens , Michael Ellerman , Steven Rostedt , Masami Hiramatsu , Ingo Molnar , Christian Brauner , Daniel Borkmann , cyphar@cyphar.com, Kees Cook , linux-arch Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 21 Jan 2020 at 15:47, Peter Zijlstra wrote: > > On Tue, Jan 21, 2020 at 06:21:09AM -0800, Paul E. McKenney wrote: > > On Tue, Jan 21, 2020 at 10:15:01AM +0100, Peter Zijlstra wrote: > > > On Mon, Jan 20, 2020 at 12:23:59PM -0800, Paul E. McKenney wrote: > > > > We also don't have __atomic_read() and __atomic_set(), yet atomic_read() > > > > and atomic_set() are considered to be non-racy, right? > > > > > > What is racy? :-) You can make data races with atomic_{read,set}() just > > > fine. > > > > Like "fairness", lots of definitions of "racy". ;-) > > > > > Anyway, traditionally we call the read-modify-write stuff atomic, not > > > the trivial load-store stuff. The only reason we care about the > > > load-store stuff in the first place is because C compilers are shit. > > > > > > atomic_read() / test_bit() are just a load, all we need is the C > > > compiler not to be an ass and split it. Yes, we've invented the term > > > single-copy atomicity for that, but that doesn't make it more or less of > > > a load. > > > > > > And exactly because it is just a load, there is no __test_bit(), which > > > would be the exact same load. > > > > Very good! Shouldn't KCSAN then define test_bit() as non-racy just as > > for atomic_read()? > > Sure it does; but my comment was aimed at the gripe that test_bit() > lives in the non-atomic bitops header. That is arguably entirely > correct. I will also point out that test_bit() is listed in Documentation/atomic_bitops.txt. What I gather from atomic_bitops.txt, is that the semantics of test_bit() is simply an unordered atomic operation: the interface promises that the load will be executed as one indivisible step, i.e. (single-copy) atomically (after compiler optimizations etc.). Although at this point probably not too important, I checked Alpha's implementation of test_bit(), and there is no smp_read_barrier_depends(). Is it safe to say that test_bit() should then be weaker in terms of ordering than READ_ONCE()? My assumption was that test_bit() is as strong as READ_ONCE(). Thanks, -- Marco