aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/compiler.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/compiler.h')
-rw-r--r--include/linux/compiler.h27
1 files changed, 17 insertions, 10 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 91c30cba984e..627e697e5d25 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -105,29 +105,36 @@ struct ftrace_branch_data {
105 }; 105 };
106}; 106};
107 107
108struct ftrace_likely_data {
109 struct ftrace_branch_data data;
110 unsigned long constant;
111};
112
108/* 113/*
109 * Note: DISABLE_BRANCH_PROFILING can be used by special lowlevel code 114 * Note: DISABLE_BRANCH_PROFILING can be used by special lowlevel code
110 * to disable branch tracing on a per file basis. 115 * to disable branch tracing on a per file basis.
111 */ 116 */
112#if defined(CONFIG_TRACE_BRANCH_PROFILING) \ 117#if defined(CONFIG_TRACE_BRANCH_PROFILING) \
113 && !defined(DISABLE_BRANCH_PROFILING) && !defined(__CHECKER__) 118 && !defined(DISABLE_BRANCH_PROFILING) && !defined(__CHECKER__)
114void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); 119void ftrace_likely_update(struct ftrace_likely_data *f, int val,
120 int expect, int is_constant);
115 121
116#define likely_notrace(x) __builtin_expect(!!(x), 1) 122#define likely_notrace(x) __builtin_expect(!!(x), 1)
117#define unlikely_notrace(x) __builtin_expect(!!(x), 0) 123#define unlikely_notrace(x) __builtin_expect(!!(x), 0)
118 124
119#define __branch_check__(x, expect) ({ \ 125#define __branch_check__(x, expect, is_constant) ({ \
120 int ______r; \ 126 int ______r; \
121 static struct ftrace_branch_data \ 127 static struct ftrace_likely_data \
122 __attribute__((__aligned__(4))) \ 128 __attribute__((__aligned__(4))) \
123 __attribute__((section("_ftrace_annotated_branch"))) \ 129 __attribute__((section("_ftrace_annotated_branch"))) \
124 ______f = { \ 130 ______f = { \
125 .func = __func__, \ 131 .data.func = __func__, \
126 .file = __FILE__, \ 132 .data.file = __FILE__, \
127 .line = __LINE__, \ 133 .data.line = __LINE__, \
128 }; \ 134 }; \
129 ______r = likely_notrace(x); \ 135 ______r = __builtin_expect(!!(x), expect); \
130 ftrace_likely_update(&______f, ______r, expect); \ 136 ftrace_likely_update(&______f, ______r, \
137 expect, is_constant); \
131 ______r; \ 138 ______r; \
132 }) 139 })
133 140
@@ -137,10 +144,10 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
137 * written by Daniel Walker. 144 * written by Daniel Walker.
138 */ 145 */
139# ifndef likely 146# ifndef likely
140# define likely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 1)) 147# define likely(x) (__branch_check__(x, 1, __builtin_constant_p(x)))
141# endif 148# endif
142# ifndef unlikely 149# ifndef unlikely
143# define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0)) 150# define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x)))
144# endif 151# endif
145 152
146#ifdef CONFIG_PROFILE_ALL_BRANCHES 153#ifdef CONFIG_PROFILE_ALL_BRANCHES