Re: [PATCH v3 3/9] mm/huge_memory: honor MM_CP_TRY_CHANGE_WRITABLE in change_huge_pud()
From: Carlos López
Date: Sun Nov 15 2026 - 17:00:40 EST
On 11/13/26 7:58 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.
>>
>> However, change_huge_pud() ignores the flag. For example, device DAX
>> mappings are write-notified once soft-dirty tracking is armed through
>> /proc/pid/clear_refs, and a protection change then leaves dirty PUDs
>> read-only, so the next write to each of them faults.
>>
>> Fix this by adding can_change_pud_writable(), based on
>> can_change_pmd_writable(). It omits the NUMA and uffd-wp checks, as
>> change_huge_pud() bails out on those changes.
>
> Again, please keep MM changes to a bare minimum for your work.
>
> If this is not required for your work, please drop it.
It is required. The new flag is not correct without it, as a protection
change that removes no permission bits still write-protects writable
PUDs. I'll explain this better.