[patch 03/52] [PATCH] Improve notify_page_fault implementation.

Martin Schwidefsky
2009-11-13T15:20:27Z

[-- Attachment #1: 102-mm-kprobe-notify.diff --]
[-- Type: text/plain, Size: 1447 bytes --]

From: Martin Schwidefsky <schwidefsky@de.ibm.com>

notify_page_fault does a preempt_disable/preempt_enable for each
fault generated by a kernel access to user space. If kprobes
is not active that is unnecessary since the interrupts are not
reenabled yet. To play safe repeat the kprobe_running check after
preempt_disable().

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

arch/s390/mm/fault.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

Index: quilt-2.6/arch/s390/mm/fault.c
===================================================================
--- quilt-2.6.orig/arch/s390/mm/fault.c 2009-11-13 16:08:12.000000000 +0100
+++ quilt-2.6/arch/s390/mm/fault.c 2009-11-13 16:08:12.000000000 +0100
@@ -52,11 +52,11 @@
extern int sysctl_userprocess_debug;
#endif

-#ifdef CONFIG_KPROBES
-static inline int notify_page_fault(struct pt_regs *regs, long err)
+static inline int notify_page_fault(struct pt_regs *regs)
{
int ret = 0;

+#ifdef CONFIG_KPROBES
/* kprobe_running() needs smp_processor_id() */
if (!user_mode(regs)) {
preempt_disable();
@@ -64,15 +64,9 @@
ret = 1;
preempt_enable();
}
-
+#endif
return ret;
}
-#else
-static inline int notify_page_fault(struct pt_regs *regs, long err)
-{
- return 0;
-}
-#endif

/*
@@ -274,7 +268,7 @@
int si_code;
int fault;

- if (notify_page_fault(regs, error_code))
+ if (notify_page_fault(regs))
return;

tsk = current;