Hardware resource access methods, systems, storage media, and program products
By using a virtual machine management system to determine the physical central processing unit for read and write requests and to process hardware resource access in parallel, the problem of low efficiency in hardware resource access in virtualization technology is solved, and more efficient IO request processing is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2026-03-10
AI Technical Summary
In existing virtualization technologies, hardware resource access efficiency is low, especially when there are a large number of concurrent I/O requests, which require switching and scheduling I/O requests across different physical CPUs, resulting in low efficiency.
The virtual machine management system determines the physical central processing unit corresponding to the read/write request, sends the request to the second virtual machine system in parallel, and uses the virtual central processing unit of the second virtual machine system to access hardware resources, ensuring that the processing flow of the same read/write request is carried out on the same physical central processing unit, avoiding switching and waiting for scheduling.
It improves the efficiency of hardware resource access, avoids the time overhead caused by switching tasks or threads on different physical central processing units and waiting for scheduling, and achieves more efficient IO request processing.
Smart Images

Figure CN118484263B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of virtualization technology, and in particular to a hardware resource access method, system, storage medium, and program product. Background Technology
[0002] With the development of virtualization technology, a new revolution has taken place in the automotive electronics ecosystem, which utilizes virtualization to achieve resource sharing and secure isolation. For example, hardware resources such as CPU (Central Processing Unit), memory, GPU (graphics processing unit), and input / output devices can all be shared through virtualization technology.
[0003] The architecture of virtualization technology typically includes a host virtual machine operating system and several guest virtual machine operating systems. These operating systems run on the same hardware devices. Through device virtualization technology, each virtual operating system can share access to the actual hardware resources through virtualized hardware, such as sharing access to GPUs, input / output devices, etc.
[0004] Virtual machine operating systems use VCPUs (Virtual Central Processing Units) to schedule and execute tasks in order to access hardware resources. When there are a large number of concurrent I / O requests, existing technologies usually need to switch and schedule the I / O requests between Host virtual machines and Guest virtual machines on different physical CPUs.
[0005] However, existing technologies suffer from low efficiency when accessing hardware resources during implementation. Summary of the Invention
[0006] This application provides a hardware resource access method, system, storage medium, and program product to improve the efficiency of hardware resource access.
[0007] In a first aspect, embodiments of this application provide a hardware resource access method, applied to a virtual machine management system, the method comprising:
[0008] Obtain multiple read / write requests for accessing hardware resources in the first virtual machine system; the multiple read / write requests are obtained through responses from the first virtual central processing unit contained in the first virtual machine system;
[0009] Based on the first virtual central processing unit corresponding to each of the multiple read and write requests, determine the physical central processing unit matched for each read and write request;
[0010] Based on the physical central processing unit corresponding to each read / write request, each read / write request is sent to the second virtual machine system in parallel; wherein, the first virtual machine system and the second virtual machine system are virtual machine systems created based on the virtual machine management system;
[0011] The second virtual machine system is used to determine the second virtual central processing unit corresponding to each read and write request based on the physical central processing unit corresponding to each read and write request, and to access the hardware resources that match the read and write requests corresponding to each second virtual central processing unit in parallel through each second virtual central processing unit.
[0012] In one possible implementation, after sending each read / write request to the second virtual machine system, the method further includes:
[0013] Obtain the access result information of the hardware resources corresponding to each read and write request sent by the second virtual machine system;
[0014] The access results are returned to the first virtual machine system.
[0015] In one possible implementation, acquiring multiple read / write requests for access to hardware resources in response to a first virtual central processing unit included in a first virtual machine system includes:
[0016] In response to an exit event triggered by the first virtual machine system;
[0017] In the case where the exit event is an event generated based on a read / write request, identify the multiple read / write requests initiated by the first virtual machine system.
[0018] In one possible implementation, based on the physical central processing unit corresponding to each read / write request, the read / write request is sent to the second virtual machine system, including:
[0019] Based on the physical central processing unit corresponding to each read and write request, each read and write request is written in parallel to the cache module jointly associated with the second virtual machine system and the virtual machine management system.
[0020] The second virtual machine system is activated via an uplink call;
[0021] The second virtual machine system is used to wake up the second virtual central processing unit corresponding to each read and write request based on the physical central processing unit corresponding to each read and write request.
[0022] In one possible implementation, there are multiple cache modules; each cache module corresponds to a different physical central processing unit.
[0023] Secondly, embodiments of this application provide a hardware resource access system, which includes a virtual machine management system and a first virtual machine system and a second virtual machine system created based on the virtual machine management system.
[0024] The first virtual machine system is used to respond to multiple read and write requests for access to hardware resources;
[0025] The virtual machine management system is used to determine the physical central processing unit matching each read and write request based on the first virtual central processing unit corresponding to each read and write request; it is also used to send each read and write request to the second virtual machine system based on the physical central processing unit corresponding to each read and write request; the first virtual central processing unit is the virtual central processing unit in the first virtual machine system that responds to the read and write requests.
[0026] The second virtual machine system is used to determine the second virtual central processing unit corresponding to each read and write request based on the physical central processing unit corresponding to each read and write request, and to access the hardware resources that match the read and write requests corresponding to each second virtual central processing unit through each virtual central processing unit.
[0027] In one possible implementation, the second virtual machine system is further configured to generate access result information of the hardware resources corresponding to the read / write request when the second virtual central processing unit completes the access to the hardware resources matched by the read / write request corresponding to the second virtual central processing unit.
[0028] The virtual machine management system is used to receive access result information of hardware resources corresponding to each read and write request, and return each access result information to the first virtual machine system;
[0029] The first virtual machine system is used to return and run the first virtual central processing unit corresponding to each read and write request after receiving the access result information corresponding to each read and write request.
[0030] In one possible implementation, the hardware resource access system further includes a caching module, and the second virtual machine system includes a service module for the virtual machine management system.
[0031] The virtual machine management system is used to write each read and write request to the cache module based on the physical central processing unit corresponding to each read and write request, and activate the second virtual machine system through uplink calls;
[0032] The service module of the virtual machine management system is used to wake up the second virtual central processing unit corresponding to each read and write request based on the physical central processing unit corresponding to each read and write request when the second virtual machine system is activated.
[0033] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor;
[0034] The memory stores the instructions that the computer executes;
[0035] The processor executes computer execution instructions stored in memory, causing the processor to perform the first aspect and / or various possible implementations of the first aspect as described above.
[0036] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the first aspect and / or various possible implementations of the first aspect.
[0037] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the first aspect and / or various possible implementations of the first aspect.
[0038] The hardware resource access method, system, storage medium, and program product provided in this application, through a virtual machine management system, determines the physical central processing unit (PCU) matching each read / write request based on the first virtual central processing unit (PLU) corresponding to multiple read / write requests obtained from a first virtual machine system. A second virtual machine system can then access the hardware resources matching each read / write request in parallel through the second virtual central processing unit determined based on the PCU corresponding to each read / write request. Thus, compared to conventional technologies, this application ensures that for each read / write request initiated by the first virtual machine system, the entire process of processing the same read / write request in both the virtual machine management system and the second virtual machine system occurs on the same physical central processing unit. This allows for concurrent processing of various read / write requests, avoiding the time overhead caused by switching and waiting for scheduling between different physical central processing units, thereby improving the efficiency of hardware resource access. Attached Figure Description
[0039] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0040] Figure 1 A schematic diagram of the hardware resource access system provided in this application;
[0041] Figure 2 Flowchart of the hardware resource access method provided in this application Figure 1 ;
[0042] Figure 3 Flowchart of the hardware resource access method provided in this application Figure 2 ;
[0043] Figure 4 A schematic diagram of the hardware resource access device provided in this application;
[0044] Figure 5 A schematic diagram of the structure of the electronic device provided in this application.
[0045] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0046] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0047] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0048] In existing technologies, virtualization technology has revolutionized the automotive electronics ecosystem, enabling resource sharing and secure isolation. For example, hardware resources such as CPUs (Central Processing Units), memory, GPUs (Graphics Processing Units), and input / output devices can all be shared through virtualization. The architecture of virtualization typically includes a Host virtual machine operating system and several Guest virtual machine operating systems. These operating systems run on the same hardware devices, and device virtualization technology allows each virtual operating system to share access to actual hardware resources, such as GPUs and input / output devices. The virtual machine operating systems use VCPUs (Virtual Central Processing Units) for task scheduling and execution to access hardware resources. However, when there are a large number of concurrent I / O requests, existing technologies typically require switching and scheduling between Host and Guest virtual machines running on different physical CPUs to handle I / O requests, resulting in low efficiency in accessing hardware resources.
[0049] Figure 1 A schematic diagram illustrating a scenario for the hardware resource access method provided in this application, such as... Figure 1 As shown, a specific application scenario of this application can be a hardware resource access system 10, which can be used in an automotive infotainment system. The hardware resource access system 10 includes a first virtual machine system 110, a virtual machine management system 120, and a second virtual machine system 130. The first virtual machine system 110 and the second virtual machine system 130 can be virtual machine operating systems created based on the virtual machine management system 120. The first virtual machine system 110 can be allocated one or more first virtual central processing units (VCPUs), and the second virtual machine system 130 can be allocated one or more second VCPUs. Both the first and second VCPUs can be virtual CPUs (VCPUs) obtained by dividing the processing power of the physical CPU using virtualization software. The first virtual machine system 110 can initiate read / write requests (IO requests), and the second virtual machine system can call backend drivers to perform hardware operations based on the content of the read / write requests.
[0050] The hardware resource access method provided in this application solves the technical problem of low efficiency in accessing hardware resources by means of a technical means that the entire process of the virtual machine management system and the second virtual machine system processing the same read / write request is carried out on the same physical central processing unit.
[0051] The technical solution of this application and how it solves the above-mentioned technical problems will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.
[0052] Figure 2 Flowchart of the hardware resource access method provided in this application Figure 1 This hardware resource access method can be applied to, for example... Figure 1 The virtual machine management system 120 shown is as follows: Figure 2 As shown, the method includes steps S201 to S203. Wherein:
[0053] S201, obtain multiple read / write requests for accessing hardware resources in the first virtual machine system; the multiple read / write requests are obtained through responses from the first virtual central processing unit contained in the first virtual machine system.
[0054] In this context, a virtual machine management system (VMMS) refers to the operating system that creates or runs virtual machines. The VMMS can run as software or a program on physical hardware. The first virtual machine system can be a virtual machine operating system within a virtualization architecture. This VMMS can access real-world hardware resources through virtualization hardware sharing; the first VMMS can refer to the guest VMMS. The first VMMS can also be the VMMS used to initiate I / O requests. The first virtual central processing unit (VCPU) refers to the logical CPU allocated to the first VMMS in the virtual environment. This can be achieved by virtualization software dividing the processing power of the physical CPU into multiple VCPUs; the first VCPU is the VCPU within the first VMMS. Read / write requests refer to I / O requests. Hardware resources refer to the actual physical hardware, such as a physical CPU, physical GPU, input / output devices, etc.
[0055] For example, the VCPU (first virtual central processing unit) included in the first virtual machine system can respond to multiple read / write requests initiated by the user, triggering a VMexit event, causing the first virtual machine system to exit and enter the processing flow of the virtual machine management system. The virtual machine management system can determine the multiple read / write requests initiated by the first virtual machine system and can determine the first virtual central processing unit that initiated each read / write request. Further, the virtual machine management system can determine the physical central processing unit corresponding to the read / write request initiated by the first virtual central processing unit based on the first virtual central processing unit.
[0056] Alternatively, multiple VCPUs can respond to multiple read / write requests separately, or a single VCPU can respond to multiple read / write requests.
[0057] Optionally, when a VMexit event occurs in the first virtual machine system, the virtual machine management system can determine the cause of the VMexit event. If the VMexit event is caused by a read / write request, the process of handling read / write requests can be entered; otherwise, the process of handling VMexit events caused by other reasons is executed, which is unrelated to the process of accessing hardware resources based on read / write requests provided in this embodiment.
[0058] S202, based on the first virtual central processing unit corresponding to each of the multiple read and write requests, determine the physical central processing unit matched for each read and write request.
[0059] The physical central processing unit refers to the actual physical central processing unit, which is a kind of physical hardware resource.
[0060] For example, for each read / write request, the virtual machine management system can determine the physical central processing unit (CPU) corresponding to the read / write request based on the first virtual CPU corresponding to the read / write request. That is, the virtual machine management system can determine on which physical CPU the entire process of processing the read / write request needs to be performed based on the first virtual CPU that initiated the read / write request, ensuring that the process of processing the same read / write request is in the same physical CPU. This way, when the virtual machine management system processes the same read / write request, it does not need to switch and wait for scheduling on different physical CPUs, thereby improving the efficiency of processing read / write requests and thus improving the efficiency of accessing hardware resources.
[0061] S203, based on the physical central processing unit corresponding to each read / write request, each read / write request is sent in parallel to the second virtual machine system; wherein, the first virtual machine system and the second virtual machine system are virtual machine systems created based on the virtual machine management system; the second virtual machine system is used to determine the second virtual central processing unit corresponding to each read / write request based on the physical central processing unit corresponding to each read / write request, and through each virtual central processing unit, access the hardware resources matching the read / write requests corresponding to each second virtual central processing unit in parallel.
[0062] The second virtual machine system can be a virtual machine operating system within the virtualization architecture. It can be a host virtual machine operating system and can be used to call backend drivers to access hardware. As an example, the first virtual machine system is the guest virtual machine operating system, the second virtual machine system is the host virtual machine operating system, and the virtual machine management system is implemented using a hypervisor. Both the guest and host virtual machine operating systems can be created based on the hypervisor.
[0063] The second virtual central processing unit can be a virtual CPU (VCPU) allocated to the second virtual machine system in the virtual environment. Hardware operations can be performed by calling backend drivers through the second virtual central processing unit.
[0064] For example, for each of multiple read / write requests, the virtual machine management system can process the request based on the physical central processing unit (PCU) corresponding to that request. For instance, it can send the read / write request to a second virtual machine system based on the PCU. The second virtual machine system can then determine the corresponding second virtual central processing unit (VCPU) based on the PCU and access the hardware resources matching the read / write request through that VCPU. In other words, it can access hardware by calling the backend driver based on the request content of the read / write request through the corresponding VCPU. This allows for parallel processing of multiple read / write requests when they occur concurrently. The processing flow for the same read / write request is implemented on the same physical CPU, avoiding the time overhead caused by switching between different physical CPUs and waiting for scheduling due to tasks or threads. This improves the efficiency of concurrent I / O request processing under multi-VCPU conditions, thereby increasing the efficiency of accessing hardware resources.
[0065] The hardware resource access method provided in this application involves a virtual machine management system determining the physical central processing unit (PCU) matching each read / write request based on the first virtual central processing unit (PLU) corresponding to multiple read / write requests obtained from a first virtual machine system. A second virtual machine system can then access the hardware resources matching each read / write request through the second virtual central processing unit determined based on the PCU corresponding to each read / write request. Thus, compared to conventional technologies, this application ensures that for each read / write request initiated by the first virtual machine system, the entire process of processing the same read / write request in both the virtual machine management system and the second virtual machine system occurs on the same physical central processing unit. This avoids the time overhead caused by switching and waiting for scheduling between different physical central processing units for tasks or threads, thereby improving the efficiency of hardware resource access.
[0066] Flowchart of the hardware resource access method provided in this application Figure 2 This hardware resource access method can be applied to, for example... Figure 1 The virtual machine management system 120 shown is as follows: Figure 3 As shown, in this embodiment... Figure 2 Based on the embodiments, the hardware resource access method is described in detail, which includes steps S301 to S307, wherein:
[0067] S301, in response to an exit event triggered by the first virtual machine system.
[0068] The exit event can be an event that causes VMexit (virtual machine exit).
[0069] For example, any first virtual central processing unit of a first virtual machine system can generate a VMexit event in response to a read / write request initiated by a user, causing the first virtual machine system to exit. The virtual machine management system can respond to the exit event of the first virtual machine system. Furthermore, the virtual machine management system can determine the reason for the exit response of the first virtual machine system.
[0070] S302, if the exit event is an event generated based on a read / write request, determine the multiple read / write requests initiated by the first virtual machine system.
[0071] For example, the virtual machine management system can determine the cause of the exit event. If the exit event is a VMexit event caused by a read / write request, the virtual machine management system can process the read / write request flow and obtain multiple read / write requests initiated by the first virtual machine system. Furthermore, for the same read / write request, the entire process of processing the read / write request is performed on the same physical central processing unit.
[0072] Optionally, if a VMexit event occurs in the first virtual machine system, the first virtual machine system exits and enters the processing flow of the virtual machine management system. The virtual machine management system can determine the cause of the VMexit event. If the VMexit event is caused by an IO request, the IO request processing flow can be entered. Otherwise, the processing flow for VMexit events caused by other reasons is executed, which is unrelated to the process of accessing hardware resources based on read and write requests provided in this embodiment.
[0073] S303, determine the physical central processing unit matched for each read / write request based on the first virtual central processing unit corresponding to each of the multiple read / write requests.
[0074] For example, for each of multiple concurrent read / write requests, the virtual machine management system can determine the physical central processing unit (PCU) corresponding to the read / write request based on the first virtual central processing unit (VCPU) of that read / write request. It is understood that the first VCPU can be bound to a corresponding physical PCU. When the virtual machine management system determines the first VCPU that initiated a certain read / write request, it can obtain the physical PCU corresponding to the first VCPU that initiated the read / write request. Then, the physical PCU can be used as the physical PCU that matches the read / write request. Furthermore, the entire process of processing the read / write request can be performed on the physical PCU that matches the read / write request. This ensures that when multiple read / write requests are concurrent, the time overhead caused by tasks or threads needing to switch and wait for scheduling on different physical PCUs is avoided. In other words, the virtual machine management system can determine on which physical central processing unit (CPU) the entire process of processing the read / write request needs to be performed based on the first virtual CPU that initiates the read / write request. This ensures that when multiple read / write requests are concurrent, the process of processing the same read / write request is performed on the same physical CPU. As a result, when the virtual machine management system processes the same read / write request, it does not need to switch and wait for scheduling on different physical CPUs, thereby improving the efficiency of processing read / write requests and thus improving the efficiency of accessing hardware resources.
[0075] S304, based on the physical central processing unit corresponding to each read / write request, writes each read / write request in parallel into the cache module that is associated with the virtual machine management system.
[0076] The caching module can be a cache area in a hardware resource access system, for example, it can be like... Figure 1 As shown, the hardware resource access system 10 includes a cache module 140. The cache module can also be a cache module included in a second virtual machine system, or a cache module included in a virtual machine management system.
[0077] For example, for any one of multiple concurrent read / write requests, the virtual machine management system (VMMS) can write the read / write request to a cache module jointly associated with the VMMS on the corresponding physical central processing unit (PCU). This cache module can be written to by the VMMS and read by the second VMMS. This ensures that the same read / write request, processed on the first VMMS, the VMMS, and the second VMMS, can be handled on the same PCU, avoiding the low processing efficiency caused by switching between different PCUs and waiting for scheduling when processing the same read / write request. This improves the efficiency of hardware resource access.
[0078] Optionally, there can be multiple cache modules; each cache module corresponds to a different physical central processing unit (CPU). For example, each cache module can correspond to a different first virtual CPU, and different first virtual CPUs can correspond to different physical CPUs, so each cache module can correspond to a different physical CPU. Alternatively, multiple physical CPUs can correspond to one cache module; for example, CPU1, CPU2, and CPU3 can correspond to the first cache module, and CPU4 and CPU5 can correspond to the second cache module.
[0079] S305 activates the second virtual machine system through an uplink call; the second virtual machine system is used to determine the second virtual central processing unit corresponding to each read and write request based on the physical central processing unit corresponding to each read and write request, and wake up the second virtual central processing unit corresponding to each read and write request, and access the hardware resources matching the read and write requests corresponding to each second virtual central processing unit in parallel through each second virtual central processing unit.
[0080] One method for uplink calls is to notify the second virtual machine system to process read / write requests by interrupting the uplink call.
[0081] For example, the virtual machine management system can notify and activate the second virtual machine system via an upcall interrupt. The second virtual machine system can process each read / write request on the corresponding physical central processing unit (CPU). That is, when multiple read / write requests are processed concurrently, for any given read / write request, the second virtual machine system can process it on the CPU corresponding to that request. The second virtual machine system can determine the second virtual CPU for invoking the backend driver for that read / write request based on the corresponding physical CPU, and wake up the corresponding second virtual CPU. Furthermore, the second virtual CPU can invoke the backend driver to perform hardware operations and access the hardware resources corresponding to the read / write request based on the request content. In this way, it can be ensured that when the same read / write request is processed on the second virtual machine system, it is on the same physical CPU as when it is processed by the first virtual machine system and the virtual machine management system.
[0082] S306, Obtain the access result information of the hardware resources corresponding to each read / write request sent by the second virtual machine system.
[0083] The access result information can refer to the information on the completion of the read / write request processing, or it can be the result information of the hardware resources corresponding to the requested content of the read / write request.
[0084] For example, after the second virtual central processing unit completes processing the read / write request, the second virtual machine system can generate access result information for the hardware resources corresponding to the read / write request, and can notify the virtual machine management system that the read / write request operation has been completed by calling a hypercall. The virtual machine management system can obtain the access result information for the hardware resources corresponding to the read / write request notified by the second virtual machine system. Furthermore, the virtual machine management system can return this access result information to the first virtual machine system.
[0085] S307 returns the access result information to the first virtual machine system.
[0086] For example, the virtual machine management system notifies the first virtual machine system of the access result information corresponding to each read and write request, and returns to the first virtual central processing unit of the first virtual machine system to complete the processing of the read and write requests.
[0087] The hardware resource access method provided in this application embodiment determines the physical central processing unit bound to the first virtual central processing unit that initiates the read / write request through the virtual machine management system. This ensures that the entire process of processing the same read / write request is within the same physical central processing unit, avoiding the problem of low processing efficiency caused by switching and waiting for scheduling on different physical central processing units when processing the same read / write request. This improves the efficiency of processing read / write requests and, consequently, the efficiency of accessing hardware resources.
[0088] Figure 1 This application provides a hardware resource access system 10, which can be used in an automotive infotainment system. The hardware resource access system includes a virtual machine management system 120 and a first virtual machine system 110 and a second virtual machine system 130 created based on the virtual machine management system 120. The names of the hardware resource access system 10 and the hardware resource access methods have the same or similar meanings, and will not be elaborated further here.
[0089] The first virtual machine system 110 is used to respond to multiple read and write requests for access to hardware resources.
[0090] For example, the VCPU (first virtual central processing unit) included in the first virtual machine system 110 can respond to multiple read and write requests initiated by the user for accessing hardware resources through the virtual front-end driver, and cause a VMexit (virtual machine exit) event. The first virtual machine system 110 can exit operation to enter the processing flow of the virtual machine management system 120.
[0091] The virtual machine management system 120 is used to determine the physical central processing unit matched by each read and write request based on the first virtual central processing unit corresponding to each read and write request; it is also used to send each read and write request to the second virtual machine system 130 based on the physical central processing unit corresponding to each read and write request; the first virtual central processing unit is the virtual central processing unit in the first virtual machine system 110 that responds to the read and write requests.
[0092] For example, the virtual machine management system 120 determines the cause of the currently occurring VMexit event. If the VMexit event is caused by a read / write request, it can proceed with the process of handling the read / write request; otherwise, it executes the processing flow for VMexit events caused by other reasons, which is unrelated to the flow in this embodiment. The virtual machine management system 120 can determine multiple read / write requests initiated in the first virtual machine system 110 through IO request distribution processing, and can also determine the first virtual central processing unit that initiated each read / write request. For each read / write request, the virtual machine management system 120 can determine the physical central processing unit corresponding to the read / write request based on the first virtual central processing unit that initiated the read / write request. The virtual machine management system 120 can determine on which physical central processing unit the entire process of processing the read / write request needs to be performed based on the first virtual central processing unit that initiated the read / write request, ensuring that the process of processing the same read / write request is in the same physical central processing unit. The virtual machine management system 120 can process the read / write request based on the physical central processing unit corresponding to the read / write request. For example, the virtual machine management system 120 can send the read / write request to the second virtual machine system 130 on the physical central processing unit corresponding to the read / write request to complete the processing flow of the read / write request in the virtual machine management system 120.
[0093] The second virtual machine system 130 is used to determine the second virtual central processing unit corresponding to each read and write request based on the physical central processing unit corresponding to each read and write request, and to access the hardware resources that match the read and write requests corresponding to each second virtual central processing unit through each virtual central processing unit.
[0094] For example, the second virtual machine system 130 can distribute and process I / O requests, determine the second virtual central processing unit corresponding to the read / write request based on the physical central processing unit corresponding to the read / write request, and can process the second virtual central processing unit (e.g., Figure 1The second virtual CPU (shown) calls the virtual backend to access the hardware resources matching the read / write request through the device driver. That is, the corresponding virtual central unit can call the backend driver to access hardware based on the content of the read / write request. In this way, when multiple read / write requests are concurrent, the processing flow for the same read / write request can be implemented on the same physical CPU, avoiding the time overhead caused by switching and waiting for scheduling on different physical CPUs due to tasks or threads. This improves the efficiency of concurrent I / O request processing under multi-VCPU conditions, thereby improving the efficiency of accessing hardware resources.
[0095] The hardware resource access system provided in this application embodiment solves the technical problem of low efficiency in accessing hardware resources by means of a technical means that, when multiple read and write requests are concurrent, the entire process of the virtual machine management system 120 and the second virtual machine system 130 processing the same read and write request is performed on the same physical central processing unit.
[0096] Figure 1 The hardware resource access system 10 shown also includes a cache module 140, and the second virtual machine system 130 includes a Hypervisor service module 1301. The Hypervisor service module may refer to the service module of the virtual machine management system 120.
[0097] The virtual machine management system 120 is used to write each read and write request to the cache module 140 based on the physical central processing unit corresponding to each read and write request, and to activate the second virtual machine system 130 through uplink calls.
[0098] For example, for any one of the multiple concurrent read / write requests, the virtual machine management system 120 can write the read / write request to the cache module 140 corresponding to the second virtual machine system 130 on the physical central processing unit that matches the read / write request. The virtual machine management system 120 can notify and activate the second virtual machine system 130 by means of an upcall interrupt.
[0099] Hypervisor service module 1301 (service module of virtual machine management system 120) can distribute and process IO requests. When the second virtual machine system 130 is activated, it wakes up the second virtual central processing unit corresponding to each read and write request based on the physical central processing unit corresponding to each read and write request.
[0100] For example, when the second virtual machine system 130 is activated, the Hypervisor service module 1301 can determine the second virtual central processing unit for calling the backend driver for the read / write request based on the physical central processing unit corresponding to the read / write request, and wake up the second virtual central processing unit corresponding to the read / write request.
[0101] The second virtual machine system 130 is also used to generate access result information of the hardware resources corresponding to the read / write request when the second virtual central processing unit completes the access to the hardware resources matched by the read / write request corresponding to the second virtual central processing unit.
[0102] For example, after the second virtual machine system 130 completes the read / write request, it can generate access result information of the hardware resources corresponding to the read / write request, and can notify the virtual machine management system 120 that the read / write request operation has been completed by calling a hypercall.
[0103] The virtual machine management system 120 is used to receive the access result information of the hardware resources corresponding to each read and write request, and return each access result information to the first virtual machine system 110.
[0104] For example, the virtual machine management system 120 can receive access result information of hardware resources corresponding to read and write requests notified by the second virtual machine system 130, and the virtual machine management system 120 notifies the first virtual machine system 110 of the access result information corresponding to each read and write request.
[0105] The first virtual machine system 110 is used to return to run the first virtual central processing unit corresponding to each read and write request after receiving the access result information corresponding to each read and write request.
[0106] For example, the first virtual machine system 110 can return to the operation of the first virtual central processing unit of the first virtual machine system 110 after receiving the access result information corresponding to each read and write request, so as to complete the processing of the read and write requests.
[0107] The hardware resource access method provided in this application embodiment determines the physical central processing unit bound to the first virtual central processing unit that initiates the read / write request through the virtual machine management system. This ensures that the entire process of processing the same read / write request is within the same physical central processing unit, avoiding the problem of low processing efficiency caused by switching and waiting for scheduling on different physical central processing units when processing the same read / write request. This improves the efficiency of processing read / write requests and, consequently, the efficiency of accessing hardware resources.
[0108] Figure 4A schematic diagram of the hardware resource access device provided in this application is shown below. Figure 4 As shown, the hardware resource access device 40 provided in this embodiment includes:
[0109] The read / write request acquisition module 401 is used to acquire multiple read / write requests for accessing hardware resources responded to by the first virtual central processing unit contained in the first virtual machine system.
[0110] The read / write request processing module 402 is used to determine the physical central processing unit matched for each read / write request based on the first virtual central processing unit corresponding to each of the multiple read / write requests.
[0111] The read / write request sending module 403 is used to send each read / write request to the second virtual machine system based on the physical central processing unit corresponding to each read / write request; wherein the first virtual machine system and the second virtual machine system are virtual machine systems created based on the virtual machine management system.
[0112] The second virtual machine system is used to determine the second virtual central processing unit corresponding to each read and write request based on the physical central processing unit corresponding to each read and write request, and to access the hardware resources that match the read and write requests corresponding to each second virtual central processing unit in parallel through each second virtual central processing unit.
[0113] In one possible implementation, the read / write request sending module 403 is further configured to send each read / write request to the second virtual machine system, obtain the access result information of the hardware resources corresponding to each read / write request sent by the second virtual machine system, and return each access result information to the first virtual machine system.
[0114] In one possible implementation, the read / write request acquisition module 401 is specifically used to respond to an exit event responded to by the first virtual machine system; in the case that the exit event is an event generated based on read / write requests, it determines multiple read / write requests initiated by the first virtual machine system.
[0115] In one possible implementation, the read / write request sending module 403 is specifically used to write each read / write request in parallel to the cache module jointly associated with the second virtual machine system and the virtual machine management system, based on the physical central processing unit corresponding to each read / write request; and to activate the second virtual machine system through an uplink call; the second virtual machine system is used to wake up the second virtual central processing unit corresponding to each read / write request based on the physical central processing unit corresponding to each read / write request.
[0116] In one possible implementation, there are multiple cache modules; each cache module corresponds to a different physical central processing unit.
[0117] The hardware resource access device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.
[0118] Figure 5 A schematic diagram of the structure of the electronic device provided in this application. Figure 5 As shown, the electronic device 50 provided in this embodiment includes at least one processor 501 and a memory 502. Optionally, the device 50 further includes a communication component 503. The processor 501, memory 502, and communication component 503 are connected via a bus 504.
[0119] In a specific implementation, at least one processor 501 executes computer execution instructions stored in memory 502, causing at least one processor 501 to perform the above-described method.
[0120] The specific implementation process of processor 501 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0121] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0122] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0123] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0124] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0125] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.
[0126] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
[0127] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.
[0128] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0129] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0130] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0131] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0132] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0133] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
Claims
1. A hardware resource access method, characterized by, The method is applied to a virtual machine management system, and comprises the following steps: Obtaining a plurality of read-write requests for accessing hardware resources in a first virtual machine system; the plurality of read-write requests are obtained by a first virtual central processing unit included in the first virtual machine system; According to the first virtual central processing units corresponding to the plurality of read-write requests, determining the physical central processing units matched with the read-write requests; Based on the physical central processing units corresponding to the read-write requests, sending the read-write requests to a second virtual machine system in parallel; wherein the first virtual machine system and the second virtual machine system are virtual machine systems created based on the virtual machine management system; The second virtual machine system is configured to determine the second virtual central processing units corresponding to the read-write requests based on the physical central processing units corresponding to the read-write requests, and access the hardware resources matched with the read-write requests through the second virtual central processing units in parallel; wherein The virtual machine management system and the second virtual machine system process the same read-write request of the first virtual machine system on the same physical central processing unit corresponding to the first virtual machine system.
2. The method of claim 1, wherein, After sending the read-write requests to the second virtual machine system, the method further comprises the following steps: Obtaining the access result information of the hardware resources corresponding to the read-write requests sent by the second virtual machine system; Returning the access result information to the first virtual machine system.
3. The method of claim 1, wherein, The method of obtaining the plurality of read-write requests for accessing hardware resources in response to the first virtual central processing unit included in the first virtual machine system comprises the following steps: In response to an exit event triggered by the first virtual machine system; In the case that the exit event is an event generated based on a read-write request, determining the plurality of read-write requests initiated by the first virtual machine system.
4. The method according to any one of claims 1 to 3, characterized in that, The method of sending the read-write requests to the second virtual machine system based on the physical central processing units corresponding to the read-write requests comprises the following steps: Based on the physical central processing units corresponding to the read-write requests, writing the read-write requests into a cache module associated with the second virtual machine system and the virtual machine management system in parallel; Activating the second virtual machine system through uplink calling; The second virtual machine system is configured to wake up the second virtual central processing units corresponding to the read-write requests based on the physical central processing units corresponding to the read-write requests.
5. The method of claim 4, wherein, The cache module has a plurality of cache modules; each cache module corresponds to a different physical central processing unit.
6. A hardware resource access system, characterized by The hardware resource access system comprises a virtual machine management system, a first virtual machine system and a second virtual machine system created based on the virtual machine management system; The first virtual machine system is configured to respond to a plurality of read-write requests for accessing hardware resources; The virtual machine management system is configured to determine a physical central processing unit corresponding to each read-write request based on a first virtual central processing unit corresponding to each read-write request, and send each read-write request to a second virtual machine system based on the physical central processing unit corresponding to each read-write request; the first virtual central processing unit is a virtual central processing unit in the first virtual machine system that responds to the read-write request; The second virtual machine system is configured to determine a second virtual central processing unit corresponding to each read-write request based on the physical central processing unit corresponding to each read-write request, and access a hardware resource corresponding to each read-write request through each virtual central processing unit; wherein, The virtual machine management system and the second virtual machine system process the same read-write request of the first virtual machine system on the same physical central processing unit corresponding to the first virtual machine system.
7. The hardware resource access system of claim 6, wherein, The second virtual machine system is further configured to generate access result information of a hardware resource corresponding to each read-write request when the second virtual central processing unit completes the access to the hardware resource corresponding to the read-write request; The virtual machine management system is configured to receive the access result information of the hardware resource corresponding to each read-write request, and return each access result information to the first virtual machine system; The first virtual machine system is configured to return the first virtual central processing unit corresponding to each read-write request when the access result information corresponding to each read-write request is received.
8. The hardware resource access system of claim 6, wherein, The hardware resource access system further comprises a cache module, and the second virtual machine system comprises a service module for the virtual machine management system; The virtual machine management system is configured to write each read-write request into the cache module based on the physical central processing unit corresponding to each read-write request, and activate the second virtual machine system through uplink calling; The service module of the virtual machine management system is configured to wake up the second virtual central processing unit corresponding to each read-write request based on the physical central processing unit corresponding to each read-write request when the second virtual machine system is activated.
9. An electronic device, comprising: comprise: a memory and a processor; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory, so that the processor executes the method of any one of claims 1-5.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer execution instructions, and the computer execution instructions are executed by the processor to implement the method of any one of claims 1-5.
11. A computer program product comprising a computer program, which, when executed by a processor, implements the method of any one of claims 1-5.
Citation Information
Patent Citations
Chip system, method for processing virtual interrupt and corresponding device
CN114371907A
Enabling host penetration based on hardware identification instructions
CN116166369A