summaryrefslogtreecommitdiffstats
path: root/include/linux/compiler.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-27 16:26:17 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-27 16:26:17 -0500
commit79b17ea740d9fab178d6a1aa15d848b5e6c01b82 (patch)
treeb0c18df8713999e16bcc6e5a32cbef880efb3b10 /include/linux/compiler.h
parente5d56efc97f8240d0b5d66c03949382b6d7e5570 (diff)
parent67d04bb2bcbd3e99f4c4daa58599c90a83ad314a (diff)
Merge tag 'trace-v4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing updates from Steven Rostedt: "This release has no new tracing features, just clean ups, minor fixes and small optimizations" * tag 'trace-v4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (25 commits) tracing: Remove outdated ring buffer comment tracing/probes: Fix a warning message to show correct maximum length tracing: Fix return value check in trace_benchmark_reg() tracing: Use modern function declaration jump_label: Reduce the size of struct static_key tracing/probe: Show subsystem name in messages tracing/hwlat: Update old comment about migration timers: Make flags output in the timer_start tracepoint useful tracing: Have traceprobe_probes_write() not access userspace unnecessarily tracing: Have COMM event filter key be treated as a string ftrace: Have set_graph_function handle multiple functions in one write ftrace: Do not hold references of ftrace_graph_{notrace_}hash out of graph_lock tracing: Reset parser->buffer to allow multiple "puts" ftrace: Have set_graph_functions handle write with RDWR ftrace: Reset fgd->hash in ftrace_graph_write() ftrace: Replace (void *)1 with a meaningful macro name FTRACE_GRAPH_EMPTY ftrace: Create a slight optimization on searching the ftrace_hash tracing: Add ftrace_hash_key() helper function ftrace: Convert graph filter to use hash tables ftrace: Expose ftrace_hash_empty and ftrace_lookup_ip ...
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