Zero copy message reception for applications
Zero copy message reception for guests is disclosed. For example, a host has a memory, a device with access to device memory addresses, a processor, and a supervisor. An application with access to application memory addresses (AMA) executes on the host. An AMA is mapped to a page table entry (PTE). The application shares access to a first page of memory addressed by the AMA with the device to store data received by the device for the first application, where the first page is mapped as a device memory address of the plurality of device memory addresses. The application later sends a request to disconnect from the device. The supervisor is configured to copy contents of the first page to a second page in the memory after receiving the request to disconnect, and then update the PTE to address the second page instead of the first page.
1. A system comprising:
a host with a first device which includes a memory, a different second device with access to a plurality of device memory addresses (DMA), a processor, and a supervisor; and
a first application with access to a plurality of application memory addresses (AMA), including a first AMA mapped to a first page table entry (PTE) in a first page table, wherein the first application is configured to execute on the processor to:
designate a portion of the plurality of AMAs as a receiving buffer;
provide the receiving buffer;
share access to a first page of the memory addressed by the first AMA with the second device to store data received by the second device for the first application, wherein the first page is mapped as a DMA of the plurality of DMAs to provide the receiving buffer for data sent through the second device to the first application; and
later send a request to disconnect from the second device, wherein
responsive to receiving the request to disconnect, the supervisor is configured to update the first PTE to address a second page instead of the first page.
2. The system of claim 1 , wherein the second device is a network interface device.
3. The system of claim 1 , wherein the supervisor is one of a hypervisor or a host operating system.
4. The system of claim 1 , wherein the supervisor assigns the second page to the first application.
5. The system of claim 1 , wherein the first application is suspended after requesting to disconnect from the second device.
6. The system of claim 1 , wherein the second device continues to access the first page after the first PTE is remapped to the second page.
7. The system of claim 1 , wherein the first page is reclaimed by the supervisor, and any remaining data in the first page is discarded.
8. The system of claim 1 , wherein a second application shares a third page of memory with the second device to store data received by the second device for the second application.
9. The system of claim 8 , wherein the second device stores first data directed to the second application to the first page, and the supervisor is further configured to:
copy the first data to the third page; and
after copying the first data, reclaim the first page from the second device, wherein the second device stores second data directed to the second application to the third page.
10. The system of claim 8 , wherein the second device stores first data directed to the second application to the first page which is inaccessible to the second application, and the second device subsequently receives a second copy of the first data which is stored in the third page.
11. The system of claim 10 , wherein the first copy of the first data is handled as a failed transmission.
12. The system of claim 8 , wherein the second application is the first application at a later point in time.
13. The system of claim 1 , wherein the first page is configured as a message queue of the second device.
14. The system of claim 1 , wherein the plurality of DMAs are virtual memory addresses mapped in a IOMMU page table, and an IOMMU manages the second device's access to the memory.
15. The system of claim 1 , wherein the second device accesses contents of the DMA through direct memory access.
16. The system of claim 1 , wherein the second device outputs data to at least one of a network device, a monitor, or a storage device.
17. A method comprising:
designating, by an application, a portion of application memory as a receiving buffer, wherein the application has access to a plurality of application memory addresses (AMA) including a first AMA, which is mapped to a page table entry (PTE) in a page table that addresses a first page of memory;
providing the receiving buffer;
sharing, by the application, access to the first page of memory, which is included in the first device and accessible to the application with the second device, which is different from the first device, to store data received by the second device for the application, to provide the receiving buffer for data sent through the second device to the application;
sending, by the application, a request to disconnect from the second device;
receiving, by a supervisor of a host of the application and the second device, the request to disconnect; and
responsive to receiving the request to disconnect, updating, by the supervisor, the PTE to address the second page instead of the first page.
18. The method of claim 17 , further comprising the second device continuing to access the first page after the PTE is remapped to the second page.
19. The method of claim 17 , further comprising outputting, by the second device, data to at least one of a network device or a monitor.
20. A computer-readable non-transitory storage medium storing executable instructions, which when executed by a computer system, cause the computer system to:
designate, by an application, a portion of application memory as a receiving buffer, wherein the application has access to a plurality of application memory addresses (AMA) including a first AMA, which is mapped to a page table entry (PTE) in a page table that addresses a first page of memory;
provide the receiving buffer;
share, by the application, access to the first page of memory, which is included in the first device and accessible to the application with the second device, which is different from the first device, to store data received by the second device for the application, to provide the receiving buffer for data sent through the second device to the application;
send, by the application, a request to disconnect from the second device;
receive, by a supervisor of a host of the application and the second device, the request to disconnect; and
responsive to receiving the request, update, by the supervisor, the PTE to address the second page instead of the first page.