lkml.org 
[lkml]   [2021]   [Oct]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 1/2] mm/mprotect: use mmu_gather
    On Sat, Sep 25, 2021 at 01:54:22PM -0700, Nadav Amit wrote:

    > @@ -338,25 +344,25 @@ static unsigned long change_protection_range(struct vm_area_struct *vma,
    > struct mm_struct *mm = vma->vm_mm;
    > pgd_t *pgd;
    > unsigned long next;
    > - unsigned long start = addr;
    > unsigned long pages = 0;
    > + struct mmu_gather tlb;
    >
    > BUG_ON(addr >= end);
    > pgd = pgd_offset(mm, addr);
    > flush_cache_range(vma, addr, end);
    > inc_tlb_flush_pending(mm);

    That seems unbalanced...

    > + tlb_gather_mmu(&tlb, mm);
    > + tlb_start_vma(&tlb, vma);
    > do {
    > next = pgd_addr_end(addr, end);
    > if (pgd_none_or_clear_bad(pgd))
    > continue;
    > - pages += change_p4d_range(vma, pgd, addr, next, newprot,
    > + pages += change_p4d_range(&tlb, vma, pgd, addr, next, newprot,
    > cp_flags);
    > } while (pgd++, addr = next, addr != end);
    >
    > - /* Only flush the TLB if we actually modified any entries: */
    > - if (pages)
    > - flush_tlb_range(vma, start, end);
    > - dec_tlb_flush_pending(mm);

    ... seeing you do remove the extra decrement.

    > + tlb_end_vma(&tlb, vma);
    > + tlb_finish_mmu(&tlb);
    >
    > return pages;
    > }
    > --
    > 2.25.1
    >

    \
     
     \ /
      Last update: 2021-10-03 14:13    [W:5.668 / U:0.132 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site