LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2/2] kprobe: remove preempt_enable/disable from kprobe_handle_fault()
@ 2008-02-03  3:00 Harvey Harrison
  2008-02-07 19:12 ` Masami Hiramatsu
  0 siblings, 1 reply; 4+ messages in thread
From: Harvey Harrison @ 2008-02-03  3:00 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, LKML

This patch removes the preempt_disable/enable pair around kprobe_running
which was originally added to avoid the assertion from smp_processor_id
which would be hit an asertion if preemption was enabled.

Kprobes can not be running if we are preemptible, so test explicitly
for preemption and bail out before hitting kprobe_running().

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 include/linux/kprobes.h |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index e5ecb1e..e099426 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -213,19 +213,16 @@ static inline struct kprobe *kprobe_running(void)
 	return (__get_cpu_var(current_kprobe));
 }
 
+/*
+ * If it is a kprobe pagefault we can not be preemptible so return before
+ * calling kprobe_running() as it will assert on smp_processor_id if
+ * preemption is enabled.
+ */
 static inline int kprobe_handle_fault(struct pt_regs *regs, int trapnr)
 {
-	int ret = 0;
-
-	/* kprobe_running() needs smp_processor_id() */
-	if (!user_mode(regs)) {
-		preempt_disable();
-		if (kprobe_running() && kprobe_fault_handler(regs, trapnr))
-			ret = 1;
-		preempt_enable();
-	}
-
-	return ret;
+	if (!user_mode(regs) && !preemptible() && kprobe_running())
+		return kprobe_fault_handler(regs, trapnr);
+	return 0;
 }
 
 static inline void reset_current_kprobe(void)
-- 
1.5.4.rc4.1142.gf5a97


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

* Re: [PATCH 2/2] kprobe: remove preempt_enable/disable from kprobe_handle_fault()
  2008-02-03  3:00 [PATCH 2/2] kprobe: remove preempt_enable/disable from kprobe_handle_fault() Harvey Harrison
@ 2008-02-07 19:12 ` Masami Hiramatsu
  0 siblings, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2008-02-07 19:12 UTC (permalink / raw)
  To: Harvey Harrison; +Cc: Andrew Morton, linux-arch, LKML

Harvey Harrison wrote:
> This patch removes the preempt_disable/enable pair around kprobe_running
> which was originally added to avoid the assertion from smp_processor_id
> which would be hit an asertion if preemption was enabled.
> 
> Kprobes can not be running if we are preemptible, so test explicitly
> for preemption and bail out before hitting kprobe_running().
> 
> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>

Acked-by: Masami Hiramatsu <mhiramat@redhat.com>


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com



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

* Re: [PATCH 2/2] kprobe: remove preempt_enable/disable from kprobe_handle_fault()
  2008-01-10  0:45               ` [PATCH 2/2] kprobe: remove preempt_enable/disable from kprobe_handle_fault() Harvey Harrison
@ 2008-01-10  3:15                 ` Masami Hiramatsu
  0 siblings, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2008-01-10  3:15 UTC (permalink / raw)
  To: Harvey Harrison
  Cc: Heiko Carstens, Christoph Hellwig, Andrew Morton, LKML,
	Ananth N Mavinakayanahalli, David Miller, hskinnemoen,
	schwidefsky, tony.luck, Ingo Molnar, Paul Mackerras,
	David Wilder, jkenisto

Harvey Harrison wrote:
> This patch removes the preempt_disable/enable pair around kprobe_running
> which was originally added to avoid the assertion from smp_processor_id
> which would be hit an asertion if preemption was enabled.
> 
> Kprobes can not be running if we are preemptible, so test explicitly
> for preemption and bail out before hitting kprobe_running().
> 
> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>

Tested on x86-64.

Acked-by: Masami Hiramatsu <mhiramat@redhat.com>

Thank you!

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com, masami.hiramatsu.pt@hitachi.com


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

* [PATCH 2/2] kprobe: remove preempt_enable/disable from kprobe_handle_fault()
  2008-01-09 23:16             ` Heiko Carstens
@ 2008-01-10  0:45               ` Harvey Harrison
  2008-01-10  3:15                 ` Masami Hiramatsu
  0 siblings, 1 reply; 4+ messages in thread
From: Harvey Harrison @ 2008-01-10  0:45 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Christoph Hellwig, Andrew Morton, LKML, Masami Hiramatsu,
	Ananth N Mavinakayanahalli, David Miller, hskinnemoen,
	schwidefsky, tony.luck, Ingo Molnar, Paul Mackerras,
	David Wilder, jkenisto

This patch removes the preempt_disable/enable pair around kprobe_running
which was originally added to avoid the assertion from smp_processor_id
which would be hit an asertion if preemption was enabled.

Kprobes can not be running if we are preemptible, so test explicitly
for preemption and bail out before hitting kprobe_running().

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 include/linux/kprobes.h |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index c01e320..e61607a 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -204,19 +204,16 @@ static inline struct kprobe *kprobe_running(void)
 	return (__get_cpu_var(current_kprobe));
 }
 
+/*
+ * If it is a kprobe pagefault we can not be preemptible so return before
+ * calling kprobe_running() as it will assert on smp_processor_id if
+ * preemption is enabled.
+ */
 static inline int kprobe_handle_fault(struct pt_regs *regs, int trapnr)
 {
-	int ret = 0;
-
-	/* kprobe_running() needs smp_processor_id() */
-	if (!user_mode(regs)) {
-		preempt_disable();
-		if (kprobe_running() && kprobe_fault_handler(regs, trapnr))
-			ret = 1;
-		preempt_enable();
-	}
-
-	return ret;
+	if (!user_mode(regs) && !preemptible() && kprobe_running())
+		return kprobe_fault_handler(regs, trapnr);
+	return 0;
 }
 
 static inline void reset_current_kprobe(void)
-- 
1.5.4.rc2.1164.g6451


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

end of thread, other threads:[~2008-02-07 19:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-03  3:00 [PATCH 2/2] kprobe: remove preempt_enable/disable from kprobe_handle_fault() Harvey Harrison
2008-02-07 19:12 ` Masami Hiramatsu
  -- strict thread matches above, loose matches on Subject: below --
2008-01-07 20:24 [PATCHv2] kprobes: Introduce is_kprobe_fault() Harvey Harrison
2008-01-08 22:45 ` Paul Mackerras
2008-01-08 23:02   ` Harvey Harrison
2008-01-09  4:19     ` [PATCHv3] kprobes: Introduce kprobe_handle_fault() Harvey Harrison
2008-01-09  6:14       ` Heiko Carstens
2008-01-09  6:22         ` Harvey Harrison
2008-01-09 22:01           ` [PATCHv4] " Harvey Harrison
2008-01-09 23:16             ` Heiko Carstens
2008-01-10  0:45               ` [PATCH 2/2] kprobe: remove preempt_enable/disable from kprobe_handle_fault() Harvey Harrison
2008-01-10  3:15                 ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).