arm64: mm: pass original fault address to handle_mm_fault() in PER_VMA_LOCK block
PATCH 1/1 arm64: mm: pass original fault address to handle_mm_fault() in PER_VMA_LOCK block
When reading the arm64's PER_VMA_LOCK support code, I found a bit difference between arm64 and other arch when calling handle_mm_fault() during VMA lock-based page fault handling: the fault address is masked before passing to handle_mm_fault(). This is also different from the usage in mmap_lock-based handling. I think we need to pass the original fault address to handle_mm_fault() as we did in commit 84c5e23edecd ("arm64: mm: Pass original fault address to handle_mm_fault()").
If we go through the code path further, we can find that the "masked" fault address can cause mismatched fault address between perf sw major/minor page fault sw event and perf page fault sw event:
do_page_fault
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, ..., addr) // orig addr
handle_mm_fault
mm_account_fault
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, ...) // masked addr
--- arch/arm64/mm/fault.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/mm/fault.c +1 -2
@@ -600,8 +600,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,vma_end_read (vma); goto lock_mmap; } - fault =handle_mm_fault (vma, addr &PAGE_MASK , - mm_flags |FAULT_FLAG_VMA_LOCK , regs); + fault =handle_mm_fault (vma, addr, mm_flags |FAULT_FLAG_VMA_LOCK , regs);vma_end_read (vma);if (!(fault &VM_FAULT_RETRY )) {
Signature · 7 lines
2.40.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 9 lines · Jisheng Zhang
When reading the arm64's
PER_VMA_LOCKsupport code, I found a bit difference between arm64 and other arch when callinghandle_mm_fault()during VMA lock-based page fault handling: the fault address is masked before passing tohandle_mm_fault(). This is also different from the usage in mmap_lock-based handling. I think we need to pass the original fault address tohandle_mm_fault()as we did in commit84c5e23edecd("arm64: mm: Pass original fault address tohandle_mm_fault()").
Quoted 3 lines
If we go through the code path further, we can find that the "masked" fault address can cause mismatched fault address between perf sw major/minor page fault sw event and perf page fault sw event:
OOPS, sorry please ignore this one. I pressed ctrl-c to interrupt the git send-mail, but it's still sent out ;)
Instead, let's focus on
https://lore.kernel.org/linux-arm-kernel/[email protected]/T/#u
The two patches are the same, I just added Suren into CC list.
Quoted 35 lines
do_page_fault
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, ..., addr)// orig addr
handle_mm_fault
mm_account_fault
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, ...)// masked addrFixes cd7f176aea5f ("arm64/mm: try VMA lock-based page fault handling first")Signed-off-by Jisheng Zhang <[email protected]>--- arch/arm64/mm/fault.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/arm64/mm/fault.c +1
-2@@ -600,8 +600,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,vma_end_read (vma); goto lock_mmap; } - fault =handle_mm_fault (vma, addr &PAGE_MASK , - mm_flags |FAULT_FLAG_VMA_LOCK , regs); + fault =handle_mm_fault (vma, addr, mm_flags |FAULT_FLAG_VMA_LOCK , regs);vma_end_read (vma);if (!(fault &VM_FAULT_RETRY )) {Signature · 7 lines
2.40.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Suren Baghdasaryan
Reviewed-byQuoted 10 lines · Jisheng Zhang
Quoted 8 lines · Jisheng Zhang
When reading the arm64's
PER_VMA_LOCKsupport code, I found a bit difference between arm64 and other arch when callinghandle_mm_fault()during VMA lock-based page fault handling: the fault address is masked before passing tohandle_mm_fault(). This is also different from the usage in mmap_lock-based handling. I think we need to pass the original fault address tohandle_mm_fault()as we did in commit84c5e23edecd("arm64: mm: Pass original fault address tohandle_mm_fault()").
Thanks for noticing. I'm not sure why this masking leaked into my patch. I don't think I wrote it before 84c5e23edecd was merged in June 2021.
Anyway, your assessment looks correct to me.
Quoted 5 lines
Quoted 4 lines
If we go through the code path further, we can find that the "masked" fault address can cause mismatched fault address between perf sw major/minor page fault sw event and perf page fault sw event:
Quoted 17 lines
OOPS, sorry please ignore this one. I pressed ctrl-c to interrupt the git send-mail, but it's still sent out ;)
Instead, let's focus on
https://lore.kernel.org/linux-arm-kernel/[email protected]/T/#uThe two patches are the same, I just added Suren into CC list.
Quoted 9 lines
do_page_fault
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, ..., addr)// orig addr
handle_mm_fault
mm_account_fault
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, ...)// masked addrFixes cd7f176aea5f ("arm64/mm: try VMA lock-based page fault handling first")Signed-off-by Jisheng Zhang <[email protected]>
Quoted 26 lines
Quoted 26 lines
--- arch/arm64/mm/fault.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/arm64/mm/fault.c +1
-3@@ -600,8 +600,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,vma_end_read (vma); goto lock_mmap; } - fault =handle_mm_fault (vma, addr &PAGE_MASK , - mm_flags |FAULT_FLAG_VMA_LOCK , regs); + fault =handle_mm_fault (vma, addr, mm_flags |FAULT_FLAG_VMA_LOCK , regs);vma_end_read (vma);if (!(fault &VM_FAULT_RETRY )) { --2.40.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 13 lines · Jisheng Zhang
When reading the arm64's
PER_VMA_LOCKsupport code, I found a bit difference between arm64 and other arch when callinghandle_mm_fault()during VMA lock-based page fault handling: the fault address is masked before passing tohandle_mm_fault(). This is also different from the usage in mmap_lock-based handling. I think we need to pass the original fault address tohandle_mm_fault()as we did in commit84c5e23edecd("arm64: mm: Pass original fault address tohandle_mm_fault()").If we go through the code path further, we can find that the "masked" fault address can cause mismatched fault address between perf sw major/minor page fault sw event and perf page fault sw event:
Quoted 8 lines
do_page_fault
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, ..., addr)// orig addr
handle_mm_fault
mm_account_fault
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, ...)// masked addrFixes cd7f176aea5f ("arm64/mm: try VMA lock-based page fault handling first")Signed-off-by Jisheng Zhang <[email protected]>
LGTM
Quoted 18 lines
--- arch/arm64/mm/fault.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/arm64/mm/fault.c +1
-2@@ -600,8 +600,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,vma_end_read (vma); goto lock_mmap; } - fault =handle_mm_fault (vma, addr &PAGE_MASK , - mm_flags |FAULT_FLAG_VMA_LOCK , regs); + fault =handle_mm_fault (vma, addr, mm_flags |FAULT_FLAG_VMA_LOCK , regs);vma_end_read (vma);if (!(fault &VM_FAULT_RETRY )) {