PCI device resource configuration method and apparatus
By virtualizing PCI devices into virtual function modules and storing operation information in mixed-criticality systems, the complexity and real-time performance issues of PCI device resource allocation are resolved, and efficient resource utilization and real-time performance are achieved.
Patent Information
- Application Number
- PCT/CN2024/134946
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-04-11
- Filing Date
- 2024-11-27
- Publication Date
- 2025-10-16
AI Technical Summary
In mixed-criticality systems, existing technologies find it difficult to provide network capabilities for both general-purpose operating systems and real-time operating systems with limited PCI device resources, resulting in increased operating system complexity and reduced real-time performance.
By virtualizing PCI devices into virtual function modules and storing their operating information in shared memory, real-time operating systems are allowed to read them directly to provide functions, avoiding repeated initialization and reducing system complexity.
The system reduces the complexity of the operating system, ensures the real-time performance of the real-time operating system, and improves the utilization rate of hardware resources in mixed criticality systems.
Smart Images

Figure CN2024134946_16102025_PF_FP_ABST
Abstract
Description
Method and apparatus for configuring PCI device resources
[0001] The present application claims priority from the Chinese patent application No. 202410439492.8 filed on April 11, 2024, and entitled "Method and apparatus for configuring PCI device resources", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0002] The present application relates to the field of computer, and in particular, to a method and apparatus for configuring peripheral component interconnect (PCI) device resources. BACKGROUND
[0003] With the development of various virtualization technologies becoming more and more mature, in order to reduce costs, improve hardware utilization, and use various programs to meet different functions, various business scenarios have begun to use virtualization technologies.
[0004] For mixed-criticality system (MCS) application scenarios (such as industrial control and autonomous driving), the number of functional requirements has been steadily increasing over the past few years, which has led MCS to evolve from using small single-core microcontrollers to run simple logic applications or real-time operating systems to powerful multi-core platforms and be able to carry mixed-criticality system deployment.
[0005] Since MCS is a converged system, it is composed of applications and operating systems of different criticalities. It is mainly divided into general purpose operating system (GPOS) and real time operating system (RTOS). Among them, the main function of RTOS is to ensure the real-time of task scheduling, which is a microkernel with low resource consumption and low system complexity.
[0006] In the case of limited static deployment of MCS hardware resources, it is hoped that limited PCI device resources can be allocated to each operating system at the same time. For example, in the scenario of industrial control, it is hoped that limited network card resources can be allocated to all GPOS and RTOS at the same time, so that they all have network capabilities. Although in the current PCI device resource allocation scheme, the operating system needs to deploy the PCI device driver to use the function of the PCI device, which leads to the increase of complexity of the operating system (such as RTOS) and the decrease of real-time performance. SUMMARY
[0007] The application provides a method and device for configuring PCI device resources, which can reduce the complexity of a system and ensure real-time performance under the premise of using the functions of a PCI device in a real-time operating system.
[0008] To achieve the above object, the embodiments of the application adopt the following technical solutions.
[0009] In a first aspect, a method for configuring PCI device resources is provided, which can be applied to a computer system including a first operating system (OS), a second OS, a memory and a PCI device. The memory is configured with a shared memory corresponding to the second OS. The method can include: virtually configuring the PCI device as a virtual function (VF) module by the first OS; then, initializing the VF module by the first OS to obtain running information of the VF module, and storing the running information of the VF module in the shared memory; and reading the running information of the VF module in the shared memory by the second OS to provide the functions of the PCI device.
[0010] According to the method provided by the application, one operating system in the computer system initializes the PCI device uniformly, and stores the running information of the VF module for providing the functions of the PCI device in the shared memory dedicated to the second OS, so that the allocation of the PCI device resources is realized. The second operating system does not need to initialize the PCI device, and only needs to read the running information of the VF module in the shared memory to provide the functions of the PCI device. In this way, the complete driver of the PCI device does not need to be configured in the second operating system, which greatly reduces the complexity of the operating system and better ensures the real-time performance of the operating system.
[0011] The shared memory corresponding to the third OS can only be accessed by the third OS and the first OS, and cannot be accessed by other OSs. The third OS is any OS.
[0012] In a possible implementation manner, the PCI device includes one or more of the following physical devices: a network card, a sound card, a display card, a modem or a data processing unit (DPU).
[0013] In another possible implementation manner, the PCI device can be a network card, and the first OS initializes the VF module to obtain the running information of the VF module, which can be specifically implemented as follows: setting a direct memory access (DMA) addressing address of the VF module, and establishing a mapping between the DMA addressing address and a virtual address of a virtual memory of the second OS; wherein the running information of the VF module includes the DMA addressing address and the virtual address.
[0014] Another possible implementation, when the PCI device is a network card, the first OS can create a two-layer device structure of the VF module, which includes the DMA addressing address, the virtual address, and the two-layer device structure is used as the running information.
[0015] Another possible implementation, the PCI device can be a network card, and the second OS provides the function of the PCI device by reading the running information of the VF module in the shared memory. Specifically, the second OS can read the virtual address in the running information of the VF module from the shared memory when sending a message packet, write the to-be-sent message packet into the virtual memory space indicated by the virtual address, and drive the network card to send the to-be-sent message packet using the running information of the VF module; and the second OS can read the virtual address from the shared memory when receiving a message packet, and read the message packet from the virtual memory space indicated by the virtual address. The running information of the VF module includes the DMA addressing address visible to the PCI device and the virtual address visible to the OS, and a mapping between the two is established in the initialization process. In this way, the second OS can write the message packet into the virtual memory space indicated by the virtual address by reading the virtual address from the running information of the VF, and then drive the PCI device to send the message packet written in the space indicated by the DMA addressing address corresponding to the virtual memory; or the message packet sent to the second OS is written into the space indicated by the DMA addressing address of the second OS, and the second OS reads the message packet from the virtual memory space indicated by the virtual address to achieve the function of receiving the message packet. In this way, the function of receiving the message packet of the network card is achieved, the second OS provides the function of the network card to the upper-layer application, and the second OS has network capability.
[0016] Another possible implementation, the second OS can use the polling method to read the message packet from the virtual memory space indicated by the virtual address.
[0017] Another possible implementation, the first OS can be a GPOS, and the second OS can be an RTOS. The implementation ensures the real-time performance of the RTOS in a system including the GPOS and the RTOS.
[0018] Another possible implementation, the first OS can be one, and the second OS can be one or more.
[0019] In another possible implementation, the second OSs are multiple, and each second OS corresponds to a shared memory. The first OS virtualizes the PCI device as a VF module, including: the first OS virtualizes a VF module for each second OS. The first OS initializes the VF module, obtains running information of the VF module, and stores the running information of the VF module in the shared memory, including: for any one of the second OSs, the first OS initializes the VF module of the second OS, obtains the running information of the VF module of the second OS, and stores the running information of the VF module of the second OS in the shared memory corresponding to the second OS. The purpose of allocating the resources of the PCI device to each second OS is achieved.
[0020] In another possible implementation, the second OSs are multiple, and part of the second OSs are target second OSs, and each target second OS corresponds to a shared memory. The first OS virtualizes the PCI device as a VF module, including: the first OS virtualizes a VF module for each target second OS. The first OS initializes the VF module, obtains running information of the VF module, and stores the running information of the VF module in the shared memory, including: for any one of the target second OSs, the first OS initializes the VF module of the target second OS, obtains the running information of the VF module of the target second OS, and stores the running information of the VF module of the target second OS in the shared memory corresponding to the second OS. The purpose of allocating the resources of the PCI device to each target second OS is achieved.
[0021] In another possible implementation, the first OS can also provide the function of the PCI device through the VF module, and the method provided in the application further includes: the first OS virtualizes a VF module for the first OS, the first OS corresponds to a shared memory, the first OS initializes the VF module of the first OS, obtains the running information of the VF module of the first OS, and stores the running information of the VF module of the first OS in the shared memory corresponding to the first OS. The first OS provides the function of the PCI device by reading the running information of the VF module in the shared memory corresponding to the first OS. The purpose of allocating the resources of the PCI device to the first OS is achieved.
[0022] In another possible implementation, the first OS is deployed with a management module, and the management module is configured to control the second OSs, and the control can include any one of the following operations: creation, start, stop, deletion, management, monitoring, or shutdown. The centralized management of the operating systems in the system is achieved.
[0023] In another possible implementation, the computer system can be an MCS, and the complexity of the system is reduced to ensure real-time performance under the premise that the real-time operating system uses the function of the PCI device in the MCS.
[0024] The MCS system can perform the solution provided in the present application to realize allocation of the PCI device resources.
[0025] In another possible implementation, the first OS is deployed with a first driver for initializing the PCI device, and the second OS is deployed with a second driver for reading the running information to execute the function of the PCI device. The first driver is a complete driver of the PCI device, and the second driver is a part of the first driver.
[0026] In a second aspect, an apparatus for configuring PCI device resources is provided. The apparatus can be applied to a computer system, and the computer system includes a first operating system (OS), a second OS, a memory, and a PCI device. The memory is configured with a shared memory corresponding to the second OS. The apparatus can include an initialization module deployed in the first OS and a processing module deployed in the second OS. The initialization module deployed in the first OS is configured to virtually configure the PCI device as a VF module, initialize the VF module, obtain running information of the VF module, and store the running information of the VF module in the shared memory. The processing module deployed in the second OS is configured to read the running information of the VF module in the shared memory to provide a function of the PCI device.
[0027] The initialization module deployed in the first OS is configured to virtually configure the PCI device as a VF module, initialize the VF module, obtain running information of the VF module, and store the running information of the VF module in the shared memory.
[0028] The processing module deployed in the second OS is configured to read the running information of the VF module in the shared memory to provide a function of the PCI device.
[0029] It should be noted that the apparatus provided in the second aspect is used to implement the method provided in the first aspect or any possible implementation manner, and the specific implementation can refer to the description in the first aspect, which will not be repeated here.
[0030] In a third aspect, a computing device is provided. The computing device includes a memory and a processor. The memory stores program code. When the processor executes the program code, the processor is configured to perform the operations of the method in the first aspect or any possible implementation manner.
[0031] In a fourth aspect, a computer system is provided. The computer system is deployed with a first OS and a second OS. The computer system is configured to perform the operations of the method in the first aspect or any possible implementation manner.
[0032] In a fifth aspect, a computer program product is provided. When the computer program product is run in a computing device, the computer program product causes the computing device to perform the operations of the method in the first aspect or any possible implementation manner.
[0033] In a sixth aspect, a computer readable storage medium is provided. The computer readable storage medium includes computer program instructions. When the computer program instructions are executed by a computing device, the computing device performs the operations of the method in the first aspect or any possible implementation manner.
[0034] It should be noted that various possible implementations of any of the above aspects can be combined under the premise that the solutions are not contradictory.
[0035] The beneficial effects of the second to sixth aspects above can be referred to the description of the first aspect or any implementation of the first aspect, and will not be repeated here. Based on the implementations provided in the above aspects, this application can also be further combined to provide more implementations. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 is a schematic diagram of an industrial control scenario;
[0037] Figure 2 is a schematic diagram of the VMware Infrastructure solution;
[0038] FIG3 is a schematic diagram of a solution for VMware vSphere supporting SR-IOV;
[0039] FIG4 is a schematic diagram of a solution under the ACRN SR-IOV architecture;
[0040] FIG5 is a schematic diagram of the structure of a computer system provided in an embodiment of the present application;
[0041] FIG6 is a schematic diagram of the structure of another computer system provided in an embodiment of the present application;
[0042] FIG7 is a flow chart of a method for configuring PCI device resources according to an embodiment of the present application;
[0043] FIG8 is a schematic diagram of the structure of an apparatus for configuring PCI device resources provided in an embodiment of the present application;
[0044] FIG9 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] In the embodiments of the present application, in order to clearly describe the technical solutions of the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects. Those skilled in the art will understand that words such as "first" and "second" do not limit the quantity or execution order, and words such as "first" and "second" do not necessarily mean different. There is no order of precedence or priority between the technical features described by "first" and "second".
[0046] In the embodiments of the present application, the words "exemplary" or "for example" are used to mean serving as an example, instance, or illustration, and not necessarily to imply any preference or superiority. In fact, an "exemplary" or "for example" embodiment should not necessarily be considered to have any advantage over other embodiments.
[0047] In the embodiments of the present application, at least one can also be described as one or more, and more can be two, three, four or more, which are not limited by the present application.
[0048] In addition, the network architecture and scenarios described in the embodiments of the present application are used to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art can know that, with the evolution of network architecture and the emergence of new business scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.
[0049] In order to facilitate understanding, the terms involved in the embodiments of the present application are first explained.
[0050] PCI device refers to an external device connected according to the PCI protocol. The PCI device can include any of the following devices: a network card, a sound card, a video card, a modem, or a DPU.
[0051] SR-IOV is a technology that virtually divides a single PCI device into multiple function devices and assigns them to different virtual machines for direct access, thereby effectively improving the I / O performance and reducing the delay of each virtual machine. For example, SR-IOV virtually divides a PCI device into multiple VFs for direct access by different virtual machines.
[0052] Shared memory is a logical memory that allows two independent (or unrelated) objects (such as processes or OS) to access. Objects that share the same logical memory can connect the same physical memory corresponding to the same logical memory to their own address space to access the shared memory.
[0053] DMA (Direct Memory Access) is an interface technology that allows external devices to exchange data with system memory directly without going through the central processing unit (CPU).
[0054] Virtual machine monitor Hypervisor is a kind of intermediate layer software running between physical servers and operating systems, which can allow multiple operating systems and applications to share a set of basic physical hardware.
[0055] The driver of the PCI device refers to the program code added to the operating system, which contains information about the PCI hardware device. With this information, the computer can communicate with the PCI hardware device.
[0056] With the development of various virtualization technologies becoming more and more mature, various business scenarios start to use virtualization technologies in order to reduce costs, improve hardware utilization, and use various programs to meet different functions. For mixed criticality system application scenarios, such as industrial control and autonomous driving, the number of functional requirements has been steadily increasing over the past few years. As a result, the architecture of the system has evolved from using small single-core microcontrollers to run simple logic applications or real-time operating systems to powerful multi-core platforms that can host mixed criticality system deployments.
[0057] The current industrial control scenario, as shown in FIG. 1, can be divided into five layers L0-L4: L0 is the industrial equipment on the industrial side, such as a robotic arm or a numerical control machine. L1 is the field control layer, responsible for implementing control of industrial equipment, such as a controller. For example, it can be a programmable logic controller (PLC), data acquisition, machine vision, etc. L2 is the process monitoring layer, responsible for managing and monitoring the control layer. For example, L2 can be a supervisory control and data acquisition (SCADA) / distributed control system (DCS) / human machine interface (HMI), or Internet of Things, intelligent, database, etc. L3 is the production management layer, which is mainly the management system of the production line. For example, L3 can be a manufacturing execution system (MES), Internet of Things, intelligent, database, etc. L4 is some enterprise management system. This is a logical layering of a system. Physically, L0 is on the production line in the factory, L1 is generally beside each industrial device, L2 is beside a production line, and L3 is beside a factory. In order to achieve centralized management, our business goal is to fuse and deploy L1-L3 layers on a hyper-converged physical base, such as a cabinet, to form a mixed criticality system (MCS).
[0058] Mixed criticality system (MCS) is composed of applications and operating systems with different criticalities. Current business is mainly divided into two kinds of operating systems, general purpose operating system (GPOS) and real-time operating system (RTOS). GPOS is generally Windows or Linux that we commonly use, mainly responsible for L2 and L3 layers. RTOS is to execute some real-time applications, such as the control of industrial equipment, mainly responsible for L1 layer, and the main function of RTOS is to ensure the real-time of task scheduling. Unlike GPOS, RTOS is a microkernel that consumes less resources and has low system complexity. Microkernel refers to placing necessary functions (such as process management, task communication, interrupt handling, process scheduling) in the kernel, while other non-essential function services (file system, PCI architecture, device management) are configured as part of the kernel. Currently, there are many different technologies to deploy MCS. For the mode of deploying RTOS directly on the hardware, allocating private CPU cores and memory resources, and IO devices, this mode is called static MCS.
[0059] In the case of limited hardware resources, we want to allocate limited PCI devices to different criticality systems. For example, in the industrial control scenario, we want to allocate limited network card resources to all GPOS and RTOS at the same time, so that they all have network capabilities. Although there are different PCI device resource allocation schemes in the industry at present, they all have their own limitations.
[0060] Solution 1, VMware Infrastructure solution is shown in Figure 2, through virtual network card (virtualised network interface card, vNIC), virtual switch (virtualised switch, vSwitch), port group (Port Groups), to provide network capability for virtual machine (virtual machine, VM). Each virtual machine has one or more exclusive vNIC, these vNIC have their own media access control (Media Access Control, MAC) address, internet protocol (internet protocol, IP) address, can respond to standard Ethernet protocol like physical network card (network interface card, NIC). The working mode of vSwitch is similar to the second layer physical switch, and exists on each host server. One side of the vSwitch is the port group connected to the virtual machine, and the other side is connected to the physical Ethernet adapter on the server where the vSwitch is located. Virtual machines achieve network communication between virtual machines and between virtual machines and external servers through connection to vSwitch.
[0061] Scheme 2, the scheme of VMware vSphere supporting SR-IOV is shown in Figure 3, which provides the capability of virtual machine (VM) direct and shared physical network card (NIC). In the NIC supporting SR-IOV, one or more virtualized physical function (PF) modules can be associated with one or more virtual function (VF) modules. The network adapter of the virtual machine can be associated with the VF to perform network communication. In the communication process, the virtual machine passes data through the input / output memory management unit (IOMMU) technology to make the data pass through the NIC without the processing of components such as vSwitch.
[0062] Scheme 3, the scheme under the ACRN SR-IOV architecture is shown in Figure 4. The service VM (Service VM) uniformly manages network resources, and the ACRN Hypervisor one-to-one simulates the PF and VF on the physical NIC to generate vdev-VF. The Hypervisor detects the VF device and does not use it, but only binds the vdev-VF on the service VM by using the PCI-stake driver. When the user VM (User VM) needs to use the VF, the corresponding vdev-VF is allocated to the user VM. The user VM runs the original VF driver to normally use the VF for network communication.
[0063] Although the above schemes achieve the provision of network capability to the virtual machine through the vNIC or the direct NIC, the VM must support the original device driver, that is, responsible for a complete set of PCI bus specifications, which improves the system complexity and cannot guarantee real-time performance. For the RTOS, when the real-time performance cannot be guaranteed, the main task of the RTOS, that is, ensuring the deterministic scheduling of tasks, will be affected.
[0064] In addition, the use of vNIC by VMware Infrastructure and vSwitch will increase the burden of the system, resulting in performance degradation. At the same time, the virtualization technology will increase the network delay, because the data needs to pass through the virtualization layer before reaching the physical NIC, and it is difficult to guarantee the real-time performance of the application. When the user VM in ACRN uses the VF for communication, the data is not directly passed through the NIC, but still processed by the vdev-VF simulated by the Hypervisor, which increases the network delay and limits the real-time performance.
[0065] Based on this, the application provides a scheme for configuring PCI device resources. An operating system (first OS) in a computer system uniformly initializes the PCI device, stores running information of a VF module for providing a PCI function in shared memory of a second OS, and realizes allocation of the PCI device resources. The second operating system does not need to initialize the PCI device, and only needs to read the running information of the VF module in the corresponding shared memory to provide the function of the PCI device to an upper-layer application. In this way, the second operating system does not need to configure a complete driver of the PCI device, greatly reduces the complexity of the operating system, and better guarantees the real-time performance of the operating system.
[0066] The scheme provided by the embodiments of the application will be described in detail below with reference to the drawings.
[0067] The scheme provided by the application can be applied to the computer system shown in FIG. 5. As shown in FIG. 5, the computer system includes a plurality of operating systems 501, a memory 502, a kernel 503, and a PCI device 504.
[0068] The operating systems 501 are carried on the memory 502 and the kernel 503, and the resources of the memory 502 and the kernel 503 are allocated to each operating system 501, so that the operating system 501 is carried on the memory 502 and the kernel 503, uses the resources of the memory 502 and the kernel 503, and completes the function of the operating system 501. Each operating system 501 uses the resources of the PCI device 504 to provide the corresponding function of the PCI device 504, such as the network capability corresponding to a network card. The PCI device 504 supports the SR-IOV technology.
[0069] For example, the computer system shown in FIG. 5 can be deployed on a single computing device, or can be deployed on a plurality of computing devices. The plurality of computing devices can be distributedly deployed.
[0070] For example, the computer system shown in FIG. 5 can be an MCS system. The MCS system can be deployed in a cabinet.
[0071] For example, the computer system shown in FIG. 5 can be a statically deployed MSC system.
[0072] For example, the computer system shown in FIG. 5 can be applied to an industrial control scene, an automatic driving scene, or other scenes, and the embodiments of the application are not limited to specific application scenes.
[0073] It should be understood that the computer system shown in FIG. 5 can further include other units, and the architecture of the computer system shown in FIG. 5 can be configured according to actual needs.
[0074] In a possible implementation, as shown in the computer system in FIG. 6, a plurality of operating systems 501 include a main operating system and one or more other operating systems. As shown in the computer system in FIG. 6, the main operating system is deployed with a management apparatus and a first driver of the PCI device 504, and the other operating systems are statically deployed on the allocated physical cores and memory resources, and the management apparatus is configured to start, stop, and monitor the other operating systems. In the other operating systems, a second driver of the PCI device 504 is deployed.
[0075] The main function of the management apparatus is to be responsible for starting, managing, and closing the other operating systems.
[0076] The main function of the first driver of the PCI device 504 is to be responsible for PCI bus initialization and management of all PCI devices, and to create a VF, initialize the VF, and initialize running information (which can be in the form of a structure) of the VF to shared memory.
[0077] The main function of the second driver of the PCI device 504 is to read the running information of the VF module of the initialized PCI device in the memory, and to drive the corresponding PCI device to provide the function of the PCI device.
[0078] For example, the main operating system can be a GPOS, the other operating system can be an RTOS, the management apparatus can be RTOS management software, the first driver can be a native driver, and the second driver can be a self-developed driver. The self-developed driver is simple in function, does not need to initialize the PCI device, and only needs to read the running information of the initialized VF of the PCI device and drive it, and therefore, the self-developed driver can be part of the native driver, has a small amount of code, and has a short running time, thereby ensuring the real-time performance of the other RTOS.
[0079] In one aspect, an embodiment of the present application provides a method for configuring a PCI device resource, which is applied to a computer system to simultaneously provide resources of a PCI device to different operating systems, so that the operating systems have the function of the PCI device.
[0080] For example, the scheme provided by the present application can be applied to an MCS. For example, the scheme can be applied to a statically deployed MCS.
[0081] It should be understood that the process of configuring different PCI device resources is the same, and the scheme provided by the present application is described below with reference to the process of configuring a PCI device resource.
[0082] Exemplarily, the PCI device described in the present application includes one or more of the following physical devices: a network card, a sound card, a display card, a modem, or a DPU. Of course, the PCI device can also be in other product forms, and any device that accesses using the PCI protocol belongs to the PCI device described in the present application.
[0083] Specifically, the computer system includes a first OS, a second OS, a memory, and a PCI device. The PCI device supports SR-IOV. The memory is configured with shared memory corresponding to the second OS. The shared memory corresponding to one OS is an exclusive accessible memory space for the OS and the first OS.
[0084] Exemplarily, the computer system includes a first OS, one or more second OSs.
[0085] Exemplarily, the first OS can be a GPOS, and the second OS can be an RTOS.
[0086] In a possible implementation manner, the first OS can deploy a virtual machine monitor, and the virtual machine monitor is used to deploy and manage a virtual machine.
[0087] Exemplarily, the virtual machine monitor can be a Hypervisor,
[0088] In another possible implementation manner, the first OS can be a virtual machine monitor-free operating system.
[0089] As shown in FIG. 7, the method for configuring a PCI device resource provided by the present application can include the following steps:
[0090] S701, the first OS virtualizes the PCI device as a VF module.
[0091] Specifically, in S701, the first OS can first identify the PCI device. Since the PCI device supports SR-IOV, the first OS can virtualize the PCI device as a VF module by using SR-IOV.
[0092] In this way, the first OS can identify the PCI device by running the driver of the PCI device.
[0093] Further, since the PCI device supports SR-IOV, the first OS can virtualize the PCI device as a specified number of VF modules by sending a special instruction to the PCI device, and the instruction carries the specified number of VF modules.
[0094] Further, in S701, the first OS can virtualize the PCI device as N VF modules.
[0095] In a possible implementation, N is the number of target operating systems in the computer system that use the PCI device function through the VF module.
[0096] For example, the target operating systems can be all the second OSs, and in S701, the first OS virtually creates a VF module for each second OS.
[0097] For example, the target operating systems can be part of the second OSs, and in S701, the first OS virtually creates a VF module for each second OS that is a target operating system.
[0098] For example, the target operating systems can be the first OS and part of the second OSs, or the target operating systems can be the first OS and all the second OSs, and in S701, the first OS virtually creates a VF module for each target operating system.
[0099] In S702, the first OS initializes the VF module, obtains the running information of the VF module, and stores the running information of the VF module in the shared memory.
[0100] The process in S702 can be performed by a driver of the PCI device deployed in the first OS.
[0101] Specifically, in S702, the first device initializes each VF module obtained in S701, and obtains the running information of each VF module.
[0102] Specifically, the purpose of initializing the VF module is to obtain the running information of the VF module, and the running information of the VF module is information necessary for the VF module to implement the function of the PCI device. The running information of the VF module is a result of the initialization of the VF module, and the running information of the VF module can include a hardware address and a register address of the PCI device. Of course, the running information of the VF module can also include other information. The process of initializing the VF module and the content of the running information of the VF module obtained after the initialization can be configured according to actual requirements, and the content of the running information of the VF module is not limited in the embodiments of the present application.
[0103] For example, when the PCI device is a network card, for the VF module of any one of the second OSs, the first OS initializes the VF module of the second OS, and obtains the running information of the VF module. Specifically, the process can be implemented as follows: setting a DMA addressing address of the VF module, and establishing a mapping between the DMA addressing address and a virtual address of a virtual memory of the second OS. The running information of the VF module includes the DMA addressing address and the virtual address.
[0104] Wherein, each OS in the computer system has a corresponding exclusive physical memory space, the shared memory of an OS is disposed in the exclusive physical memory space of the OS, the DMA addressing address is an address in the exclusive physical memory space visible to the PCI device, the OS accesses the physical memory through the dedicated virtual memory, and after the DMA addressing address of an OS is mapped with a virtual address in the virtual memory of the OS, the operation of the virtual address by the OS is mapped as the operation of the physical memory.
[0105] Further, the running information of the VF module can be stored in the shared memory in the form of a structure.
[0106] The following describes the initialization process when the PCI device is a network card.
[0107] Currently, in the existing network card driving architecture, each operating system needs to initialize the network card in the system and provide the packet receiving and sending capability of the network card, and the specific process includes: 1) setting the DMA addressing limit and cache consistency; 2) applying kernel memory for packet receiving and sending preparation; 3) creating, initializing and registering the struct net_device(three-layer device) structure; 4) registering the network card callback function on the net_device; and 5) registering the poll function to the NAPI system.
[0108] In the network card architecture driving provided by the scheme, the first OS initializes the VF module to obtain the running information of the VF module, including: 1) setting the DMA addressing address of the VF module; 2) mapping the DMA addressing address with a virtual address in the virtual memory of the second OS; and 3) taking the DMA addressing address and the virtual address as the running information of the VF module and creating in the form of a two-layer device structure.
[0109] Of course, in the process of obtaining the running information of the VF module, only the key DMA addressing address and virtual address are described, the running information of the VF module includes all information used by the VF module when providing the PCI device function, in addition to the DMA addressing address and the virtual address of the VF module, the MAC address or other information can also be included, and the embodiments of the present application are not limited in this regard.
[0110] Compared with the initialization process in the existing network card driving architecture, the network card driving architecture provided by the scheme does not create a three-layer network device visible in the main system from the third step, but a two-layer device, because the main system can not use the VF module and only needs to be initialized, and thus the main system does not need to be notified, the network card architecture driving provided by the scheme omits the fourth step and the fifth step, and does not register the network card callback function and the interrupt.
[0111] Further, the initialization process of the VF module of other types of PCI devices can refer to the initialization process of the VF module of the operating system, and the embodiments of the present application are not limited thereto.
[0112] Further, in S702, the initialization is performed on each VF module respectively to obtain the running information of the VF module, and then the running information of the VF module is stored in the shared memory corresponding to the OS. For example, the running information of the VF module of the fourth OS is stored in the shared memory of the fourth module.
[0113] For example, the second OS is multiple, in S701, the first OS virtually creates a VF module for each second OS, in S702, the first OS initializes the VF module to obtain the running information of the VF module, and stores the running information of the VF module in the shared memory. Specifically, for any one of the second OS, the first OS initializes the VF module of the second OS to obtain the running information of the VF module of the second OS, and stores the running information of the VF module of the second OS in the shared memory corresponding to the second OS.
[0114] It should be noted that S702 essentially includes: the first OS initializes the VF module of each target OS to obtain the running information of the VF module of each target OS, and stores the running information of the VF module in the shared memory corresponding to each target OS.
[0115] In S703, the second OS reads the running information of the VF module in the shared memory to provide the function of the PCI device.
[0116] Specifically, the second OS reads the running information of the VF module in the shared memory corresponding to the second OS, and can provide the function of the PCI device to the upper layer application.
[0117] For example, the PCI device is a network card, and the function of the PCI device mainly includes the ability of sending and receiving packets. When the second OS sends a message packet, the virtual address in the running information of the VF module in the shared memory is read, the to-be-sent message packet is written into the virtual memory space indicated by the virtual address, and the network card is driven to send the to-be-sent message packet using the running information of the VF module; when the second OS receives a message packet, the virtual address is read from the shared memory, and the message packet is read from the virtual memory space indicated by the virtual address.
[0118] The message packet sent to one second OS is stored in the physical memory space indicated by the DMA addressing address of the second OS. Since the physical memory space is mapped with the virtual memory, the second OS can use the polling method to read the message packet from the virtual memory space indicated by the virtual address of the second OS.
[0119] For other types of PCI devices, the second OS reads the running information of the VF module in the shared memory to provide the function of the PCI device. The process is similar to the network card. For the specific implementation of the PCI function through the VF module, refer to the specific implementation of the PCI function through the VF module, which will not be repeated here.
[0120] Through the scheme provided in the present application, one operating system in the computer system uniformly initializes the PCI device, stores the running information of the VF module for providing the PCI function in the shared memory dedicated to the second OS, and realizes the allocation of the PCI device resources. The second operating system does not need to initialize the PCI device, and only needs to read the running information of the VF module in the shared memory to provide the function of the PCI device. In this way, the second operating system does not need to configure the complete driver of the PCI device, which greatly reduces the complexity of the operating system and better guarantees the real-time performance of the operating system.
[0121] Further, the OS that provides the PCI device function through the VF module can be referred to as a target operating system (target OS), and the first OS can perform the operation performed on the second OS in the above embodiments on each target OS. Each target OS can also perform the operation performed by the second OS in the above embodiments to achieve the purpose of providing the function of the PCI device by each target OS.
[0122] Further, a management module can be deployed in the first OS to manage and control the second OS. The management and control includes any of the following operations: creating, starting, stopping, deleting, managing, monitoring, or closing.
[0123] Further, the first OS is deployed with a first driver for initializing the PCI device; and the second OS is deployed with a second driver for reading the running information to execute the PCI device function.
[0124] Illustratively, the first driver is a complete driver of the PCI device, and the second driver is a part of the first driver.
[0125] Exemplarily, for the microkernel such as RTOS, the embedded system usually uses simple on-board IO devices instead of high-performance general-purpose PCI devices. For MCS, the simple and light use of PCI devices by RTOS is crucial. In the scheme provided by the application, the driver in the main system GPOS (the first OS) initializes all PCI devices, thereby reducing the work that needs to be done by the RTOS (the second OS). The driver in the RTOS directly reads the initialized PCI devices (running information of the VF module) in the shared memory, thereby making the RTOS more lightweight. Meanwhile, by using the existing SR-IOV technology of the PCI device, the main system GPOS virtually outputs multiple VFs from the limited PCI device and allocates the VFs to each RTOS. In the case of limited physical resources, the overall bare-metal hybrid deployment architecture has more PCI resources for use and better scalability.
[0126] As described above, in the static hybrid deployment scenario, the initialization of the existing PCI device is generally left to the RTOS itself. In the case of limited physical resources, only a small number of RTOS systems can be started. In addition, the initialization of all PCI devices in the RTOS also reduces the startup speed of the RTOS itself. The scheme provided by the application proposes a unified initialization and allocation of PCI resources, which mainly includes that the initialization of all PCI devices is completed by the main system GPOS. Based on the SR-IOV capability of the PCI device, a corresponding number of VFs are generated. The main system initializes all VFs and stores the information (running information) required for use in runtime into the shared memory. The RTOS only needs to use the running information to drive the VF to complete the corresponding work and provide the function of the PCI device.
[0127] Further, for the initialization of the PCI device left to the GPOS, the scheme provided by the application has better scalability. By using the VF capability, more RTOSs can be run in one environment. In addition, the RTOS does not need to initialize these PCI devices, thereby greatly reducing the complexity of the RTOS system and better ensuring the operation of the real-time operating system.
[0128] Further, for the general hybrid deployment technology, virtualization technology is generally used to simulate many devices for each device. Due to the use of software simulation, there is a certain delay. The application directly passes through the PCI device by using the SR-IOV capability of the PCI device, thereby having better performance.
[0129] Further, in the scheme of the application, the operating system reads the running information of the VF module, and the driver used when realizing the function of the PCI device needs to rewrite the native driver software. Based on this, the driver software can be further abstracted and managed, so that the native driver only initializes a part of the function, but does not need to rewrite the native driver, so that the scheme provided by the application has better adaptability.
[0130] For example, the current native driver is abstracted into a small-grained functional unit, such as abstracting the initialization part into a functional unit, and abstracting the part of reading the running information to provide the function of the PCI device into a functional unit. Then, in the operating system (such as the second OS described in the application) that needs to ensure real-time, the functional unit of the part of reading the running information to provide the function of the PCI device can be deployed, without the need to rewrite the native driver.
[0131] For example, the native driver of the PCI device can be designed in a function-configurable form. In the operating system (such as the second OS described in the application) that needs to ensure real-time, the native driver with part of the function closed can be deployed, without the need to rewrite the native driver.
[0132] The method and / or steps realized in each of the above embodiments can be realized by a computing device in the MCS, or by a component (such as a processor, a chip, a chip system, a circuit, a logic module, or software) in the computing device.
[0133] The above mainly introduces the scheme provided by the application. Accordingly, the application also provides a device for configuring PCI device resources, which is used to realize various methods in the above method embodiments.
[0134] In some embodiments, the device for configuring PCI device resources contains hardware structures and / or software modules for performing various functions in order to realize the above functions. Those skilled in the art should easily realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in the present application can be realized in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the application.
[0135] The embodiment of the present application can divide the device for configuring PCI device resources into functional modules according to the method embodiment, for example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The integrated module can be realized in the form of hardware or in the form of a software functional module. It should be noted that the division of the modules in the embodiment of the present application is illustrative, and is only a logical functional division, and another division mode can be used in actual implementation.
[0136] The embodiment of the present application provides a device 80 for configuring PCI device resources, as shown in FIG. 8, the device 80 for configuring PCI device resources can include an initialization module 801 and a processing module 802.
[0137] The initialization module 801 is disposed in the first OS, and is configured to perform any operation in S701 and S702 of the method shown in FIG. 7.
[0138] The processing module 802 is disposed in the second OS, and is configured to perform the operation in S703 of the method shown in FIG. 7.
[0139] The embodiment of the present application provides a computing device 90 for deploying an MCS, which can be a physical device or a cluster composed of multiple physical devices, and the embodiment of the present application does not limit this. As shown in FIG. 9, the computing device 90 provided by the embodiment of the present application can include a processor 901, a bus 902, a communication interface 903, and a memory 904. The processor 901, the memory 904, and the communication interface 903 communicate through the bus 902. It should be understood that the number of processors and memories in the computing device 90 is not limited by the present application.
[0140] The bus 902 can be a PCI bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For convenience of representation, only one line is shown in FIG. 9, but it does not mean that there is only one bus or only one type of bus. The bus 902 can include a path for transmitting information between various components (for example, the memory 904, the processor 901, and the communication interface 903) of the computing device 90.
[0141] The processor 901 can include any one or more of a CPU, a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP) and the like.
[0142] The memory 904 can include volatile memory, such as random access memory (RAM), and non-volatile memory, such as read-only memory (ROM), a floppy disk, a hard disk drive, a solid state drive, or a combination of these.
[0143] The communication interface 903 uses a transceiving module such as, but not limited to, a network interface card, a transceiver, to enable communication between the computing device 900 and other devices or communication networks.
[0144] The memory 904 stores executable program code that, when executed by the processor 901, implements the functionality of the management node or the terminal node in the aforementioned method embodiments, respectively. That is, the memory 904 has instructions for performing the aforementioned communication method.
[0145] In yet another aspect, the embodiments of the present application also provide a computer program product containing instructions, which, when executed on a computing device, cause the computing device to perform the method described in any of the embodiments.
[0146] In yet another aspect, the embodiments of the present application also provide a computer readable storage medium. The computer readable storage medium stores computer programs or instructions, which, when executed on a computing device, cause the computing device to perform the method described in any of the embodiments.
[0147] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions according to the embodiments of the present application are generated. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions can be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (for example, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (for example, infrared, wireless, microwave, etc.) mode. The computer readable storage medium can be any available medium that can be accessed by a computer or data storage device such as one or more servers, data centers, etc. integrated with one or more media. The available media can be magnetic media (for example, floppy disk, hard disk, magnetic tape), optical media (for example, DVD), or semiconductor media (for example, solid state disk (SSD)) and the like.
[0148] Those skilled in the art can appreciate that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0149] Those skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working processes of the above-described system, device and unit can refer to the corresponding processes in the foregoing method embodiments, which will not be described here.
[0150] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other manners. For example, the described device embodiments are merely schematic. The division of the units is merely logical function division. There can be other division manners in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between different units, can be indirect couplings or communication connections through some interfaces, devices or units, and can be in electrical, mechanical or other forms.
[0151] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0152] In addition, each functional unit in the various embodiments of the present application can be integrated into one processing unit, or each unit can exist physically, or two or more units can be integrated into one unit.
[0153] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of a software product in essence or in the part that contributes to the prior art, or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or an access network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a ROM, a random access memory RAM, a magnetic disk or an optical disk, and various media that can store program codes.
[0154] Although the present application is described herein in conjunction with various embodiments, other variations of the disclosed embodiments can be understood and implemented by those skilled in the art with reference to the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "one" does not exclude a plurality. A single processor or other unit can implement several functions listed in the claims. Some measures described in mutually different dependent claims can be combined and produce good results.
[0155] Although the present application has been described in connection with certain specific features and embodiments thereof, it is to be understood that it is provided as an exemplification of the application and is not intended to limit the scope of the application, which is defined in the claims. Various modifications and changes can be made thereto without departing from the spirit and scope of the application. Accordingly, it is intended that all such modifications and changes be included within the scope of the application as claimed. Obviously, many modifications and variations of the present application are possible in light of the above teachings. It is, therefore, to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.
Claims
1. A method for configuring peripheral component interconnect standard PCI device resources, characterized in that: Applied to a computer system, the computer system includes a first operating system (OS), a second OS, a memory, and a PCI device; the shared memory of the second OS is configured in the memory; the method includes: The first OS virtualizes the PCI device into a virtual function VF module; The first OS initializes the VF module, obtains running information of the VF module, and stores the running information of the VF module in the shared memory; The second OS provides the function of the PCI device by reading the operation information of the VF module in the shared memory.
2. The method according to claim 1, characterized in that The PCI device includes one or more of the following devices: a network card, a sound card, a graphics card, a modem or a data processing unit (DPU).
3. The method according to claim 1 or 2, characterized in that The PCI device is a network card. The first OS initializes the VF module and obtains operation information of the VF module, including: Set the direct memory access DMA addressing address of the VF module; A mapping is established between the DMA addressing address and the virtual address of the virtual memory of the second OS; wherein the operation information of the VF module includes the DMA addressing address and the virtual address.
4. The method according to claim 3, characterized in that The second OS provides the function of the PCI device by reading the operation information of the VF module in the shared memory, including: When sending a message packet, the second OS reads the virtual address from the shared memory, writes the message packet to be sent into the virtual memory space indicated by the virtual address, and uses the running information of the VF to drive the network card to send the message packet to be sent; When receiving a message packet, the second OS reads the virtual address from the shared memory, and reads the message packet from the virtual memory space indicated by the virtual address.
5. The method according to any one of claims 1 to 3, characterized in that The first OS is a general purpose operating system GPOS, and the second OS is a real-time operating system RTOS.
6. The method according to any one of claims 1 to 5, characterized in that There are multiple second OSs, and each second OS corresponds to one shared memory; The first OS virtualizes the PCI device into a virtual function VF module, including: the first OS virtualizing a VF module for each of the second OSs; Initializing, by the first OS, the VF module, obtaining running information of the VF module, and storing the running information of the VF module in the shared memory includes: for any second OS among the second OSs, initializing, by the first OS, the VF module of the second OS, obtaining running information of the VF module of the second OS, and storing the running information of the VF module of the second OS in the shared memory corresponding to the second OS.
7. The method according to any one of claims 1 to 6, characterized in that A management module is deployed in the first OS, and the management module is used to manage and control the second OS, and the management and control includes any of the following operations: create, start, stop, delete, manage, monitor or shut down.
8. The method according to any one of claims 1 to 7, characterized in that The computer system is a mixed criticality system MCS.
9. A device for configuring peripheral component interconnect standard PCI device resources, characterized in that: Applied to a computer system, the computer system includes a first operating system (OS), a second OS, a memory, and a PCI device; the memory is configured with a shared memory corresponding to the second OS; the device includes: an initialization module deployed in the first OS, configured to virtualize the PCI device into a virtual function (VF) module; initialize the VF module, obtain operation information of the VF module, and store the operation information of the VF module in the shared memory; The processing module deployed in the second OS is used to read the running information of the VF module in the shared memory to provide the function of the PCI device.
10. A computing device, characterized in that The method comprises a memory and a processor, wherein the memory stores a program code, and when the processor executes the program code, the processor is configured to execute the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium includes computer instructions; when the computer instructions are executed in a computing device, the computing device executes the method according to any one of claims 1 to 8.
12. A computer program product, characterized in that When the computer program product is run in a computing device, the computing device performs the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Method and apparatus for sharing memory medium between multiple operating systems
CN101477511A
Multi-root I / O (Input / Output) virtualization sharing method and system
CN102707991A
Direct I / O virtualization method and device used for multi-root sharing system
CN102819447A
Computer system and memory access device
CN107894913A
Resource management method, computing device and computer readable storage medium
CN116974690A