linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marco Elver <elver@google.com>
To: sedat.dilek@gmail.com
Cc: Arnd Bergmann <arnd@arndb.de>, Will Deacon <will@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Borislav Petkov <bp@alien8.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Dmitry Vyukov <dvyukov@google.com>,
	Alexander Potapenko <glider@google.com>,
	Andrey Konovalov <andreyknvl@google.com>,
	kasan-dev <kasan-dev@googlegroups.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Stephen Rothwell <sfr@canb.auug.org.au>
Subject: Re: [PATCH -tip] compiler_types.h: Optimize __unqual_scalar_typeof compilation time
Date: Wed, 27 May 2020 21:14:54 +0200	[thread overview]
Message-ID: <CANpmjNOA2Oa=AJkKYadbvEVOaqzgD840aC5wfGGrFvDqUmjhpg@mail.gmail.com> (raw)
In-Reply-To: <CA+icZUVK=5agY_FPdPeRbZyn3EoUgnmPToR3iGWuCzY+KHtoAA@mail.gmail.com>

On Wed, 27 May 2020 at 21:11, Sedat Dilek <sedat.dilek@gmail.com> wrote:
>
> On Wed, May 27, 2020 at 3:57 PM Marco Elver <elver@google.com> wrote:
> >
> > On Wed, 27 May 2020 at 15:37, Sedat Dilek <sedat.dilek@gmail.com> wrote:
> > >
> > > On Wed, May 27, 2020 at 3:30 PM Marco Elver <elver@google.com> wrote:
> > > >
> > > > On Wed, 27 May 2020 at 15:11, Sedat Dilek <sedat.dilek@gmail.com> wrote:
> > > > >
> > > > > On Wed, May 27, 2020 at 2:50 PM Arnd Bergmann <arnd@arndb.de> wrote:
> > > > > >
> > > > > > On Wed, May 27, 2020 at 2:35 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> > > > > > > On Wed, May 27, 2020 at 2:31 PM Arnd Bergmann <arnd@arndb.de> wrote:
> > > > > > > > On Wed, May 27, 2020 at 1:36 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> > > > > > > > > On Wed, May 27, 2020 at 1:27 PM Arnd Bergmann <arnd@arndb.de> wrote:
> > > > > > > > > > On Wed, May 27, 2020 at 12:33 PM Marco Elver <elver@google.com> wrote:
> > > > > > > > > >
> > > > > > > > > > This gives us back 80% of the performance drop on clang, and 50%
> > > > > > > > > > of the drop I saw with gcc, compared to current mainline.
> > > > > > > > > >
> > > > > > > > > > Tested-by: Arnd Bergmann <arnd@arndb.de>
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > Hi Arnd,
> > > > > > > > >
> > > > > > > > > with "mainline" you mean Linux-next aka Linux v5.8 - not v5.7?
> > > > > > > >
> > > > > > > > I meant v5.7.
> > > > > > > >
> > > > > > > > > I have not seen __unqual_scalar_typeof(x) in compiler_types.h in Linux v5.7.
> > > > > > > > >
> > > > > > > > > Is there a speedup benefit also for Linux v5.7?
> > > > > > > > > Which patches do I need?
> > > > > > > >
> > > > > > > > v5.7-rc is the baseline and is the fastest I currently see. On certain files,
> > > > > > > > I saw an intermittent 10x slowdown that was already fixed earlier, now
> > > > > > > > linux-next
> > > > > > > > is more like 2x slowdown for me and 1.2x with this patch on top, so we're
> > > > > > > > almost back to the speed of linux-5.7.
> > > > > > > >
> > > > > > >
> > > > > > > Which clang version did you use - and have you set KCSAN kconfigs -
> > > > > > > AFAICS this needs clang-11?
> > > > > >
> > > > > > I'm currently using clang-11, but I see the same problem with older
> > > > > > versions, and both with and without KCSAN enabled. I think the issue
> > > > > > is mostly the deep nesting of macros that leads to code bloat.
> > > > > >
> > > > >
> > > > > Thanks.
> > > > >
> > > > > With clang-10:
> > > > >
> > > > > $ scripts/diffconfig /boot/config-5.7.0-rc7-2-amd64-clang .config
> > > > >  BUILD_SALT "5.7.0-rc7-2-amd64-clang" -> "5.7.0-rc7-3-amd64-clang"
> > > > > +HAVE_ARCH_KCSAN y
> > > >
> > > > Clang 10 doesn't support KCSAN (HAVE_KCSAN_COMPILER unset).
> > > >
> > > > > With clang-11:
> > > > >
> > > > > $ scripts/diffconfig /boot/config-5.7.0-rc7-2-amd64-clang .config
> > > > >  BUILD_SALT "5.7.0-rc7-2-amd64-clang" -> "5.7.0-rc7-3-amd64-clang"
> > > > >  CLANG_VERSION 100001 -> 110000
> > > > > +CC_HAS_ASM_INLINE y
> > > > > +HAVE_ARCH_KCSAN y
> > > > > +HAVE_KCSAN_COMPILER y
> > > > > +KCSAN n
> > > > >
> > > > > Which KCSAN kconfigs did you enable?
> > > >
> > > > To clarify: as said in [1], KCSAN (or any other instrumentation) is no
> > > > longer relevant to the issue here, and the compile-time regression is
> > > > observable with most configs. The problem is due to pre-processing and
> > > > parsing, which came about due to new READ_ONCE() and the
> > > > __unqual_scalar_typeof() macro (which this patch optimizes).
> > > >
> > > > KCSAN and new ONCEs got tangled up because we first attempted to
> > > > annotate {READ,WRITE}_ONCE() with data_race(), but that turned out to
> > > > have all kinds of other issues (explanation in [2]). So we decided to
> > > > drop all the KCSAN-specific bits from ONCE, and require KCSAN to be
> > > > Clang 11. Those fixes were applied to the first version of new
> > > > {READ,WRITE}_ONCE() in -tip, which actually restored the new ONCEs to
> > > > the pre-KCSAN version (now that KCSAN can deal with them without
> > > > annotations).
> > > >
> > > > Hope this makes more sense now.
> > > >
> > > > [1] https://lore.kernel.org/lkml/CANpmjNOUdr2UG3F45=JaDa0zLwJ5ukPc1MMKujQtmYSmQnjcXg@mail.gmail.com/
> > > > [2] https://lore.kernel.org/lkml/20200521142047.169334-1-elver@google.com/
> > > >
> > >
> > > Thanks, Marco.
> > >
> > > I pulled tip.git#locking/kcsan on top of Linux v5.7-rc7 and applied this patch.
> > > Just wanted to try KCSAN for the first time and it will also be my
> > > first building with clang-11.
> > > That's why I asked.
> >
> > In general, CONFIG_KCSAN=y and the defaults for the other KCSAN
> > options should be good. Depending on the size of your system, you
> > could also tweak KCSAN runtime performance:
> > https://lwn.net/Articles/816850/#Interacting%20with%20KCSAN%20at%20Runtime
> > -- the defaults should be good for most systems though.
> > Hope this helps. Any more questions, do let me know.
> >
>
> Which "projects" and packages do I need?
>
> I have installed:
>
> # LC_ALL=C apt-get install llvm-11 clang-11 lld-11
> --no-install-recommends -t llvm-toolchain -y
>
> # dpkg -l | grep
> 1:11~++20200527111130+65030821d4a-1~exp1~20200527091804.3261 | awk
> '/^ii/ {print $1 " " $2 " " $3}' | column -t
> ii  clang-11
> 1:11~++20200527111130+65030821d4a-1~exp1~20200527091804.3261
> ii  libclang-common-11-dev
> 1:11~++20200527111130+65030821d4a-1~exp1~20200527091804.3261
> ii  libclang-cpp11
> 1:11~++20200527111130+65030821d4a-1~exp1~20200527091804.3261
> ii  libclang1-11
> 1:11~++20200527111130+65030821d4a-1~exp1~20200527091804.3261
> ii  libllvm11:amd64
> 1:11~++20200527111130+65030821d4a-1~exp1~20200527091804.3261
> ii  lld-11
> 1:11~++20200527111130+65030821d4a-1~exp1~20200527091804.3261
> ii  llvm-11
> 1:11~++20200527111130+65030821d4a-1~exp1~20200527091804.3261
> ii  llvm-11-runtime
> 1:11~++20200527111130+65030821d4a-1~exp1~20200527091804.3261
>
> Is that enough?

Just clang-11 (and its transitive dependencies) is enough. Unsure what
your installed binary is, likely "clang-11", so if you can do "make
CC=clang-11 defconfig" (and check for CONFIG_HAVE_KCSAN_COMPILER)
you're good to go.

Thanks,
-- Marco

  reply	other threads:[~2020-05-27 19:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27 10:32 [PATCH -tip] compiler_types.h: Optimize __unqual_scalar_typeof compilation time Marco Elver
2020-05-27 11:26 ` Arnd Bergmann
2020-05-27 11:36   ` Sedat Dilek
2020-05-27 12:31     ` Arnd Bergmann
2020-05-27 12:35       ` Sedat Dilek
2020-05-27 12:50         ` Arnd Bergmann
2020-05-27 13:11           ` Sedat Dilek
2020-05-27 13:30             ` Marco Elver
2020-05-27 13:37               ` Sedat Dilek
2020-05-27 13:56                 ` Marco Elver
2020-05-27 19:11                   ` Sedat Dilek
2020-05-27 19:14                     ` Marco Elver [this message]
2020-05-28  2:12                       ` Sedat Dilek
2020-05-28 15:16                         ` Marco Elver
2020-05-28 16:39                           ` Sedat Dilek
2020-05-27 15:25 ` [tip: locking/kcsan] " tip-bot2 for Marco Elver
2020-05-27 15:29 ` [PATCH -tip] " Nathan Chancellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANpmjNOA2Oa=AJkKYadbvEVOaqzgD840aC5wfGGrFvDqUmjhpg@mail.gmail.com' \
    --to=elver@google.com \
    --cc=andreyknvl@google.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=clang-built-linux@googlegroups.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sedat.dilek@gmail.com \
    --cc=sfr@canb.auug.org.au \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).