Re: [PATCH v3] mm/mprotect: try avoiding write faults for exclusive anonymous pages when changing protection

From: Peter Xu
Date: Wed Jun 15 2022 - 16:17:02 EST


On Wed, Jun 15, 2022 at 09:52:11PM +0200, David Hildenbrand wrote:
> write unprotection is a change from RO->RW, so I don't immediately see
> the difference.

In my view "unprotect a pte" is only a subset of "grant pte write
permission", since: "unprotect" has a prerequisite that it used to be
"protected" so that's why we can unprotect. Aka, in mm term that's only
when VM_WRITE set.

So basically it is a hint that we're only working on VM_WRITE regions,
where I thought "unprotect" was slightly better.

>
> Anyhow, I don't like the sounding of TRY_WRITE_UNPROTECT.
>
> I made it match the function name that I had:
>
> MM_CP_TRY_CHANGE_WRITABLE
> -> !pte_write()?
> -> can_change_pte_writable() ?
> ->pte_mkwrite()
>
> Maybe MM_CP_TRY_MAKE_WRITABLE / MM_CP_TRY_MAKE_PTE_WRITABLE is clearer?
>
> Open for suggestions because I'm apparently not the bast at naming
> things either.

Me neither. I don't have a strong opinion anyway, and frankly indeed the
old naming is not great either to me. Maybe there's better thoughts.

Thanks,

--
Peter Xu