Received: by 10.213.65.68 with SMTP id h4csp1314657imn; Wed, 4 Apr 2018 17:07:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+13TkzRzn0DLSBYQ5YDRIJBUGC/+p5aIvvfOpDPg4M5dLnKJvqJ6Z6h+DAlqafJPFeBiWt X-Received: by 2002:a17:902:7292:: with SMTP id d18-v6mr20106858pll.289.1522886828588; Wed, 04 Apr 2018 17:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522886828; cv=none; d=google.com; s=arc-20160816; b=V99agv0JMNJRhFH5l5Jp5YDca2IL1IJI3CUC36iLSrO48bYo4AYdD0LWrDDWrD7IR8 XHfE4ZVBMbTTMIR08hTkIa1PgRKzA63iI5Yj4yRz7DFmsrzuo/8epi8zN5d5usogESnV uD290pcdByMz0Trr/UykX27g4eVyRLtbENVaz5qoJceTvbDPU/tULn6yaSZVxWJfsRgt 6mjDZFMhE6Jb1viaDPFbL6nn0wKB6aYz3zwvevd2I2nmdy8ymeu6CBjbJmoGLNOcK4M/ ac3/4mTCy5VPweDcY9SXm0iYBNN1kDbKBhejVBCY4LKn2UUuifW+m0zLWQ5DMbQReMiF V7aw== 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 :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=ECTNhd7sZ4CWcFLuntGNv6lsyBDmqQ6Er/L83dC+SPc=; b=jQnUvBxCoinKG8yV5MwavO9gwJ28bbqZn6zwRItww8IkYOy8IdQ0SoVOVlUieLwHcc exLyW5uM6KX+f4VJnnYBs3AqAuomI3RyB3d+3Fg9fKKVV3RO3INMPQoNhTtmD8sdMRRA i+aT312CrHC5Qzl2ZRXRQPZP+PiRu5izncoKdzoPaUsZIf3FhF5ibWNlQ7dl0FU/oNUx GKE01KQI76/rv4a3ZHKxf8D6u0b956OoWLlkC5JvnYegokULgpK9PZkmFwNdMXhFU3m0 z4hvre0LF8upybvyE/dSuQhDhQkcSepCFKi8jja+/aZzQN3T/6brqDF/jxQ7XwHRVh6/ p7dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GruHUrVC; dkim=fail header.i=@linux-foundation.org header.s=google header.b=SBfWyZte; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u14si4514773pgq.103.2018.04.04.17.06.54; Wed, 04 Apr 2018 17:07:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GruHUrVC; dkim=fail header.i=@linux-foundation.org header.s=google header.b=SBfWyZte; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752642AbeDEAF2 (ORCPT + 99 others); Wed, 4 Apr 2018 20:05:28 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:37581 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752311AbeDEAF0 (ORCPT ); Wed, 4 Apr 2018 20:05:26 -0400 Received: by mail-it0-f67.google.com with SMTP id 71-v6so1034997ith.2 for ; Wed, 04 Apr 2018 17:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ECTNhd7sZ4CWcFLuntGNv6lsyBDmqQ6Er/L83dC+SPc=; b=GruHUrVCKdbVu43qXlRgUZaK6w9jjnyZiQxgg3o7gnblC5kVhptI4OFgmrIIgcHWZW xZVWz3fHVZzAGcSc1ePWCyk31yvwSDPg/6KzOy8l2HCnbFyMIEgo6j8Q+VSYb6G+f2Rx Tppv/3puah5C4Y/bIoZtEtMiCXmU0up1+ITebeNW2uI0VW40tFyCez9WoM69TXX6DRE9 D04YtvxT61tqQkpKh3PK4d8XW0C8REIL/iebWiBKY6QSxxUTzcvM3fX5V1ynh9MFiQZ3 +6pnsp2sOdpkMfrYWY5t8Ibhw2gYg8eWkLLLlBIBsKCOXIRk9pJC/5lnhm8zOWgIMyTi BVeQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ECTNhd7sZ4CWcFLuntGNv6lsyBDmqQ6Er/L83dC+SPc=; b=SBfWyZtetsoVoi1eUePOcGTgmU+AKyUTl8s4BkLz2NhlK5VIa3Lt3pJ6loyroM4K29 BsYpIacTmGE5AyE245qQetkfy4mPGH0kBfZdM/7wO3r0rtPnMaa08FuKJbO4IFSM3rzf sbWWVke1CRXqD80RhVI5Vc/X/GoSwfxos+/yg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ECTNhd7sZ4CWcFLuntGNv6lsyBDmqQ6Er/L83dC+SPc=; b=Mph1yLq/41T6GUSul5p0IZHZ26Z0txqtpN+RlZ0np5dozwijxQEfb1wbd/9NtpWTAp 2iSEK0Tq+UJ6Xo9+qCkJvN/TZhZE2hlY1Nry39gzg2QHWPEbTx7Eta4kgRDxNJbCtvkU WMTMU5e5Q86bwLzBQiPd5icPy54hNB+reDyq/inuDHQAs5+MrB5uRvhoQHh2Ps/7n3Q1 L50LDVIYCcepBlpKPA2A4ANKZioandjQ9EKf7CcETuiB4VJPMeVxp2fCL+a1g4msXVjk cYbEBFR56PUVR9IqHKVQPuzV2ij/2K8D4GQf4dI6vfZi/93myvcZepPrTMO2pFAgtccR awCw== X-Gm-Message-State: ALQs6tCCc3XbhmrDenV00SBXzey0mDIkoHFAVGnHDHcpXnbvYLNevsTf geY9Xb8Sg5Hrka4ApBjL9DcnyoNXa7a/97TqqU4= X-Received: by 2002:a24:5852:: with SMTP id f79-v6mr11787628itb.108.1522886725918; Wed, 04 Apr 2018 17:05:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.95.15 with HTTP; Wed, 4 Apr 2018 17:05:25 -0700 (PDT) In-Reply-To: <20180404233111.GJ87376@google.com> References: <20180403180658.GE87376@google.com> <20180404093007.GI4082@hirez.programming.kicks-ass.net> <20180404191724.GF87376@google.com> <20180404205848.GG87376@google.com> <20180404214639.GH87376@google.com> <20180404221744.GI87376@google.com> <20180404233111.GJ87376@google.com> From: Linus Torvalds Date: Wed, 4 Apr 2018 17:05:25 -0700 X-Google-Sender-Auth: vvA8Fb8YYDnj95s0eLd5C8-9-b4 Message-ID: Subject: Re: [GIT PULL] x86/build changes for v4.17 To: Matthias Kaehlcke Cc: Arnd Bergmann , Peter Zijlstra , Ingo Molnar , Linux Kernel Mailing List , Thomas Gleixner , Andrew Morton , James Y Knight , Chandler Carruth , Stephen Hines , Nick Desaulniers , Kees Cook , Guenter Roeck , Greg Hackmann , Greg Kroah-Hartman 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, Apr 4, 2018 at 4:31 PM, Matthias Kaehlcke wrote: > > From some experiments it looks like clang, in difference to gcc, does > not treat constant values passed as parameters to inline function as > constants. Yeah, I think gcc used to have those semantics a long time ago too. Many of our __builtin_constant_p() uses are indeed just in macros, but certainly not all. Other examples are found in our "fortified" string functions. There a clang build will likely simply miss some of the build-time fortification checks, and trigger them at runtime instead. Of course, we hopefully don't *have* any build-time failures, because gcc will have caught them, so you won't care as long as clang is a secondary compiler, but long-term they'd be good. > I'll ask our compiler folks to take a look, with lower priority than > other issues in this thread though. Ack. "asm goto" is way more important. The __builtin_constant_p() stuff tends to be for various peephole optimizations. Another example of that can be found in our x86 bit operations macros: static __always_inline void set_bit(long nr, volatile unsigned long *addr) { if (IS_IMMEDIATE(nr)) { asm volatile(LOCK_PREFIX "orb %1,%0" : CONST_MASK_ADDR(nr, addr) : "iq" ((u8)CONST_MASK(nr)) : "memory"); } else { asm volatile(LOCK_PREFIX __ASM_SIZE(bts) " %1,%0" : BITOP_ADDR(addr) : "Ir" (nr) : "memory"); } } where that IS_IMMEDIATE() hides a __builtin_constant_p(). But we could actually change that - for some reason the test_bit() case looks like this: #define test_bit(nr, addr) \ (__builtin_constant_p((nr)) \ ? constant_test_bit((nr), (addr)) \ : variable_test_bit((nr), (addr))) which is much more straightforward anyway. I'm not quite sure why we did it that odd way anyway, but I bet it's just "hysterical raisins" along with the test_bit() not needing inline asm at all for the constant case. Linus