diff options
Diffstat (limited to 'include/linux/compiler.h')
-rw-r--r-- | include/linux/compiler.h | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index cf0fa5d86059..627e697e5d25 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -27,7 +27,11 @@ extern void __chk_user_ptr(const volatile void __user *); | |||
27 | extern void __chk_io_ptr(const volatile void __iomem *); | 27 | extern void __chk_io_ptr(const volatile void __iomem *); |
28 | # define ACCESS_PRIVATE(p, member) (*((typeof((p)->member) __force *) &(p)->member)) | 28 | # define ACCESS_PRIVATE(p, member) (*((typeof((p)->member) __force *) &(p)->member)) |
29 | #else /* __CHECKER__ */ | 29 | #else /* __CHECKER__ */ |
30 | # define __user | 30 | # ifdef STRUCTLEAK_PLUGIN |
31 | # define __user __attribute__((user)) | ||
32 | # else | ||
33 | # define __user | ||
34 | # endif | ||
31 | # define __kernel | 35 | # define __kernel |
32 | # define __safe | 36 | # define __safe |
33 | # define __force | 37 | # define __force |
@@ -101,29 +105,36 @@ struct ftrace_branch_data { | |||
101 | }; | 105 | }; |
102 | }; | 106 | }; |
103 | 107 | ||
108 | struct ftrace_likely_data { | ||
109 | struct ftrace_branch_data data; | ||
110 | unsigned long constant; | ||
111 | }; | ||
112 | |||
104 | /* | 113 | /* |
105 | * Note: DISABLE_BRANCH_PROFILING can be used by special lowlevel code | 114 | * Note: DISABLE_BRANCH_PROFILING can be used by special lowlevel code |
106 | * to disable branch tracing on a per file basis. | 115 | * to disable branch tracing on a per file basis. |
107 | */ | 116 | */ |
108 | #if defined(CONFIG_TRACE_BRANCH_PROFILING) \ | 117 | #if defined(CONFIG_TRACE_BRANCH_PROFILING) \ |
109 | && !defined(DISABLE_BRANCH_PROFILING) && !defined(__CHECKER__) | 118 | && !defined(DISABLE_BRANCH_PROFILING) && !defined(__CHECKER__) |
110 | void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); | 119 | void ftrace_likely_update(struct ftrace_likely_data *f, int val, |
120 | int expect, int is_constant); | ||
111 | 121 | ||
112 | #define likely_notrace(x) __builtin_expect(!!(x), 1) | 122 | #define likely_notrace(x) __builtin_expect(!!(x), 1) |
113 | #define unlikely_notrace(x) __builtin_expect(!!(x), 0) | 123 | #define unlikely_notrace(x) __builtin_expect(!!(x), 0) |
114 | 124 | ||
115 | #define __branch_check__(x, expect) ({ \ | 125 | #define __branch_check__(x, expect, is_constant) ({ \ |
116 | int ______r; \ | 126 | int ______r; \ |
117 | static struct ftrace_branch_data \ | 127 | static struct ftrace_likely_data \ |
118 | __attribute__((__aligned__(4))) \ | 128 | __attribute__((__aligned__(4))) \ |
119 | __attribute__((section("_ftrace_annotated_branch"))) \ | 129 | __attribute__((section("_ftrace_annotated_branch"))) \ |
120 | ______f = { \ | 130 | ______f = { \ |
121 | .func = __func__, \ | 131 | .data.func = __func__, \ |
122 | .file = __FILE__, \ | 132 | .data.file = __FILE__, \ |
123 | .line = __LINE__, \ | 133 | .data.line = __LINE__, \ |
124 | }; \ | 134 | }; \ |
125 | ______r = likely_notrace(x); \ | 135 | ______r = __builtin_expect(!!(x), expect); \ |
126 | ftrace_likely_update(&______f, ______r, expect); \ | 136 | ftrace_likely_update(&______f, ______r, \ |
137 | expect, is_constant); \ | ||
127 | ______r; \ | 138 | ______r; \ |
128 | }) | 139 | }) |
129 | 140 | ||
@@ -133,10 +144,10 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); | |||
133 | * written by Daniel Walker. | 144 | * written by Daniel Walker. |
134 | */ | 145 | */ |
135 | # ifndef likely | 146 | # ifndef likely |
136 | # define likely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 1)) | 147 | # define likely(x) (__branch_check__(x, 1, __builtin_constant_p(x))) |
137 | # endif | 148 | # endif |
138 | # ifndef unlikely | 149 | # ifndef unlikely |
139 | # define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0)) | 150 | # define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x))) |
140 | # endif | 151 | # endif |
141 | 152 | ||
142 | #ifdef CONFIG_PROFILE_ALL_BRANCHES | 153 | #ifdef CONFIG_PROFILE_ALL_BRANCHES |