Skip to content

RFC EMM Notifier V3

Christoph Lameter kvm linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest10 patches 12 repliesIn review

V2->V3 from the cover letter

- Fix rcu issues
- Fix emm_referenced handling
- Use Andrea's mm_lock/unlock to prevent registration races.
- Keep simple API since there does not seem to be a need to add additional callbacks (mm_lock does not require callbacks like emm_start/stop that I envisioned).
- Reduce CC list (the volume we are producing here must be annoying...).

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10emm: mm_lock: Lock a process against reclaiminclude/linux/mm.h mm/mmap.c+76 -05 replies
2/10emm: notifier logicinclude/linux/mm_types.h include/linux/rmap.h kernel/fork.c +9 more+212 -107 replies
3/10emm: Move tlb flushing into free_pgtablesinclude/linux/mm.h mm/memory.c mm/mmap.c+15 -90 replies
4/10emm: Convert i_mmap_lock to i_mmap_semarch/x86/mm/hugetlbpage.c fs/hugetlbfs/inode.c fs/inode.c +12 more+66 -780 replies
5/10emm: Remove tlb pointer from the parameters of unmap vmasinclude/linux/mm.h mm/memory.c mm/mmap.c+21 -430 replies
6/10emm: Convert anon_vma lock to rw_sem and refcountinclude/linux/rmap.h mm/migrate.c mm/mmap.c +1 more+73 -540 replies
7/10xpmem: This patch exports zap_page_range as it is needed by XPMEM.mm/memory.c+1 -00 replies
8/10xpmem: Locking rules for taking multiple mmap_sem locks.mm/filemap.c+3 -00 replies
9/10xpmem: The device driverdrivers/misc/Makefile drivers/misc/xp/Makefile drivers/misc/xp/xpmem.h +7 more+4395 -00 replies
10/10xpmem: Simple examplexpmem_test/A1.c xpmem_test/A2.c xpmem_test/Makefile +1 more+278 -00 replies

Reviews trailers per patch

1 of 10 patches has a Reviewed-by or Acked-by.

PatchPaul E. McKenney
1/10
2/10A-b
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [patch 00/10] [RFC] EMM Notifier V3

V2->V3:
- Fix rcu issues
- Fix emm_referenced handling
- Use Andrea's mm_lock/unlock to prevent registration races.
- Keep simple API since there does not seem to be a need to add additional callbacks (mm_lock does not require callbacks like emm_start/stop that I envisioned).
- Reduce CC list (the volume we are producing here must be annoying...).

V1->V2:
- Additional optimizations in the VM
- Convert vm spinlocks to rw sems.
- Add XPMEM driver (requires sleeping in callbacks)
- Add XPMEM example

This patch implements a simple callback for device drivers that establish their own references to pages (KVM, GRU, XPmem, RDMA/Infiniband, DMA engines etc). These references are unknown to the VM (therefore external).

With these callbacks it is possible for the device driver to release external references when the VM requests it. This enables swapping, page migration and allows support of remapping, permission changes etc etc for the externally mapped memory.

With this functionality it becomes also possible to avoid pinning or mlocking pages (commonly done to stop the VM from unmapping device mapped pages).

A device driver must subscribe to a process using

emm_register_notifier(struct emm_notifier *, struct mm_struct *)

The VM will then perform callbacks for operations that unmap or change permissions of pages in that address space. When the process terminates the callback function is called with emm_release.

Callbacks are performed before and after the unmapping action of the VM.

emm_invalidate_start before

emm_invalidate_end after

The device driver must hold off establishing new references to pages in the range specified between a callback with emm_invalidate_start and the subsequent call with emm_invalidate_end set. This allows the VM to ensure that no concurrent driver actions are performed on an address range while performing remapping or unmapping operations.

This patchset contains additional modifications needed to ensure that the callbacks can sleep. For that purpose two key locks in the vm need to be converted to rw_sems. These patches are brand new, invasive and need extensive discussion and evaluation.

The first patch alone may be applied if callbacks in atomic context are sufficient for a device driver (likely the case for KVM and GRU and simple DMA drivers).

Following the VM modifications is the XPMEM device driver that allows sharing of memory between processes running on different instances of Linux. This is also a prototype. It is known to run trivial sample programs included as the last patch.