Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp550095ybk; Wed, 13 May 2020 07:01:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymH/FeR4LH6g4nj6+CgZJuiT+EA35cfy0KOiG0SfrgGdLw3l8GObcZnCcR8TORisYJC3/S X-Received: by 2002:a05:6402:1847:: with SMTP id v7mr1594277edy.255.1589378512353; Wed, 13 May 2020 07:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589378512; cv=none; d=google.com; s=arc-20160816; b=Zl3W/Zyk6Cvju+bqCNfay6QeZj+/+MHockxtdfUuQQmTMO9zV988Zd3YtEkRma0hBm uKuEQUXHeXv4f3t4tE2yqtLWi0qsBGuJpsfoaVM7UrYF3Qt5/8XUlFsIttKOfQrsCBdj 0h3caoScGTYFwHdczDntRE5ofbNi6skD9I57y83qjtz3T8MedWHgxvUdV1kmwAi6YHGp ZWQVKQvuCZkcJfy7IJ3qytd8+fCW43iAMuzYS/gms79BpzJCIW/TLGI1NUfP7grEdVs4 Tw0q1FltWgZLIZ+STIJHgDOo68uGbKxOlZpgVsHe0MUY0xiStmRVfEeE6Ynp/txZ6JVb FMGA== 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=XKVsm8+o6TWBeM8ddWuZqPxPRMMfRRMfxWfMoYOLd8o=; b=pkqct3cEw2hf9FQxVGjnmxVJjuURgFWdLibjDqE/b/MFtbjCkSZlFpKziLfaywF4eG /a0Do7AbhOUJvu/WHPv/pfUG3f5D88wMaIlDFLnbYqJ+AdTr32b6VotQdMWX6U8wDdqT QlvHN5/pj2ZZWONlDhBFyWagakCAIcTIRXyqr5xeKGKKTHMjkxi2e/W8EsXAeJ6vTYFE ZPXl6yHW3bBOLmfCfjV5LPPSdNTS6jjxjyK0WlFaxe6kagTtlFCWva+rFNaiv2/pmt14 A+/V8ZUIq1DgQ4taVCJ3aNwUWnOVzRjBkf1qWlz/aWw0XBI+sQ2TyzCXrTJotGeWFwA6 WxOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Bh9kVRB6; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si9053413ejh.303.2020.05.13.07.01.27; Wed, 13 May 2020 07:01:52 -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=@google.com header.s=20161025 header.b=Bh9kVRB6; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388604AbgEMN6n (ORCPT + 99 others); Wed, 13 May 2020 09:58:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387608AbgEMN6n (ORCPT ); Wed, 13 May 2020 09:58:43 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 173CEC061A0C for ; Wed, 13 May 2020 06:58:43 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id k110so13461017otc.2 for ; Wed, 13 May 2020 06:58:43 -0700 (PDT) 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=XKVsm8+o6TWBeM8ddWuZqPxPRMMfRRMfxWfMoYOLd8o=; b=Bh9kVRB6kF/GhfSyWtETid4E9wHv43XaApaVooXoGG3KtCGBncXa2KTeXQxRzEMFUk ptqPaMh1EpA/UWNxL1LyDqrrJ+BXO13jqKYg9Jp0nU14JMEa1A1NiPDLnrZnWrrxKEnI hGnJaFnOtgz6c6nKKiGTNUwxgDRr8pcvOtCOkFDQEy4R0QE/ED6dsnF7QRdDyFUEj9aR S6iTcIVlwdRj6/0VyStHMyGb3IVfh89mKgjYS3h0l0zc+se7SR6rXjAzEWBmrp1fNCOi vcdNsW1S01fV8KhME4yRPw6Vh3U2rTAViLFjDsa/HjopVg1lFmZ4gQ+vk/npuPG+q2Bx qtcw== 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=XKVsm8+o6TWBeM8ddWuZqPxPRMMfRRMfxWfMoYOLd8o=; b=Pi5epyqQpfgZOjoV7ZHBFMdjLavu3IaPVy3HbUvQGuwFFCILDV7hzIDjUoTgroMWd1 uDdiQp+6ZXGbJLdo21tjL6/3oI6aYRMhNuy7bNsUA8p5hyEzeDfgQOjzaIJfCX1EsZGV dnE8qpayNgvtw2yCM29C5fBeqRHYouSSStYpsETb/jcpdWjdYxx851UQfP3J4+aVKe0t v4lOzuyvkZsYnOrMoy0CmTNB+Lb8c1tcbDDW7Yqh8oTmkrGQUi3Izg6XxyWycp4QJP+1 kVamDpmID2p1FClJOSL+ewTVzBMr4HM7uId2/8QhCBtlEfi4A9PinTkj1gyjnpEoDtMr u2YQ== X-Gm-Message-State: AGi0PubTwa58f6e7o2B6suZlejExOj98Ejoun70RUib5oO0E+gpotsxk I2RkvhIZoJ9l/GciJogIZSfQax6EU9uxxVXfCgn8kA== X-Received: by 2002:a9d:68c5:: with SMTP id i5mr19281082oto.251.1589378322170; Wed, 13 May 2020 06:58:42 -0700 (PDT) MIME-Version: 1.0 References: <20200511204150.27858-1-will@kernel.org> <20200512081826.GE2978@hirez.programming.kicks-ass.net> <20200512190755.GL2957@hirez.programming.kicks-ass.net> <20200513111057.GN2957@hirez.programming.kicks-ass.net> <20200513123243.GO2957@hirez.programming.kicks-ass.net> <20200513124021.GB20278@willie-the-truck> <20200513132440.GN2978@hirez.programming.kicks-ass.net> In-Reply-To: <20200513132440.GN2978@hirez.programming.kicks-ass.net> From: Marco Elver Date: Wed, 13 May 2020 15:58:30 +0200 Message-ID: Subject: Re: [PATCH v5 00/18] Rework READ_ONCE() to improve codegen To: Peter Zijlstra Cc: Will Deacon , LKML , Thomas Gleixner , "Paul E. McKenney" , Ingo Molnar , Dmitry Vyukov 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 Wed, 13 May 2020 at 15:24, Peter Zijlstra wrote: > > On Wed, May 13, 2020 at 03:15:55PM +0200, Marco Elver wrote: > > So far so good, except: both __no_sanitize_or_inline and > > __no_kcsan_or_inline *do* avoid KCSAN instrumenting plain accesses, it > > just doesn't avoid explicit kcsan_check calls, like those in > > READ/WRITE_ONCE if KCSAN is enabled for the compilation unit. That's > > just because macros won't be redefined just for __no_sanitize > > functions. Similarly, READ_ONCE_NOCHECK does work as expected, and its > > access is unchecked. > > > > This will have the expected result: > > __no_sanitize_or_inline void foo(void) { x++; } // no data races reported > > > > This will not work as expected: > > __no_sanitize_or_inline void foo(void) { READ_ONCE(x); } // data > > races are reported > > > > All this could be fixed if GCC devs would finally take my patch to > > make -fsanitize=thread distinguish volatile [1], but then we have to > > wait ~years for the new compilers to reach us. So please don't hold > > your breath for this one any time soon. > > [1] https://gcc.gnu.org/pipermail/gcc-patches/2020-April/544452.html > > Right, but that does not address the much larger issue of the attribute > vs inline tranwreck :/ Could you check if Clang is equally broken for you? I think GCC and Clang have differing behaviour on this. No idea what it takes to fix GCC though. > Also, could not this compiler instrumentation live as a kernel specific > GCC-plugin instead of being part of GCC proper? Because in that case, > we'd have much better control over it. I'd like it if we could make it a GCC-plugin for GCC, but how? I don't see a way to affect TSAN instrumentation. FWIW Clang already has distinguish-volatile support (unreleased Clang 11). Thanks, -- Marco