Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp804462ybk; Wed, 13 May 2020 13:36:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylc/9L76OIFT7yJsplZ6JivG1ER1w/RAiKbVYB9UOdcKMDDWl98IIgxiMqezwy4IuUFH4Z X-Received: by 2002:a17:906:848e:: with SMTP id m14mr754977ejx.344.1589402186921; Wed, 13 May 2020 13:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589402186; cv=none; d=google.com; s=arc-20160816; b=dYpokgJdomVcrUKZb9/HQEbw0ZTm3SLdliLtloQnHLG/gnCNICKQJE3nfJEJtjTQAC ZQLjNFubNz601GeL7FdmbbnA5rCz+1QVid5PyJ3dhWBYQCT87KYPjOVDRyuI8i+FHSdU 5dS11O1tW+Cxj7UHg6fB1xGvwTS6/QrSCDX0fz/RD4dnXHdki3CgKYn59jy+WwXb2uPL 5kWNH7Dda6j3HT62RhMz3iQ2JjooOrGDekMOkJfOvXypbyqaBFoLP+e7c9MzWNKV1IPy QWT+dS7lfHO6yuCskzGVIGR48ApbzMa4HGgjdOvz+zqvbnJDX5yaamaB6o1iBUB4xuVX 5FFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=q/Wqq3uOvtKbZfYJc48mNiATxJyfIVdSSR1DgfaLH54=; b=GvA/mKZXME7yqO9E1SMs9VUtmIhYALljU//uflnCow1alXmbYSBg9wJ9sGODgG8RFo kJ8EA3CGvwphgYduitwt6uPhe0bVXIQsknngAlKMWshnEpBk5O8KjFTlsSld0J+whFOG 5a0p8eVoUG4uBE2uNdzeqUh6HdQPspQlQaETqtJpPT/IJNU4YxR0J/y++IccDksG6D6D 5B+UPQyDQ524rYfwKcukEmct48wNH1v5HbmJ/a39k8dsA/3UWz7+IRxQ67/BwEEogv4a d/UIZxd6/mtD0iD8fhuWeu0t8tUqNXKNZ+QGJ0hRBjHiRyKZohKVzulxN646ynEfmQEW U3Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=b32vjakt; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x20si454573edi.323.2020.05.13.13.36.04; Wed, 13 May 2020 13:36:26 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=b32vjakt; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731245AbgEMLPL (ORCPT + 99 others); Wed, 13 May 2020 07:15:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730567AbgEMLPK (ORCPT ); Wed, 13 May 2020 07:15:10 -0400 Received: from merlin.infradead.org (unknown [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4409FC061A0C for ; Wed, 13 May 2020 04:15:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=q/Wqq3uOvtKbZfYJc48mNiATxJyfIVdSSR1DgfaLH54=; b=b32vjaktLO98mX8LKLQxIPBAJO XfWpic6QU9m6K/Lt9sQ9zp/4xgZLexxa/EyjhsOp/Ns91PCIML33BaxMeP99/SGI3L5U10CGShJwe xBUUnFY8t3UE+ufFh/O7uBBhaeQjUWzxiGlOBysHlgg7+YW8hYkzWA6pY+ehH5gjoPmjtPvuQZeda LQLdtDiLwI2wpg4gss04jlEYbZFwEZIFQeNSXa3L8DiEoxDh6600x12ITYY8EATZ0j7NrNhxbxe+d vAnrbPBg/IPA7YLiWi/b/EaqGGa/OQCQ6L0E81WfI5EFGGOINIwszOCDsSrbXAafrKAaHv/93khGj ulY1MT/g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jYpLd-0004dS-Ir; Wed, 13 May 2020 11:14:49 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id AE5E7301205; Wed, 13 May 2020 13:14:47 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 9AF2424C0C643; Wed, 13 May 2020 13:14:47 +0200 (CEST) Date: Wed, 13 May 2020 13:14:47 +0200 From: Peter Zijlstra To: Marco Elver Cc: Will Deacon , LKML , Thomas Gleixner , "Paul E. McKenney" , Ingo Molnar , dvyukov@google.com Subject: Re: [PATCH v5 00/18] Rework READ_ONCE() to improve codegen Message-ID: <20200513111447.GE3001@hirez.programming.kicks-ass.net> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200513111057.GN2957@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 13, 2020 at 01:10:57PM +0200, Peter Zijlstra wrote: > So then I end up with something like the below, and I've validated that > does not generate instrumentation... HOWEVER, I now need ~10g of memory > and many seconds to compile each file in arch/x86/kernel/. > diff --git a/include/linux/compiler.h b/include/linux/compiler.h > index 3bb962959d8b..48f85d1d2db6 100644 > --- a/include/linux/compiler.h > +++ b/include/linux/compiler.h > @@ -241,7 +241,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, > * atomicity or dependency ordering guarantees. Note that this may result > * in tears! > */ > -#define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) > +#define __READ_ONCE(x) data_race((*(const volatile __unqual_scalar_typeof(x) *)&(x))) > > #define __READ_ONCE_SCALAR(x) \ > ({ \ > @@ -260,7 +260,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, > > #define __WRITE_ONCE(x, val) \ > do { \ > - *(volatile typeof(x) *)&(x) = (val); \ > + data_race(*(volatile typeof(x) *)&(x) = (val)); \ > } while (0) > > #define __WRITE_ONCE_SCALAR(x, val) \ The above is responsible for that, the below variant is _MUCH_ better again. It really doesn't like nested data_race(), as in _REALLY_ doesn't like. --- diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 3bb962959d8b..2ea532b19e75 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -241,12 +241,12 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, * atomicity or dependency ordering guarantees. Note that this may result * in tears! */ -#define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) +#define __READ_ONCE(x) data_race((*(const volatile __unqual_scalar_typeof(x) *)&(x))) #define __READ_ONCE_SCALAR(x) \ ({ \ typeof(x) *__xp = &(x); \ - __unqual_scalar_typeof(x) __x = data_race(__READ_ONCE(*__xp)); \ + __unqual_scalar_typeof(x) __x = __READ_ONCE(*__xp); \ kcsan_check_atomic_read(__xp, sizeof(*__xp)); \ smp_read_barrier_depends(); \ (typeof(x))__x; \ @@ -260,14 +260,14 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, #define __WRITE_ONCE(x, val) \ do { \ - *(volatile typeof(x) *)&(x) = (val); \ + data_race(*(volatile typeof(x) *)&(x) = (val)); \ } while (0) #define __WRITE_ONCE_SCALAR(x, val) \ do { \ typeof(x) *__xp = &(x); \ kcsan_check_atomic_write(__xp, sizeof(*__xp)); \ - data_race(({ __WRITE_ONCE(*__xp, val); 0; })); \ + __WRITE_ONCE(*__xp, val); \ } while (0) #define WRITE_ONCE(x, val) \