x86, mm, kprobes: fault.c, simplify notify_page_fault()
authorIngo Molnar <mingo@elte.hu>
Fri, 20 Feb 2009 21:42:57 +0000 (22:42 +0100)
committerIngo Molnar <mingo@elte.hu>
Fri, 20 Feb 2009 23:09:42 +0000 (00:09 +0100)
Impact: cleanup

Remove an #ifdef from notify_page_fault(). The function still
compiles to nothing in the !CONFIG_KPROBES case.

Introduce kprobes_built_in() and kprobe_fault_handler() helpers
to allow this - they returns 0 if !CONFIG_KPROBES.

No code changed:

   text    data     bss     dec     hex filename
   4618      32      24    4674    1242 fault.o.before
   4618      32      24    4674    1242 fault.o.after

Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/mm/fault.c
include/linux/kprobes.h

index fe99af4b86d9970c3264d6601892cd0364e013d7..379beaec6caae6018a98e98692f6f44c9c284705 100644 (file)
@@ -68,11 +68,10 @@ static inline int kmmio_fault(struct pt_regs *regs, unsigned long addr)
 
 static inline int notify_page_fault(struct pt_regs *regs)
 {
-#ifdef CONFIG_KPROBES
        int ret = 0;
 
        /* kprobe_running() needs smp_processor_id() */
-       if (!user_mode_vm(regs)) {
+       if (kprobes_built_in() && !user_mode_vm(regs)) {
                preempt_disable();
                if (kprobe_running() && kprobe_fault_handler(regs, 14))
                        ret = 1;
@@ -80,9 +79,6 @@ static inline int notify_page_fault(struct pt_regs *regs)
        }
 
        return ret;
-#else
-       return 0;
-#endif
 }
 
 /*
index 32851eef48f058908f2e30312007692540cedd2e..2ec6cc14a1146e584ee7da0f99e9c1d67349ce61 100644 (file)
@@ -182,6 +182,14 @@ struct kprobe_blackpoint {
 DECLARE_PER_CPU(struct kprobe *, current_kprobe);
 DECLARE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
 
+/*
+ * For #ifdef avoidance:
+ */
+static inline int kprobes_built_in(void)
+{
+       return 1;
+}
+
 #ifdef CONFIG_KRETPROBES
 extern void arch_prepare_kretprobe(struct kretprobe_instance *ri,
                                   struct pt_regs *regs);
@@ -271,8 +279,16 @@ void unregister_kretprobes(struct kretprobe **rps, int num);
 void kprobe_flush_task(struct task_struct *tk);
 void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head);
 
-#else /* CONFIG_KPROBES */
+#else /* !CONFIG_KPROBES: */
 
+static inline int kprobes_built_in(void)
+{
+       return 0;
+}
+static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
+{
+       return 0;
+}
 static inline struct kprobe *get_kprobe(void *addr)
 {
        return NULL;
@@ -329,5 +345,5 @@ static inline void unregister_kretprobes(struct kretprobe **rps, int num)
 static inline void kprobe_flush_task(struct task_struct *tk)
 {
 }
-#endif                         /* CONFIG_KPROBES */
-#endif                         /* _LINUX_KPROBES_H */
+#endif /* CONFIG_KPROBES */
+#endif /* _LINUX_KPROBES_H */
This page took 0.036116 seconds and 5 git commands to generate.