Turn private hugetlb mapping into VM_SHARED
heep
0x60 at pm.me
Sun Jul 12 16:38:46 EDT 2020
Hello, list,
I am working on a tool to introspect live memory of KVM machines, and mmapping its memory, instead of calling process_vm_readv on every read, would increase its performance significantly. Understandably, almost all virtual machine monitors (like QEMU) create private mappings for the memory. So, trying to understand the memory managment subsystem I am hoping to write a kernel module to do the remappings, and conversion from private, to shared mappings.
My current focus is on hugetlb pages. At first, I remapped the pages using remap_pfn_range, but there is a memory safety risk when the VM shuts off, and that memory gets used elsewhere. Now, I am trying to turn the underlying mapping into a shared one, so that the kernel can keep track of the memory used. What would be the best way to do so?
I noticed there is resv_map that stores represented mappings, and while on private mappings it's on vma, on the shared ones - it is in the inode, but making the inode point to the VMAs map leads to a bus error in userspace. I must be missing some key pieces.
Does anyone know how to best achieve what I am trying to? Or is it something fundamentally wrong to do?
Many thanks,
Auri B.
More information about the Kernelnewbies
mailing list