Re: [PATCH v2 1/3] drivers/char/mem: eliminate unnecessary use of success_hook

From: David Hildenbrand (Arm)

Date: Mon Jun 01 2026 - 11:19:26 EST


On 5/22/26 18:00, Lorenzo Stoakes wrote:
> /dev/zero, uniquely, marks memory mapped there as anonymous. This is
> currently achieved using the mmap_action->success_hook.
>
> However this hook circumvents the abstraction of VMA initialisation so it's
> preferable to do things a different way.
>
> To achieve this, this patch firstly defaults the VMA descriptor's vm_ops
> field to the dummy VMA operations, which is what file-backed VMAs default
> this field to.
>
> That way, we can detect whether a driver sets this field to NULL in order
> to mark it anonymous.
>
> We then introduce vma_desc_set_anonymous() to do this explicitly, and
> invoke it in mmap_zero_prepare().
>
> This way, any driver which does not explicitly set desc->vm_ops, retains
> the dummy vm_ops as they would previously.
>
> We also update set_vma_user_defined_fields() to make clear that we are
> either setting vma->vm_ops to what is provided by the driver (or defaulting
> to dummy_vm_ops if not set), or setting the VMA anonymous.
>
> This lays the groundwork for removing the success hook.
>
> Signed-off-by: Lorenzo Stoakes <ljs@xxxxxxxxxx>
> ---

Looks good

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David