History

mm: merge parameters for change_protection()

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.

Peter Xu committed 6 years ago

Commit 58705441 parent 72981e05 files · +33 −17Browse files

Showing the changes to include/linux (2 of 5 files). Show all

Unified · Split

2 files
  1. include/linux/huge_mm.h +1 −1
  2. include/linux/mm.h +13 −1
include/linux/huge_mm.h+1−1
@@ -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);
47extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,47extern 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);
50vm_fault_t vmf_insert_pfn_pmd_prot(struct vm_fault *vmf, pfn_t pfn,50vm_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
include/linux/mm.h+13−1
@@ -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
1774extern unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,1786extern 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);
1777extern int mprotect_fixup(struct vm_area_struct *vma,1789extern 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);