All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -tip  0/5] Kprobes updates
@ 2010-10-14  3:10 Masami Hiramatsu
  2010-10-14  3:10 ` [PATCH -tip 1/5] [RESEND] kprobes: Update document about irq disabled state in kprobe handler Masami Hiramatsu
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Masami Hiramatsu @ 2010-10-14  3:10 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Rusty Russell, Ananth N Mavinakayanahalli, linux-kernel, 2nddept-manager

Hi,

This series of patches fixes some code/docs which are related to
kprobes (especially optprobe).
First 2 resend patches update document and selftest since
optprobe changes kprobes behavior.
Next 2 patches fix double get_cpu() by using __stop_machine().
And the last patch makes text_poke_smp() depending on
stop_machine() on smp, because without stop_machine(),
it can't ensure safety on smp.

Thank you,

---

Masami Hiramatsu (5):
      [BUGFIX] kconfig/x86: Add HAVE_TEXT_POKE_SMP config for stop_machine dependency
      [BUGFIX] x86: Use __stop_machine() in text_poke_smp()
      Define __stop_machine when CONFIG_STOP_MACHINE=n
      [RESEND][BUGFIX] kprobes: Fix selftest to clear flags field for reusing probes
      [RESEND] kprobes: Update document about irq disabled state in kprobe handler


 Documentation/kprobes.txt     |    8 +++++---
 arch/x86/Kconfig              |    5 +++++
 arch/x86/kernel/alternative.c |    3 ++-
 include/linux/stop_machine.h  |   10 ++++++++--
 kernel/test_kprobes.c         |   12 +++++++++---
 5 files changed, 29 insertions(+), 9 deletions(-)

-- 
Masami HIRAMATSU
2nd Dept. Linux Technology Center
Hitachi, Ltd., Systems Development Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com


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

* [PATCH -tip 1/5] [RESEND] kprobes: Update document about irq disabled state in kprobe handler
  2010-10-14  3:10 [PATCH -tip 0/5] Kprobes updates Masami Hiramatsu
@ 2010-10-14  3:10 ` Masami Hiramatsu
  2010-10-14  7:39   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
  2010-10-14  3:10 ` [PATCH -tip 2/5] [RESEND][BUGFIX] kprobes: Fix selftest to clear flags field for reusing probes Masami Hiramatsu
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Masami Hiramatsu @ 2010-10-14  3:10 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Rusty Russell, Ananth N Mavinakayanahalli, linux-kernel,
	2nddept-manager, Masami Hiramatsu, Ananth N Mavinakayanahalli,
	Ingo Molnar, linux-kernel, linux-doc

Update kprobes.txt about interrupts disabled state inside
kprobes handlers, because optimized probe/boosted kretprobe
run without disabling interrrupts on x86.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org
Cc: linux-doc@vger.kernel.org
---

 Documentation/kprobes.txt |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Documentation/kprobes.txt b/Documentation/kprobes.txt
index 1762b81..741fe66 100644
--- a/Documentation/kprobes.txt
+++ b/Documentation/kprobes.txt
@@ -542,9 +542,11 @@ Kprobes does not use mutexes or allocate memory except during
 registration and unregistration.
 
 Probe handlers are run with preemption disabled.  Depending on the
-architecture, handlers may also run with interrupts disabled.  In any
-case, your handler should not yield the CPU (e.g., by attempting to
-acquire a semaphore).
+architecture and optimization state, handlers may also run with
+interrupts disabled (e.g., kretprobe handlers and optimized kprobe
+handlers run without interrupt disabled on x86/x86-64).  In any case,
+your handler should not yield the CPU (e.g., by attempting to acquire
+a semaphore).
 
 Since a return probe is implemented by replacing the return
 address with the trampoline's address, stack backtraces and calls


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

* [PATCH -tip 2/5] [RESEND][BUGFIX] kprobes: Fix selftest to clear flags field for reusing probes
  2010-10-14  3:10 [PATCH -tip 0/5] Kprobes updates Masami Hiramatsu
  2010-10-14  3:10 ` [PATCH -tip 1/5] [RESEND] kprobes: Update document about irq disabled state in kprobe handler Masami Hiramatsu
@ 2010-10-14  3:10 ` Masami Hiramatsu
  2010-10-14  7:40   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
  2010-10-14  3:10 ` [PATCH -tip 3/5] Define __stop_machine when CONFIG_STOP_MACHINE=n Masami Hiramatsu
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Masami Hiramatsu @ 2010-10-14  3:10 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Rusty Russell, Ananth N Mavinakayanahalli, linux-kernel,
	2nddept-manager, Masami Hiramatsu, Ananth N Mavinakayanahalli,
	Ingo Molnar, linux-kernel

Fix selftest to clear flags field for reusing probes
because the flags field can be modified by Kprobes.
This also set NULL to kprobe.addr instead of 0.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org
---

 kernel/test_kprobes.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel/test_kprobes.c b/kernel/test_kprobes.c
index 4f10451..f8b11a2 100644
--- a/kernel/test_kprobes.c
+++ b/kernel/test_kprobes.c
@@ -115,7 +115,9 @@ static int test_kprobes(void)
 	int ret;
 	struct kprobe *kps[2] = {&kp, &kp2};
 
-	kp.addr = 0; /* addr should be cleard for reusing kprobe. */
+	/* addr and flags should be cleard for reusing kprobe. */
+	kp.addr = NULL;
+	kp.flags = 0;
 	ret = register_kprobes(kps, 2);
 	if (ret < 0) {
 		printk(KERN_ERR "Kprobe smoke test failed: "
@@ -210,7 +212,9 @@ static int test_jprobes(void)
 	int ret;
 	struct jprobe *jps[2] = {&jp, &jp2};
 
-	jp.kp.addr = 0; /* addr should be cleard for reusing kprobe. */
+	/* addr and flags should be cleard for reusing kprobe. */
+	jp.kp.addr = NULL;
+	jp.kp.flags = 0;
 	ret = register_jprobes(jps, 2);
 	if (ret < 0) {
 		printk(KERN_ERR "Kprobe smoke test failed: "
@@ -323,7 +327,9 @@ static int test_kretprobes(void)
 	int ret;
 	struct kretprobe *rps[2] = {&rp, &rp2};
 
-	rp.kp.addr = 0; /* addr should be cleard for reusing kprobe. */
+	/* addr and flags should be cleard for reusing kprobe. */
+	rp.kp.addr = NULL;
+	rp.kp.flags = 0;
 	ret = register_kretprobes(rps, 2);
 	if (ret < 0) {
 		printk(KERN_ERR "Kprobe smoke test failed: "


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

* [PATCH -tip  3/5] Define __stop_machine when CONFIG_STOP_MACHINE=n
  2010-10-14  3:10 [PATCH -tip 0/5] Kprobes updates Masami Hiramatsu
  2010-10-14  3:10 ` [PATCH -tip 1/5] [RESEND] kprobes: Update document about irq disabled state in kprobe handler Masami Hiramatsu
  2010-10-14  3:10 ` [PATCH -tip 2/5] [RESEND][BUGFIX] kprobes: Fix selftest to clear flags field for reusing probes Masami Hiramatsu
@ 2010-10-14  3:10 ` Masami Hiramatsu
  2010-10-14  5:00   ` Tejun Heo
  2010-10-14  7:40   ` [tip:perf/core] stopmachine: " tip-bot for Masami Hiramatsu
  2010-10-14  3:10 ` [PATCH -tip 4/5] [BUGFIX] x86: Use __stop_machine() in text_poke_smp() Masami Hiramatsu
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 13+ messages in thread
From: Masami Hiramatsu @ 2010-10-14  3:10 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Rusty Russell, Ananth N Mavinakayanahalli, linux-kernel,
	2nddept-manager, Masami Hiramatsu, Tejun Heo, Peter Zijlstra,
	Rusty Russell, Ingo Molnar, linux-kernel

Define dummy __stop_machine() function even when CONFIG_STOP_MACHINE=n.
This getcpu-required version of stop_machine() will be used from
poke_text_smp().

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org
---

 include/linux/stop_machine.h |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/linux/stop_machine.h b/include/linux/stop_machine.h
index 6b524a0..1808960 100644
--- a/include/linux/stop_machine.h
+++ b/include/linux/stop_machine.h
@@ -126,8 +126,8 @@ int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus);
 
 #else	 /* CONFIG_STOP_MACHINE && CONFIG_SMP */
 
-static inline int stop_machine(int (*fn)(void *), void *data,
-			       const struct cpumask *cpus)
+static inline int __stop_machine(int (*fn)(void *), void *data,
+				 const struct cpumask *cpus)
 {
 	int ret;
 	local_irq_disable();
@@ -136,5 +136,11 @@ static inline int stop_machine(int (*fn)(void *), void *data,
 	return ret;
 }
 
+static inline int stop_machine(int (*fn)(void *), void *data,
+			       const struct cpumask *cpus)
+{
+	return __stop_machine(fn, data, cpus);
+}
+
 #endif	/* CONFIG_STOP_MACHINE && CONFIG_SMP */
 #endif	/* _LINUX_STOP_MACHINE */


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

* [PATCH -tip 4/5] [BUGFIX] x86: Use __stop_machine() in text_poke_smp()
  2010-10-14  3:10 [PATCH -tip 0/5] Kprobes updates Masami Hiramatsu
                   ` (2 preceding siblings ...)
  2010-10-14  3:10 ` [PATCH -tip 3/5] Define __stop_machine when CONFIG_STOP_MACHINE=n Masami Hiramatsu
@ 2010-10-14  3:10 ` Masami Hiramatsu
  2010-10-14  7:41   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
  2010-10-14  3:10 ` [PATCH -tip 5/5] [BUGFIX] kconfig/x86: Add HAVE_TEXT_POKE_SMP config for stop_machine dependency Masami Hiramatsu
  2010-10-14  6:52 ` [PATCH -tip 0/5] Kprobes updates Ingo Molnar
  5 siblings, 1 reply; 13+ messages in thread
From: Masami Hiramatsu @ 2010-10-14  3:10 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Rusty Russell, Ananth N Mavinakayanahalli, linux-kernel,
	2nddept-manager, Masami Hiramatsu, Mathieu Desnoyers,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel

Use __stop_machine() in text_poke_smp() because the caller
must get online_cpus before calling text_poke_smp(), but
stop_machine() do it again. We don't need it.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
---

 arch/x86/kernel/alternative.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index cb0e6d3..a36bb90 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -637,7 +637,8 @@ void *__kprobes text_poke_smp(void *addr, const void *opcode, size_t len)
 	tpp.len = len;
 	atomic_set(&stop_machine_first, 1);
 	wrote_text = 0;
-	stop_machine(stop_machine_text_poke, (void *)&tpp, NULL);
+	/* Use __stop_machine() because the caller already got online_cpus. */
+	__stop_machine(stop_machine_text_poke, (void *)&tpp, NULL);
 	return addr;
 }
 


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

* [PATCH -tip 5/5] [BUGFIX] kconfig/x86: Add HAVE_TEXT_POKE_SMP config for stop_machine dependency
  2010-10-14  3:10 [PATCH -tip 0/5] Kprobes updates Masami Hiramatsu
                   ` (3 preceding siblings ...)
  2010-10-14  3:10 ` [PATCH -tip 4/5] [BUGFIX] x86: Use __stop_machine() in text_poke_smp() Masami Hiramatsu
@ 2010-10-14  3:10 ` Masami Hiramatsu
  2010-10-14  7:41   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
  2010-10-14  6:52 ` [PATCH -tip 0/5] Kprobes updates Ingo Molnar
  5 siblings, 1 reply; 13+ messages in thread
From: Masami Hiramatsu @ 2010-10-14  3:10 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Rusty Russell, Ananth N Mavinakayanahalli, linux-kernel,
	2nddept-manager, Masami Hiramatsu, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, Mathieu Desnoyers, linux-kernel

Since the text_poke_smp() definately depends on actual stop_machine()
on smp, add that dependency to Kconfig.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: linux-kernel@vger.kernel.org
---

 arch/x86/Kconfig |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f6510b0..226c7ce 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -66,6 +66,7 @@ config X86
 	select GENERIC_IRQ_PROBE
 	select GENERIC_PENDING_IRQ if SMP
 	select HAVE_ARCH_JUMP_LABEL
+	select HAVE_TEXT_POKE_SMP
 
 config INSTRUCTION_DECODER
 	def_bool (KPROBES || PERF_EVENTS)
@@ -2080,6 +2081,10 @@ config HAVE_ATOMIC_IOMAP
 	def_bool y
 	depends on X86_32
 
+config HAVE_TEXT_POKE_SMP
+	bool
+	select STOP_MACHINE if SMP
+
 source "net/Kconfig"
 
 source "drivers/Kconfig"


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

* Re: [PATCH -tip  3/5] Define __stop_machine when CONFIG_STOP_MACHINE=n
  2010-10-14  3:10 ` [PATCH -tip 3/5] Define __stop_machine when CONFIG_STOP_MACHINE=n Masami Hiramatsu
@ 2010-10-14  5:00   ` Tejun Heo
  2010-10-14  7:40   ` [tip:perf/core] stopmachine: " tip-bot for Masami Hiramatsu
  1 sibling, 0 replies; 13+ messages in thread
From: Tejun Heo @ 2010-10-14  5:00 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Ingo Molnar, Rusty Russell, Ananth N Mavinakayanahalli,
	linux-kernel, 2nddept-manager, Peter Zijlstra

On 10/14/2010 05:10 AM, Masami Hiramatsu wrote:
> Define dummy __stop_machine() function even when CONFIG_STOP_MACHINE=n.
> This getcpu-required version of stop_machine() will be used from
> poke_text_smp().
> 
> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: linux-kernel@vger.kernel.org

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

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

* Re: [PATCH -tip  0/5] Kprobes updates
  2010-10-14  3:10 [PATCH -tip 0/5] Kprobes updates Masami Hiramatsu
                   ` (4 preceding siblings ...)
  2010-10-14  3:10 ` [PATCH -tip 5/5] [BUGFIX] kconfig/x86: Add HAVE_TEXT_POKE_SMP config for stop_machine dependency Masami Hiramatsu
@ 2010-10-14  6:52 ` Ingo Molnar
  5 siblings, 0 replies; 13+ messages in thread
From: Ingo Molnar @ 2010-10-14  6:52 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Rusty Russell, Ananth N Mavinakayanahalli, linux-kernel, 2nddept-manager


* Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> wrote:

> Hi,
> 
> This series of patches fixes some code/docs which are related to
> kprobes (especially optprobe).
> First 2 resend patches update document and selftest since
> optprobe changes kprobes behavior.
> Next 2 patches fix double get_cpu() by using __stop_machine().
> And the last patch makes text_poke_smp() depending on
> stop_machine() on smp, because without stop_machine(),
> it can't ensure safety on smp.
> 
> Thank you,
> 
> ---
> 
> Masami Hiramatsu (5):
>       [BUGFIX] kconfig/x86: Add HAVE_TEXT_POKE_SMP config for stop_machine dependency
>       [BUGFIX] x86: Use __stop_machine() in text_poke_smp()
>       Define __stop_machine when CONFIG_STOP_MACHINE=n
>       [RESEND][BUGFIX] kprobes: Fix selftest to clear flags field for reusing probes
>       [RESEND] kprobes: Update document about irq disabled state in kprobe handler
> 
> 
>  Documentation/kprobes.txt     |    8 +++++---
>  arch/x86/Kconfig              |    5 +++++
>  arch/x86/kernel/alternative.c |    3 ++-
>  include/linux/stop_machine.h  |   10 ++++++++--
>  kernel/test_kprobes.c         |   12 +++++++++---
>  5 files changed, 29 insertions(+), 9 deletions(-)

Applied to tip:perf/core, thanks a lot Masami!

	Ingo

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

* [tip:perf/core] kprobes: Update document about irq disabled state in kprobe handler
  2010-10-14  3:10 ` [PATCH -tip 1/5] [RESEND] kprobes: Update document about irq disabled state in kprobe handler Masami Hiramatsu
@ 2010-10-14  7:39   ` tip-bot for Masami Hiramatsu
  0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2010-10-14  7:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, ananth, hpa, mingo, masami.hiramatsu.pt, rusty,
	tglx, mingo

Commit-ID:  0f55a2f3d496133dd22f1e4e49fb7301da87c7bb
Gitweb:     http://git.kernel.org/tip/0f55a2f3d496133dd22f1e4e49fb7301da87c7bb
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Thu, 14 Oct 2010 12:10:18 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 14 Oct 2010 08:55:27 +0200

kprobes: Update document about irq disabled state in kprobe handler

Update kprobes.txt about interrupts disabled state inside
kprobes handlers, because optimized probe/boosted kretprobe
run without disabling interrrupts on x86.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: 2nddept-manager@sdl.hitachi.co.jp
LKML-Reference: <20101014031018.4100.64883.stgit@ltc236.sdl.hitachi.co.jp>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 Documentation/kprobes.txt |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Documentation/kprobes.txt b/Documentation/kprobes.txt
index 1762b81..741fe66 100644
--- a/Documentation/kprobes.txt
+++ b/Documentation/kprobes.txt
@@ -542,9 +542,11 @@ Kprobes does not use mutexes or allocate memory except during
 registration and unregistration.
 
 Probe handlers are run with preemption disabled.  Depending on the
-architecture, handlers may also run with interrupts disabled.  In any
-case, your handler should not yield the CPU (e.g., by attempting to
-acquire a semaphore).
+architecture and optimization state, handlers may also run with
+interrupts disabled (e.g., kretprobe handlers and optimized kprobe
+handlers run without interrupt disabled on x86/x86-64).  In any case,
+your handler should not yield the CPU (e.g., by attempting to acquire
+a semaphore).
 
 Since a return probe is implemented by replacing the return
 address with the trampoline's address, stack backtraces and calls

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

* [tip:perf/core] kprobes: Fix selftest to clear flags field for reusing probes
  2010-10-14  3:10 ` [PATCH -tip 2/5] [RESEND][BUGFIX] kprobes: Fix selftest to clear flags field for reusing probes Masami Hiramatsu
@ 2010-10-14  7:40   ` tip-bot for Masami Hiramatsu
  0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2010-10-14  7:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, ananth, hpa, mingo, masami.hiramatsu.pt, rusty,
	tglx, mingo

Commit-ID:  fd02e6f7ae085840d43d780149fcf95a614eca5e
Gitweb:     http://git.kernel.org/tip/fd02e6f7ae085840d43d780149fcf95a614eca5e
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Thu, 14 Oct 2010 12:10:24 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 14 Oct 2010 08:55:27 +0200

kprobes: Fix selftest to clear flags field for reusing probes

Fix selftest to clear flags field for reusing probes
because the flags field can be modified by Kprobes.
This also set NULL to kprobe.addr instead of 0.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: 2nddept-manager@sdl.hitachi.co.jp
LKML-Reference: <20101014031024.4100.50107.stgit@ltc236.sdl.hitachi.co.jp>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/test_kprobes.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel/test_kprobes.c b/kernel/test_kprobes.c
index 4f10451..f8b11a2 100644
--- a/kernel/test_kprobes.c
+++ b/kernel/test_kprobes.c
@@ -115,7 +115,9 @@ static int test_kprobes(void)
 	int ret;
 	struct kprobe *kps[2] = {&kp, &kp2};
 
-	kp.addr = 0; /* addr should be cleard for reusing kprobe. */
+	/* addr and flags should be cleard for reusing kprobe. */
+	kp.addr = NULL;
+	kp.flags = 0;
 	ret = register_kprobes(kps, 2);
 	if (ret < 0) {
 		printk(KERN_ERR "Kprobe smoke test failed: "
@@ -210,7 +212,9 @@ static int test_jprobes(void)
 	int ret;
 	struct jprobe *jps[2] = {&jp, &jp2};
 
-	jp.kp.addr = 0; /* addr should be cleard for reusing kprobe. */
+	/* addr and flags should be cleard for reusing kprobe. */
+	jp.kp.addr = NULL;
+	jp.kp.flags = 0;
 	ret = register_jprobes(jps, 2);
 	if (ret < 0) {
 		printk(KERN_ERR "Kprobe smoke test failed: "
@@ -323,7 +327,9 @@ static int test_kretprobes(void)
 	int ret;
 	struct kretprobe *rps[2] = {&rp, &rp2};
 
-	rp.kp.addr = 0; /* addr should be cleard for reusing kprobe. */
+	/* addr and flags should be cleard for reusing kprobe. */
+	rp.kp.addr = NULL;
+	rp.kp.flags = 0;
 	ret = register_kretprobes(rps, 2);
 	if (ret < 0) {
 		printk(KERN_ERR "Kprobe smoke test failed: "

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

* [tip:perf/core] stopmachine: Define __stop_machine when CONFIG_STOP_MACHINE=n
  2010-10-14  3:10 ` [PATCH -tip 3/5] Define __stop_machine when CONFIG_STOP_MACHINE=n Masami Hiramatsu
  2010-10-14  5:00   ` Tejun Heo
@ 2010-10-14  7:40   ` tip-bot for Masami Hiramatsu
  1 sibling, 0 replies; 13+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2010-10-14  7:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, peterz, ananth,
	masami.hiramatsu.pt, tj, tglx, mingo

Commit-ID:  087a4eb55971dfcc8df18312faf9393d0a479f3a
Gitweb:     http://git.kernel.org/tip/087a4eb55971dfcc8df18312faf9393d0a479f3a
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Thu, 14 Oct 2010 12:10:30 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 14 Oct 2010 08:55:28 +0200

stopmachine: Define __stop_machine when CONFIG_STOP_MACHINE=n

Define dummy __stop_machine() function even when
CONFIG_STOP_MACHINE=n. This getcpu-required version of
stop_machine() will be used from poke_text_smp().

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: 2nddept-manager@sdl.hitachi.co.jp
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <20101014031030.4100.34156.stgit@ltc236.sdl.hitachi.co.jp>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/linux/stop_machine.h |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/linux/stop_machine.h b/include/linux/stop_machine.h
index 6b524a0..1808960 100644
--- a/include/linux/stop_machine.h
+++ b/include/linux/stop_machine.h
@@ -126,8 +126,8 @@ int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus);
 
 #else	 /* CONFIG_STOP_MACHINE && CONFIG_SMP */
 
-static inline int stop_machine(int (*fn)(void *), void *data,
-			       const struct cpumask *cpus)
+static inline int __stop_machine(int (*fn)(void *), void *data,
+				 const struct cpumask *cpus)
 {
 	int ret;
 	local_irq_disable();
@@ -136,5 +136,11 @@ static inline int stop_machine(int (*fn)(void *), void *data,
 	return ret;
 }
 
+static inline int stop_machine(int (*fn)(void *), void *data,
+			       const struct cpumask *cpus)
+{
+	return __stop_machine(fn, data, cpus);
+}
+
 #endif	/* CONFIG_STOP_MACHINE && CONFIG_SMP */
 #endif	/* _LINUX_STOP_MACHINE */

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

* [tip:perf/core] x86: Use __stop_machine() in text_poke_smp()
  2010-10-14  3:10 ` [PATCH -tip 4/5] [BUGFIX] x86: Use __stop_machine() in text_poke_smp() Masami Hiramatsu
@ 2010-10-14  7:41   ` tip-bot for Masami Hiramatsu
  0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2010-10-14  7:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, mathieu.desnoyers, rusty, ananth,
	masami.hiramatsu.pt, tglx, mingo

Commit-ID:  3caa37519ccbb200c7fbbf6ff4fb306a30f29425
Gitweb:     http://git.kernel.org/tip/3caa37519ccbb200c7fbbf6ff4fb306a30f29425
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Thu, 14 Oct 2010 12:10:36 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 14 Oct 2010 08:55:28 +0200

x86: Use __stop_machine() in text_poke_smp()

Use __stop_machine() in text_poke_smp() because the caller
must get online_cpus before calling text_poke_smp(), but
stop_machine() do it again. We don't need it.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: 2nddept-manager@sdl.hitachi.co.jp
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
LKML-Reference: <20101014031036.4100.83989.stgit@ltc236.sdl.hitachi.co.jp>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/kernel/alternative.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index cb0e6d3..a36bb90 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -637,7 +637,8 @@ void *__kprobes text_poke_smp(void *addr, const void *opcode, size_t len)
 	tpp.len = len;
 	atomic_set(&stop_machine_first, 1);
 	wrote_text = 0;
-	stop_machine(stop_machine_text_poke, (void *)&tpp, NULL);
+	/* Use __stop_machine() because the caller already got online_cpus. */
+	__stop_machine(stop_machine_text_poke, (void *)&tpp, NULL);
 	return addr;
 }
 

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

* [tip:perf/core] kconfig/x86: Add HAVE_TEXT_POKE_SMP config for stop_machine dependency
  2010-10-14  3:10 ` [PATCH -tip 5/5] [BUGFIX] kconfig/x86: Add HAVE_TEXT_POKE_SMP config for stop_machine dependency Masami Hiramatsu
@ 2010-10-14  7:41   ` tip-bot for Masami Hiramatsu
  0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2010-10-14  7:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, mathieu.desnoyers, rusty, ananth,
	masami.hiramatsu.pt, tglx, mingo

Commit-ID:  3cba11d32bb4b24c3ba257043595772df4b9c7b5
Gitweb:     http://git.kernel.org/tip/3cba11d32bb4b24c3ba257043595772df4b9c7b5
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Thu, 14 Oct 2010 12:10:42 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 14 Oct 2010 08:55:29 +0200

kconfig/x86: Add HAVE_TEXT_POKE_SMP config for stop_machine dependency

Since the text_poke_smp() definately depends on actual
stop_machine() on smp, add that dependency to Kconfig.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: 2nddept-manager@sdl.hitachi.co.jp
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
LKML-Reference: <20101014031042.4100.90877.stgit@ltc236.sdl.hitachi.co.jp>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/Kconfig |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index b431a08..c14d8b4 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -60,6 +60,7 @@ config X86
 	select HAVE_ARCH_KMEMCHECK
 	select HAVE_USER_RETURN_NOTIFIER
 	select HAVE_ARCH_JUMP_LABEL
+	select HAVE_TEXT_POKE_SMP
 
 config INSTRUCTION_DECODER
 	def_bool (KPROBES || PERF_EVENTS)
@@ -2126,6 +2127,10 @@ config HAVE_ATOMIC_IOMAP
 	def_bool y
 	depends on X86_32
 
+config HAVE_TEXT_POKE_SMP
+	bool
+	select STOP_MACHINE if SMP
+
 source "net/Kconfig"
 
 source "drivers/Kconfig"

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

end of thread, other threads:[~2010-10-14  7:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-14  3:10 [PATCH -tip 0/5] Kprobes updates Masami Hiramatsu
2010-10-14  3:10 ` [PATCH -tip 1/5] [RESEND] kprobes: Update document about irq disabled state in kprobe handler Masami Hiramatsu
2010-10-14  7:39   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2010-10-14  3:10 ` [PATCH -tip 2/5] [RESEND][BUGFIX] kprobes: Fix selftest to clear flags field for reusing probes Masami Hiramatsu
2010-10-14  7:40   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2010-10-14  3:10 ` [PATCH -tip 3/5] Define __stop_machine when CONFIG_STOP_MACHINE=n Masami Hiramatsu
2010-10-14  5:00   ` Tejun Heo
2010-10-14  7:40   ` [tip:perf/core] stopmachine: " tip-bot for Masami Hiramatsu
2010-10-14  3:10 ` [PATCH -tip 4/5] [BUGFIX] x86: Use __stop_machine() in text_poke_smp() Masami Hiramatsu
2010-10-14  7:41   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2010-10-14  3:10 ` [PATCH -tip 5/5] [BUGFIX] kconfig/x86: Add HAVE_TEXT_POKE_SMP config for stop_machine dependency Masami Hiramatsu
2010-10-14  7:41   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2010-10-14  6:52 ` [PATCH -tip 0/5] Kprobes updates Ingo Molnar

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.