Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp946902ybm; Wed, 27 May 2020 11:53:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7H5IxNNLTiGHMxOUUfkBfILXeVLVRMfdsb8EH1Fh1E/l0V19r18Q1EjyKmXyQVhRMqnVo X-Received: by 2002:a17:906:398:: with SMTP id b24mr7684391eja.44.1590605599599; Wed, 27 May 2020 11:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590605599; cv=none; d=google.com; s=arc-20160816; b=DLkODF3bxWcrO6Xq6tP7KuNYrDoWucOPW2AKiRX0VemKb4Mcs7lLlVZ0B+OJrgK4Ut E8JQIBC4lLwCt5ytEl6zKPlpGPP29eMF5RrDGsoe3JfqZFMFAiuz/vx79QZZipsmsC6n kACl4llqQsIpq6wqxe1xdgi+0UWFWHFjtcY6GMLK6UGoh0TlSlF5rWTA1/45teRHq7Vm vPmAZUtcl65uhK6BXPrQSmhCvYoDZ2SnUAncFv0G+KAfmlEI87gwRo9uVw0m9eagbtav JFTUGIkIlvQzRF2gsz8goIWRGNnKm2Ek0bKX3VxDGfIIMkeid/fSNBDSR5H4CH2tmcSy uG8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=js0hmeN51WIFWX50dUa/JBdswo6XdmlP0nzZx5sMGFw=; b=MOX87nir/4Y6PlKGmzalBqp8g5nOLPZLJwkmjsZoLD+D2QpHBgkXj/BX1O9ZWl3Ag7 ycCAAJFP7pr7hWiuK33KXZ8l1mK4++TiGqHjzOJ6v5qeC7HMbstVbDdecpZKo1bifKV3 +Wz7+vRmnigZ4dX1VzWAZ/5+fsAv6HIRv0q2fvbxwlK9BV8C1pIOCxd8q0FXBZBZ2FfI 7iYb3UZhNEtaVbNbwgWA7QonMj40OOTw3dVSwovHdzN3096Q3XqFZE8olH/w8ZtuXACr ownNpXl2W34koC2W7IEA14Z855fCH+Fd77/YypYzFTrR5MDIwPuS0gbmA3fgRz8rNSCY noLQ== ARC-Authentication-Results: i=1; mx.google.com; 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 m22si2150530edp.611.2020.05.27.11.52.56; Wed, 27 May 2020 11:53:19 -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; 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 S1730280AbgE0PZo (ORCPT + 98 others); Wed, 27 May 2020 11:25:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbgE0PZo (ORCPT ); Wed, 27 May 2020 11:25:44 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07F98C05BD1E; Wed, 27 May 2020 08:25:44 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jdxw3-0006uM-OZ; Wed, 27 May 2020 17:25:39 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 30C291C00ED; Wed, 27 May 2020 17:25:39 +0200 (CEST) Date: Wed, 27 May 2020 15:25:39 -0000 From: "tip-bot2 for Marco Elver" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/kcsan] compiler_types.h: Optimize __unqual_scalar_typeof compilation time Cc: Arnd Bergmann , Marco Elver , Borislav Petkov , Peter Zijlstra , x86 , LKML In-Reply-To: <20200527103236.148700-1-elver@google.com> References: <20200527103236.148700-1-elver@google.com> MIME-Version: 1.0 Message-ID: <159059313900.17951.16258985921157909524.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the locking/kcsan branch of tip: Commit-ID: a5dead405f6be1fb80555bdcb77c406bf133fdc8 Gitweb: https://git.kernel.org/tip/a5dead405f6be1fb80555bdcb77c406bf133fdc8 Author: Marco Elver AuthorDate: Wed, 27 May 2020 12:32:36 +02:00 Committer: Borislav Petkov CommitterDate: Wed, 27 May 2020 14:03:26 +02:00 compiler_types.h: Optimize __unqual_scalar_typeof compilation time If the compiler supports C11's _Generic, use it to speed up compilation times of __unqual_scalar_typeof(). GCC version 4.9 or later and all supported versions of Clang support the feature (the oldest supported compiler that doesn't support _Generic is GCC 4.8, for which we use the slower alternative). The non-_Generic variant relies on multiple expansions of __pick_integer_type -> __pick_scalar_type -> __builtin_choose_expr, which increases pre-processed code size, and can cause compile times to increase in files with numerous expansions of READ_ONCE(), or other users of __unqual_scalar_typeof(). Summary of compile-time benchmarking done by Arnd Bergmann: clang-11 gcc-9 this patch 0.78 0.91 ideal 0.76 0.86 See https://lkml.kernel.org/r/CAK8P3a3UYQeXhiufUevz=rwe09WM_vSTCd9W+KvJHJcOeQyWVA@mail.gmail.com Further compile-testing done with: gcc 4.8, 4.9, 5.5, 6.4, 7.5, 8.4; clang 9, 10. Reported-by: Arnd Bergmann Signed-off-by: Marco Elver Signed-off-by: Borislav Petkov Acked-by: Peter Zijlstra Tested-by: Arnd Bergmann Link: https://lkml.kernel.org/r/20200527103236.148700-1-elver@google.com Link: https://lkml.kernel.org/r/CAK8P3a0RJtbVi1JMsfik=jkHCNFv+DJn_FeDg-YLW+ueQW3tNg@mail.gmail.com --- include/linux/compiler_types.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 5faf68e..a529fa2 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -245,7 +245,9 @@ struct ftrace_likely_data { /* * __unqual_scalar_typeof(x) - Declare an unqualified scalar type, leaving * non-scalar types unchanged. - * + */ +#if defined(CONFIG_CC_IS_GCC) && CONFIG_GCC_VERSION < 40900 +/* * We build this out of a couple of helper macros in a vain attempt to * help you keep your lunch down while reading it. */ @@ -267,6 +269,24 @@ struct ftrace_likely_data { __pick_integer_type(x, int, \ __pick_integer_type(x, long, \ __pick_integer_type(x, long long, x)))))) +#else +/* + * If supported, prefer C11 _Generic for better compile-times. As above, 'char' + * is not type-compatible with 'signed char', and we define a separate case. + */ +#define __scalar_type_to_expr_cases(type) \ + type: (type)0, unsigned type: (unsigned type)0 + +#define __unqual_scalar_typeof(x) typeof( \ + _Generic((x), \ + __scalar_type_to_expr_cases(char), \ + signed char: (signed char)0, \ + __scalar_type_to_expr_cases(short), \ + __scalar_type_to_expr_cases(int), \ + __scalar_type_to_expr_cases(long), \ + __scalar_type_to_expr_cases(long long), \ + default: (x))) +#endif /* Is this type a native word size -- useful for atomic operations */ #define __native_word(t) \