Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] Notify page fault call chain for i386

Overloading of page fault notification with the notify_die() has performance
issues(since the only interested components for page fault is kprobes and/or
kdb) and hence this patch introduces the new notifier call chain exclusively
for page fault notifications their by avoiding notifying unnecessary
components in the do_page_fault() code path.

Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Anil S Keshavamurthy and committed by
Linus Torvalds
b71b5b65 1bd858a5

+38 -2
+36 -2
arch/i386/mm/fault.c
··· 30 30 31 31 extern void die(const char *,struct pt_regs *,long); 32 32 33 + #ifdef CONFIG_KPROBES 34 + ATOMIC_NOTIFIER_HEAD(notify_page_fault_chain); 35 + int register_page_fault_notifier(struct notifier_block *nb) 36 + { 37 + vmalloc_sync_all(); 38 + return atomic_notifier_chain_register(&notify_page_fault_chain, nb); 39 + } 40 + 41 + int unregister_page_fault_notifier(struct notifier_block *nb) 42 + { 43 + return atomic_notifier_chain_unregister(&notify_page_fault_chain, nb); 44 + } 45 + 46 + static inline int notify_page_fault(enum die_val val, const char *str, 47 + struct pt_regs *regs, long err, int trap, int sig) 48 + { 49 + struct die_args args = { 50 + .regs = regs, 51 + .str = str, 52 + .err = err, 53 + .trapnr = trap, 54 + .signr = sig 55 + }; 56 + return atomic_notifier_call_chain(&notify_page_fault_chain, val, &args); 57 + } 58 + #else 59 + static inline int notify_page_fault(enum die_val val, const char *str, 60 + struct pt_regs *regs, long err, int trap, int sig) 61 + { 62 + return NOTIFY_DONE; 63 + } 64 + #endif 65 + 66 + 33 67 /* 34 68 * Unlock any spinlocks which will prevent us from getting the 35 69 * message out ··· 358 324 if (unlikely(address >= TASK_SIZE)) { 359 325 if (!(error_code & 0x0000000d) && vmalloc_fault(address) >= 0) 360 326 return; 361 - if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14, 327 + if (notify_page_fault(DIE_PAGE_FAULT, "page fault", regs, error_code, 14, 362 328 SIGSEGV) == NOTIFY_STOP) 363 329 return; 364 330 /* ··· 368 334 goto bad_area_nosemaphore; 369 335 } 370 336 371 - if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14, 337 + if (notify_page_fault(DIE_PAGE_FAULT, "page fault", regs, error_code, 14, 372 338 SIGSEGV) == NOTIFY_STOP) 373 339 return; 374 340
+2
include/asm-i386/kdebug.h
··· 19 19 20 20 extern int register_die_notifier(struct notifier_block *); 21 21 extern int unregister_die_notifier(struct notifier_block *); 22 + extern int register_page_fault_notifier(struct notifier_block *); 23 + extern int unregister_page_fault_notifier(struct notifier_block *); 22 24 extern struct atomic_notifier_head i386die_chain; 23 25 24 26