Skip to content

Commit

Permalink
[IA64] optimize pagefaults a little
Browse files Browse the repository at this point in the history
Get rid of the notifier list and call the kprobes code directly
if compiled in.  This mirrors the changes that recently went
into powerpc, s390 and sparc64.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Tony Luck <tony.luck@intel.com>
  • Loading branch information
Christoph Hellwig authored and Tony Luck committed May 16, 2007
1 parent 17028c5 commit 576fe0b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 38 deletions.
9 changes: 1 addition & 8 deletions arch/ia64/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ static int __kprobes post_kprobes_handler(struct pt_regs *regs)
return 1;
}

static int __kprobes kprobes_fault_handler(struct pt_regs *regs, int trapnr)
int __kprobes kprobes_fault_handler(struct pt_regs *regs, int trapnr)
{
struct kprobe *cur = kprobe_running();
struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
Expand Down Expand Up @@ -904,13 +904,6 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
if (post_kprobes_handler(args->regs))
ret = NOTIFY_STOP;
break;
case DIE_PAGE_FAULT:
/* kprobe_running() needs smp_processor_id() */
preempt_disable();
if (kprobe_running() &&
kprobes_fault_handler(args->regs, args->trapnr))
ret = NOTIFY_STOP;
preempt_enable();
default:
break;
}
Expand Down
41 changes: 14 additions & 27 deletions arch/ia64/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,24 @@
extern void die (char *, struct pt_regs *, long);

#ifdef CONFIG_KPROBES
ATOMIC_NOTIFIER_HEAD(notify_page_fault_chain);

/* Hook to register for page fault notifications */
int register_page_fault_notifier(struct notifier_block *nb)
{
return atomic_notifier_chain_register(&notify_page_fault_chain, nb);
}

int unregister_page_fault_notifier(struct notifier_block *nb)
static inline int notify_page_fault(struct pt_regs *regs, int trap)
{
return atomic_notifier_chain_unregister(&notify_page_fault_chain, nb);
}
int ret = 0;

if (!user_mode(regs)) {
/* kprobe_running() needs smp_processor_id() */
preempt_disable();
if (kprobe_running() && kprobes_fault_handler(regs, trap))
ret = 1;
preempt_enable();
}

static inline int notify_page_fault(enum die_val val, const char *str,
struct pt_regs *regs, long err, int trap, int sig)
{
struct die_args args = {
.regs = regs,
.str = str,
.err = err,
.trapnr = trap,
.signr = sig
};
return atomic_notifier_call_chain(&notify_page_fault_chain, val, &args);
return ret;
}
#else
static inline int notify_page_fault(enum die_val val, const char *str,
struct pt_regs *regs, long err, int trap, int sig)
static inline int notify_page_fault(struct pt_regs *regs, int trap)
{
return NOTIFY_DONE;
return 0;
}
#endif

Expand Down Expand Up @@ -117,8 +105,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
/*
* This is to handle the kprobes on user space access instructions
*/
if (notify_page_fault(DIE_PAGE_FAULT, "page fault", regs, code, TRAP_BRKPT,
SIGSEGV) == NOTIFY_STOP)
if (notify_page_fault(regs, TRAP_BRKPT))
return;

down_read(&mm->mmap_sem);
Expand Down
16 changes: 13 additions & 3 deletions include/asm-ia64/kdebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,24 @@
*/
#include <linux/notifier.h>

extern int register_page_fault_notifier(struct notifier_block *);
extern int unregister_page_fault_notifier(struct notifier_block *);
/*
* These are only here because kprobes.c wants them to implement a
* blatant layering violation. Will hopefully go away soon once all
* architectures are updated.
*/
static inline int register_page_fault_notifier(struct notifier_block *nb)
{
return 0;
}
static inline int unregister_page_fault_notifier(struct notifier_block *nb)
{
return 0;
}

enum die_val {
DIE_BREAK = 1,
DIE_FAULT,
DIE_OOPS,
DIE_PAGE_FAULT,
DIE_MACHINE_HALT,
DIE_MACHINE_RESTART,
DIE_MCA_MONARCH_ENTER,
Expand Down
1 change: 1 addition & 0 deletions include/asm-ia64/kprobes.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ struct arch_specific_insn {
unsigned short slot;
};

extern int kprobes_fault_handler(struct pt_regs *regs, int trapnr);
extern int kprobe_exceptions_notify(struct notifier_block *self,
unsigned long val, void *data);

Expand Down

0 comments on commit 576fe0b

Please sign in to comment.