diff options
| author | Ingo Molnar <mingo@elte.hu> | 2010-09-24 03:12:05 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2010-09-24 03:12:05 -0400 |
| commit | a5a2bad55de89a0adf7d6f783cb87ab7eb1a894f (patch) | |
| tree | 452cb8addc26f5c79fdd4e2fea92c78dc17fc8e8 /include/linux | |
| parent | d0303d71c2fb9bcb90a8d48e6462c78c86f70ce6 (diff) | |
| parent | 46eb3b64dddd20f44e76b08676fa642dd374bf1d (diff) | |
Merge branch 'tip/perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into perf/core
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/dynamic_debug.h | 39 | ||||
| -rw-r--r-- | include/linux/jump_label.h | 64 | ||||
| -rw-r--r-- | include/linux/module.h | 5 | ||||
| -rw-r--r-- | include/linux/tracepoint.h | 5 |
4 files changed, 93 insertions, 20 deletions
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 52c0da4bdd18..bef3cda44c4c 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #ifndef _DYNAMIC_DEBUG_H | 1 | #ifndef _DYNAMIC_DEBUG_H |
| 2 | #define _DYNAMIC_DEBUG_H | 2 | #define _DYNAMIC_DEBUG_H |
| 3 | 3 | ||
| 4 | #include <linux/jump_label.h> | ||
| 5 | |||
| 4 | /* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which | 6 | /* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which |
| 5 | * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They | 7 | * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They |
| 6 | * use independent hash functions, to reduce the chance of false positives. | 8 | * use independent hash functions, to reduce the chance of false positives. |
| @@ -22,8 +24,6 @@ struct _ddebug { | |||
| 22 | const char *function; | 24 | const char *function; |
| 23 | const char *filename; | 25 | const char *filename; |
| 24 | const char *format; | 26 | const char *format; |
| 25 | char primary_hash; | ||
| 26 | char secondary_hash; | ||
| 27 | unsigned int lineno:24; | 27 | unsigned int lineno:24; |
| 28 | /* | 28 | /* |
| 29 | * The flags field controls the behaviour at the callsite. | 29 | * The flags field controls the behaviour at the callsite. |
| @@ -33,6 +33,7 @@ struct _ddebug { | |||
| 33 | #define _DPRINTK_FLAGS_PRINT (1<<0) /* printk() a message using the format */ | 33 | #define _DPRINTK_FLAGS_PRINT (1<<0) /* printk() a message using the format */ |
| 34 | #define _DPRINTK_FLAGS_DEFAULT 0 | 34 | #define _DPRINTK_FLAGS_DEFAULT 0 |
| 35 | unsigned int flags:8; | 35 | unsigned int flags:8; |
| 36 | char enabled; | ||
| 36 | } __attribute__((aligned(8))); | 37 | } __attribute__((aligned(8))); |
| 37 | 38 | ||
| 38 | 39 | ||
| @@ -42,33 +43,35 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, | |||
| 42 | #if defined(CONFIG_DYNAMIC_DEBUG) | 43 | #if defined(CONFIG_DYNAMIC_DEBUG) |
| 43 | extern int ddebug_remove_module(const char *mod_name); | 44 | extern int ddebug_remove_module(const char *mod_name); |
| 44 | 45 | ||
| 45 | #define __dynamic_dbg_enabled(dd) ({ \ | ||
| 46 | int __ret = 0; \ | ||
| 47 | if (unlikely((dynamic_debug_enabled & (1LL << DEBUG_HASH)) && \ | ||
| 48 | (dynamic_debug_enabled2 & (1LL << DEBUG_HASH2)))) \ | ||
| 49 | if (unlikely(dd.flags)) \ | ||
| 50 | __ret = 1; \ | ||
| 51 | __ret; }) | ||
| 52 | |||
| 53 | #define dynamic_pr_debug(fmt, ...) do { \ | 46 | #define dynamic_pr_debug(fmt, ...) do { \ |
| 47 | __label__ do_printk; \ | ||
| 48 | __label__ out; \ | ||
| 54 | static struct _ddebug descriptor \ | 49 | static struct _ddebug descriptor \ |
| 55 | __used \ | 50 | __used \ |
| 56 | __attribute__((section("__verbose"), aligned(8))) = \ | 51 | __attribute__((section("__verbose"), aligned(8))) = \ |
| 57 | { KBUILD_MODNAME, __func__, __FILE__, fmt, DEBUG_HASH, \ | 52 | { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \ |
| 58 | DEBUG_HASH2, __LINE__, _DPRINTK_FLAGS_DEFAULT }; \ | 53 | _DPRINTK_FLAGS_DEFAULT }; \ |
| 59 | if (__dynamic_dbg_enabled(descriptor)) \ | 54 | JUMP_LABEL(&descriptor.enabled, do_printk); \ |
| 60 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \ | 55 | goto out; \ |
| 56 | do_printk: \ | ||
| 57 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \ | ||
| 58 | out: ; \ | ||
| 61 | } while (0) | 59 | } while (0) |
| 62 | 60 | ||
| 63 | 61 | ||
| 64 | #define dynamic_dev_dbg(dev, fmt, ...) do { \ | 62 | #define dynamic_dev_dbg(dev, fmt, ...) do { \ |
| 63 | __label__ do_printk; \ | ||
| 64 | __label__ out; \ | ||
| 65 | static struct _ddebug descriptor \ | 65 | static struct _ddebug descriptor \ |
| 66 | __used \ | 66 | __used \ |
| 67 | __attribute__((section("__verbose"), aligned(8))) = \ | 67 | __attribute__((section("__verbose"), aligned(8))) = \ |
| 68 | { KBUILD_MODNAME, __func__, __FILE__, fmt, DEBUG_HASH, \ | 68 | { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \ |
| 69 | DEBUG_HASH2, __LINE__, _DPRINTK_FLAGS_DEFAULT }; \ | 69 | _DPRINTK_FLAGS_DEFAULT }; \ |
| 70 | if (__dynamic_dbg_enabled(descriptor)) \ | 70 | JUMP_LABEL(&descriptor.enabled, do_printk); \ |
| 71 | dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ | 71 | goto out; \ |
| 72 | do_printk: \ | ||
| 73 | dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ | ||
| 74 | out: ; \ | ||
| 72 | } while (0) | 75 | } while (0) |
| 73 | 76 | ||
| 74 | #else | 77 | #else |
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h new file mode 100644 index 000000000000..b72cd9f92c2e --- /dev/null +++ b/include/linux/jump_label.h | |||
| @@ -0,0 +1,64 @@ | |||
| 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 arch_jump_label_text_poke_early(jump_label_t addr); | ||
| 24 | extern void jump_label_update(unsigned long key, enum jump_label_type type); | ||
| 25 | extern void jump_label_apply_nops(struct module *mod); | ||
| 26 | extern int jump_label_text_reserved(void *start, void *end); | ||
| 27 | |||
| 28 | #define enable_jump_label(key) \ | ||
| 29 | jump_label_update((unsigned long)key, JUMP_LABEL_ENABLE); | ||
| 30 | |||
| 31 | #define disable_jump_label(key) \ | ||
| 32 | jump_label_update((unsigned long)key, JUMP_LABEL_DISABLE); | ||
| 33 | |||
| 34 | #else | ||
| 35 | |||
| 36 | #define JUMP_LABEL(key, label) \ | ||
| 37 | do { \ | ||
| 38 | if (unlikely(*key)) \ | ||
| 39 | goto label; \ | ||
| 40 | } while (0) | ||
| 41 | |||
| 42 | #define enable_jump_label(cond_var) \ | ||
| 43 | do { \ | ||
| 44 | *(cond_var) = 1; \ | ||
| 45 | } while (0) | ||
| 46 | |||
| 47 | #define disable_jump_label(cond_var) \ | ||
| 48 | do { \ | ||
| 49 | *(cond_var) = 0; \ | ||
| 50 | } while (0) | ||
| 51 | |||
| 52 | static inline int jump_label_apply_nops(struct module *mod) | ||
| 53 | { | ||
| 54 | return 0; | ||
| 55 | } | ||
| 56 | |||
| 57 | static inline int jump_label_text_reserved(void *start, void *end) | ||
| 58 | { | ||
| 59 | return 0; | ||
| 60 | } | ||
| 61 | |||
| 62 | #endif | ||
| 63 | |||
| 64 | #endif | ||
diff --git a/include/linux/module.h b/include/linux/module.h index 8a6b9fdc7ffa..403ac26023ce 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
| @@ -350,7 +350,10 @@ struct module | |||
| 350 | struct tracepoint *tracepoints; | 350 | struct tracepoint *tracepoints; |
| 351 | unsigned int num_tracepoints; | 351 | unsigned int num_tracepoints; |
| 352 | #endif | 352 | #endif |
| 353 | 353 | #ifdef HAVE_JUMP_LABEL | |
| 354 | struct jump_entry *jump_entries; | ||
| 355 | unsigned int num_jump_entries; | ||
| 356 | #endif | ||
| 354 | #ifdef CONFIG_TRACING | 357 | #ifdef CONFIG_TRACING |
| 355 | const char **trace_bprintk_fmt_start; | 358 | const char **trace_bprintk_fmt_start; |
| 356 | unsigned int num_trace_bprintk_fmt; | 359 | unsigned int num_trace_bprintk_fmt; |
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 103d1b61aacb..a4a90b6726ce 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
| 18 | #include <linux/types.h> | 18 | #include <linux/types.h> |
| 19 | #include <linux/rcupdate.h> | 19 | #include <linux/rcupdate.h> |
| 20 | #include <linux/jump_label.h> | ||
| 20 | 21 | ||
| 21 | struct module; | 22 | struct module; |
| 22 | struct tracepoint; | 23 | struct tracepoint; |
| @@ -145,7 +146,9 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin, | |||
| 145 | extern struct tracepoint __tracepoint_##name; \ | 146 | extern struct tracepoint __tracepoint_##name; \ |
| 146 | static inline void trace_##name(proto) \ | 147 | static inline void trace_##name(proto) \ |
| 147 | { \ | 148 | { \ |
| 148 | if (unlikely(__tracepoint_##name.state)) \ | 149 | JUMP_LABEL(&__tracepoint_##name.state, do_trace); \ |
| 150 | return; \ | ||
| 151 | do_trace: \ | ||
| 149 | __DO_TRACE(&__tracepoint_##name, \ | 152 | __DO_TRACE(&__tracepoint_##name, \ |
| 150 | TP_PROTO(data_proto), \ | 153 | TP_PROTO(data_proto), \ |
| 151 | TP_ARGS(data_args)); \ | 154 | TP_ARGS(data_args)); \ |
