Data processing method based on DPU, electronic equipment and storage medium
By using DPU chips to transfer data in the communication between virtual machines and hosts, the problem of high CPU occupancy is solved, and the user experience and device performance are improved.
Patent Information
- Application Number
- CN202411114781.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-08-14
AI Technical Summary
The communication method between the virtual machine and the host depends on the CPU, resulting in a high CPU occupancy rate, affecting the running speed and user experience of other tasks of the device.
The DPU-based data processing method is adopted to transfer data in the memory through the DPU chip in the network card, and notify the central processor after the data transfer is completed, reducing the management burden of the central processor and reducing the CPU occupancy rate.
It effectively reduces the occupancy rate of the central processor, improves the user experience, and reduces the impact on the running speed of other tasks.
Smart Images

Figure CN118981358A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a DPU-based data processing method, electronic device and storage medium. Background Art
[0002] Virtualization Input / Output (virtio) is a standardized framework for providing high-performance virtual devices in a virtualized environment. It makes the communication between virtual machines and host machines more efficient by separating the front-end and back-end.
[0003] At present, the communication between the virtual machine and the host is usually that the virtio front end is located in the virtual machine, and the virtio back end is implemented by the host's central processing unit (CPU) and memory. Finally, the communication between the virtual machine and the host is completed through the separated virtio front and back ends. It can be seen that this communication method requires CPU support in the virtio back end, and the CPU itself, as the core component of the device, needs to be responsible for processing most of the device's computing tasks and control instructions. Since the virtio back end needs to manage and operate a large amount of data, this will lead to a high CPU occupancy rate, thereby affecting the running speed of other tasks of the device and a poor user experience. Summary of the invention
[0004] In order to solve the above technical problems, the present application provides a DPU-based data processing method, electronic device and storage medium, which can save CPU resources and improve user experience.
[0005] In a first aspect, the present application provides an electronic device, comprising: a network card, a central processing unit, and a memory connected via a bus; the network card comprises a DPU chip; the central processing unit is used to: when determining that a data operation needs to be performed, send a data operation notification to the DPU chip in the network card; the DPU chip in the network card is used to: determine a target circular queue according to the data operation notification; move data in the memory according to a target descriptor in the target circular queue; after the data move is completed, add the information of the target descriptor to a completion circular queue buffer; the central processing unit is also used to: when the target descriptor information is read in the completion circular queue buffer, determine that the target descriptor has been used up and release the target descriptor.
[0006] In the second aspect, the present application provides a DPU-based data processing method, including: when receiving a data operation notification, determining a target ring queue according to the data operation notification; moving data according to a target descriptor in the target ring queue; after the data move is completed, adding the target descriptor information to a completion ring queue buffer to indicate that the target descriptor has been used up.
[0007] In a third aspect, the present application provides a computer-readable storage medium, including: a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, it implements the DPU-based data processing method as in the second aspect.
[0008] In a fourth aspect, the present application provides a computer program product, comprising: when the computer program product runs on a computer, the computer implements the DPU-based data processing method as in the second aspect.
[0009] The technical solution provided by the present application has the following advantages compared with the prior art: First, when the central processor determines that a data operation needs to be performed, it sends a data operation notification to the DPU chip in the network card. After that, the DPU chip in the network card determines the target circular queue according to the data operation notification, and moves the data in the memory according to the target descriptor in the target circular queue; after the data is moved, the information of the target descriptor is added to the completion circular queue buffer. Finally, when the central processor completes the circular queue buffer and reads the information of the target descriptor, it determines that the target descriptor has been used up and releases the target descriptor. In this way, when the central processor determines that a data operation needs to be performed, the DPU chip in the network card is used to move the data in the memory, and the central processor is notified after the move is completed, that is, when managing the data in the target circular queue, the specific management process is performed by the DPU chip in the network card, and the central processor only needs to execute the sending of the data operation notification and the receiving of the processing completion information to complete the management of the target circular queue. In other words, the management of the target circular queue in the electronic device is no longer heavily dependent on the central processor, which greatly reduces the occupancy rate of the central processor and indirectly reduces the impact on the running speed of other tasks on the electronic device, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0011] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0012] Figure 1 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0013] Figure 2 A schematic diagram of an application scenario of a DPU-based data processing method provided in an embodiment of the present application;
[0014] Figure 3 One of the flow charts of the DPU-based data processing method provided in the embodiment of the present application;
[0015] Figure 4 The second flowchart of the DPU-based data processing method provided in the embodiment of the present application;
[0016] Figure 5 The third flowchart of the DPU-based data processing method provided in the embodiment of the present application;
[0017] Figure 6 A fourth flowchart of a DPU-based data processing method provided in an embodiment of the present application;
[0018] Figure 7 A fifth flowchart of a DPU-based data processing method provided in an embodiment of the present application;
[0019] Figure 8 Flow chart of the DPU-based data processing method provided in the embodiment of the present application is as follows:
[0020] Fig. 9 The seventh flowchart of the DPU-based data processing method provided in the embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0022] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only part of the embodiments of the present application, rather than all of the embodiments.
[0023] First, some nouns or terms involved in the specification and claims of this application are explained below.
[0024] Vring: short for virtio ring buffer, used to transfer data between virtual machines and the host machine.
[0025] The available ring queue buffer (avail_ring) is used to store the data header that needs to be moved. The data header contains the queue number and descriptor address of the ring queue. The descriptor address can be used to obtain the corresponding descriptor from the descriptor ring queue buffer (desc_ring).
[0026] Descriptor ring queue buffer (desc_ring): used to store descriptors that need to be moved. The descriptor contains the queue number of the ring queue, direct memory access (DMA) address, data length and other data flow movement information. It is used for data DMA operations to implement read and write operations of the virtual input / output (IO) interface.
[0027] Completion ring queue buffer (used_ring): used to store the completion information that needs to be returned, including the queue number of the completion ring queue, the completion data header and the completion descriptor.
[0028] The following, in conjunction with the accompanying drawings, describes in detail the DPU-based data processing method, electronic device and storage medium provided in the embodiments of the present application through specific embodiments.
[0029] At present, the communication between the virtual machine and the host is usually that the virtio front end is located in the virtual machine, and the virtio back end is implemented by the host's central processing unit (CPU) and memory. Finally, the communication between the virtual machine and the host is completed through the separated virtio front and back ends. It can be seen that this communication method requires CPU support in the virtio back end, and the CPU itself, as the core component of the device, needs to be responsible for processing most of the device's computing tasks and control instructions. Since the virtio back end needs to manage and operate a large amount of data, this will lead to a high CPU occupancy rate, thereby affecting the running speed of other tasks of the device and a poor user experience.
[0030] In response to the above problems, an embodiment of the present application provides a DPU-based data processing method, which can determine the target ring queue according to the data operation notification when receiving the data operation notification; move data according to the target descriptor in the target ring queue; after the data move is completed, add the target descriptor information to the completion ring queue buffer to indicate that the target descriptor has been used up, which can reduce the occupancy rate of the central processing unit and indirectly reduce the impact on the running speed of other tasks on the electronic device, thereby improving the user experience.
[0031] The DPU-based data processing method provided in the embodiment of the present application can be executed by a DPU-based data processing device, and the DPU-based data processing device can be hardware or software. When the DPU-based data processing device is hardware, it can be various electronic devices with a DPU-based data processing function, including but not limited to mobile phones, computers, computers, tablet computers, televisions, smart TVs, vehicle-mounted equipment, smart vehicles, laser projection equipment, monitors, electronic whiteboards (electronic bulletin boards), electronic desktops (electronic tables), etc. When the DPU-based data processing device is software, it can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules, or it can be implemented as a single software or software module. No specific limitation is made here.
[0032] Figure 1 A software configuration diagram of an electronic device provided in an embodiment of the present application, such as Figure 1 As shown, the electronic device includes a central processing unit 101, a network card 102, a memory 103 and a bus 104. The central processing unit 101, the network card 102 and the memory 103 are connected via the bus 104.
[0033] The CPU 101 may be a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application.
[0034] The memory 103 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.
[0035] The network card 102 can be a wired network card (such as an Ethernet card) or a wireless network card (such as a Wi-Fi network card), which allows electronic devices to perform high-speed data exchange in a local area network (LAN), a wireless local area network (WLAN), or a wide area network (WLAN).
[0036] In some embodiments, the electronic device may further include a communication interface, wherein the communication interface, the central processor 101, the network card 102, and the memory 103 may be coupled to each other, for example, via a bus 104. The communication interface is used to exchange information with other devices, for example, to support information exchange between the electronic device and other devices.
[0037] In some embodiments, the network card 102 includes a DPU chip.
[0038] When the central processing unit 101 determines that a data operation needs to be performed, it sends a data operation notification to the DPU chip in the network card 102; the DPU chip in the network card 102 determines the target circular queue according to the data operation notification; moves data in the memory 103 according to the target descriptor in the target circular queue; after the data movement is completed, the information of the target descriptor is added to the completion circular queue buffer; when the central processing unit 101 completes the circular queue buffer and reads the information of the target descriptor, it determines that the target descriptor has been used up and releases the target descriptor.
[0039] In the above scheme, when the CPU determines that a data operation needs to be performed, the DPU chip in the network card is used to move data in the memory, and the CPU is notified after the move is completed. That is, when managing the data in the target circular queue, the specific management process is performed by the DPU chip in the network card, and the CPU only needs to send data operation notifications and receive processing completion information to complete the management of the target circular queue. In other words, the management of the target circular queue in the electronic device is no longer heavily dependent on the CPU, which greatly reduces the CPU occupancy rate and indirectly reduces the impact on the running speed of other tasks on the electronic device, thereby improving the user experience.
[0040] In some embodiments, Figure 1 and Figure 2As shown, the DPU chip includes a virtio-net conversion layer and a virtio module; the virtio-net conversion layer is used to: determine the target circular queue according to the data operation notification when receiving the data operation notification; read the descriptor data header of the available circular queue buffer according to the target circular queue; pass the descriptor data header to the virtio module; the virtio module is used to: parse the descriptor data header to obtain the descriptor address; access the target descriptor circular queue buffer corresponding to the descriptor address, read the target descriptor; and move data in the memory 103 according to the target descriptor; return the completion information to the virtio-net conversion layer after the data move is completed; the virtio-net conversion layer is also used to: after obtaining the completion information, add the information of the target descriptor to the completion circular queue buffer.
[0041] In the above scheme, the data in the memory can be moved through the interaction between the virtio-net conversion layer and the virtio module in the DPU chip, avoiding the problem of high CPU occupancy when the virtio backend is supported by the central processing unit of the electronic device, thereby affecting the running speed of other tasks of the device, thereby improving the user experience.
[0042] In some embodiments, the virtio-net translation layer is specifically used to: determine the available ring write pointer (avail_wr_idx), available ring read pointer (avail_rd_idx), and descriptor header prefetch quantity (desc_fetch_cnt) of the target ring queue when the data operation notification is used to indicate receiving data; when the available ring write pointer is greater than the available ring read pointer and the descriptor header prefetch quantity is less than a first threshold, read the descriptor data header of an available ring queue buffer. In some embodiments, the virtio-net translation layer is also used to: receive an available ring write pointer update indication before receiving the data operation notification, and add N to the available ring write pointer according to the update indication; N is used to indicate the number of prefetched descriptor data headers.
[0043] In the above scheme, when the available ring write pointer, the available ring read pointer, and the number of pre-fetched descriptor headers meet the conditions, a descriptor data header can be read, so as to facilitate the subsequent reading of the target descriptor according to the descriptor data header. On the one hand, it avoids the abnormal situation that when the descriptor data header is read directly, there is no descriptor data header that meets the conditions in the available ring queue buffer, thereby ensuring the normal operation of the electronic device. On the other hand, the actual location of the descriptor in the memory can be referenced through the descriptor data header, without the need to copy the data, thereby improving the efficiency of data transmission.
[0044] In some embodiments, the virtio-net conversion layer is specifically used to: after reading the descriptor data header, increase the available ring read pointer and the descriptor header prefetch quantity by one; determine the number of internal cache descriptors; and when the descriptor header prefetch quantity is greater than a second threshold and the number of internal cache descriptors is less than a third threshold, pass the descriptor data header to the virtio module.
[0045] In the above scheme, the available ring read pointer and the number of descriptor header pre-fetches can be maintained, and when the number of descriptor header pre-fetches and the number of internal cache descriptors meet the conditions, the descriptor data header is passed to the virtio module to facilitate the subsequent reading of the target descriptor according to the descriptor data header. On the one hand, it avoids the abnormal situation that the number of descriptor header pre-fetches is insufficient or the number of internal cache descriptors is too large when the target descriptor is read according to the descriptor data header when the descriptor data header is directly passed, thereby ensuring the normal operation of the electronic device. On the other hand, the actual location of the descriptor in the memory can be referenced through the descriptor data header, without the need to copy the data, thereby improving the efficiency of data transmission.
[0046] In some embodiments, the virtio-net translation layer is specifically used to: determine an available ring write pointer and an available ring read pointer of a target ring queue when a data operation notification is used to indicate sending data; increase the available ring write pointer by one; and read a descriptor data header of an available ring queue buffer when the available ring write pointer is greater than the available ring read pointer.
[0047] In the above scheme, when the available ring write pointer and the available ring read pointer meet the conditions, a descriptor data header can be read, so as to facilitate the subsequent reading of the target descriptor according to the descriptor data header. On the one hand, it avoids the abnormal situation that when the descriptor data header is directly read, there is no descriptor data header that meets the conditions in the available ring queue buffer, thereby ensuring the normal operation of the electronic device. On the other hand, the actual location of the descriptor in the memory can be referenced through the descriptor data header, without the need to copy the data, thereby improving the data transmission efficiency.
[0048] In some embodiments, the virtio-net conversion layer is specifically used to: after reading the descriptor data header, determine the available ring read pointer, the descriptor write pointer (desc_wr_idx), and the descriptor read pointer (desc_rd_idx); increase the available ring read pointer by one; and when the difference between the descriptor write pointer and the descriptor read pointer is one, pass the descriptor data header to the virtio module.
[0049] In the above scheme, the available ring read pointer and descriptor write pointer are maintained, and when the descriptor write pointer and the descriptor read pointer meet the conditions, the descriptor data header is passed to the virtio module, so as to read the target descriptor according to the descriptor data header. On the one hand, the descriptor data header is passed when the difference between the descriptor write pointer and the descriptor read pointer is limited to one, that is, when there is one descriptor left in the cache, the descriptor data header is passed to indicate to read the next descriptor, which can save cache resources as much as possible when there are descriptors available in the cache. On the other hand, the actual location of the descriptor in the memory can be referenced through the descriptor data header, and there is no need to copy the data, which improves the data transmission efficiency.
[0050] In some embodiments, the virtio-net translation layer is further used to: after the virtio module reads a target descriptor, increase the descriptor write pointer by one; after the virtio module uses a target descriptor to move data, increase the descriptor read pointer by one; the virtio-net translation layer is specifically used to: after obtaining the completion information, determine the completion pointer (used_idx), and add the descriptor data header and completion pointer of the target descriptor to the completion ring queue buffer; increase the completion pointer by one.
[0051] In the above scheme, the descriptor write pointer, descriptor read pointer and completion pointer can be maintained, so that the descriptor write pointer, descriptor read pointer and completion pointer can be used to process the data in the target circular queue again, thereby ensuring the sustainable use of resources.
[0052] In some embodiments, the central processor 101 is specifically used to: when it is determined that a data operation needs to be performed, read the completion pointer from the completion ring queue buffer and determine the available ring read pointer; when the completion pointer is less than the available ring read pointer, send a data operation notification to the DPU chip in the network card 102.
[0053] In the above scheme, the available ring read pointer and the completion pointer can be used to indicate the data processing capability of the virtio module in the DPU chip, thereby ensuring the normal operation of the electronic device.
[0054] Figure 3 A flow chart of a DPU-based data processing method provided in an embodiment of the present application is applied to a DPU chip, such as Figure 3 As shown, the data processing method based on DPU may include the following steps:
[0055] S11. When a data operation notification is received, a target ring queue is determined according to the data operation notification.
[0056] First, the data operation notification is usually issued by the central processor. The central processor determines that the data operation needs to be performed. It can be determined that the data operation needs to be performed when it is determined that there is a virtual IO operation requirement. After that, the central processor sends the data operation notification to the DPU in the network card in the following way: Figure 2 As shown, the central processing unit sends a data operation notification to the DPU of the network card through the memory via the bus.
[0057] Afterwards, when the data operation notification is received, the target ring queue is determined according to the data operation notification. Specifically, the method of determining the target ring queue according to the data operation notification may be to determine the target ring queue according to the ring queue information in the data operation notification. Exemplarily, the data operation notification may include the ring queue information, and the method of determining the target ring queue according to the data operation notification may be to determine the target ring queue according to the ring queue information in the data operation notification.
[0058] S12. Move data according to the target descriptor in the target ring queue.
[0059] In some embodiments, Figure 4 As shown, according to the method of moving data by the target descriptor in the target ring queue, the following steps may be included:
[0060] S121. Read the descriptor data header of the available circular queue buffer according to the target circular queue.
[0061] Specifically, according to the method of reading the descriptor data header of the available ring queue buffer by the target ring queue, the descriptor data header of an available ring queue buffer can be read when the available ring write pointer, the available ring read pointer, and the descriptor header prefetch quantity meet the constraints.
[0062] S122. Parse the descriptor data header to obtain the descriptor address.
[0063] S123. Access the target descriptor circular queue buffer corresponding to the descriptor address and read the target descriptor.
[0064] S124. Move data in the memory according to the target descriptor.
[0065] First, since the target descriptor circular queue buffer is located in the memory, data is moved in the memory according to the target descriptors in the target descriptor circular queue buffer.
[0066] Secondly, the target descriptor includes data flow movement information such as the queue number, DMA address and data length of the target ring queue. Therefore, the way to move data in the memory according to the target descriptor is to access the memory according to the DMA address in the descriptor and move the data according to the data flow movement information in the descriptor.
[0067] In the above solution, data migration can be completed through the DPU chip, avoiding the problem of high CPU occupancy when the virtio backend is supported by the central processor of the electronic device, thereby affecting the running speed of other tasks of the device, and improving the user experience. In addition, the descriptor can be used to directly reference the actual location of the data in the memory, without the need to copy the data, thus improving the data transmission efficiency.
[0068] S13. After the data is moved, the information of the target descriptor is added to the completion ring queue buffer to indicate that the target descriptor has been used up.
[0069] The completion ring queue buffer is usually used to store the completion information to be returned, which generally includes the queue number of the completion ring queue and the descriptor data header of the completion descriptor. Therefore, the method of adding the information of the target descriptor to the completion ring queue buffer is to add the queue number of the target ring queue and the descriptor data header of the target descriptor to the completion ring queue buffer. In this way, when the CPU reads the descriptor data header of the target descriptor in the completion ring queue buffer, it determines that the target descriptor of the target ring queue has been used up and releases the target descriptor.
[0070] In the above scheme, when it is determined that data operations need to be performed, the DPU chip is used to move data, that is, when managing the data in the target circular queue, the specific management process is performed by the DPU chip, and the central processing unit only needs to send data operation notifications and receive processing completion information to complete the management of the target circular queue. In other words, the management of the target circular queue in the electronic device is no longer heavily dependent on the central processing unit, which greatly reduces the occupancy rate of the central processing unit and indirectly reduces the impact on the running speed of other tasks on the electronic device, thereby improving the user experience.
[0071] In some embodiments, the DPU-based data processing method may further include: managing the target ring queue by maintaining the available ring write pointer (avail_wr_idx), the available ring read pointer (avail_rd_idx), the descriptor header pre-fetch quantity (desc_fetch_cnt), the descriptor write pointer (desc_wr_idx), the descriptor read pointer (desc_rd_idx), and the completion pointer (used_idx). In some embodiments, the maximum values of the available ring write pointer, the available ring read pointer, the descriptor write pointer, the descriptor read pointer, and the completion pointer are all preset, for example, a default value or a value set according to actual conditions, for example, the maximum values of the available ring write pointer, the available ring read pointer, and the completion pointer are all 32768, and the maximum values of the descriptor read pointer and the descriptor write pointer are both 4.
[0072] In some embodiments, the DPU-based data processing method further includes: before receiving the data operation notification, receiving an available ring write pointer update indication, and adding N to the available ring write pointer according to the update indication.
[0073] Wherein, N is used to indicate the number of pre-fetched descriptor data headers, and these descriptor data headers are used to move data when a data operation notification indicating receiving data is received.
[0074] Specifically, the CPU sends an available ring write pointer update indication during the initialization prefetching phase (i.e., the phase of initializing the number of prefetching descriptor data headers), or when the number of descriptor data headers is less than the lowest horizontal line. Thus, when receiving the available ring write pointer update indication, the available ring write pointer is increased by N according to the update indication. The values of the lowest horizontal line and N are both preset, for example, default values, or values set according to actual conditions, for example, N is 32768 and the lowest horizontal line is 4.
[0075] In the above scheme, the available ring write pointer can be updated in time during the initialization prefetch phase or when the number of descriptor data headers is less than the minimum horizontal line, thereby avoiding the problem that the DPU-based data processing method cannot run due to insufficient available ring write pointers.
[0076] In some embodiments, Figure 5 As shown, according to the method of the target circular queue reading the descriptor data header of the available circular queue buffer, the following steps may be included:
[0077] S1211. When the data operation notification is used to indicate receiving data, determine the available ring write pointer, available ring read pointer, and descriptor header prefetch quantity of the target ring queue.
[0078] Specifically, the available ring write pointer, the available ring read pointer, and the number of descriptor header prefetches are all values maintained by the virtio-net conversion layer in the DPU. Therefore, the method for determining the available ring write pointer, the available ring read pointer, and the number of descriptor header prefetches of the target ring queue can be to directly read the available ring write pointer, the available ring read pointer, and the number of descriptor header prefetches corresponding to the target ring queue.
[0079] S1212: When the available ring write pointer is greater than the available ring read pointer and the descriptor header pre-fetch quantity is less than a first threshold, read a descriptor data header of an available ring queue buffer.
[0080] The first threshold is preset, for example, a default value, or a value set according to actual conditions, for example, the first threshold is 16.
[0081] In the above scheme, when the available ring write pointer, the available ring read pointer, and the number of pre-fetched descriptor headers meet the conditions, a descriptor data header can be read, so as to facilitate the subsequent reading of the target descriptor according to the descriptor data header. On the one hand, it avoids the abnormal situation that when the descriptor data header is read directly, there is no descriptor data header that meets the conditions in the available ring queue buffer, thereby ensuring the normal operation of the electronic device. On the other hand, the actual location of the descriptor in the memory can be referenced through the descriptor data header, without the need to copy the data, thereby improving the efficiency of data transmission.
[0082] In some embodiments, Figure 6 As shown, before parsing the descriptor data header, the DPU-based data processing method further includes the following steps:
[0083] S1201. After reading the descriptor data header, increase the available ring read pointer and the descriptor header prefetch quantity by one.
[0084] Specifically, after reading the descriptor data header, since the descriptor data header of an available ring queue buffer has been read, the available ring read pointer and the descriptor header prefetch quantity are both increased by one; at the same time, the available ring write pointer is decreased by one.
[0085] S1202: Determine the number of internal cache descriptors.
[0086] Specifically, for immediate use, a small number of descriptors may be cached in the DPU. Therefore, the number of descriptors in the internal cache may be determined by determining the number of descriptors in the current internal cache.
[0087] S1203: When the number of pre-fetched descriptor headers is greater than the second threshold and the number of internal cache descriptors is less than the third threshold, parse the descriptor data header.
[0088] Among them, the second threshold is smaller than the first threshold; the second threshold and the third threshold are both preset, for example, default values, or values set according to actual conditions, for example, the second threshold is 4 and the third threshold is 4.
[0089] In the above scheme, the available ring read pointer and the number of pre-fetched descriptor headers can be maintained, and when the number of pre-fetched descriptor headers and the number of internal cache descriptors meet the conditions, the descriptor data header is parsed to facilitate the subsequent reading of the target descriptor according to the descriptor data header. On the one hand, it avoids the abnormal situation that the number of pre-fetched descriptor headers is insufficient or the number of internal cache descriptors is too large when the target descriptor is read according to the descriptor data header when the descriptor data header is directly passed, thereby ensuring the normal operation of the electronic device. On the other hand, the actual location of the descriptor in the memory can be referenced through the descriptor data header, without the need to copy the data, thereby improving the efficiency of data transmission.
[0090] In some embodiments, Figure 7 As shown, according to the method of the target circular queue reading the descriptor data header of the available circular queue buffer, the following steps may be included:
[0091] S1213: When the data operation notification is used to indicate sending data, determine an available ring write pointer and an available ring read pointer of the target ring queue.
[0092] Specifically, the method of determining the available ring write pointer and the available ring read pointer of the target ring queue is the same as the method of determining the available ring write pointer and the available ring read pointer of the target ring queue in step S1211, which will not be repeated here.
[0093] S1214, increase the available ring write pointer by one.
[0094] S1215. When the available ring write pointer is greater than the available ring read pointer, read a descriptor data header of an available ring queue buffer.
[0095] In the above scheme, when the available ring write pointer and the available ring read pointer meet the conditions, a descriptor data header can be read, so as to facilitate the subsequent reading of the target descriptor according to the descriptor data header. On the one hand, it avoids the abnormal situation that when the descriptor data header is directly read, there is no descriptor data header that meets the conditions in the available ring queue buffer, thereby ensuring the normal operation of the electronic device. On the other hand, the actual location of the descriptor in the memory can be referenced through the descriptor data header, without the need to copy the data, thereby improving the data transmission efficiency.
[0096] In some embodiments, Figure 8 As shown, before parsing the descriptor data header, the DPU-based data processing method further includes the following steps:
[0097] S1204. After reading the descriptor data header, determine the available ring read pointer, descriptor write pointer, and descriptor read pointer.
[0098] Specifically, the available ring read pointer, descriptor write pointer, and descriptor read pointer are all values maintained by the virtio-net translation layer in the DPU. Therefore, the method for determining the available ring read pointer, descriptor write pointer, and descriptor read pointer can be to directly read and determine the available ring read pointer, descriptor write pointer, and descriptor read pointer.
[0099] S1205, increase the available ring read pointer by one.
[0100] Specifically, after reading the descriptor data header, since the descriptor data header of an available ring queue buffer has been read, the available ring read pointer is increased by one; at the same time, the available ring write pointer is decreased by one.
[0101] S1206. When the difference between the descriptor write pointer and the descriptor read pointer is one, parse the descriptor data header.
[0102] Specifically, the difference between the descriptor write pointer and the descriptor read pointer is one, which means that there is only one descriptor available in the internal cache at this time. If the descriptor is not read, the subsequent processing speed may be affected. Therefore, the descriptor data header is parsed at this time, and the descriptor is continued to be read to ensure the stable existence of the descriptor in the internal cache.
[0103] In the above scheme, the available ring read pointer and descriptor write pointer are maintained, and when the descriptor write pointer and the descriptor read pointer meet the conditions, the descriptor data header is passed to the virtio module, so as to read the target descriptor according to the descriptor data header. On the one hand, the descriptor data header is passed when the difference between the descriptor write pointer and the descriptor read pointer is limited to one, that is, when there is one descriptor left in the cache, the descriptor data header is passed to indicate to read the next descriptor, which can save cache resources as much as possible when there are descriptors available in the cache. On the other hand, the actual location of the descriptor in the memory can be referenced through the descriptor data header, and there is no need to copy the data, which improves the data transmission efficiency.
[0104] In some embodiments, Fig. 9 As shown, the DPU-based data processing method also includes the following steps:
[0105] S1207. After reading a target descriptor, increase the descriptor write pointer by one.
[0106] Specifically, after reading a target descriptor, since a target descriptor of a target descriptor ring queue buffer has been read, the available ring read pointer is increased by one; at the same time, the available ring write pointer is decreased by one. In addition, since the target descriptor is read from the target descriptor ring queue buffer, the target descriptor needs to be written into the internal cache, so at this time, the descriptor write pointer is increased by one to record the descriptor written into the internal cache.
[0107] S1208. After using a target descriptor to move data, increase the descriptor read pointer by one.
[0108] Specifically, after a target descriptor is used to move data, it means that the target descriptor has been read and used, so the descriptor read pointer is increased by one at this time.
[0109] S1209: After the data migration is completed, determine the completion pointer.
[0110] Specifically, the completion pointer is also a value maintained by the virtio-net translation layer in the DPU, so the completion pointer can be read directly.
[0111] S1210 . Add the descriptor data header and completion pointer of the target descriptor to the completion ring queue buffer, and increase the completion pointer by one.
[0112] The completion pointer is used to determine whether the DPU can continue to process new data according to the data operation notification.
[0113] In the above scheme, the descriptor write pointer, descriptor read pointer and completion pointer can be maintained, so that the descriptor write pointer, descriptor read pointer and completion pointer can be used to process the data in the target circular queue again, thereby ensuring the sustainable use of resources.
[0114] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the DPU-based data processing method in the above method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0115] The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0116] An embodiment of the present application provides a computer program product, which stores a computer program. When the computer program is executed by a processor, each process of the DPU-based data processing method in the above method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0117] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media that include computer-usable program code.
[0118] In this application, memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0119] In this application, computer-readable media includes permanent and non-permanent, removable and non-removable storage media. Storage media can be implemented by any method or technology to store information, and the information can be computer-readable instructions, data structures, modules of programs or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. According to the definition in this article, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data and carrier waves.
[0120] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0121] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An electronic device, characterized in that: include: Network card, CPU, memory and bus; The network card, the central processing unit, and the memory are connected via the bus; The network card includes a DPU chip; The central processor is used to: when determining that a data operation needs to be performed, send a data operation notification to the DPU chip in the network card; The DPU chip in the network card is used to: determine the target circular queue according to the data operation notification; move data in the memory according to the target descriptor in the target circular queue; after the data movement is completed, add the information of the target descriptor to the completion circular queue buffer; The central processing unit is further used for: when the information of the target descriptor is read in the completion ring queue buffer, determining that the target descriptor has been used up and releasing the target descriptor.
2. The electronic device according to claim 1, characterized in that: The DPU chip includes a virtio-net conversion layer and a virtio module; The virtio-net conversion layer is used to: upon receiving a data operation notification, determine a target circular queue according to the data operation notification; read a descriptor data header of an available circular queue buffer according to the target circular queue; and pass the descriptor data header to the virtio module; The virtio module is used to: parse the descriptor data header to obtain the descriptor address; Accessing the target descriptor circular queue buffer corresponding to the descriptor address to read the target descriptor; and moving the data in the memory according to the target descriptor; and returning completion information to the virtio-net conversion layer after the data movement is completed; The virtio-net conversion layer is further used to: after obtaining the completion information, add the information of the target descriptor to the completion ring queue buffer.
3. The electronic device according to claim 2, characterized in that: The virtio-net conversion layer is specifically used for: When the data operation notification is used to indicate receiving data, determining an available ring write pointer, an available ring read pointer, and a descriptor header prefetch quantity of a target ring queue; When the available ring write pointer is greater than the available ring read pointer and the descriptor header pre-fetch quantity is less than a first threshold, a descriptor data header of an available ring queue buffer is read.
4. The electronic device according to claim 3, characterized in that: The virtio-net conversion layer is specifically used for: After reading the descriptor data header, the available ring read pointer and the descriptor header pre-fetch quantity are both increased by one; Determine the number of internal cache descriptors; When the number of pre-fetched descriptor headers is greater than a second threshold and the number of internal cache descriptors is less than a third threshold, the descriptor data header is transferred to the virtio module.
5. The electronic device according to claim 3, characterized in that: The virtio-net conversion layer is also used to: before receiving the data operation notification, receive an available ring write pointer update indication, and add N to the available ring write pointer according to the update indication; N is used to indicate the number of pre-fetched descriptor data headers.
6. The electronic device according to claim 2, characterized in that: The virtio-net conversion layer is specifically used for: When the data operation notification is used to indicate sending data, determining an available ring write pointer and an available ring read pointer of the target ring queue; Incrementing the available ring write pointer by one; When the available ring write pointer is greater than the available ring read pointer, a descriptor data header of an available ring queue buffer is read.
7. The electronic device according to claim 6, characterized in that: The virtio-net conversion layer is specifically used for: After reading the descriptor data header, determining an available ring read pointer, a descriptor write pointer, and a descriptor read pointer; Incrementing the available ring read pointer by one; When the difference between the descriptor write pointer and the descriptor read pointer is one, the descriptor data header is transferred to the virtio module.
8. The electronic device according to claim 4 or 7, characterized in that: The virtio-net translation layer is also used to: After the virtio module reads a target descriptor, the descriptor write pointer is incremented by one; After the virtio module uses a target descriptor to move data, the descriptor read pointer is incremented by one; The virtio-net conversion layer is specifically used for: After the completion information is acquired, a completion pointer is determined, and the descriptor data header and the completion pointer of the target descriptor are added to the completion ring queue buffer; and the completion pointer is increased by one.
9. The electronic device according to claim 7, characterized in that: The central processing unit is specifically used for: When it is determined that a data operation needs to be performed, a completion pointer is read from a completion ring queue buffer, and an available ring read pointer is determined; When the completion pointer is equal to the available ring read pointer, a data operation notification is sent to the DPU chip in the network card.
10. A data processing method based on DPU, characterized in that: include: When receiving a data operation notification, determining a target ring queue according to the data operation notification; Moving data according to the target descriptor in the target ring queue; After the data migration is completed, the information of the target descriptor is added to the completion ring queue buffer to indicate that the target descriptor has been used up.
11. A computer-readable storage medium, characterized in that: include: The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the DPU-based data processing method as claimed in claim 10 is implemented.
12. A computer program product, characterized in that When the computer program product is executed on a computer, the computer is enabled to implement the DPU-based data processing method according to claim 10 .
Citation Information
Patent Citations
Descriptor queue and memory optimization method, system and application of network storage service
CN113535395A
Data packet receiving method and device, equipment and storage medium
CN116633879A
Arm-based Virtio-net control queue implementation method
CN116820684A
Method and device for sending anomaly detection and method and device for receiving anomaly detection
CN117014339A
Problem diagnosis method and device for virtio equipment, equipment, storage medium and program product
CN118227503A
Cited By
Fault-tolerant method and system for DMA efficient data transmission
CN120086058A
A fault-tolerant method and system for DMA efficient data transmission
CN120086058B
