Re: [PATCH v3 1/3] drivers/char/mem: eliminate unnecessary use of success_hook
From: Greg Kroah-Hartman
Date: Wed Jun 03 2026 - 12:32:13 EST
On Tue, Jun 02, 2026 at 12:06:25PM +0100, 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>
> Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Acked-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>