aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jones <drjones@redhat.com>2013-08-09 10:21:57 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2013-08-09 10:53:54 -0400
commit851cf6e7d6366195d4ee033cdc7787df1a649a14 (patch)
tree24e863ab40ae34501f54c1584f98563f25c611d0
parent4a1ed4ca681e7df38ed1b609a11aab38cbc515b3 (diff)
jump_label: Split jumplabel ratelimit
Commit b202952075f62603bea9bfb6ebc6b0420db11949 ("perf, core: Rate limit perf_sched_events jump_label patching") introduced rate limiting for jump label disabling. The changes were made in the jump label code in order to be more widely available and to keep things tidier. This is all fine, except now jump_label.h includes linux/workqueue.h, which makes it impossible to include jump_label.h from anything that workqueue.h needs. For example, it's now impossible to include jump_label.h from asm/spinlock.h, which is done in proposed pv-ticketlock patches. This patch splits out the rate limiting related changes from jump_label.h into a new file, jump_label_ratelimit.h, to resolve the issue. Signed-off-by: Andrew Jones <drjones@redhat.com> Link: http://lkml.kernel.org/r/1376058122-8248-10-git-send-email-raghavendra.kt@linux.vnet.ibm.com Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com> Acked-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--include/linux/jump_label.h28
-rw-r--r--include/linux/jump_label_ratelimit.h34
-rw-r--r--include/linux/perf_event.h1
-rw-r--r--kernel/jump_label.c1
4 files changed, 37 insertions, 27 deletions
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 0976fc46d1e0..a5079072da66 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -48,7 +48,6 @@
48 48
49#include <linux/types.h> 49#include <linux/types.h>
50#include <linux/compiler.h> 50#include <linux/compiler.h>
51#include <linux/workqueue.h>
52 51
53#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL) 52#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
54 53
@@ -61,12 +60,6 @@ struct static_key {
61#endif 60#endif
62}; 61};
63 62
64struct static_key_deferred {
65 struct static_key key;
66 unsigned long timeout;
67 struct delayed_work work;
68};
69
70# include <asm/jump_label.h> 63# include <asm/jump_label.h>
71# define HAVE_JUMP_LABEL 64# define HAVE_JUMP_LABEL
72#endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */ 65#endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */
@@ -78,6 +71,7 @@ enum jump_label_type {
78 71
79struct module; 72struct module;
80 73
74#include <linux/atomic.h>
81#ifdef HAVE_JUMP_LABEL 75#ifdef HAVE_JUMP_LABEL
82 76
83#define JUMP_LABEL_TRUE_BRANCH 1UL 77#define JUMP_LABEL_TRUE_BRANCH 1UL
@@ -119,10 +113,7 @@ extern void arch_jump_label_transform_static(struct jump_entry *entry,
119extern int jump_label_text_reserved(void *start, void *end); 113extern int jump_label_text_reserved(void *start, void *end);
120extern void static_key_slow_inc(struct static_key *key); 114extern void static_key_slow_inc(struct static_key *key);
121extern void static_key_slow_dec(struct static_key *key); 115extern void static_key_slow_dec(struct static_key *key);
122extern void static_key_slow_dec_deferred(struct static_key_deferred *key);
123extern void jump_label_apply_nops(struct module *mod); 116extern void jump_label_apply_nops(struct module *mod);
124extern void
125jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);
126 117
127#define STATIC_KEY_INIT_TRUE ((struct static_key) \ 118#define STATIC_KEY_INIT_TRUE ((struct static_key) \
128 { .enabled = ATOMIC_INIT(1), .entries = (void *)1 }) 119 { .enabled = ATOMIC_INIT(1), .entries = (void *)1 })
@@ -131,8 +122,6 @@ jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);
131 122
132#else /* !HAVE_JUMP_LABEL */ 123#else /* !HAVE_JUMP_LABEL */
133 124
134#include <linux/atomic.h>
135
136struct static_key { 125struct static_key {
137 atomic_t enabled; 126 atomic_t enabled;
138}; 127};
@@ -141,10 +130,6 @@ static __always_inline void jump_label_init(void)
141{ 130{
142} 131}
143 132
144struct static_key_deferred {
145 struct static_key key;
146};
147
148static __always_inline bool static_key_false(struct static_key *key) 133static __always_inline bool static_key_false(struct static_key *key)
149{ 134{
150 if (unlikely(atomic_read(&key->enabled)) > 0) 135 if (unlikely(atomic_read(&key->enabled)) > 0)
@@ -169,11 +154,6 @@ static inline void static_key_slow_dec(struct static_key *key)
169 atomic_dec(&key->enabled); 154 atomic_dec(&key->enabled);
170} 155}
171 156
172static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
173{
174 static_key_slow_dec(&key->key);
175}
176
177static inline int jump_label_text_reserved(void *start, void *end) 157static inline int jump_label_text_reserved(void *start, void *end)
178{ 158{
179 return 0; 159 return 0;
@@ -187,12 +167,6 @@ static inline int jump_label_apply_nops(struct module *mod)
187 return 0; 167 return 0;
188} 168}
189 169
190static inline void
191jump_label_rate_limit(struct static_key_deferred *key,
192 unsigned long rl)
193{
194}
195
196#define STATIC_KEY_INIT_TRUE ((struct static_key) \ 170#define STATIC_KEY_INIT_TRUE ((struct static_key) \
197 { .enabled = ATOMIC_INIT(1) }) 171 { .enabled = ATOMIC_INIT(1) })
198#define STATIC_KEY_INIT_FALSE ((struct static_key) \ 172#define STATIC_KEY_INIT_FALSE ((struct static_key) \
diff --git a/include/linux/jump_label_ratelimit.h b/include/linux/jump_label_ratelimit.h
new file mode 100644
index 000000000000..113788389b3d
--- /dev/null
+++ b/include/linux/jump_label_ratelimit.h
@@ -0,0 +1,34 @@
1#ifndef _LINUX_JUMP_LABEL_RATELIMIT_H
2#define _LINUX_JUMP_LABEL_RATELIMIT_H
3
4#include <linux/jump_label.h>
5#include <linux/workqueue.h>
6
7#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
8struct static_key_deferred {
9 struct static_key key;
10 unsigned long timeout;
11 struct delayed_work work;
12};
13#endif
14
15#ifdef HAVE_JUMP_LABEL
16extern void static_key_slow_dec_deferred(struct static_key_deferred *key);
17extern void
18jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);
19
20#else /* !HAVE_JUMP_LABEL */
21struct static_key_deferred {
22 struct static_key key;
23};
24static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
25{
26 static_key_slow_dec(&key->key);
27}
28static inline void
29jump_label_rate_limit(struct static_key_deferred *key,
30 unsigned long rl)
31{
32}
33#endif /* HAVE_JUMP_LABEL */
34#endif /* _LINUX_JUMP_LABEL_RATELIMIT_H */
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index c43f6eabad5b..226be8da3f85 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -48,6 +48,7 @@ struct perf_guest_info_callbacks {
48#include <linux/cpu.h> 48#include <linux/cpu.h>
49#include <linux/irq_work.h> 49#include <linux/irq_work.h>
50#include <linux/static_key.h> 50#include <linux/static_key.h>
51#include <linux/jump_label_ratelimit.h>
51#include <linux/atomic.h> 52#include <linux/atomic.h>
52#include <linux/sysfs.h> 53#include <linux/sysfs.h>
53#include <linux/perf_regs.h> 54#include <linux/perf_regs.h>
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 60f48fa0fd0d..297a9247a3b3 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -13,6 +13,7 @@
13#include <linux/sort.h> 13#include <linux/sort.h>
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/static_key.h> 15#include <linux/static_key.h>
16#include <linux/jump_label_ratelimit.h>
16 17
17#ifdef HAVE_JUMP_LABEL 18#ifdef HAVE_JUMP_LABEL
18 19