From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932214Ab0JYWcE (ORCPT ); Mon, 25 Oct 2010 18:32:04 -0400 Received: from terminus.zytor.com ([198.137.202.10]:38979 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755531Ab0JYWcA (ORCPT ); Mon, 25 Oct 2010 18:32:00 -0400 Message-ID: <4CC60529.7030102@zytor.com> Date: Mon, 25 Oct 2010 15:31:05 -0700 From: "H. Peter Anvin" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Thunderbird/3.1.4 MIME-Version: 1.0 To: Thomas Gleixner CC: Steven Rostedt , Mathieu Desnoyers , Koki Sanagi , Peter Zijlstra , Ingo Molnar , Frederic Weisbecker , nhorman@tuxdriver.com, scott.a.mcmillan@intel.com, laijs@cn.fujitsu.com, LKML , eric.dumazet@gmail.com, kaneshige.kenji@jp.fujitsu.com, David Miller , izumi.taku@jp.fujitsu.com, kosaki.motohiro@jp.fujitsu.com, Heiko Carstens , "Luck, Tony" Subject: Re: [PATCH] tracing: Cleanup the convoluted softirq tracepoints References: <1287395077.29097.1543.camel@twins> <1287398936.29097.1548.camel@twins> <4CBD79CF.2060706@jp.fujitsu.com> <20101019132236.GA19197@Krystal> <1287496495.16971.372.camel@gandalf.stny.rr.com> <20101019142820.GA14520@Krystal> <1287521757.16971.397.camel@gandalf.stny.rr.com> <1287523439.16971.433.camel@gandalf.stny.rr.com> <1287527634.16971.536.camel@gandalf.stny.rr.com> <1287680725.16971.586.camel@gandalf.stny.rr.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/21/2010 12:56 PM, Thomas Gleixner wrote: > On Thu, 21 Oct 2010, Steven Rostedt wrote: > >> On Thu, 2010-10-21 at 18:18 +0200, Thomas Gleixner wrote: >>> >>> On Tue, 19 Oct 2010, Steven Rostedt wrote: >>> >>>> On Wed, 2010-10-20 at 00:04 +0200, Thomas Gleixner wrote: >>>> >>>>> hpa just posted code which does the _RIGHT_ _THING_ independent of any >>>>> compiler madness and you tracer folks just missed it. >>>> >>>> Thomas, >>>> >>>> Can you try this patch and see if it makes the object code better? >>> >>> Nope, same result. >> >> Yeah, I figured. Do you have CC_OPTIMIZE_FOR_SIZE set? And if you do, >> what happens if you disable it? > > Hmm. Indeed. That gets rid of the double jump. > -Os unfortunately drops a bunch of optimizations. With gcc 4.5.1 there is actually a way to guarantee to get rid of double jumps, which is that you tell gcc that it is branching to one of two targets: asm goto("1: .byte 0xe9 ; .long %l[t_no]-2f\n" "2:\n" /* patching infrastructure goes here */ : : "i" (bit) : : t_no, t_yes); __builtin_unreachable(); t_no: return false; t_yes: return true; [The open-coding of the jump is necessary to force the 5-byte form instead of the 2-byte form.] The patching machinery can recognize the case where the jump offset is zero and patch in a NOP instead. There does, however, seem to be a couple of problems: a) gcc 4.5.1 is required due to a bug in previous versions of gcc when an asm goto doesn't have a fallthrough case. b) it seems to encourage gcc to actively jump around as it reorders blocks, since gcc no longer sees a fallthrough case at all. Not sure I have a good solution for this, at least not with current gcc. -hpa