Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755008AbZCMDe0 (ORCPT ); Thu, 12 Mar 2009 23:34:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757910AbZCMDeF (ORCPT ); Thu, 12 Mar 2009 23:34:05 -0400 Received: from hrndva-omtalb.mail.rr.com ([71.74.56.125]:58906 "EHLO hrndva-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757857AbZCMDeE (ORCPT ); Thu, 12 Mar 2009 23:34:04 -0400 Date: Thu, 12 Mar 2009 23:34:01 -0400 (EDT) From: Steven Rostedt X-X-Sender: rostedt@gandalf.stny.rr.com To: KOSAKI Motohiro cc: linux-kernel@vger.kernel.org, Ingo Molnar , Andrew Morton , Peter Zijlstra , Frederic Weisbecker , Lai Jiangshan , Steven Rostedt Subject: Re: [PATCH 08/16] tracing: have event_trace_printk use static tracer In-Reply-To: <20090313122235.43EB.A69D9226@jp.fujitsu.com> Message-ID: References: <20090313120855.43E8.A69D9226@jp.fujitsu.com> <20090313122235.43EB.A69D9226@jp.fujitsu.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1962 Lines: 52 On Fri, 13 Mar 2009, KOSAKI Motohiro wrote: > > > > +#define event_trace_printk(ip, fmt, args...) \ > > > > +do { \ > > > > + __trace_printk_check_format(fmt, ##args); \ > > > > + tracing_record_cmdline(current); \ > > > > + if (__builtin_constant_p(fmt)) { \ > > > > + static const char *trace_printk_fmt \ > > > > + __attribute__((section("__trace_printk_fmt"))) = \ > > > > + __builtin_constant_p(fmt) ? fmt : NULL; \ > > > > > > Why __builtin_constant_p(fmt) evaluate twice? > > > > It's explained in another patch. But this was a real PITA. We first tried > > this with just the "if (__builtin_return_p(fmt))" but the way gcc works, > > it handles the global data assignments before optimizing out condition > > logic. Thus we ended up getting errors about can not initialize static > > variable with a non constant. > > > > But the ? : operation of the assignment is optimized before the assignment > > is made. Thus, if fmt is not constant, then we avoid this warning. Then > > during the conditional optimization, gcc will remove that part of the code > > altogether. > > > > Thus the double __builtin_constant_p(fmt) is needed twice. Try taking out > > one of them and see what happens with: > > > > myfunc(const char *fmt) { > > > > event_trace_printk(fmt); > > > > } > > > > Of course the way this is made, we may not call it that way, but I wanted > > to be safe. > > Thanks for kindful explain. > So, I guess many developer feel it's strange. > adding comment is better? Yeah, I cut and pasted this out from the trace_printk in kernel.h where I had the comment there. But I think you are right, I probably should copy that comment here too. -- Steve -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/