All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC V3 0/8] jump-label: allow early jump_label_enable()
@ 2011-10-04 19:18 Jeremy Fitzhardinge
  2011-10-04 19:18 ` [PATCH RFC V3 1/8] jump_label: use proper atomic_t initializer Jeremy Fitzhardinge
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Jeremy Fitzhardinge @ 2011-10-04 19:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: David S. Miller, David Daney, Michael Ellerman, Jan Glauber,
	Jason Baron, the arch/x86 maintainers, Xen Devel,
	Linux Kernel Mailing List, Jeremy Fitzhardinge

From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

[ Change from V2: add arch_jump_label_transform_static() for use on
  code which can't possibly be currently executing (ie, a freshly
  loaded module), which can avoid heavyweight things like
  stop_machine.  The default implementation is simply
  arch_jump_label_transform(), so only architectures which would
  particularly benefit need implement it (x86 and s390 in this
  series). ]

While trying to use the jump-label stuff for my PV ticketlock changes,
I had some problems using jump labels early in the kernel's lifetime
(pre-SMP).

The basic problem is that even if I enable a jump_label_key, the
jump_label_init() initializer ends up nopping out all the code sites.

This series enables early use of jump labels by making
jump_label_init() respect already-enabled keys.

To do this, I've dropped arch_jump_label_poke_text_early() and
replaced it with arch_jump_label_transform(), allowing it to either
insert an optimal nop, or leave the jump in place.

Part of this series makes sure that stop_machine() is safe to call
in an early pre-SMP environment, by making it just call the function
with interrupts disabled.

git://github.com/jsgf/linux-xen upstream/jump-label-noearly

Jeremy Fitzhardinge (8):
  jump_label: use proper atomic_t initializer
  stop_machine: make stop_machine safe and efficient to call early
  jump_label: if a key has already been initialized, don't nop it out
  x86/jump_label: drop arch_jump_label_text_poke_early()
  sparc/jump_label: drop arch_jump_label_text_poke_early()
  jump_label: add arch_jump_label_transform_static() to optimise
    non-live code updates
  s390/jump-label: add arch_jump_label_transform_static()
  x86/jump_label: add arch_jump_label_transform_static()

 arch/s390/kernel/jump_label.c  |   51 ++++++++++++++++++++++++---------------
 arch/sparc/kernel/jump_label.c |    8 ------
 arch/x86/kernel/jump_label.c   |   20 +++++++++++----
 include/linux/jump_label.h     |    9 ++++---
 kernel/jump_label.c            |   32 +++++++++++++++---------
 kernel/stop_machine.c          |   22 +++++++++++++++++
 6 files changed, 92 insertions(+), 50 deletions(-)

-- 
1.7.6.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH RFC V3 1/8] jump_label: use proper atomic_t initializer
  2011-10-04 19:18 [PATCH RFC V3 0/8] jump-label: allow early jump_label_enable() Jeremy Fitzhardinge
@ 2011-10-04 19:18 ` Jeremy Fitzhardinge
  2011-10-04 19:18 ` [PATCH RFC V3 2/8] stop_machine: make stop_machine safe and efficient to call early Jeremy Fitzhardinge
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jeremy Fitzhardinge @ 2011-10-04 19:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: David S. Miller, David Daney, Michael Ellerman, Jan Glauber,
	Jason Baron, the arch/x86 maintainers, Xen Devel,
	Linux Kernel Mailing List, Jeremy Fitzhardinge

From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

ATOMIC_INIT() is the proper thing to use.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 include/linux/jump_label.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 66f23dc..1213e9d 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -28,9 +28,9 @@ struct module;
 #ifdef HAVE_JUMP_LABEL
 
 #ifdef CONFIG_MODULES
-#define JUMP_LABEL_INIT {{ 0 }, NULL, NULL}
+#define JUMP_LABEL_INIT {ATOMIC_INIT(0), NULL, NULL}
 #else
-#define JUMP_LABEL_INIT {{ 0 }, NULL}
+#define JUMP_LABEL_INIT {ATOMIC_INIT(0), NULL}
 #endif
 
 static __always_inline bool static_branch(struct jump_label_key *key)
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH RFC V3 2/8] stop_machine: make stop_machine safe and efficient to call early
  2011-10-04 19:18 [PATCH RFC V3 0/8] jump-label: allow early jump_label_enable() Jeremy Fitzhardinge
  2011-10-04 19:18 ` [PATCH RFC V3 1/8] jump_label: use proper atomic_t initializer Jeremy Fitzhardinge
@ 2011-10-04 19:18 ` Jeremy Fitzhardinge
  2011-10-05  1:15   ` Rusty Russell
  2011-10-04 19:18 ` [PATCH RFC V3 3/8] jump_label: if a key has already been initialized, don't nop it out Jeremy Fitzhardinge
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Jeremy Fitzhardinge @ 2011-10-04 19:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: David S. Miller, David Daney, Michael Ellerman, Jan Glauber,
	Jason Baron, the arch/x86 maintainers, Xen Devel,
	Linux Kernel Mailing List, Jeremy Fitzhardinge, Rusty Russell,
	Peter Zijlstra, Andrew Morton, H. Peter Anvin, Ingo Molnar

From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

Make stop_machine() safe to call early in boot, before stop_machine()
has been set up, by simply calling the callback function directly if
there's only one CPU online.

[ Fixes from AKPM:
   - add comment
   - local_irq_flags, not save_flags
   - also call hard_irq_disable() for systems which need it

  Tejun suggested using an explicit flag rather than just looking at
  the online cpu count. ]

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: H. Peter Anvin <hpa@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/stop_machine.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index ba5070c..d3f960a 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -41,6 +41,7 @@ struct cpu_stopper {
 };
 
 static DEFINE_PER_CPU(struct cpu_stopper, cpu_stopper);
+static bool stop_machine_initialized = false;
 
 static void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo)
 {
@@ -386,6 +387,8 @@ static int __init cpu_stop_init(void)
 	cpu_stop_cpu_callback(&cpu_stop_cpu_notifier, CPU_ONLINE, bcpu);
 	register_cpu_notifier(&cpu_stop_cpu_notifier);
 
+	stop_machine_initialized = true;
+
 	return 0;
 }
 early_initcall(cpu_stop_init);
@@ -485,6 +488,25 @@ int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus)
 					    .num_threads = num_online_cpus(),
 					    .active_cpus = cpus };
 
+	if (!stop_machine_initialized) {
+		/*
+		 * Handle the case where stop_machine() is called
+		 * early in boot before stop_machine() has been
+		 * initialized.
+		 */
+ 		unsigned long flags;
+		int ret;
+
+		WARN_ON_ONCE(smdata.num_threads != 1);
+
+		local_irq_save(flags);
+		hard_irq_disable();
+		ret = (*fn)(data);
+		local_irq_restore(flags);
+
+		return ret;
+	}
+
 	/* Set the initial state and stop all online cpus. */
 	set_state(&smdata, STOPMACHINE_PREPARE);
 	return stop_cpus(cpu_online_mask, stop_machine_cpu_stop, &smdata);
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH RFC V3 3/8] jump_label: if a key has already been initialized, don't nop it out
  2011-10-04 19:18 [PATCH RFC V3 0/8] jump-label: allow early jump_label_enable() Jeremy Fitzhardinge
  2011-10-04 19:18 ` [PATCH RFC V3 1/8] jump_label: use proper atomic_t initializer Jeremy Fitzhardinge
  2011-10-04 19:18 ` [PATCH RFC V3 2/8] stop_machine: make stop_machine safe and efficient to call early Jeremy Fitzhardinge
@ 2011-10-04 19:18 ` Jeremy Fitzhardinge
  2011-10-04 19:18 ` [PATCH RFC V3 4/8] x86/jump_label: drop arch_jump_label_text_poke_early() Jeremy Fitzhardinge
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jeremy Fitzhardinge @ 2011-10-04 19:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: David S. Miller, David Daney, Michael Ellerman, Jan Glauber,
	Jason Baron, the arch/x86 maintainers, Xen Devel,
	Linux Kernel Mailing List, Jeremy Fitzhardinge

From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

If a key has been enabled before jump_label_init() is called, don't
nop it out.

This removes arch_jump_label_text_poke_early() (which can only nop
out a site) and uses arch_jump_label_transform() instead.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 include/linux/jump_label.h |    3 +--
 kernel/jump_label.c        |   20 ++++++++------------
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 1213e9d..12e804e 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -44,8 +44,7 @@ extern struct jump_entry __stop___jump_table[];
 extern void jump_label_lock(void);
 extern void jump_label_unlock(void);
 extern void arch_jump_label_transform(struct jump_entry *entry,
-				 enum jump_label_type type);
-extern void arch_jump_label_text_poke_early(jump_label_t addr);
+				      enum jump_label_type type);
 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);
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index a8ce450..059202d5 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -121,13 +121,6 @@ static void __jump_label_update(struct jump_label_key *key,
 	}
 }
 
-/*
- * Not all archs need this.
- */
-void __weak arch_jump_label_text_poke_early(jump_label_t addr)
-{
-}
-
 static __init int jump_label_init(void)
 {
 	struct jump_entry *iter_start = __start___jump_table;
@@ -139,12 +132,15 @@ static __init int jump_label_init(void)
 	jump_label_sort_entries(iter_start, iter_stop);
 
 	for (iter = iter_start; iter < iter_stop; iter++) {
-		arch_jump_label_text_poke_early(iter->code);
-		if (iter->key == (jump_label_t)(unsigned long)key)
+		struct jump_label_key *iterk;
+
+		iterk = (struct jump_label_key *)(unsigned long)iter->key;
+		arch_jump_label_transform(iter, jump_label_enabled(iterk) ?
+					  JUMP_LABEL_ENABLE : JUMP_LABEL_DISABLE);
+		if (iterk == key)
 			continue;
 
-		key = (struct jump_label_key *)(unsigned long)iter->key;
-		atomic_set(&key->enabled, 0);
+		key = iterk;
 		key->entries = iter;
 #ifdef CONFIG_MODULES
 		key->next = NULL;
@@ -212,7 +208,7 @@ void jump_label_apply_nops(struct module *mod)
 		return;
 
 	for (iter = iter_start; iter < iter_stop; iter++)
-		arch_jump_label_text_poke_early(iter->code);
+		arch_jump_label_transform(iter, JUMP_LABEL_DISABLE);
 }
 
 static int jump_label_add_module(struct module *mod)
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH RFC V3 4/8] x86/jump_label: drop arch_jump_label_text_poke_early()
  2011-10-04 19:18 [PATCH RFC V3 0/8] jump-label: allow early jump_label_enable() Jeremy Fitzhardinge
                   ` (2 preceding siblings ...)
  2011-10-04 19:18 ` [PATCH RFC V3 3/8] jump_label: if a key has already been initialized, don't nop it out Jeremy Fitzhardinge
@ 2011-10-04 19:18 ` Jeremy Fitzhardinge
  2011-10-04 19:18 ` [PATCH RFC V3 5/8] sparc/jump_label: " Jeremy Fitzhardinge
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jeremy Fitzhardinge @ 2011-10-04 19:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: David S. Miller, David Daney, Michael Ellerman, Jan Glauber,
	Jason Baron, the arch/x86 maintainers, Xen Devel,
	Linux Kernel Mailing List, Jeremy Fitzhardinge

From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

It is no longer used.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Jason Baron <jbaron@redhat.com>
---
 arch/x86/kernel/jump_label.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
index 3fee346..2ad0298 100644
--- a/arch/x86/kernel/jump_label.c
+++ b/arch/x86/kernel/jump_label.c
@@ -42,10 +42,4 @@ void arch_jump_label_transform(struct jump_entry *entry,
 	put_online_cpus();
 }
 
-void arch_jump_label_text_poke_early(jump_label_t addr)
-{
-	text_poke_early((void *)addr, ideal_nops[NOP_ATOMIC5],
-			JUMP_LABEL_NOP_SIZE);
-}
-
 #endif
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH RFC V3 5/8] sparc/jump_label: drop arch_jump_label_text_poke_early()
  2011-10-04 19:18 [PATCH RFC V3 0/8] jump-label: allow early jump_label_enable() Jeremy Fitzhardinge
                   ` (3 preceding siblings ...)
  2011-10-04 19:18 ` [PATCH RFC V3 4/8] x86/jump_label: drop arch_jump_label_text_poke_early() Jeremy Fitzhardinge
@ 2011-10-04 19:18 ` Jeremy Fitzhardinge
  2011-10-04 19:18 ` [PATCH RFC V3 6/8] jump_label: add arch_jump_label_transform_static() to optimise non-live code updates Jeremy Fitzhardinge
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jeremy Fitzhardinge @ 2011-10-04 19:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: David S. Miller, David Daney, Michael Ellerman, Jan Glauber,
	Jason Baron, the arch/x86 maintainers, Xen Devel,
	Linux Kernel Mailing List, Jeremy Fitzhardinge

From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

It is no longer used.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: David Miller <davem@davemloft.net>
---
 arch/sparc/kernel/jump_label.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/arch/sparc/kernel/jump_label.c b/arch/sparc/kernel/jump_label.c
index ea2dafc..971fd43 100644
--- a/arch/sparc/kernel/jump_label.c
+++ b/arch/sparc/kernel/jump_label.c
@@ -36,12 +36,4 @@ void arch_jump_label_transform(struct jump_entry *entry,
 	put_online_cpus();
 }
 
-void arch_jump_label_text_poke_early(jump_label_t addr)
-{
-	u32 *insn_p = (u32 *) (unsigned long) addr;
-
-	*insn_p = 0x01000000;
-	flushi(insn_p);
-}
-
 #endif
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH RFC V3 6/8] jump_label: add arch_jump_label_transform_static() to optimise non-live code updates
  2011-10-04 19:18 [PATCH RFC V3 0/8] jump-label: allow early jump_label_enable() Jeremy Fitzhardinge
                   ` (4 preceding siblings ...)
  2011-10-04 19:18 ` [PATCH RFC V3 5/8] sparc/jump_label: " Jeremy Fitzhardinge
@ 2011-10-04 19:18 ` Jeremy Fitzhardinge
  2011-10-04 19:18 ` [PATCH RFC V3 7/8] s390/jump-label: add arch_jump_label_transform_static() Jeremy Fitzhardinge
  2011-10-04 19:18 ` [PATCH RFC V3 8/8] x86/jump_label: " Jeremy Fitzhardinge
  7 siblings, 0 replies; 15+ messages in thread
From: Jeremy Fitzhardinge @ 2011-10-04 19:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: David S. Miller, David Daney, Michael Ellerman, Jan Glauber,
	Jason Baron, the arch/x86 maintainers, Xen Devel,
	Linux Kernel Mailing List, Jeremy Fitzhardinge

From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

When updating a newly loaded module, the code is definitely not yet
executing on any processor, so it can be updated with no need for any
heavyweight synchronization.

This patch adds arch_jump_label_static() which is implemented as
arch_jump_label_transform() by default, but architectures can override
it if it avoids, say, a call to stop_machine().

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 include/linux/jump_label.h |    2 ++
 kernel/jump_label.c        |   14 +++++++++++++-
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 12e804e..56594e4 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -45,6 +45,8 @@ extern void jump_label_lock(void);
 extern void jump_label_unlock(void);
 extern void arch_jump_label_transform(struct jump_entry *entry,
 				      enum jump_label_type type);
+extern void arch_jump_label_transform_static(struct jump_entry *entry,
+					     enum jump_label_type type);
 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);
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 059202d5..f0a9bef 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -104,6 +104,18 @@ static int __jump_label_text_reserved(struct jump_entry *iter_start,
 	return 0;
 }
 
+/* 
+ * Update code which is definitely not currently executing.
+ * Architectures which need heavyweight synchronization to modify
+ * running code can override this to make the non-live update case
+ * cheaper.
+ */
+void __weak arch_jump_label_transform_static(struct jump_entry *entry,
+					    enum jump_label_type type)
+{
+	arch_jump_label_transform(entry, type);	
+}
+
 static void __jump_label_update(struct jump_label_key *key,
 				struct jump_entry *entry,
 				struct jump_entry *stop, int enable)
@@ -208,7 +220,7 @@ void jump_label_apply_nops(struct module *mod)
 		return;
 
 	for (iter = iter_start; iter < iter_stop; iter++)
-		arch_jump_label_transform(iter, JUMP_LABEL_DISABLE);
+		arch_jump_label_transform_static(iter, JUMP_LABEL_DISABLE);
 }
 
 static int jump_label_add_module(struct module *mod)
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH RFC V3 7/8] s390/jump-label: add arch_jump_label_transform_static()
  2011-10-04 19:18 [PATCH RFC V3 0/8] jump-label: allow early jump_label_enable() Jeremy Fitzhardinge
                   ` (5 preceding siblings ...)
  2011-10-04 19:18 ` [PATCH RFC V3 6/8] jump_label: add arch_jump_label_transform_static() to optimise non-live code updates Jeremy Fitzhardinge
@ 2011-10-04 19:18 ` Jeremy Fitzhardinge
  2011-10-04 19:18 ` [PATCH RFC V3 8/8] x86/jump_label: " Jeremy Fitzhardinge
  7 siblings, 0 replies; 15+ messages in thread
From: Jeremy Fitzhardinge @ 2011-10-04 19:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: David S. Miller, David Daney, Michael Ellerman, Jan Glauber,
	Jason Baron, the arch/x86 maintainers, Xen Devel,
	Linux Kernel Mailing List, Jeremy Fitzhardinge

From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

This allows jump-label entries to be cheaply updated on code which is
not yet live.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Jan Glauber <jang@linux.vnet.ibm.com>
---
 arch/s390/kernel/jump_label.c |   51 +++++++++++++++++++++++++----------------
 1 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/arch/s390/kernel/jump_label.c b/arch/s390/kernel/jump_label.c
index 44cc06b..b987ab2 100644
--- a/arch/s390/kernel/jump_label.c
+++ b/arch/s390/kernel/jump_label.c
@@ -18,26 +18,15 @@ struct insn {
 } __packed;
 
 struct insn_args {
-	unsigned long *target;
-	struct insn *insn;
-	ssize_t size;
+	struct jump_entry *entry;
+	enum jump_label_type type;
 };
 
-static int __arch_jump_label_transform(void *data)
+static void __jump_label_transform(struct jump_entry *entry,
+				   enum jump_label_type type)
 {
-	struct insn_args *args = data;
-	int rc;
-
-	rc = probe_kernel_write(args->target, args->insn, args->size);
-	WARN_ON_ONCE(rc < 0);
-	return 0;
-}
-
-void arch_jump_label_transform(struct jump_entry *entry,
-			       enum jump_label_type type)
-{
-	struct insn_args args;
 	struct insn insn;
+	int rc;
 
 	if (type == JUMP_LABEL_ENABLE) {
 		/* brcl 15,offset */
@@ -49,11 +38,33 @@ void arch_jump_label_transform(struct jump_entry *entry,
 		insn.offset = 0;
 	}
 
-	args.target = (void *) entry->code;
-	args.insn = &insn;
-	args.size = JUMP_LABEL_NOP_SIZE;
+	rc = probe_kernel_write((void *)entry->code, &insn, JUMP_LABEL_NOP_SIZE);
+	WARN_ON_ONCE(rc < 0);
+}
 
-	stop_machine(__arch_jump_label_transform, &args, NULL);
+static int __sm_arch_jump_label_transform(void *data)
+{
+	struct insn_args *args = data;
+
+	__jump_label_transform(args->entry, args->type);
+	return 0;
+}
+
+void arch_jump_label_transform(struct jump_entry *entry,
+			       enum jump_label_type type)
+{
+	struct insn_args args;
+
+	args.entry = entry;
+	args.type = type;
+
+	stop_machine(__sm_arch_jump_label_transform, &args, NULL);
+}
+
+void arch_jump_label_transform_static(struct jump_entry *entry,
+				      enum jump_label_type type)
+{
+	__jump_label_transform(entry, type);
 }
 
 #endif
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH RFC V3 8/8] x86/jump_label: add arch_jump_label_transform_static()
  2011-10-04 19:18 [PATCH RFC V3 0/8] jump-label: allow early jump_label_enable() Jeremy Fitzhardinge
                   ` (6 preceding siblings ...)
  2011-10-04 19:18 ` [PATCH RFC V3 7/8] s390/jump-label: add arch_jump_label_transform_static() Jeremy Fitzhardinge
@ 2011-10-04 19:18 ` Jeremy Fitzhardinge
  7 siblings, 0 replies; 15+ messages in thread
From: Jeremy Fitzhardinge @ 2011-10-04 19:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: David S. Miller, David Daney, Michael Ellerman, Jan Glauber,
	Jason Baron, the arch/x86 maintainers, Xen Devel,
	Linux Kernel Mailing List, Jeremy Fitzhardinge

From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

This allows jump-label entries to be cheaply updated on code which is
not yet live.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Jason Baron <jbaron@redhat.com>
---
 arch/x86/kernel/jump_label.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
index 2ad0298..ea9d5f2f 100644
--- a/arch/x86/kernel/jump_label.c
+++ b/arch/x86/kernel/jump_label.c
@@ -24,8 +24,9 @@ union jump_code_union {
 	} __attribute__((packed));
 };
 
-void arch_jump_label_transform(struct jump_entry *entry,
-			       enum jump_label_type type)
+static void __jump_label_transform(struct jump_entry *entry,
+				   enum jump_label_type type,
+				   void *(*poker)(void *, const void *, size_t))
 {
 	union jump_code_union code;
 
@@ -35,11 +36,24 @@ void arch_jump_label_transform(struct jump_entry *entry,
 				(entry->code + JUMP_LABEL_NOP_SIZE);
 	} else
 		memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
+
+	(*poker)((void *)entry->code, &code, JUMP_LABEL_NOP_SIZE);
+}
+
+void arch_jump_label_transform(struct jump_entry *entry,
+			       enum jump_label_type type)
+{
 	get_online_cpus();
 	mutex_lock(&text_mutex);
-	text_poke_smp((void *)entry->code, &code, JUMP_LABEL_NOP_SIZE);
+	__jump_label_transform(entry, type, text_poke_smp);
 	mutex_unlock(&text_mutex);
 	put_online_cpus();
 }
 
+void arch_jump_label_transform_static(struct jump_entry *entry,
+				      enum jump_label_type type)
+{
+	__jump_label_transform(entry, type, text_poke_early);
+}
+
 #endif
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH RFC V3 2/8] stop_machine: make stop_machine safe and efficient to call early
  2011-10-04 19:18 ` [PATCH RFC V3 2/8] stop_machine: make stop_machine safe and efficient to call early Jeremy Fitzhardinge
@ 2011-10-05  1:15   ` Rusty Russell
  2011-10-10  7:34     ` Ingo Molnar
  0 siblings, 1 reply; 15+ messages in thread
From: Rusty Russell @ 2011-10-05  1:15 UTC (permalink / raw)
  To: Jeremy Fitzhardinge, Steven Rostedt
  Cc: David S. Miller, David Daney, Michael Ellerman, Jan Glauber,
	Jason Baron, the arch/x86 maintainers, Xen Devel,
	Linux Kernel Mailing List, Jeremy Fitzhardinge, Peter Zijlstra,
	Andrew Morton, H. Peter Anvin, Ingo Molnar

On Tue,  4 Oct 2011 12:18:03 -0700, Jeremy Fitzhardinge <jeremy@goop.org> wrote:
> From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
> 
> Make stop_machine() safe to call early in boot, before stop_machine()
> has been set up, by simply calling the callback function directly if
> there's only one CPU online.

Not that you need this, since it's >90% Tejun's code now, but:

Acked-by: Rusty Russell <rusty@rustcorp.com.au>

Cheers,
Rusty.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH RFC V3 2/8] stop_machine: make stop_machine safe and efficient to call early
  2011-10-05  1:15   ` Rusty Russell
@ 2011-10-10  7:34     ` Ingo Molnar
  2011-10-10 20:01       ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 15+ messages in thread
From: Ingo Molnar @ 2011-10-10  7:34 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Jeremy Fitzhardinge, Steven Rostedt, David S. Miller,
	David Daney, Michael Ellerman, Jan Glauber, Jason Baron,
	the arch/x86 maintainers, Xen Devel, Linux Kernel Mailing List,
	Jeremy Fitzhardinge, Peter Zijlstra, Andrew Morton,
	H. Peter Anvin


* Rusty Russell <rusty@rustcorp.com.au> wrote:

> On Tue,  4 Oct 2011 12:18:03 -0700, Jeremy Fitzhardinge <jeremy@goop.org> wrote:
> > From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
> > 
> > Make stop_machine() safe to call early in boot, before stop_machine()
> > has been set up, by simply calling the callback function directly if
> > there's only one CPU online.
> 
> Not that you need this, since it's >90% Tejun's code now, but:
> 
> Acked-by: Rusty Russell <rusty@rustcorp.com.au>

hey, extra review is always useful.

Jeremy, Tejun, what's the expected merge path of these changes?

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH RFC V3 2/8] stop_machine: make stop_machine safe and efficient to call early
  2011-10-10  7:34     ` Ingo Molnar
@ 2011-10-10 20:01       ` Jeremy Fitzhardinge
  2011-10-12  7:34         ` Ingo Molnar
  0 siblings, 1 reply; 15+ messages in thread
From: Jeremy Fitzhardinge @ 2011-10-10 20:01 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Rusty Russell, Steven Rostedt, David S. Miller, David Daney,
	Michael Ellerman, Jan Glauber, Jason Baron,
	the arch/x86 maintainers, Xen Devel, Linux Kernel Mailing List,
	Jeremy Fitzhardinge, Peter Zijlstra, Andrew Morton,
	H. Peter Anvin

On 10/10/2011 12:34 AM, Ingo Molnar wrote:
> * Rusty Russell <rusty@rustcorp.com.au> wrote:
>
>> On Tue,  4 Oct 2011 12:18:03 -0700, Jeremy Fitzhardinge <jeremy@goop.org> wrote:
>>> From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
>>>
>>> Make stop_machine() safe to call early in boot, before stop_machine()
>>> has been set up, by simply calling the callback function directly if
>>> there's only one CPU online.
>> Not that you need this, since it's >90% Tejun's code now, but:
>>
>> Acked-by: Rusty Russell <rusty@rustcorp.com.au>
> hey, extra review is always useful.
>
> Jeremy, Tejun, what's the expected merge path of these changes?

Andrew has already picked up the stop_machine patch, I think.  But it's
pretty settled now, so it shouldn't cause any problem if it gets via
multiple paths.

What about the jump-label stuff?  Has that been going via tip.git in the
past, or by some other path?

    J

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH RFC V3 2/8] stop_machine: make stop_machine safe and efficient to call early
  2011-10-10 20:01       ` Jeremy Fitzhardinge
@ 2011-10-12  7:34         ` Ingo Molnar
  2011-10-12  7:45           ` Peter Zijlstra
  2011-10-12 15:44           ` Jeremy Fitzhardinge
  0 siblings, 2 replies; 15+ messages in thread
From: Ingo Molnar @ 2011-10-12  7:34 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Rusty Russell, Steven Rostedt, David S. Miller, David Daney,
	Michael Ellerman, Jan Glauber, Jason Baron,
	the arch/x86 maintainers, Xen Devel, Linux Kernel Mailing List,
	Jeremy Fitzhardinge, Peter Zijlstra, Andrew Morton,
	H. Peter Anvin


* Jeremy Fitzhardinge <jeremy@goop.org> wrote:

> On 10/10/2011 12:34 AM, Ingo Molnar wrote:
> > * Rusty Russell <rusty@rustcorp.com.au> wrote:
> >
> >> On Tue,  4 Oct 2011 12:18:03 -0700, Jeremy Fitzhardinge <jeremy@goop.org> wrote:
> >>> From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
> >>>
> >>> Make stop_machine() safe to call early in boot, before stop_machine()
> >>> has been set up, by simply calling the callback function directly if
> >>> there's only one CPU online.
> >> Not that you need this, since it's >90% Tejun's code now, but:
> >>
> >> Acked-by: Rusty Russell <rusty@rustcorp.com.au>
> > hey, extra review is always useful.
> >
> > Jeremy, Tejun, what's the expected merge path of these changes?
> 
> Andrew has already picked up the stop_machine patch, I think.  But it's
> pretty settled now, so it shouldn't cause any problem if it gets via
> multiple paths.
> 
> What about the jump-label stuff?  Has that been going via tip.git in the
> past, or by some other path?

If it has Jason's and PeterZ's ack then it can go via any other tree 
in this cycle - we are not carrying jump label patches right now.

But those acks are very much desired.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH RFC V3 2/8] stop_machine: make stop_machine safe and efficient to call early
  2011-10-12  7:34         ` Ingo Molnar
@ 2011-10-12  7:45           ` Peter Zijlstra
  2011-10-12 15:44           ` Jeremy Fitzhardinge
  1 sibling, 0 replies; 15+ messages in thread
From: Peter Zijlstra @ 2011-10-12  7:45 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Jeremy Fitzhardinge, Rusty Russell, Steven Rostedt,
	David S. Miller, David Daney, Michael Ellerman, Jan Glauber,
	Jason Baron, the arch/x86 maintainers, Xen Devel,
	Linux Kernel Mailing List, Jeremy Fitzhardinge, Andrew Morton,
	H. Peter Anvin

On Wed, 2011-10-12 at 09:34 +0200, Ingo Molnar wrote:
> 
> If it has Jason's and PeterZ's ack then it can go via any other tree 
> in this cycle - we are not carrying jump label patches right now.

I don't seem to have them in my inbox, just one or two patches of a
larger series.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH RFC V3 2/8] stop_machine: make stop_machine safe and efficient to call early
  2011-10-12  7:34         ` Ingo Molnar
  2011-10-12  7:45           ` Peter Zijlstra
@ 2011-10-12 15:44           ` Jeremy Fitzhardinge
  1 sibling, 0 replies; 15+ messages in thread
From: Jeremy Fitzhardinge @ 2011-10-12 15:44 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Rusty Russell, Steven Rostedt, David S. Miller, David Daney,
	Michael Ellerman, Jan Glauber, Jason Baron,
	the arch/x86 maintainers, Xen Devel, Linux Kernel Mailing List,
	Jeremy Fitzhardinge, Peter Zijlstra, Andrew Morton,
	H. Peter Anvin

On 10/12/2011 12:34 AM, Ingo Molnar wrote:
> * Jeremy Fitzhardinge <jeremy@goop.org> wrote:
>
>> On 10/10/2011 12:34 AM, Ingo Molnar wrote:
>>> * Rusty Russell <rusty@rustcorp.com.au> wrote:
>>>
>>>> On Tue,  4 Oct 2011 12:18:03 -0700, Jeremy Fitzhardinge <jeremy@goop.org> wrote:
>>>>> From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
>>>>>
>>>>> Make stop_machine() safe to call early in boot, before stop_machine()
>>>>> has been set up, by simply calling the callback function directly if
>>>>> there's only one CPU online.
>>>> Not that you need this, since it's >90% Tejun's code now, but:
>>>>
>>>> Acked-by: Rusty Russell <rusty@rustcorp.com.au>
>>> hey, extra review is always useful.
>>>
>>> Jeremy, Tejun, what's the expected merge path of these changes?
>> Andrew has already picked up the stop_machine patch, I think.  But it's
>> pretty settled now, so it shouldn't cause any problem if it gets via
>> multiple paths.
>>
>> What about the jump-label stuff?  Has that been going via tip.git in the
>> past, or by some other path?
> If it has Jason's and PeterZ's ack then it can go via any other tree 
> in this cycle - we are not carrying jump label patches right now.
>
> But those acks are very much desired.

Jason has already Acked it, but then pointed out a couple of problems to
address.

I'll add PeterZ to the next repost.

    J

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2011-10-12 15:44 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-04 19:18 [PATCH RFC V3 0/8] jump-label: allow early jump_label_enable() Jeremy Fitzhardinge
2011-10-04 19:18 ` [PATCH RFC V3 1/8] jump_label: use proper atomic_t initializer Jeremy Fitzhardinge
2011-10-04 19:18 ` [PATCH RFC V3 2/8] stop_machine: make stop_machine safe and efficient to call early Jeremy Fitzhardinge
2011-10-05  1:15   ` Rusty Russell
2011-10-10  7:34     ` Ingo Molnar
2011-10-10 20:01       ` Jeremy Fitzhardinge
2011-10-12  7:34         ` Ingo Molnar
2011-10-12  7:45           ` Peter Zijlstra
2011-10-12 15:44           ` Jeremy Fitzhardinge
2011-10-04 19:18 ` [PATCH RFC V3 3/8] jump_label: if a key has already been initialized, don't nop it out Jeremy Fitzhardinge
2011-10-04 19:18 ` [PATCH RFC V3 4/8] x86/jump_label: drop arch_jump_label_text_poke_early() Jeremy Fitzhardinge
2011-10-04 19:18 ` [PATCH RFC V3 5/8] sparc/jump_label: " Jeremy Fitzhardinge
2011-10-04 19:18 ` [PATCH RFC V3 6/8] jump_label: add arch_jump_label_transform_static() to optimise non-live code updates Jeremy Fitzhardinge
2011-10-04 19:18 ` [PATCH RFC V3 7/8] s390/jump-label: add arch_jump_label_transform_static() Jeremy Fitzhardinge
2011-10-04 19:18 ` [PATCH RFC V3 8/8] x86/jump_label: " Jeremy Fitzhardinge

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.