Re: [PATCH 1/1] linux headers: header file(s) changes to enablespinlock use jumplabel

From: Andrew Jones
Date: Tue Feb 21 2012 - 10:24:47 EST


On Mon, Feb 20, 2012 at 11:21:16PM +0530, Raghavendra K T wrote:
> Perhaps we need jump_label.h to define a "minimal
> >jump label", and then we can create an "extended jump label",
> >which has rate limiting and other capabilities.
> >
>
> I completely agree. seeing that, you have not started that, it seems
> it's good idea for me to take a look at that option, (but may be at
> slower pace considering some changes I require (TODO) for kvm paravirt
> spinlock).
>

Below is the patch I wrote when I first proposed the idea to
Gleb. This patch isn't exactly what I stated above, because
it's splitting original and ratelimit, rather than minimal and
extended. Maybe this is sufficient for now? Or maybe we don't
want to split at all?

Drew

---

From: Andrew Jones <drjones@xxxxxxxxxx>
Date: Thu, 26 Jan 2012 13:59:30 +0100
Subject: [PATCH] split out rate limiting from jump_label.h

Commit b202952075f62603bea9bfb6ebc6b0420db11949 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 was done in Jeremy's 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@xxxxxxxxxx>
---
include/linux/jump_label.h | 24 ------------------------
include/linux/jump_label_ratelimit.h | 32 ++++++++++++++++++++++++++++++++
include/linux/perf_event.h | 2 +-
kernel/jump_label.c | 2 +-
4 files changed, 34 insertions(+), 26 deletions(-)
create mode 100644 include/linux/jump_label_ratelimit.h

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 5ce8b14..b15954a 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -3,7 +3,6 @@

#include <linux/types.h>
#include <linux/compiler.h>
-#include <linux/workqueue.h>

#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)

@@ -15,12 +14,6 @@ struct jump_label_key {
#endif
};

-struct jump_label_key_deferred {
- struct jump_label_key key;
- unsigned long timeout;
- struct delayed_work work;
-};
-
# include <asm/jump_label.h>
# define HAVE_JUMP_LABEL
#endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */
@@ -58,11 +51,8 @@ extern void arch_jump_label_transform_static(struct jump_entry *entry,
extern int jump_label_text_reserved(void *start, void *end);
extern void jump_label_inc(struct jump_label_key *key);
extern void jump_label_dec(struct jump_label_key *key);
-extern void jump_label_dec_deferred(struct jump_label_key_deferred *key);
extern bool jump_label_enabled(struct jump_label_key *key);
extern void jump_label_apply_nops(struct module *mod);
-extern void jump_label_rate_limit(struct jump_label_key_deferred *key,
- unsigned long rl);

#else /* !HAVE_JUMP_LABEL */

@@ -78,10 +68,6 @@ static __always_inline void jump_label_init(void)
{
}

-struct jump_label_key_deferred {
- struct jump_label_key key;
-};
-
static __always_inline bool static_branch(struct jump_label_key *key)
{
if (unlikely(atomic_read(&key->enabled)))
@@ -99,11 +85,6 @@ static inline void jump_label_dec(struct jump_label_key *key)
atomic_dec(&key->enabled);
}

-static inline void jump_label_dec_deferred(struct jump_label_key_deferred *key)
-{
- jump_label_dec(&key->key);
-}
-
static inline int jump_label_text_reserved(void *start, void *end)
{
return 0;
@@ -121,11 +102,6 @@ static inline int jump_label_apply_nops(struct module *mod)
{
return 0;
}
-
-static inline void jump_label_rate_limit(struct jump_label_key_deferred *key,
- unsigned long rl)
-{
-}
#endif /* HAVE_JUMP_LABEL */

#define jump_label_key_enabled ((struct jump_label_key){ .enabled = ATOMIC_INIT(1), })
diff --git a/include/linux/jump_label_ratelimit.h b/include/linux/jump_label_ratelimit.h
new file mode 100644
index 0000000..2cf61b9
--- /dev/null
+++ b/include/linux/jump_label_ratelimit.h
@@ -0,0 +1,32 @@
+#ifndef _LINUX_JUMP_LABEL_RATELIMIT_H
+#define _LINUX_JUMP_LABEL_RATELIMIT_H
+
+#include <linux/jump_label.h>
+#include <linux/workqueue.h>
+
+#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
+struct jump_label_key_deferred {
+ struct jump_label_key key;
+ unsigned long timeout;
+ struct delayed_work work;
+};
+#endif
+
+#ifdef HAVE_JUMP_LABEL
+extern void jump_label_dec_deferred(struct jump_label_key_deferred *key);
+extern void jump_label_rate_limit(struct jump_label_key_deferred *key,
+ unsigned long rl);
+#else
+struct jump_label_key_deferred {
+ struct jump_label_key key;
+};
+static inline void jump_label_dec_deferred(struct jump_label_key_deferred *key)
+{
+ jump_label_dec(&key->key);
+}
+static inline void jump_label_rate_limit(struct jump_label_key_deferred *key,
+ unsigned long rl)
+{
+}
+#endif
+#endif /* _LINUX_JUMP_LABEL_RATELIMIT_H */
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 0885561..7ae33d9 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -512,7 +512,7 @@ struct perf_guest_info_callbacks {
#include <linux/ftrace.h>
#include <linux/cpu.h>
#include <linux/irq_work.h>
-#include <linux/jump_label.h>
+#include <linux/jump_label_ratelimit.h>
#include <linux/atomic.h>
#include <asm/local.h>

diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 01d3b70..f736308 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -12,7 +12,7 @@
#include <linux/slab.h>
#include <linux/sort.h>
#include <linux/err.h>
-#include <linux/jump_label.h>
+#include <linux/jump_label_ratelimit.h>

#ifdef HAVE_JUMP_LABEL

--
1.7.7.6


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/