change_protection() was used by either the NUMA or mprotect() code, there's one parameter for each of the callers (dirty_accountable and prot_numa). Further, these parameters are passed along the calls: - change_protection_range() - change_p4d_range() - change_pud_range() - change_pmd_range() - ... Now we introduce a flag for change_protect() and all these helpers to replace these parameters. Then we can avoid passing multiple parameters multiple times along the way. More importantly, it'll greatly simplify the work if we want to introduce any new parameters to change_protection(). In the follow up patches, a new parameter for userfaultfd write protection will be introduced. No functional change at all.
Showing the changes to include/linux (2 of 5 files). Show all
Unified · Split
| @@ -46,7 +46,7 @@ extern bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr, · 45 unmodified lines | |||
| 46 | pmd_t *old_pmd, pmd_t *new_pmd); | 46 | pmd_t *old_pmd, pmd_t *new_pmd); |
| 47 | extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, | 47 | extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, |
| 48 | unsigned long addr, pgprot_t newprot, | 48 | unsigned long addr, pgprot_t newprot, |
| 49 | int prot_numa); | 49 | unsigned long cp_flags); |
| 50 | vm_fault_t vmf_insert_pfn_pmd_prot(struct vm_fault *vmf, pfn_t pfn, | 50 | vm_fault_t vmf_insert_pfn_pmd_prot(struct vm_fault *vmf, pfn_t pfn, |
| 51 | pgprot_t pgprot, bool write); | 51 | pgprot_t pgprot, bool write); |
| 52 | 52 | ||
| @@ -1771,9 +1771,21 @@ extern unsigned long move_page_tables(struct vm_area_struct *vma, · 1770 unmodified lines | |||
| 1771 | unsigned long old_addr, struct vm_area_struct *new_vma, | 1771 | unsigned long old_addr, struct vm_area_struct *new_vma, |
| 1772 | unsigned long new_addr, unsigned long len, | 1772 | unsigned long new_addr, unsigned long len, |
| 1773 | bool need_rmap_locks); | 1773 | bool need_rmap_locks); |
| 1774 | |||
| 1775 | /* | ||
| 1776 | * Flags used by change_protection(). For now we make it a bitmap so | ||
| 1777 | * that we can pass in multiple flags just like parameters. However | ||
| 1778 | * for now all the callers are only use one of the flags at the same | ||
| 1779 | * time. | ||
| 1780 | */ | ||
| 1781 | /* Whether we should allow dirty bit accounting */ | ||
| 1782 | #define MM_CP_DIRTY_ACCT (1UL << 0) | ||
| 1783 | /* Whether this protection change is for NUMA hints */ | ||
| 1784 | #define MM_CP_PROT_NUMA (1UL << 1) | ||
| 1785 | |||
| 1774 | extern unsigned long change_protection(struct vm_area_struct *vma, unsigned long start, | 1786 | extern unsigned long change_protection(struct vm_area_struct *vma, unsigned long start, |
| 1775 | unsigned long end, pgprot_t newprot, | 1787 | unsigned long end, pgprot_t newprot, |
| 1776 | int dirty_accountable, int prot_numa); | 1788 | unsigned long cp_flags); |
| 1777 | extern int mprotect_fixup(struct vm_area_struct *vma, | 1789 | extern int mprotect_fixup(struct vm_area_struct *vma, |
| 1778 | struct vm_area_struct **pprev, unsigned long start, | 1790 | struct vm_area_struct **pprev, unsigned long start, |
| 1779 | unsigned long end, unsigned long newflags); | 1791 | unsigned long end, unsigned long newflags); |