lkml.org 
[lkml]   [2019]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 02/25] tracing: Improve "if" macro code generation
On Wed, 20 Mar 2019 10:26:17 -0700
Linus Torvalds <torvalds@linux-foundation.org> wrote:


> - Steven has this crazy model of "more underscores are better". They
> aren't. They don't help if things nest anyway, but what does help is
> meaningful names. Both when things don't nest, and when looking at
> generated asm files.

Note, at the time I had Ingo as a mentor ;-)

> include/linux/compiler.h | 35 ++++++++++++++++++-----------------
> 1 file changed, 18 insertions(+), 17 deletions(-)
>
> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> index 445348facea9..8aaf7cd026b0 100644
> --- a/include/linux/compiler.h
> +++ b/include/linux/compiler.h
> @@ -53,23 +53,24 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
> * "Define 'is'", Bill Clinton
> * "Define 'if'", Steven Rostedt
> */
> -#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> -#define __trace_if(cond) \
> - if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
> - ({ \
> - int ______r; \
> - static struct ftrace_branch_data \
> - __aligned(4) \
> - __section("_ftrace_branch") \
> - ______f = { \
> - .func = __func__, \
> - .file = __FILE__, \
> - .line = __LINE__, \
> - }; \
> - ______r = !!(cond); \
> - ______f.miss_hit[______r]++; \
> - ______r; \
> - }))
> +#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
> +
> +#define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
> +
> +#define __trace_if_value(cond) ({ \
> + static struct ftrace_branch_data \
> + __aligned(4) \
> + __section("_ftrace_branch") \
> + __if_trace = { \
> + .func = __func__, \
> + .file = __FILE__, \
> + .line = __LINE__, \
> + }; \
> + (cond) ? \
> + (__if_trace.miss_hit[1]++,1) : \
> + (__if_trace.miss_hit[0]++,0); \

Probably want to add a space between the comma and the numbers.

But other than that.

Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve

> +})
> +
> #endif /* CONFIG_PROFILE_ALL_BRANCHES */
>
> #else

\
 
 \ /
  Last update: 2019-03-20 19:19    [W:0.101 / U:0.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site