trace: consolidate unlikely and likely profiler
Impact: clean up to make one profiler of like and unlikely tracer The likely and unlikely profiler prints out the file and line numbers of the annotated branches that it is profiling. It shows the number of times it was correct or incorrect in its guess. Having two different files or sections for that matter to tell us if it was a likely or unlikely is pretty pointless. We really only care if it was correct or not. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Родитель
42f565e116
Коммит
45b797492a
|
@ -46,12 +46,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_TRACE_BRANCH_PROFILING
|
#ifdef CONFIG_TRACE_BRANCH_PROFILING
|
||||||
#define LIKELY_PROFILE() VMLINUX_SYMBOL(__start_likely_profile) = .; \
|
#define LIKELY_PROFILE() VMLINUX_SYMBOL(__start_annotated_branch_profile) = .; \
|
||||||
*(_ftrace_likely) \
|
*(_ftrace_annotated_branch) \
|
||||||
VMLINUX_SYMBOL(__stop_likely_profile) = .; \
|
VMLINUX_SYMBOL(__stop_annotated_branch_profile) = .;
|
||||||
VMLINUX_SYMBOL(__start_unlikely_profile) = .; \
|
|
||||||
*(_ftrace_unlikely) \
|
|
||||||
VMLINUX_SYMBOL(__stop_unlikely_profile) = .;
|
|
||||||
#else
|
#else
|
||||||
#define LIKELY_PROFILE()
|
#define LIKELY_PROFILE()
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -77,32 +77,18 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
|
||||||
#define likely_notrace(x) __builtin_expect(!!(x), 1)
|
#define likely_notrace(x) __builtin_expect(!!(x), 1)
|
||||||
#define unlikely_notrace(x) __builtin_expect(!!(x), 0)
|
#define unlikely_notrace(x) __builtin_expect(!!(x), 0)
|
||||||
|
|
||||||
#define likely_check(x) ({ \
|
#define __branch_check__(x, expect) ({ \
|
||||||
int ______r; \
|
int ______r; \
|
||||||
static struct ftrace_branch_data \
|
static struct ftrace_branch_data \
|
||||||
__attribute__((__aligned__(4))) \
|
__attribute__((__aligned__(4))) \
|
||||||
__attribute__((section("_ftrace_likely"))) \
|
__attribute__((section("_ftrace_annotated_branch"))) \
|
||||||
______f = { \
|
______f = { \
|
||||||
.func = __func__, \
|
.func = __func__, \
|
||||||
.file = __FILE__, \
|
.file = __FILE__, \
|
||||||
.line = __LINE__, \
|
.line = __LINE__, \
|
||||||
}; \
|
}; \
|
||||||
______r = likely_notrace(x); \
|
______r = likely_notrace(x); \
|
||||||
ftrace_likely_update(&______f, ______r, 1); \
|
ftrace_likely_update(&______f, ______r, expect); \
|
||||||
______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__, \
|
|
||||||
}; \
|
|
||||||
______r = unlikely_notrace(x); \
|
|
||||||
ftrace_likely_update(&______f, ______r, 0); \
|
|
||||||
______r; \
|
______r; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -112,10 +98,10 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
|
||||||
* written by Daniel Walker.
|
* written by Daniel Walker.
|
||||||
*/
|
*/
|
||||||
# ifndef likely
|
# ifndef likely
|
||||||
# define likely(x) (__builtin_constant_p(x) ? !!(x) : likely_check(x))
|
# define likely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 1))
|
||||||
# endif
|
# endif
|
||||||
# ifndef unlikely
|
# ifndef unlikely
|
||||||
# define unlikely(x) (__builtin_constant_p(x) ? !!(x) : unlikely_check(x))
|
# define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0))
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define likely(x) __builtin_expect(!!(x), 1)
|
# define likely(x) __builtin_expect(!!(x), 1)
|
||||||
|
|
|
@ -166,8 +166,7 @@ config TRACE_BRANCH_PROFILING
|
||||||
This tracer profiles all the the likely and unlikely macros
|
This tracer profiles all the the likely and unlikely macros
|
||||||
in the kernel. It will display the results in:
|
in the kernel. It will display the results in:
|
||||||
|
|
||||||
/debugfs/tracing/profile_likely
|
/debugfs/tracing/profile_annotated_branch
|
||||||
/debugfs/tracing/profile_unlikely
|
|
||||||
|
|
||||||
Note: this will add a significant overhead, only turn this
|
Note: this will add a significant overhead, only turn this
|
||||||
on if you need to profile the system's use of these macros.
|
on if you need to profile the system's use of these macros.
|
||||||
|
|
|
@ -261,7 +261,7 @@ static struct seq_operations tracing_likely_seq_ops = {
|
||||||
.show = t_show,
|
.show = t_show,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int tracing_likely_open(struct inode *inode, struct file *file)
|
static int tracing_branch_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -274,25 +274,18 @@ static int tracing_likely_open(struct inode *inode, struct file *file)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct file_operations tracing_likely_fops = {
|
static const struct file_operations tracing_branch_fops = {
|
||||||
.open = tracing_likely_open,
|
.open = tracing_branch_open,
|
||||||
.read = seq_read,
|
.read = seq_read,
|
||||||
.llseek = seq_lseek,
|
.llseek = seq_lseek,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern unsigned long __start_likely_profile[];
|
extern unsigned long __start_annotated_branch_profile[];
|
||||||
extern unsigned long __stop_likely_profile[];
|
extern unsigned long __stop_annotated_branch_profile[];
|
||||||
extern unsigned long __start_unlikely_profile[];
|
|
||||||
extern unsigned long __stop_unlikely_profile[];
|
|
||||||
|
|
||||||
static struct ftrace_pointer ftrace_likely_pos = {
|
static const struct ftrace_pointer ftrace_annotated_branch_pos = {
|
||||||
.start = __start_likely_profile,
|
.start = __start_annotated_branch_profile,
|
||||||
.stop = __stop_likely_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)
|
static __init int ftrace_branch_init(void)
|
||||||
|
@ -302,18 +295,12 @@ static __init int ftrace_branch_init(void)
|
||||||
|
|
||||||
d_tracer = tracing_init_dentry();
|
d_tracer = tracing_init_dentry();
|
||||||
|
|
||||||
entry = debugfs_create_file("profile_likely", 0444, d_tracer,
|
entry = debugfs_create_file("profile_annotated_branch", 0444, d_tracer,
|
||||||
&ftrace_likely_pos,
|
&ftrace_annotated_branch_pos,
|
||||||
&tracing_likely_fops);
|
&tracing_branch_fops);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
pr_warning("Could not create debugfs 'profile_likely' entry\n");
|
pr_warning("Could not create debugfs "
|
||||||
|
"'profile_annotatet_branch' entry\n");
|
||||||
entry = debugfs_create_file("profile_unlikely", 0444, d_tracer,
|
|
||||||
&ftrace_unlikely_pos,
|
|
||||||
&tracing_likely_fops);
|
|
||||||
if (!entry)
|
|
||||||
pr_warning("Could not create debugfs"
|
|
||||||
" 'profile_unlikely' entry\n");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче