A high-performance unikernel virtual machine communication method and device based on vmfunc
Patent Information
- Application Number
- CN202311230216.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2043-09-22
AI Technical Summary
在传统通信方法中,数据需要进行多次拷贝和格式转换,这会消耗大量的CPU时间和内存带宽
[0032] The high-performance Unikernel virtual machine communication method based on vmfunc provided by this invention realizes the switching of memory views between different Unikernel virtual machines by the CPU through the vmfunc instruction, and performs data transfer and reorganization in different memory views through the CPU general-purpose registers. It also innovatively uses the vmfunc instruction to perform concurrent control of data transmission between multiple Unikernel virtual machines.
Smart Images

Figure CN117478625B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of cloud computing technology, and specifically relates to a high-performance Unikernel virtual machine communication method and device based on vmfunc. Background Technology
[0002] Serverless computing has become an increasingly popular development paradigm. It allows users to focus solely on developing their applications while relying on cloud service providers to manage the underlying operating system and hardware infrastructure. The typical cost to the user is only in handling incoming requests and designing functional containers to implement FaaS (Function as a Service). This is particularly advantageous for intermittent business scenarios as it significantly reduces the cost of renting computing resources. As a next-generation virtual machine technology, Unikernel (a single-address-space operating system) generates a virtual machine image with a single address space, retaining only the kernel modules required by the application. Therefore, Unikernel avoids unnecessary instruction cycles and state switching overhead. Furthermore, it is suitable for lightweight, high-performance, and secure applications in serverless environments.
[0003] Current optimization efforts for Unikernel in serverless scenarios mainly focus on saving memory during cold starts and accelerating communication (Cadden J, Unger T, Awad Y, et al. SEUSS: skip redundant paths to make serverless fast [C] / / Proceedings of the Fifteenth European Conference on Computer Systems. 2020: 1-15.). Existing methods consider accelerating inter-instance communication of Unikernel based on vmfunc (a CPU virtualization instruction) (Tan B, Liu H, Rao J, et al. Towards lightweight serverless computing via unikernel as a function [C] / / 2020IEEE / ACM 28th International Symposium on Quality of Service (IWQoS). IEEE, 2020: 1-10.), and propose a session-function (sf) architecture, where a function is a Unikernel specifically designed to perform a function, and the session acts as a remote call to the function Unikernel. The session functionality switches memory to the memory space of the unikernel function via `vmfunc` and returns until execution is complete. It assumes that existing microservices have many overlapping business functions, and multiple sessions can reduce instance startup by reusing these unikernel functions. Furthermore, by leveraging virtual machine features like `vmfunc` to avoid VM exits, communication efficiency far surpasses RPC. However, this method cannot support large data transfers, thus it cannot execute function calls requiring large data parameters.
[0004] Therefore, the following problems currently exist in inter-unikernel communication:
[0005] (1) Currently, communication between Unikernels mostly uses traditional network communication methods, which introduces high overhead and latency. In traditional communication methods, data needs to be copied and converted multiple times, which consumes a lot of CPU time and memory bandwidth.
[0006] (2) As a lightweight operating system, Unikernel has very limited I / O capabilities, and it is prone to crashing when faced with large amounts of data transmission through traditional network communication methods.
[0007] (3) The existing technology of using the vmfunc instruction to communicate between Unikernels can only support the transmission of small data and cannot execute certain function calls that require large data parameters. Summary of the Invention
[0008] The purpose of this invention is to provide a high-performance Unikernel virtual machine communication method and device based on vmfunc, which can effectively reduce the high overhead and communication latency caused by Unikernel network communication and realize the efficient transmission of large amounts of data between Unikernels.
[0009] This invention provides the following technical solution:
[0010] A high-performance Unikernel virtual machine communication method based on vmfunc, characterized in that the method includes the following steps:
[0011] (1) Build the Unikernel virtual machine, including uk1 and uk2, start and initialize the Unikernel virtual machine, and allocate EPTP Index (Extended Page Table Pointer Index) to the Unikernel virtual machine;
[0012] (2) uk2 starts listening for connection requests. uk1 sends a connection request to uk2. uk2 receives the connection request from uk1 and clears the connection information. Both parties then enter the data transmission phase.
[0013] (3) uk1 divides the data d to be transmitted into n blocks and prepares memory pointers;
[0014] (4) uk1 loads the first block of the data to be transferred d into the CPU's general-purpose registers, uses the vmfunc instruction to jump to the memory view to uk2, and moves the values of the general-purpose registers to uk2 respectively; repeat this process to move n blocks to uk2; and complete one transfer.
[0015] (5) Repeat steps (2)-(4) to transmit the next data.
[0016] Furthermore, in step (1), the method for constructing Unikernel virtual machines uk1 and uk2 is as follows: Lib-vmfunc is added to Unikernel for construction. Lib-vmfunc provides an array of fixed physical addresses for each Unikernel, including a data receive buffer array and a connection pool array.
[0017] Further, in step (1), the Unikernel virtual machine is started by launching the corresponding virtual machine image; the method for initializing and allocating an EPTP Index to the Unikernel virtual machine is as follows:
[0018] (1-1) Create a global extended page table pointer array for KVM (Kernel-based Virtual Machine). KVM will write the starting address of the EPTP List and the index of the first 0 value in the EPTP List, EPTPIndex, into the Unikernel virtual machine.
[0019] (1-2) Write the EPTP Index value in the Unikernel virtual machine into the eax register, and then resume the operation inside the Unikernel virtual machine;
[0020] (1-3) After the Unikernel virtual machine resumes internal operation, it reads the value of the eax register, thereby obtaining its own EPTP Index value inside the Unikernel virtual machine.
[0021] Furthermore, in step (2), the method by which both parties enter the data transmission phase is as follows:
[0022] (2-1) In the Unikernel virtual machine, all the values in the connection pool array are 0. uk2 polls the values in the connection pool array in a loop and waits for a certain value to become non-zero.
[0023] (2-2) The EPTP Index value of uk1 itself is eid1. After uk1 obtains the EPTP Index value eid2 of uk2, it uses the vmfunc instruction to switch its own memory view to uk2, and modifies the value of the item with index eid1 in the connection pool array of uk2 to a non-zero value. Then, it uses vmfunc to switch back to its own memory view, listens to the item with index eid1 in its own connection pool array, and waits for the item to become a non-zero value.
[0024] (2-3) After uk2 finds that the item at index eid1 in its own connection pool array has been modified to a non-zero value, it breaks the listening loop and modifies the value back to 0. It then uses the vmfunc instruction to switch its memory view to uk1 and modifies the item at index eid1 in uk1's connection pool array to a non-zero value.
[0025] (2-4) After uk1 queries its own connection pool array and finds that the item with index eid1 has been modified to a non-zero value, it breaks the listening loop and modifies the value back to 0. Then uk1 and uk2 enter the data transmission phase.
[0026] Furthermore, in step (3), uk1 divides the data to be transmitted d into n blocks of 64 bytes each.
[0027] Furthermore, in step (3), when uk1 prepares the data d to be transmitted, a flag of type int is added to the end of the data d to be transmitted.
[0028] Further, in step (3), uk1 prepares two untyped memory pointers p1 and p2, p1 pointing to the first address of the data receiving buffer array and p2 pointing to the first address of the data d to be transmitted.
[0029] Further, in step (4), uk1 loads the first block of the data to be transferred d into one of the eight general-purpose registers of the CPU, uses the vmfunc instruction to jump the memory view to uk2, and moves the values of the eight general-purpose registers to uk2 respectively; in this way, n blocks of 64 bytes each are moved to uk2.
[0030] The present invention also provides a high-performance Unikernel virtual machine communication device based on vmfunc, including a memory and one or more processors, wherein the memory stores executable code, and wherein the one or more processors execute the executable code to implement the above-mentioned high-performance Unikernel virtual machine communication method based on vmfunc.
[0031] The present invention also provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, is used to implement the above-described high-performance Unikernel virtual machine communication method based on vmfunc.
[0032] The high-performance Unikernel virtual machine communication method based on vmfunc provided by this invention realizes the switching of memory views between different Unikernel virtual machines by the CPU through the vmfunc instruction, and performs data transfer and reorganization in different memory views through the CPU general-purpose registers. It also innovatively uses the vmfunc instruction to perform concurrent control of data transmission between multiple Unikernel virtual machines.
[0033] Compared with the prior art, the method and apparatus provided by the present invention have the following superior effects:
[0034] This invention, based on VMFunc technology, designs a high-performance data transmission protocol for the Unikernel virtual machine. By performing communication operations directly at the processor level, it bypasses the multiple data copies and format conversions of traditional communication, reducing CPU time and memory bandwidth consumption, thereby reducing communication overhead and latency. Therefore, this invention can effectively solve the high overhead and high latency problems introduced by traditional network communication in Unikernel.
[0035] The high-performance data transmission protocol of this invention communicates at the CPU hardware level, making full use of the processor's performance and resources, avoiding the I / O limitations of the Unikernel, achieving efficient large-scale data transmission, and improving data transmission performance; thus, it can effectively solve the problem of the Unikernel's limited I / O capabilities and its tendency to crash.
[0036] This invention leverages the fast memory switching functionality between virtual machines provided by vmfunc, using CPU registers to move and reorganize specific variables between Unikernels. It supports the transmission of large amounts of data and the execution of function calls requiring large data parameters, overcoming the limitation of existing Unikernel-based vmfunc-based inter-instance communication acceleration methods that cannot handle large data transfers, thus making the communication method more flexible and comprehensive. Attached Figure Description
[0037] Figure 1 This is a flowchart illustrating a high-performance Unikernel virtual machine communication method based on vmfunc, provided as an embodiment of the present invention. Detailed Implementation
[0038] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0039] It should be noted that, unless otherwise specified, the features in the following embodiments and implementation methods can be combined with each other.
[0040] like Figure 1 As shown, the high-performance Unikernel virtual machine communication method based on vmfunc provided in this embodiment includes:
[0041] Step 1: Build several specific Unikernel virtual machines, start and initialize the Unikernel virtual machines, and allocate EPTP Indexes to the Unikernel virtual machines.
[0042] In this embodiment, the Unikernel virtual machine includes uk1 and uk2, and the communication method between these two virtual machines, uk1 and uk2, will be used as an example for illustration.
[0043] In this embodiment, QEMU is used to start uk1 and uk2, and KVM initializes the EPTP List and assigns EPTP Indexes to uk1 and uk2. Specifically, the following steps are included:
[0044] Step 1-1: Unikernel virtual machines uk1 and uk2 need to add Lib-vmfunc to Unikernel for construction. Lib-vmfunc provides each Unikernel with an array of fixed physical addresses: a data receive buffer and a connection pool. It also provides a complete set of Unikernel communication protocols based on vmfunc. The specific operation of this communication protocol will be explained in detail in Steps 2, 3 and 4 below.
[0045] Steps 1-2: After the Unikernel virtual machine is built, use QEMU to start the corresponding virtual machine image. This will enter the KVM virtual machine initialization phase. During the virtual machine initialization phase, the method described in this invention will create a global Extended Page Table Pointer Array (EPTP List) for KVM. Whenever a Unikernel virtual machine is created, KVM will write the starting address of the EPTP List into the EPTP_List field of the virtual machine's vmcs structure, and find the first index of 0 in the EPTP List, the EPTP Index, and write its index into the EPTP_Index field of the virtual machine's vmcs structure.
[0046] Steps 1-3: After the Unikernel virtual machine finishes booting, its main function performs an I / O operation on port 0xe123, causing the VM to exit and enter the io_handler function in KVM. The method described in this invention adds a function to io_handler: when the virtual machine performs an I / O operation on port 0xe123, io_handler captures the information, writes the virtual machine's EPTP Index value into the eax register, and then resumes operation within the virtual machine.
[0047] Steps 1-4: After the virtual machine resumes internal operation, it reads the value of the eax register to obtain its own EPTP Index value inside the virtual machine.
[0048] Step 2: uk2 starts listening for connection requests. uk1 sends a connection request to uk2. uk2 receives the connection request from uk1 and clears the connection information. Both parties then enter the data transmission phase.
[0049] The specific method is as follows:
[0050] Step 2-1: Initially, all values in the connections array in the Unikernel virtual machine are 0. uk2 performs an infinite loop to listen to the values of the array items in connections, waiting for a certain value to become non-zero.
[0051] Step 2-2: uk1's own EPTP Index value is eid1. After uk1 obtains uk2's EPTP Index value eid2, it uses the vmfunc command to switch its memory view to uk2, modifies the value of the item with index eid1 in uk2's connections array to a non-zero value, and then uses vmfunc again to switch back to its own memory view, listens to the item with index eid1 in its own connections array, and waits for the item to become a non-zero value.
[0052] Steps 2-3: After uk2 finds that the item at index eid1 in its own connections array has been modified to a non-zero value, it breaks the listening loop and modifies the value back to 0. Then, it uses the vmfunc instruction to switch its memory view to uk1 and modifies the item at index eid1 in uk1's connections array to a non-zero value.
[0053] Steps 2-4: After uk1 checks its own connections array and finds that the item at index eid1 has been modified to a non-zero value, it breaks the listening loop and modifies the value back to 0. Then uk1 and uk2 enter the data transmission phase.
[0054] Step 3: uk1 divides the data d to be transmitted into n blocks and prepares the memory pointers.
[0055] In this embodiment, uk1 divides the data d into n blocks of size 64 bytes each (n is sizeof(d) / 64 rounded up).
[0056] In this embodiment, uk1 prepares the data d to be transmitted and adds a flag of type int to the end of the data d.
[0057] Specifically, the memory pointers are as follows: uk1 prepares two untyped memory pointers p1 and p2, p1 points to the first address of the buffer array, and p2 points to the first address of the data d to be transferred.
[0058] Step 4: uk1 loads the first block of the data to be transferred, d, into the CPU's general-purpose registers. Then, using the vmfunc instruction, it jumps to the memory view of uk2 and moves the values of the general-purpose registers to uk2. This process is repeated until all n blocks are moved to uk2, completing one transfer.
[0059] In this embodiment, the specific steps are as follows: the first 64 bytes are loaded into eight general-purpose registers of the CPU, the vmfunc instruction is used to jump the memory view to uk2, and the values of the eight general-purpose registers are moved to the pre-prepared buffer array uk2. This process is repeated until n 64-byte blocks have been moved to the corresponding positions in the uk2 buffer array.
[0060] For a specific example, eight bytes at memory offsets of 0, 8, 16, 24, 32, 40, 48, and 56 bytes starting from p2 are stored in the CPU's rdi, rsi, rdx, r8, r9, r10, r11, and r12 registers, respectively, and the address value of p2 is incremented by 64 bytes. uk1 uses the vmfunc instruction to switch its memory view to uk2 and moves the aforementioned eight CPU registers to the eight memory addresses at offsets of 0, 8, 16, 24, 32, 40, 48, and 56 bytes starting from p1. This process is repeated n times, resulting in a complete and efficient transfer of data between the two Unikernel virtual machines.
[0061] Step 5: To proceed with the next data transfer, start from step 2.
[0062] This invention also provides a high-performance Unikernel virtual machine communication device based on vmfunc, including one or more processors. Executable code is stored in the memory. When the processor executes the executable code, it implements the high-performance Unikernel virtual machine communication method based on vmfunc described in the above embodiments. Taking software implementation as an example, as a logical device, it is formed by the processor of any data processing device that it resides in reading the corresponding computer program instructions from non-volatile memory into memory for execution. From a hardware perspective, in addition to the processor, memory, network interface, and non-volatile memory, the data processing device in the embodiments typically includes other hardware depending on the actual function of that data processing device, which will not be elaborated further.
[0063] This invention also provides a computer-readable storage medium storing a program that, when executed by a processor, implements the high-performance Unikernel virtual machine communication method with vmfunc described in the above embodiments. The computer-readable storage medium can be an internal storage unit of any data-processing device as described in any of the foregoing embodiments, such as a hard disk or memory. The computer-readable storage medium can also be any data-processing device, such as a plug-in hard disk, Smart Media Card (SMC), SD card, or Flash8Card equipped on the device. Furthermore, the computer-readable storage medium can include both internal storage units of any data-processing device and external storage devices. The computer-readable storage medium is used to store the computer program and other programs and data required by the data-processing device, and can also be used to temporarily store data that has been output or will be output.
[0064] The above description is merely an embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the present invention should be included within the scope of the claims of the present invention.
Claims
1. A high-performance Unikernel virtual machine communication method based on vmfunc, characterized in that, The method includes the following steps: (1) Build the Unikernel virtual machine, including uk1 and uk2, start and initialize the Unikernel virtual machine, and allocate EPTP Index to the Unikernel virtual machine; (2) uk2 starts listening for connection requests. uk1 sends a connection request to uk2. uk2 receives the connection request from uk1 and clears the connection information. Both parties then enter the data transmission phase. (3) uk1 divides the data d to be transmitted into n blocks and prepares memory pointers; (4) uk1 loads the first block of the data to be transferred d into the CPU's general-purpose registers, uses the vmfunc instruction to jump the memory view to uk2, and moves the values of the general-purpose registers to uk2 respectively; repeat this process to move n blocks to uk2; and complete one transfer. Repeat steps (2)-(4) to transmit the next data; In step (1), the method for constructing Unikernel virtual machines uk1 and uk2 is as follows: Lib-vmfunc is added to Unikernel for construction. Lib-vmfunc provides an array of fixed physical addresses for each Unikernel, including an array of data receive buffers and an array of connection pools. In step (1), the Unikernel virtual machine is started by launching the corresponding virtual machine image; the method for initializing and allocating an EPTP Index to the Unikernel virtual machine is as follows: KVM creates a global array of extended page table pointers. KVM writes the starting address of the EPTP List and the index of the first 0 value in the EPTP List, the EPTP Index, into the Unikernel virtual machine. Write the EPTP Index value from the Unikernel virtual machine into the eax register, and then resume operation inside the Unikernel virtual machine; After the Unikernel virtual machine resumes its internal operation, it reads the value of the eax register, thereby obtaining its own EPTP Index value inside the Unikernel virtual machine. In step (2), the method by which both parties enter the data transmission phase is as follows: (2-1) In the Unikernel virtual machine, all the values in the connection pool array are 0. uk2 polls the values in the connection pool array in a loop and waits for a certain value to become non-zero. (2-2) The EPTP Index value of uk1 itself is eid1. After uk1 obtains the EPTP Index value eid2 of uk2, it uses the vmfunc instruction to switch its own memory view to uk2, and modifies the value of the item with index eid1 in the connection pool array of uk2 to a non-zero value. Then, it uses vmfunc to switch back to its own memory view, listens to the item with index eid1 in its own connection pool array, and waits for the item to become a non-zero value. (2-3) After uk2 finds that the item at index eid1 in its own connection pool array has been modified to a non-zero value, it breaks the listening loop and modifies the value back to 0. It then uses the vmfunc instruction to switch its memory view to uk1 and modifies the item at index eid1 in uk1's connection pool array to a non-zero value. (2-4) After uk1 queries its own connection pool array and finds that the item with index eid1 has been modified to a non-zero value, it breaks the listening loop and modifies the value back to 0. Then uk1 and uk2 enter the data transmission phase.
2. The high-performance Unikernel virtual machine communication method based on vmfunc according to claim 1, characterized in that, In step (3), uk1 divides the data to be transmitted d into n blocks of 64 bytes each.
3. The high-performance Unikernel virtual machine communication method based on vmfunc according to claim 1, characterized in that, In step (3), when uk1 prepares the data d to be transmitted, a flag of type int is added to the end of the data d to be transmitted.
4. The high-performance Unikernel virtual machine communication method based on vmfunc according to claim 1, characterized in that, In step (3), uk1 prepares two untyped memory pointers p1 and p2, p1 pointing to the first address of the data receiving buffer array and p2 pointing to the first address of the data d to be transmitted.
5. The high-performance Unikernel virtual machine communication method based on vmfunc according to claim 2, characterized in that, In step (4), uk1 loads the first block of the data to be transferred d into eight general-purpose registers of the CPU, uses the vmfunc instruction to jump the memory view to uk2, and moves the values of the eight general-purpose registers to uk2 respectively; in this way, n blocks of 64 bytes each are moved to uk2.
6. A high-performance Unikernel virtual machine communication device based on vmfunc, comprising a memory and one or more processors, wherein the memory stores executable code, characterized in that, When the one or more processors execute the executable code, they are used to implement the high-performance Unikernel virtual machine communication method based on vmfunc as described in any one of claims 1-5.
7. A computer-readable storage medium having a program stored thereon, characterized in that, When executed by the processor, this program is used to implement the high-performance Unikernel virtual machine communication method based on vmfunc as described in any one of claims 1-5.