Kernel Newbies archive on lore.kernel.org
 help / color / Atom feed
* Re: Turn private hugetlb mapping into VM_SHARED
@ 2020-07-14  8:55 heep
  0 siblings, 0 replies; 2+ messages in thread
From: heep @ 2020-07-14  8:55 UTC (permalink / raw)
  To: kernelnewbies

> 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.

It appears I have been mistaken when it came to remap_pfn_range being memory unsafe, I just haven't read get_user_pages_remote documentation attentively enough. Sorry for that, this whole unshared -> shared mapping change is very much not the right thing to do.




_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Turn private hugetlb mapping into VM_SHARED
       [not found] <t05ASlBD6RRi_zSEFljpStRYGL0yt7cmZI0644S9jYhI5TJtsIyNXh0IBgzzvzm-mexlUxSsOjUl54CQyse3DctieDa5pmDxDSCky5tIG0Y=@pm.me>
@ 2020-07-12 20:38 ` heep
  0 siblings, 0 replies; 2+ messages in thread
From: heep @ 2020-07-12 20:38 UTC (permalink / raw)
  To: kernelnewbies

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.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14  8:55 Turn private hugetlb mapping into VM_SHARED heep
     [not found] <t05ASlBD6RRi_zSEFljpStRYGL0yt7cmZI0644S9jYhI5TJtsIyNXh0IBgzzvzm-mexlUxSsOjUl54CQyse3DctieDa5pmDxDSCky5tIG0Y=@pm.me>
2020-07-12 20:38 ` heep

Kernel Newbies archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org
	public-inbox-index kernelnewbies

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git