Re: [PATCH 2/2] mm/mprotect: do not flush on permission promotion

From: David Hildenbrand
Date: Thu Oct 07 2021 - 08:13:22 EST


On 25.09.21 22:54, Nadav Amit wrote:
From: Nadav Amit <namit@xxxxxxxxxx>

Currently, using mprotect() to unprotect a memory region or uffd to
unprotect a memory region causes a TLB flush. At least on x86, as
protection is promoted, no TLB flush is needed.

Add an arch-specific pte_may_need_flush() which tells whether a TLB
flush is needed based on the old PTE and the new one. Implement an x86
pte_may_need_flush().

For x86, PTE protection promotion or changes of software bits does
require a flush, also add logic that considers the dirty-bit. Changes to
the access-bit do not trigger a TLB flush, although architecturally they
should, as Linux considers the access-bit as a hint.

Is the added LOC worth the benefit? IOW, do we have some benchmark that really benefits from that?


--
Thanks,

David / dhildenb