Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp825065ybm; Wed, 27 May 2020 08:53:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCQuKW9sUK0jcC+ACtGv6sbmKA/v9eEMl/LsbA2gKOxZzP9hVpnQfIbeOFJsL1jrVQnvkI X-Received: by 2002:a17:906:dbda:: with SMTP id yc26mr6466785ejb.82.1590594829996; Wed, 27 May 2020 08:53:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590594829; cv=none; d=google.com; s=arc-20160816; b=IP7feB7tU/OsjEqWGFPCGNz2ydlnHzTpqJvTSaMi+y+CtljJcIi+SMhbIjXaB70f2a Xv2zROxhrJ2po9CboktKL90mo6XdwNbafPGxSLysaPuO17Oh6GDdTm/RktyDkk7mLrpQ xk86O/P+tJSTMUkd+m0J9mwPNWcPtrqTJkGeysp6QIE/lGRD3b67aK7V/xeoEus1LBZm qsK9Tqw9lB5rpyyW0lQZSayO8+NeBh7zgkgvI/xysqzp5f2fjh4mV8S2WHJ4mIj2yFrI Pq3rSVYhb83+7R775QHxFf9tQkI663mrbqs58pkMD9uAsJ5VqYTgYocuDxUkEJYmN6uu gIcg== 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=AwQUYVAQCrlzegHmktwvd3qax/+buVYaETqLr5p2maM=; b=qlKkLM6YADJ8n11agW0g8qe+rj3MHa4GtuS2xzoYqrSm8tVuc5+jtpv4mB7S4o88Eq 3yZic8nJ+Dja2rRD3kNsigSCJb2LrFpWyTc24RwWXr7kqeK+2CvcGdMfi59HlUcP54N3 PRoXK36RJG6o2DWkYtDDndqXdUPaG0lzpDuB7+Tupw2V5arUitNcd3BCnVQxurEwbcUv 7QR7eeb4wC/aBRj9Pp+NqR5QaF16fFWYx1OnXGoSxN40kH0OUIEvWEuqFVHE0zLg4S6p HZTu9Zyai0vdJP1ivKa+Ql2SAQ9b66qyWhR0Jpf7VGSK/KroOlXrs74ReRth+XX9cAlt dJlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QbtHWfZ+; 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 df16si1777198edb.158.2020.05.27.08.53.26; Wed, 27 May 2020 08:53:49 -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=QbtHWfZ+; 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 S2387973AbgE0NaW (ORCPT + 99 others); Wed, 27 May 2020 09:30:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387650AbgE0NaW (ORCPT ); Wed, 27 May 2020 09:30:22 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6DB9C08C5C1 for ; Wed, 27 May 2020 06:30:20 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id y85so21620560oie.11 for ; Wed, 27 May 2020 06:30:20 -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=AwQUYVAQCrlzegHmktwvd3qax/+buVYaETqLr5p2maM=; b=QbtHWfZ+3Qn7pFIVdE8kootB1/hpqh6cfr1A6fbeIkZWk9X+jlCcUo+2S7UscWIQ8V iLD2Eef7owQ6gimvFljcZvOj2M7Z2y7HkIhUKMt4riLH1kSKS7CeU2nNsquAO+Em8JbP B1lH3ndXXUv6OdO5KkDbvUIpSRfAE1QAY25cACsl76HMTl38XidUpY1SnfS+nEJISJpi 2izV4yJqOPrbeRwgmQnC8UAeksSKJxh9qcb4DQdSup5X7bRP4/xQKFfM3cm8FFt56MqA 4lyeZAH8vk+N6eMdm2iI6hClLYVYa/cC4NoLmdHBiOYoqZwJ/o9ppqukrZRB6r95zWBt YE4g== 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=AwQUYVAQCrlzegHmktwvd3qax/+buVYaETqLr5p2maM=; b=qXU5juQSxt2APGHYorjFd4loCDqF4aC4wQ5eUz/VqIDDatQnGjBNVzHlkMUsNEt9eP 6jXqjjLL72eXPaLLwzGkC4KuZscrWX9WSl/vlFN2jToRXN9TrYodIBoMRfxzDiF622C+ GJ8hE0vlhaswSrqeXhlnONhsh5ONpXXgHlsMK7CbWyopK31fhNz/8+mhXdB1sFPJQ1rq Q+bAd/c6UFXUg4bsKSVVtAXLy0KgpGKE+anV29caFrPpgjBH7O/bp04xOjmZcIHc7lJ2 dRg6XKMjBv03Pd6k6uZJEqdHrxegPcDygETaRVQxp4xR6JCM98PF3g2JJVUVTN8OxDrv UT/Q== X-Gm-Message-State: AOAM530AlUzT3TJ62lbdBlT7bS4qDRRUbUelh4jMC6XKTIGKl2aoHQsx vWxVAY9vCmfTEtXNS6AZSX1RXqP++GbkpYMkS0feCQ== X-Received: by 2002:aca:d0d:: with SMTP id 13mr2676966oin.172.1590586219764; Wed, 27 May 2020 06:30:19 -0700 (PDT) MIME-Version: 1.0 References: <20200527103236.148700-1-elver@google.com> In-Reply-To: From: Marco Elver Date: Wed, 27 May 2020 15:30:08 +0200 Message-ID: Subject: Re: [PATCH -tip] compiler_types.h: Optimize __unqual_scalar_typeof compilation time To: sedat.dilek@gmail.com 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, 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