diff options
author | Jason Baron <jbaron@redhat.com> | 2010-09-17 11:09:00 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-09-22 16:29:41 -0400 |
commit | bf5438fca2950b03c21ad868090cc1a8fcd49536 (patch) | |
tree | 9fc5693763263704de8d8ba1c37a84172dbe5eb7 /include/linux/jump_label.h | |
parent | fa6f2cc77081792e4edca9168420a3422299ef15 (diff) |
jump label: Base patch for jump label
base patch to implement 'jump labeling'. Based on a new 'asm goto' inline
assembly gcc mechanism, we can now branch to labels from an 'asm goto'
statment. This allows us to create a 'no-op' fastpath, which can subsequently
be patched with a jump to the slowpath code. This is useful for code which
might be rarely used, but which we'd like to be able to call, if needed.
Tracepoints are the current usecase that these are being implemented for.
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jason Baron <jbaron@redhat.com>
LKML-Reference: <ee8b3595967989fdaf84e698dc7447d315ce972a.1284733808.git.jbaron@redhat.com>
[ cleaned up some formating ]
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'include/linux/jump_label.h')
-rw-r--r-- | include/linux/jump_label.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h new file mode 100644 index 000000000000..de58656d28e0 --- /dev/null +++ b/include/linux/jump_label.h | |||
@@ -0,0 +1,58 @@ | |||
1 | #ifndef _LINUX_JUMP_LABEL_H | ||
2 | #define _LINUX_JUMP_LABEL_H | ||
3 | |||
4 | #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_HAVE_ARCH_JUMP_LABEL) | ||
5 | # include <asm/jump_label.h> | ||
6 | # define HAVE_JUMP_LABEL | ||
7 | #endif | ||
8 | |||
9 | enum jump_label_type { | ||
10 | JUMP_LABEL_ENABLE, | ||
11 | JUMP_LABEL_DISABLE | ||
12 | }; | ||
13 | |||
14 | struct module; | ||
15 | |||
16 | #ifdef HAVE_JUMP_LABEL | ||
17 | |||
18 | extern struct jump_entry __start___jump_table[]; | ||
19 | extern struct jump_entry __stop___jump_table[]; | ||
20 | |||
21 | extern void arch_jump_label_transform(struct jump_entry *entry, | ||
22 | enum jump_label_type type); | ||
23 | extern void jump_label_update(unsigned long key, enum jump_label_type type); | ||
24 | extern void jump_label_apply_nops(struct module *mod); | ||
25 | extern void arch_jump_label_text_poke_early(jump_label_t addr); | ||
26 | |||
27 | #define enable_jump_label(key) \ | ||
28 | jump_label_update((unsigned long)key, JUMP_LABEL_ENABLE); | ||
29 | |||
30 | #define disable_jump_label(key) \ | ||
31 | jump_label_update((unsigned long)key, JUMP_LABEL_DISABLE); | ||
32 | |||
33 | #else | ||
34 | |||
35 | #define JUMP_LABEL(key, label) \ | ||
36 | do { \ | ||
37 | if (unlikely(*key)) \ | ||
38 | goto label; \ | ||
39 | } while (0) | ||
40 | |||
41 | #define enable_jump_label(cond_var) \ | ||
42 | do { \ | ||
43 | *(cond_var) = 1; \ | ||
44 | } while (0) | ||
45 | |||
46 | #define disable_jump_label(cond_var) \ | ||
47 | do { \ | ||
48 | *(cond_var) = 0; \ | ||
49 | } while (0) | ||
50 | |||
51 | static inline int jump_label_apply_nops(struct module *mod) | ||
52 | { | ||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | #endif | ||
57 | |||
58 | #endif | ||