Re: [PATCH v3 4/9] mm: keep writable entries writable on protection changes

From: David Hildenbrand (Arm)

Date: Thu Nov 26 2026 - 09:11:05 EST


On 11/15/26 22:59, Carlos López wrote:
> On 11/13/26 7:56 PM, David Hildenbrand (Arm) wrote:
>> On 11/12/26 15:20, Carlos López wrote:
>>> change_protection() applies vma->vm_page_prot, which lacks the write bit
>>> for CoW and write-notified mappings. MM_CP_TRY_CHANGE_WRITABLE makes
>>> entries writable again if a write fault would only set the write bit.
>>> In shared mappings, it relies on the dirty bit for this, as a clean
>>> entry might still need a write fault to notify the FS.
>>>
>>> However, this misses clean entries that were already writable. For
>>> example, a uffd-wp unprotect makes shmem PTEs read-only if they were
>>> mapped by a read fault before uffd-wp was registered, so the next write
>>> to each of them faults.
>>
>> See my other reply, adding such optimizations without any motivation why we
>> should even care is not really what we want.
>>
>> Drop it from your series and keep the MM changes to a bare minimum please.
>>
>> Or is there a real dependency for your work?
>>
>
> Yes there is, but I clearly did not explain it properly.
>
> The whole point of the series is to avoid zaps when no permission bits
> are removed by a protection change, e.g. mprotect(PROT_READ |
> PROT_WRITE) on a read-only VMA. My proposal is for change_protection()
> to signal this is the case to MMU notifiers with a new flag. However,
> change_protection() sometimes write-protects entries that were writable,
> which makes the flag wrong, so this patch fixes that.
>
> I'll be sure to explain this properly.

I think there are some weird interactions between things.

I'm swamped with other stuff right now, but once you resend and explain it
better, maybe I can figure out how to do this cleanly.

--
Cheers,

David