diff --git a/[refs] b/[refs] index 30d8a50def54..80e6db6bbc93 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0429149fb5e01edc410648591c19095d2074ee00 +refs/heads/master: 1d926f2756392c6909f60e0c9fe2a09d5462e376 diff --git a/trunk/include/asm-generic/vmlinux.lds.h b/trunk/include/asm-generic/vmlinux.lds.h index eba835a2c2cd..3b46ae464933 100644 --- a/trunk/include/asm-generic/vmlinux.lds.h +++ b/trunk/include/asm-generic/vmlinux.lds.h @@ -46,21 +46,16 @@ #endif #ifdef CONFIG_TRACE_BRANCH_PROFILING -#define LIKELY_PROFILE() VMLINUX_SYMBOL(__start_annotated_branch_profile) = .; \ - *(_ftrace_annotated_branch) \ - VMLINUX_SYMBOL(__stop_annotated_branch_profile) = .; +#define LIKELY_PROFILE() VMLINUX_SYMBOL(__start_likely_profile) = .; \ + *(_ftrace_likely) \ + VMLINUX_SYMBOL(__stop_likely_profile) = .; \ + VMLINUX_SYMBOL(__start_unlikely_profile) = .; \ + *(_ftrace_unlikely) \ + VMLINUX_SYMBOL(__stop_unlikely_profile) = .; #else #define LIKELY_PROFILE() #endif -#ifdef CONFIG_PROFILE_ALL_BRANCHES -#define BRANCH_PROFILE() VMLINUX_SYMBOL(__start_branch_profile) = .; \ - *(_ftrace_branch) \ - VMLINUX_SYMBOL(__stop_branch_profile) = .; -#else -#define BRANCH_PROFILE() -#endif - /* .data section */ #define DATA_DATA \ *(.data) \ @@ -80,8 +75,7 @@ VMLINUX_SYMBOL(__start___tracepoints) = .; \ *(__tracepoints) \ VMLINUX_SYMBOL(__stop___tracepoints) = .; \ - LIKELY_PROFILE() \ - BRANCH_PROFILE() + LIKELY_PROFILE() #define RO_DATA(align) \ . = ALIGN((align)); \ diff --git a/trunk/include/linux/compiler.h b/trunk/include/linux/compiler.h index ea7c6be354b7..c7d804a7a4d6 100644 --- a/trunk/include/linux/compiler.h +++ b/trunk/include/linux/compiler.h @@ -63,16 +63,8 @@ struct ftrace_branch_data { const char *func; const char *file; unsigned line; - union { - struct { - unsigned long correct; - unsigned long incorrect; - }; - struct { - unsigned long miss; - unsigned long hit; - }; - }; + unsigned long correct; + unsigned long incorrect; }; /* @@ -85,18 +77,34 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); #define likely_notrace(x) __builtin_expect(!!(x), 1) #define unlikely_notrace(x) __builtin_expect(!!(x), 0) -#define __branch_check__(x, expect) ({ \ +#define likely_check(x) ({ \ int ______r; \ static struct ftrace_branch_data \ __attribute__((__aligned__(4))) \ - __attribute__((section("_ftrace_annotated_branch"))) \ + __attribute__((section("_ftrace_likely"))) \ ______f = { \ .func = __func__, \ .file = __FILE__, \ .line = __LINE__, \ }; \ + ______f.line = __LINE__; \ ______r = likely_notrace(x); \ - ftrace_likely_update(&______f, ______r, expect); \ + ftrace_likely_update(&______f, ______r, 1); \ + ______r; \ + }) +#define unlikely_check(x) ({ \ + int ______r; \ + static struct ftrace_branch_data \ + __attribute__((__aligned__(4))) \ + __attribute__((section("_ftrace_unlikely"))) \ + ______f = { \ + .func = __func__, \ + .file = __FILE__, \ + .line = __LINE__, \ + }; \ + ______f.line = __LINE__; \ + ______r = unlikely_notrace(x); \ + ftrace_likely_update(&______f, ______r, 0); \ ______r; \ }) @@ -106,37 +114,11 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); * written by Daniel Walker. */ # ifndef likely -# define likely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 1)) +# define likely(x) (__builtin_constant_p(x) ? !!(x) : likely_check(x)) # endif # ifndef unlikely -# define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0)) +# define unlikely(x) (__builtin_constant_p(x) ? !!(x) : unlikely_check(x)) # endif - -#ifdef CONFIG_PROFILE_ALL_BRANCHES -/* - * "Define 'is'", Bill Clinton - * "Define 'if'", Steven Rostedt - */ -#define if(cond) if (__builtin_constant_p((cond)) ? !!(cond) : \ - ({ \ - int ______r; \ - static struct ftrace_branch_data \ - __attribute__((__aligned__(4))) \ - __attribute__((section("_ftrace_branch"))) \ - ______f = { \ - .func = __func__, \ - .file = __FILE__, \ - .line = __LINE__, \ - }; \ - ______r = !!(cond); \ - if (______r) \ - ______f.hit++; \ - else \ - ______f.miss++; \ - ______r; \ - })) -#endif /* CONFIG_PROFILE_ALL_BRANCHES */ - #else # define likely(x) __builtin_expect(!!(x), 1) # define unlikely(x) __builtin_expect(!!(x), 0) diff --git a/trunk/init/main.c b/trunk/init/main.c index e810196bf2f2..79213c0785d2 100644 --- a/trunk/init/main.c +++ b/trunk/init/main.c @@ -723,7 +723,7 @@ int do_one_initcall(initcall_t fn) disable_boot_trace(); rettime = ktime_get(); delta = ktime_sub(rettime, calltime); - ret.duration = (unsigned long long) delta.tv64 >> 10; + ret.duration = (unsigned long long) ktime_to_ns(delta) >> 10; trace_boot_ret(&ret, fn); printk("initcall %pF returned %d after %Ld usecs\n", fn, ret.result, ret.duration); diff --git a/trunk/kernel/trace/Kconfig b/trunk/kernel/trace/Kconfig index 61e8cca6ff45..b8378fad29a3 100644 --- a/trunk/kernel/trace/Kconfig +++ b/trunk/kernel/trace/Kconfig @@ -166,29 +166,14 @@ config TRACE_BRANCH_PROFILING This tracer profiles all the the likely and unlikely macros in the kernel. It will display the results in: - /debugfs/tracing/profile_annotated_branch + /debugfs/tracing/profile_likely + /debugfs/tracing/profile_unlikely Note: this will add a significant overhead, only turn this on if you need to profile the system's use of these macros. Say N if unsure. -config PROFILE_ALL_BRANCHES - bool "Profile all if conditionals" - depends on TRACE_BRANCH_PROFILING - help - This tracer profiles all branch conditions. Every if () - taken in the kernel is recorded whether it hit or miss. - The results will be displayed in: - - /debugfs/tracing/profile_branch - - This configuration, when enabled, will impose a great overhead - on the system. This should only be enabled when the system - is to be analyzed - - Say N if unsure. - config TRACING_BRANCHES bool help diff --git a/trunk/kernel/trace/trace_branch.c b/trunk/kernel/trace/trace_branch.c index 877ee88e6a74..23f9b02ce967 100644 --- a/trunk/kernel/trace/trace_branch.c +++ b/trunk/kernel/trace/trace_branch.c @@ -185,13 +185,12 @@ EXPORT_SYMBOL(ftrace_likely_update); struct ftrace_pointer { void *start; void *stop; - int hit; }; static void * t_next(struct seq_file *m, void *v, loff_t *pos) { - const struct ftrace_pointer *f = m->private; + struct ftrace_pointer *f = m->private; struct ftrace_branch_data *p = v; (*pos)++; @@ -224,17 +223,13 @@ static void t_stop(struct seq_file *m, void *p) static int t_show(struct seq_file *m, void *v) { - const struct ftrace_pointer *fp = m->private; struct ftrace_branch_data *p = v; const char *f; - long percent; + unsigned long percent; if (v == (void *)1) { - if (fp->hit) - seq_printf(m, " miss hit %% "); - else - seq_printf(m, " correct incorrect %% "); - seq_printf(m, " Function " + seq_printf(m, " correct incorrect %% " + " Function " " File Line\n" " ------- --------- - " " -------- " @@ -248,20 +243,13 @@ static int t_show(struct seq_file *m, void *v) f--; f++; - /* - * The miss is overlayed on correct, and hit on incorrect. - */ if (p->correct) { percent = p->incorrect * 100; percent /= p->correct + p->incorrect; } else - percent = p->incorrect ? 100 : -1; + percent = p->incorrect ? 100 : 0; - seq_printf(m, "%8lu %8lu ", p->correct, p->incorrect); - if (percent < 0) - seq_printf(m, " X "); - else - seq_printf(m, "%3ld ", percent); + seq_printf(m, "%8lu %8lu %3lu ", p->correct, p->incorrect, percent); seq_printf(m, "%-30.30s %-20.20s %d\n", p->func, f, p->line); return 0; } @@ -273,7 +261,7 @@ static struct seq_operations tracing_likely_seq_ops = { .show = t_show, }; -static int tracing_branch_open(struct inode *inode, struct file *file) +static int tracing_likely_open(struct inode *inode, struct file *file) { int ret; @@ -286,30 +274,25 @@ static int tracing_branch_open(struct inode *inode, struct file *file) return ret; } -static const struct file_operations tracing_branch_fops = { - .open = tracing_branch_open, +static struct file_operations tracing_likely_fops = { + .open = tracing_likely_open, .read = seq_read, .llseek = seq_lseek, }; -#ifdef CONFIG_PROFILE_ALL_BRANCHES -extern unsigned long __start_branch_profile[]; -extern unsigned long __stop_branch_profile[]; +extern unsigned long __start_likely_profile[]; +extern unsigned long __stop_likely_profile[]; +extern unsigned long __start_unlikely_profile[]; +extern unsigned long __stop_unlikely_profile[]; -static const struct ftrace_pointer ftrace_branch_pos = { - .start = __start_branch_profile, - .stop = __stop_branch_profile, - .hit = 1, +static struct ftrace_pointer ftrace_likely_pos = { + .start = __start_likely_profile, + .stop = __stop_likely_profile, }; -#endif /* CONFIG_PROFILE_ALL_BRANCHES */ - -extern unsigned long __start_annotated_branch_profile[]; -extern unsigned long __stop_annotated_branch_profile[]; - -static const struct ftrace_pointer ftrace_annotated_branch_pos = { - .start = __start_annotated_branch_profile, - .stop = __stop_annotated_branch_profile, +static struct ftrace_pointer ftrace_unlikely_pos = { + .start = __start_unlikely_profile, + .stop = __stop_unlikely_profile, }; static __init int ftrace_branch_init(void) @@ -319,21 +302,18 @@ static __init int ftrace_branch_init(void) d_tracer = tracing_init_dentry(); - entry = debugfs_create_file("profile_annotated_branch", 0444, d_tracer, - (void *)&ftrace_annotated_branch_pos, - &tracing_branch_fops); + entry = debugfs_create_file("profile_likely", 0444, d_tracer, + &ftrace_likely_pos, + &tracing_likely_fops); if (!entry) - pr_warning("Could not create debugfs " - "'profile_annotatet_branch' entry\n"); + pr_warning("Could not create debugfs 'profile_likely' entry\n"); -#ifdef CONFIG_PROFILE_ALL_BRANCHES - entry = debugfs_create_file("profile_branch", 0444, d_tracer, - (void *)&ftrace_branch_pos, - &tracing_branch_fops); + entry = debugfs_create_file("profile_unlikely", 0444, d_tracer, + &ftrace_unlikely_pos, + &tracing_likely_fops); if (!entry) pr_warning("Could not create debugfs" - " 'profile_branch' entry\n"); -#endif + " 'profile_unlikely' entry\n"); return 0; }