major page fault handler in Linux kernel
Asked Answered
A

1

7

I am wondering where is the major page fault handler.

I wrote an algorithm to minimize page faults in the kernel. So I need to record something whenever a page fault happens. I currently record a page fault happen at do_page_fault(...) in arch/x86/mm/fault_32.c

However, it seems both minor and major page fault will go to do_page_fault(...) ... And minor page faults happen all the time and messed up the algorithm.

I guess I only want to record stuff when a major page_fault happens. So, kernel hackers, would you please tell me where should I put my code? Which file and which function.

By the way, I am hacking kernel 2.6.24

Thank you very much! Alfred

Admittance answered 4/5, 2012 at 1:4 Comment(0)
P
9

The handle_mm_fault function handles the page fault. Its return value is a set of flags. if VM_FAULT_MAJOR is set, then it's a major page fault. The kernel calls perf_sw_event(PERF_COUNT_SW_PAGE_FAULT_MAJ, 1, 0, ... on every major page fault.

Pren answered 4/5, 2012 at 1:11 Comment(1)
Thank you so much, David! Which file is perf_sw_event in? I tried a grep and didn't find it...Admittance

© 2022 - 2024 — McMap. All rights reserved.