[RFC v1 0/3] udmabuf: Replace pages when there is FALLOC_FL_PUNCH_HOLE in memfd

Vivek Kasireddy
2023-07-18T08:50:32Z

This patch series attempts to solve the coherency problem seen when
a hole is punched in the region(s) of the mapping (associated with
the memfd) that overlaps with pages registered with a udmabuf fd.

The first patch introduces a new mmu notifier to let drivers know
when a new page is faulted into a mapping (backed by shmem or
hugetlbfs). The second patch updates the udmabuf driver to
register a handler for receiving mapping updates in order to
update its list with new pages. The last patch adds two new tests
to the udmabuf selftest to test the huge page support and also
FALLOC_FL_PUNCH_HOLE.

Cc: David Hildenbrand <david@redhat.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Dongwon Kim <dongwon.kim@intel.com>
Cc: Junxiao Chang <junxiao.chang@intel.com>

Vivek Kasireddy (3):
mm/mmu_notifier: Add a new notifier for mapping updates (new pages)
udmabuf: Replace pages when there is FALLOC_FL_PUNCH_HOLE in memfd
selftests/dma-buf/udmabuf: Add tests for huge pages and
FALLOC_FL_PUNCH_HOLE

drivers/dma-buf/udmabuf.c | 172 ++++++++++++++++++
include/linux/mmu_notifier.h | 27 +++
mm/hugetlb.c | 9 +-
mm/mmu_notifier.c | 17 ++
mm/shmem.c | 7 +-
.../selftests/drivers/dma-buf/udmabuf.c | 165 ++++++++++++++++-
6 files changed, 391 insertions(+), 6 deletions(-)

--
2.39.2