Free memory page hinting by virtual machines
Systems and methods for free memory hinting by virtual machines. An example method comprises: identifying, by a virtual machine running on a host computer system, a first memory page referenced by a free memory list maintained by the virtual machine; identifying a second memory page residing in a hinting buffer associated with the virtual machine; moving the second memory page to the free memory list; disassociating the first memory page from the free memory list; and notifying the host computer system of an identifier of the first memory page.
1. A method comprising:
identifying, by a virtual machine running on a host computer system, a first memory page referenced by a free memory list maintained by the virtual machine;
identifying a second memory page residing in a hinting buffer associated with the virtual machine;
performing an atomic operation to move the second memory page to the free memory list and disassociate the first memory page from the free memory list; and
notifying the host computer system of an identifier of the first memory page.
2. The method of claim 1 , wherein notifying the host computer system of the identifier of the first memory page causes the host computer system to reuse, without copying the first memory page to a persistent storage, a physical memory page that is allocated to the first memory page.
3. The method of claim 1 , further comprising:
responsive to receiving a completion notification from the host computer system, moving the first memory page to the hinting buffer.
4. The method of claim 1 , further comprising:
responsive to receiving a notification from the host computer system, moving the second memory page to the hinting buffer.
5. The method of claim 1 , further comprising:
allocating, by a balloon memory driver of the virtual machine, a plurality of memory pages to the hinting buffer.
6. The method of claim 1 , wherein moving the second memory page to the free memory list is performed responsive to evaluating a memory pressure metric.
7. A system comprising:
a memory; and
a processing device operatively coupled to the memory, the processing device to:
identify a first memory page referenced by a free memory list maintained by a virtual machine;
identify a second memory page residing in a hinting buffer associated with the virtual machine;
perform an atomic operation to move the second memory page to the free memory list and disassociate the first memory page from the free memory list; and
notify a hypervisor of an identifier of the first memory page.
8. The system of claim 7 , wherein notifying the hypervisor of the identifier of the first memory page causes the hypervisor to reuse, without copying the first memory page to a persistent storage, a physical memory page that is allocated to the first memory page.
9. The system of claim 7 , wherein the processing device is further to:
responsive to receiving a completion notification from the hypervisor, move the first memory page to the hinting buffer.
10. The system of claim 7 , wherein the processing device is further to:
responsive to receiving a notification from the hypervisor, move the second memory page to the hinting buffer.
11. The system of claim 7 , wherein the processing device is further to:
allocate, by a balloon memory driver of the virtual machine, a plurality of memory pages to the hinting buffer.
12. The system of claim 7 , wherein moving the second memory page to the free memory list is performed responsive to evaluating a memory pressure metric.
13. A non-transitory machine-readable storage medium storing executable instructions that, when executed by a processing device, cause the processing device to:
identify, by a virtual machine, a first memory page referenced by a free memory list maintained by the virtual machine;
identifying a second memory page residing in a hinting buffer associated with the virtual machine;
perform an atomic operation to move the second memory page to the free memory list and disassociate the first memory page from the free memory list; and
notifying a hypervisor of an identifier of the first memory page.
14. The non-transitory machine-readable storage medium of claim 13 , wherein notifying the hypervisor of the identifier of the first memory page causes the hypervisor to reuse, without copying the first memory page to a persistent storage, a physical memory page that is allocated to the first memory page.
15. The non-transitory machine-readable storage medium of claim 13 , further comprising executable instructions that, when executed by the processing device, cause the processing device to:
responsive to receiving a completion notification from the hypervisor, move the first memory page to the hinting buffer.
16. The non-transitory machine-readable storage medium of claim 13 , further comprising executable instructions that, when executed by the processing device, cause the processing device to:
responsive to receiving a notification from the hypervisor, move the second memory page to the hinting buffer.
17. The non-transitory machine-readable storage medium of claim 13 , further comprising executable instructions that, when executed by the processing device, cause the processing device to:
allocate, by a balloon memory driver of the virtual machine, a plurality of memory pages to the hinting buffer.
18. The non-transitory machine-readable storage medium of claim 13 , wherein moving the second memory page to the free memory list is performed responsive to evaluating a memory pressure metric.