mremap: skip page table lookup for non-faulted anonymous VMAs
Subsystems (2)
PATCH 1/1 mremap: skip page table lookup for non-faulted anonymous VMAs
If an anonymous vma has not yet been faulted, move_page_tables() in move_vma() is not necessary for it.
---
mm/mremap.c +5 -0
@@ -200,6 +200,10 @@ static unsigned long move_vma(struct vm_area_struct *vma,if (!new_vma)return -ENOMEM ; +/* An anonymous vma has not been faulted, no pagetables lookup. */ +if (!vma->vm_file && !vma->anon_vma) + goto page_tables_ok; + moved_len =move_page_tables (vma, old_addr, new_vma, new_addr, old_len);if (moved_len < old_len) {/*
@@ -213,6 +217,7 @@ static unsigned long move_vma(struct vm_area_struct *vma, old_addr = new_addr; new_addr = -ENOMEM ; } +page_tables_ok:/* Conceal VM_ACCOUNT so old reservation is not undone */ if (vm_flags &VM_ACCOUNT ) {
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 2 lines · Nai Xia
If an anonymous vma has not yet been faulted,
move_page_tables()inmove_vma()is not necessary for it.
I actually thought of adding that (in fact fork has it and it's more likely to be beneficial for fork than for mremap I suspect), but this adds a branch to the fast path for a case that shouldn't normally materialize. So I don't think it's worth adding it as I expect it to add overhead in average.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 10 lines · Andrea Arcangeli
Quoted 2 lines · Nai Xia
If an anonymous vma has not yet been faulted,
move_page_tables()inmove_vma()is not necessary for it.I actually thought of adding that (in fact fork has it and it's more likely to be beneficial for fork than for mremap I suspect), but this adds a branch to the fast path for a case that shouldn't normally materialize. So I don't think it's worth adding it as I expect it to add overhead in average.
Well, it seems like I forgot to embrace it with unlikely(), with instr prefetching this line seems a trivial even for the average cases.
But in case it really materializes, it may avoid tedious page table locking and pmd allocation and furthermore, a semantically confusing operation of move_page_tables() on a same VMA.
Anyway, it's not a big deal, indeed. You are the maintainers, it's left for you to decide.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>