Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5197455imb; Thu, 7 Mar 2019 09:49:21 -0800 (PST) X-Google-Smtp-Source: APXvYqy1VD2vx307CIIH7cvbOfc+tTFblkpGwrI7q+IqLTfz4XQ/CXkH4VknnTP9aQEyeKfxOtFG X-Received: by 2002:a17:902:6b47:: with SMTP id g7mr14407614plt.100.1551980961380; Thu, 07 Mar 2019 09:49:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551980961; cv=none; d=google.com; s=arc-20160816; b=fnZ1NdJfsXbmJVHtIzFb20x/9XqNwZrQA39ls2e4vX3hdoAGTPixlrqWUHVJPmn/ta /5eA6E9i5o48218yzp/kNXL/vMXfSbsFgUK2rVjisZzQQSrhRgeDmZ7648vqmXExD2pp Flyn6sRTwlO6gO88PathCof8pucPi9W4Di2KCNC9r4pLzO/AWXaR5RMK5nwak0RgENJj Qpww1fvWD/zdK/UJo6ich7QUwjpGD0EmoF+8nllaWqRPND3E+mpMTktaC5VD3JiXdICR CnWat7GnkyNlXRPLanQ+jDerJzWcfNVEIWamsZ2a1gJNq8VJFqm4SMHhJ/kBFI7MVQTk WVFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=rTVuIx4Qyc4NLRDzLtIKvKuSRL8A9OYBQQxomhCfjyw=; b=os0Cy8cHL0PUEp+0HzJVAZfnF7jugo4gl79K4S/CWVH0+H/ZDigQVwPy3pjtxE+jJl 9DTWTTfdz/e+7mwlAli9QTClodtoKWDGsM46CM9Lm8M00EjvAZ50r3EOfx/XF3+iXb/q qL5YZiV+eZvjM9bTYZYScYNzVDPpz00oDRoidlySC09idbzwcxJseccHbTlhhNibugjG MOWFrIW55DJWwXn5NbHwFh3L9Jvg8VoDfF31JkHB2/OQKys06qPvQIktTu/oLMnZE2p6 WNuT34KiRsxzQjo8aUjbRzeQ4k5nuoQQdzO4Jx8WdxFEezonaO+TdvrYAyjpQxMIstlm BP3w== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 8si4392523pgq.591.2019.03.07.09.49.05; Thu, 07 Mar 2019 09:49:21 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726765AbfCGRsI (ORCPT + 99 others); Thu, 7 Mar 2019 12:48:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39834 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726729AbfCGRsG (ORCPT ); Thu, 7 Mar 2019 12:48:06 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1E9B307D98B; Thu, 7 Mar 2019 17:48:05 +0000 (UTC) Received: from treble (ovpn-120-61.rdu2.redhat.com [10.10.120.61]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E24245D9C6; Thu, 7 Mar 2019 17:48:03 +0000 (UTC) Date: Thu, 7 Mar 2019 11:48:02 -0600 From: Josh Poimboeuf To: Peter Zijlstra Cc: torvalds@linux-foundation.org, tglx@linutronix.de, hpa@zytor.com, julien.thierry@arm.com, will.deacon@arm.com, luto@amacapital.net, mingo@kernel.org, catalin.marinas@arm.com, james.morse@arm.com, valentin.schneider@arm.com, brgerst@gmail.com, luto@kernel.org, bp@alien8.de, dvlasenk@redhat.com, linux-kernel@vger.kernel.org, dvyukov@google.com, rostedt@goodmis.org Subject: Re: [PATCH 00/20] objtool: UACCESS validation v3 Message-ID: <20190307174802.46fmpysxyo35hh43@treble> References: <20190307114511.870090179@infradead.org> <20190307120317.GD32477@hirez.programming.kicks-ass.net> <20190307125526.GB32534@hirez.programming.kicks-ass.net> <20190307131312.GC32534@hirez.programming.kicks-ass.net> <20190307164705.qbu4ytdfdmsighas@treble> <20190307174322.GK32477@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190307174322.GK32477@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 07 Mar 2019 17:48:06 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 07, 2019 at 06:43:22PM +0100, Peter Zijlstra wrote: > On Thu, Mar 07, 2019 at 10:47:05AM -0600, Josh Poimboeuf wrote: > > > This "fixes" it, and also seems to help -Os make much code: > > > > diff --git a/include/linux/compiler.h b/include/linux/compiler.h > > index 445348facea9..8de63db58fdd 100644 > > --- a/include/linux/compiler.h > > +++ b/include/linux/compiler.h > > @@ -67,7 +67,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, > > .line = __LINE__, \ > > }; \ > > ______r = !!(cond); \ > > - ______f.miss_hit[______r]++; \ > > + if (______r) ______f.miss_hit[1]++; else ______f.miss_hit[0]++; \ > > ______r; \ > > })) > > #endif /* CONFIG_PROFILE_ALL_BRANCHES */ > > Excellen; let me put the kids to bed and then I'll have a poke. Here's a proper patch. From: Josh Poimboeuf Subject: [PATCH] tracing: Improve "if" macro code generation With CONFIG_PROFILE_ALL_BRANCHES, the "if" macro converts the conditional to an array index. This can cause GCC to create horrible code. When there are nested ifs, the generated code uses register values to encode branching decisions. Make it easier for GCC to optimize by keeping the conditional as a conditional rather than converting it to an integer. This shrinks the generated code quite a bit, and also makes the code sane enough for objtool to understand. Reported-by: Peter Zijlstra Signed-off-by: Josh Poimboeuf --- include/linux/compiler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 445348facea9..d58aa0db05f9 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -67,7 +67,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, .line = __LINE__, \ }; \ ______r = !!(cond); \ - ______f.miss_hit[______r]++; \ + ______r ? ______f.miss_hit[1]++ : ______f.miss_hit[0]++;\ ______r; \ })) #endif /* CONFIG_PROFILE_ALL_BRANCHES */ -- 2.17.2