Re: [PATCH v4 3/4] mm: Optimize mprotect() by PTE-batching

From: David Hildenbrand
Date: Thu Jul 03 2025 - 09:00:09 EST


On 02.07.25 17:22, Lorenzo Stoakes wrote:
On Wed, Jul 02, 2025 at 08:33:39PM +0530, Dev Jain wrote:

On 02/07/25 4:02 pm, Lorenzo Stoakes wrote:
On Tue, Jul 01, 2025 at 02:40:14PM +0100, Lorenzo Stoakes wrote:
Let me fiddle with this code and see if I can suggest something sensible.
OK this is _even more fiddly_ than I thought.

Dev - feel free to do a respin (once David's stuff's landed in mm-new, which I
think maybe it has now?), and we can maybe discuss a v6 with everything else in
place if this is still problematic.

Ryan mentioned an iterator solution, which actually now seems sensible here, if
fiddly. Please do try to attack that in v5 to see if something's workable there.

Why are computers so complicated...

Sure! I'll be out next week so the mm list can take a breather from my patches : )
My brain exploded trying to understand your and Ryan's implementation conversation,
will read it all and try to come up with something nice.


No worries, it's actually genuinely annoyingly tricky this... :) we may need a
few more iterations to get there.

Really the underlying issue (other than inherent complexity) is the poor
mprotect implementation in the first instance that makes the complexity here
less easy to integrate.


I haven't really scanned all the discussions yet, just something to keep in mind:

In the common case, all PAE values will match. This is the case to optimize for.

Having some PAE values not match is the corner case, that can be left suboptimal if it makes the code nicer.

--
Cheers,

David / dhildenb