Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp905457ybm; Wed, 27 May 2020 10:47:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAdgE0x5ZeaRMOTZKXbTzeutfAgG7wBQrxsiBMAS2y9BfCun1PQ+HDZ5+syhZhWiFDCn8N X-Received: by 2002:a05:6402:783:: with SMTP id d3mr25035654edy.295.1590601667823; Wed, 27 May 2020 10:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590601667; cv=none; d=google.com; s=arc-20160816; b=U3hi2PfVaki9wimgwHz1VwdOOF6y/Oja6Fxl15wd67Cci54qju/b+VLvC4+FQlKjlu LDmoTBlLb8wrE3Fgre0t0lFAIaYzNvUMV/ITHs+GdRqTR5ygxcgtqromepALokr5vFlN Tr80WOgL1K8Bpo63fvV5yZ8hyGzgPb5xL4HyYT/Gejkj9mLsIo+VWSowqnruWl74dM65 Rp8e0cwRrwwSzSXmY0UbGqXyjeh1eHc6nPsLdNnOpSLP3AxlfeEByiiY7s0xEEjgW7g7 OmSb1MOVTzEg4Y16Wnbs6Y56GV8QWfndiBvMCleV50L7tPczfesysLbUle1vMsAmEXxK 3X6w== 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 :reply-to:in-reply-to:references:mime-version:dkim-signature; bh=98asfAGM0k82DbjTjDjy1krArq/Ou3skB4zttUQk7aU=; b=Udwi0XzdZEWdaqPGgdFx9EY0tMRLWps/pxlL7wmfjMBU4F9URbECKXJl/q/bDq5iAn mfL1Mima5+hlp5XZjUFr8WPXDxG/4N2iiEgK4OsISKC0TmW9qUzPkPtRAaYB+G6/8zRK 3V49UesfmN6UD0mHmmK3idwhjyYrU0wzS2nrmBx+h414ODEb7Kar69L0SOZw1am9Eqbt eBHQLcbNtWRAenTe+EI60+ODfQnch+a1q6b0v+Y1h5jmvHRST135KX5CguaAVzMAkQnc kod94pn/5iKOfLixrsg7aSjs7BieCY3Z99Y9x5VwjZYC2EeWcpFL1tcui56uur744K3E Mp5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=C6l+HeyB; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lc14si2336690ejb.555.2020.05.27.10.47.24; Wed, 27 May 2020 10:47:47 -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=@gmail.com header.s=20161025 header.b=C6l+HeyB; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388217AbgE0Nh2 (ORCPT + 99 others); Wed, 27 May 2020 09:37:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387682AbgE0Nh2 (ORCPT ); Wed, 27 May 2020 09:37:28 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C7F0C08C5C1 for ; Wed, 27 May 2020 06:37:28 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id y5so3102947iob.12 for ; Wed, 27 May 2020 06:37:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=98asfAGM0k82DbjTjDjy1krArq/Ou3skB4zttUQk7aU=; b=C6l+HeyBVKE+Cn6DaIhJIKh/dNr5LdcYYhXoLT9WlQDSymZTQI/b7tuo14PCxMri/k 87baw8GERGb+NhjRzujAHlogK5w2frPh8/BHj4a7ZKwZR2W0r69jAYT1YpVmOilxzG/c BtLQGTURRpnGOtKzFpjP0NsWfCp+E1cSKcsOLhjKArAVCV/sjCpgO4hHUjVtkLp/wwL8 g74v/SIJAj9/qbZ0xjW69FubPUlOWBhc70jlyqyU2ImlR3IMNLRiicSsijyXgzUGMP83 OMD0/wTscBeC1ISxbSwnFi3y1CkzPNiaaUo3xqHOr7KKdpdurNfap9ZMKCrg+0Dczkbm bH/w== 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:reply-to :from:date:message-id:subject:to:cc; bh=98asfAGM0k82DbjTjDjy1krArq/Ou3skB4zttUQk7aU=; b=exhK4+iSQvIqDO9Tz8KI0pJuxAP4dG6SCr6kDNueyGo7i4EnqmT+7C8qUUxywz5g1F Z5o1y5sYE2gIYyNBjv8NTt9Mt6lXbgl/YnKO+zN0vLHjmj+jPaH9r+sPylee0s/OAhg5 7qmmWhDikADfo29FniTo5rJa8kYHTbAyOBKuaA4gppsbslQPvQwZXm+TWiS4ui3WL1WB 269RSu80G2MUvhSqZ4hAyZ6YD6qos4uC6UmTDFN818poLbC3KjlDnqQAubRw20p6wJS9 SB7ESrYiPRKTwikZo4yxITX4YcrJnN03MUd6wkE/bh0V6IrfZxOPPB+zkJRu6LHGN25U idhA== X-Gm-Message-State: AOAM533yN1pS26GhoyX0VX+aag8K0wO82v6pTa0tXbEtqFsemqAnSkXU vQDKeFCAn9u2Fk1Br3jFs1ZTFPx2JyCiG9uV6wM= X-Received: by 2002:a02:b0d1:: with SMTP id w17mr5599803jah.75.1590586647220; Wed, 27 May 2020 06:37:27 -0700 (PDT) MIME-Version: 1.0 References: <20200527103236.148700-1-elver@google.com> In-Reply-To: Reply-To: sedat.dilek@gmail.com From: Sedat Dilek Date: Wed, 27 May 2020 15:37:19 +0200 Message-ID: Subject: Re: [PATCH -tip] compiler_types.h: Optimize __unqual_scalar_typeof compilation time To: Marco Elver Cc: Arnd Bergmann , Will Deacon , Peter Zijlstra , Borislav Petkov , Thomas Gleixner , Ingo Molnar , clang-built-linux , "Paul E. McKenney" , Dmitry Vyukov , Alexander Potapenko , Andrey Konovalov , kasan-dev , "linux-kernel@vger.kernel.org" , Nick Desaulniers , Stephen Rothwell 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, May 27, 2020 at 3:30 PM Marco Elver wrote: > > On Wed, 27 May 2020 at 15:11, Sedat Dilek wrote: > > > > On Wed, May 27, 2020 at 2:50 PM Arnd Bergmann wrote: > > > > > > On Wed, May 27, 2020 at 2:35 PM Sedat Dilek wrote: > > > > On Wed, May 27, 2020 at 2:31 PM Arnd Bergmann wrote: > > > > > On Wed, May 27, 2020 at 1:36 PM Sedat Dilek wrote: > > > > > > On Wed, May 27, 2020 at 1:27 PM Arnd Bergmann wrote: > > > > > > > On Wed, May 27, 2020 at 12:33 PM Marco Elver 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 > > > > > > > > > > > > > > > > > > > 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. - Sedat -