Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp591183ybm; Wed, 27 May 2020 03:12:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRkeKJQz6kls5vWgLlD8Mn0Y+ccAU9ScWC1LWiuITxjxZbDu3jbwsZ3+z9YPkwyNGCH3Ga X-Received: by 2002:a17:906:3b9a:: with SMTP id u26mr5185150ejf.456.1590574319882; Wed, 27 May 2020 03:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590574319; cv=none; d=google.com; s=arc-20160816; b=AbuQiNYZZm1ca17u4Nwi5KNwUWSomPf/LbmU2CA0Y1XoN/buX/bNq4w3JgIR5RfCW2 GMPPCCaDSwGHtixc5eDGtSEJ6h78dJ0TiNXPsCATvFb1yhTdctMR4Gx46ZlJDDKchETO b9evfCcVIUuWp6GnAjeh2R/QRzoOktZHGGD/802mlwqTdU7Xed8Y1YHop28iQtyNEJCH jP5lZnBOBoUSOMh5dZMWQjW6CzobHcfs8cgBs5SPSt7a4jxLQ+bVVRP2LOtGZo8OQN/l WDq+t47svtLbjoXt6Pc6QWKNn+zV1kjFuOFTK6U22sIZNLmytGR97GX+b7m5wXIgYNGA PIbg== 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:message-id:subject:cc :to:from:date:dkim-signature; bh=wXNgw/9N1yLecXIMKo58F3VQTu9ecWYXXeWvi6fmpEY=; b=QDSv9FT9i5m6/NoXHslAc/DhlS5/hJzPwJE6cVv0h/hIvrH4IbeXZMhWycxWzImNht /PWSh1bYarhChcb/TZsFOZL2zq0DLf4IZvmOjlu8Oomq7LoWyJ8a4KNzKdtAJDx0FQo8 72OXt3y89z/1cx2n0jHjFFGyFlI0zzhPAIAc5BDYhNRwjfno8RdZyOE2A0qtaH81mSuW XH27wGbcTepYcLAdxYTPiXYfUOsw6U7kiqi5ZbxghWZJ0aQSuzbxykCyicfSX1jeM24F pkE8aRkWRpaFVrAkKTnyF0SEsnNrYr9Qmso48Jmk8muSHNs4VvkhBglR1n7JjM8rg3ws AzLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JjMYLITu; 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 jo20si1577358ejb.456.2020.05.27.03.11.36; Wed, 27 May 2020 03:11:59 -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=default header.b=JjMYLITu; 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 S1729187AbgE0HW4 (ORCPT + 99 others); Wed, 27 May 2020 03:22:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:44288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728303AbgE0HW4 (ORCPT ); Wed, 27 May 2020 03:22:56 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (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 4F96B20C56; Wed, 27 May 2020 07:22:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590564175; bh=1aq3yZzokjVj+RoQhhhzUgjY0nXbOLSSfK8XA7fR4Do=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JjMYLITu4AH/Co3BABCLGX1qgQBoQdNzHH36mQeMM6h79+RSteQzen2+qpGHf+rXr Qpn8iIKkzrId+/F1cUN1RdeBjuqFB/mEDB98+afZLXWFAybb/SGvcx6dt0nqsxbsp8 8TTzh3dX8FNL9lfvsJB9dXUGijtMCz9CUTs2bKEo= Date: Wed, 27 May 2020 08:22:49 +0100 From: Will Deacon To: Arnd Bergmann Cc: Marco Elver , Nick Desaulniers , "Paul E. McKenney" , Dmitry Vyukov , Alexander Potapenko , Andrey Konovalov , kasan-dev , LKML , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , clang-built-linux , Borislav Petkov Subject: Re: [PATCH -tip v3 09/11] data_race: Avoid nested statement expression Message-ID: <20200527072248.GA9887@willie-the-truck> References: <20200521142047.169334-1-elver@google.com> <20200521142047.169334-10-elver@google.com> <20200526120245.GB27166@willie-the-truck> <20200526173312.GA30240@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 27, 2020 at 01:10:00AM +0200, Arnd Bergmann wrote: > On Tue, May 26, 2020 at 9:00 PM Arnd Bergmann wrote: > > > > On Tue, May 26, 2020 at 7:33 PM 'Marco Elver' via Clang Built Linux > > wrote: > > > On Tue, 26 May 2020, Marco Elver wrote: > > > > On Tue, 26 May 2020 at 14:19, Arnd Bergmann wrote: > > > > Note that an 'allyesconfig' selects KASAN and not KCSAN by default. > > > > But I think that's not relevant, since KCSAN-specific code was removed > > > > from ONCEs. In general though, it is entirely expected that we have a > > > > bit longer compile times when we have the instrumentation passes > > > > enabled. > > > > > > > > But as you pointed out, that's irrelevant, and the significant > > > > overhead is from parsing and pre-processing. FWIW, we can probably > > > > optimize Clang itself a bit: > > > > https://github.com/ClangBuiltLinux/linux/issues/1032#issuecomment-633712667 > > > > > > Found that optimizing __unqual_scalar_typeof makes a noticeable > > > difference. We could use C11's _Generic if the compiler supports it (and > > > all supported versions of Clang certainly do). > > > > > > Could you verify if the below patch improves compile-times for you? E.g. > > > on fs/ocfs2/journal.c I was able to get ~40% compile-time speedup. > > > > Yes, that brings both the preprocessed size and the time to preprocess it > > with clang-11 back to where it is in mainline, and close to the speed with > > gcc-10 for this particular file. > > > > I also cross-checked with gcc-4.9 and gcc-10 and found that they do see > > the same increase in the preprocessor output, but it makes little difference > > for preprocessing performance on gcc. > > Just for reference, I've tested this against a patch I made that completely > shortcuts READ_ONCE() on anything but alpha (which needs the > read_barrier_depends()): > > --- a/include/linux/compiler.h > +++ b/include/linux/compiler.h > @@ -224,18 +224,21 @@ 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) (*(const volatile typeof(x) *)&(x)) > > +#ifdef CONFIG_ALPHA /* smp_read_barrier_depends is a NOP otherwise */ > #define __READ_ONCE_SCALAR(x) \ > ({ \ > __unqual_scalar_typeof(x) __x = __READ_ONCE(x); \ > smp_read_barrier_depends(); \ > - (typeof(x))__x; \ > + __x; \ > }) > +#else > +#define __READ_ONCE_SCALAR(x) __READ_ONCE(x) > +#endif Nice! FWIW, I'm planning to have Alpha override __READ_ONCE_SCALAR() eventually, so that smp_read_barrier_depends() can disappear forever. I just bit off more than I can chew for 5.8 :( However, '__unqual_scalar_typeof()' is still useful for load-acquire/store-release on arm64, so we still need a better solution to the build-time regression imo. I'm not fond of picking random C11 features to accomplish that, but I also don't have any better ideas... Is there any mileage in the clever trick from Rasmus? https://lore.kernel.org/r/6cbc8ae1-8eb1-a5a0-a584-2081fca1c4aa@rasmusvillemoes.dk Will