[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <00EDCFA2-5BFE-4C7A-A41A-DD8902F0E494@gmail.com>
Date: Tue, 5 Oct 2021 09:34:06 -0700
From: Nadav Amit <nadav.amit@...il.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
LKML <linux-kernel@...r.kernel.org>,
Linux-MM <linux-mm@...ck.org>, Peter Xu <peterx@...hat.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Andrew Cooper <andrew.cooper3@...rix.com>,
Andy Lutomirski <luto@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>,
Will Deacon <will@...nel.org>, Yu Zhao <yuzhao@...gle.com>,
Nick Piggin <npiggin@...il.com>, x86@...nel.org
Subject: Re: [PATCH 1/2] mm/mprotect: use mmu_gather
> On Oct 4, 2021, at 11:53 PM, Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Mon, Oct 04, 2021 at 12:24:14PM -0700, Nadav Amit wrote:
>>
>>
>>> On Oct 3, 2021, at 5:10 AM, Peter Zijlstra <peterz@...radead.org> wrote:
>>>
>>> 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...
>>
>> Bad rebase. Thanks for catching it!
>>
>>>
>>>> + 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.
>>
>> Is it really needed? We do not put this comment elsewhere for
>> tlb_finish_mmu(). But no problem, I’ll keep it.
>
> -ENOPARSE, did you read decrement as comment? In any case, I don't
> particularly care about the comment, and tlb_*_mmu() imply the inc/dec
> thingies.
>
> All I tried to do is point out that removing the dec but leaving the inc
> is somewhat inconsistent :-)
The autocorrect in my mind was broken so I read as “documentation”
instead of “decrement”.
I will send v2 soon.
Thanks again!
Nadav
Powered by blists - more mailing lists