A data read-write method, device and intelligent network card
By introducing multiple data lists and counter mechanisms into the smart network interface card (NIC), the problems of data redundancy and complexity in the management of shared data space in multiple linked lists are solved, achieving efficient utilization of storage space and simplified resource management, thereby improving operational efficiency and scalability.
Patent Information
- Application Number
- CN202411554023.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2044-11-01
AI Technical Summary
In existing technologies, the management of shared data space using multiple linked lists suffers from problems such as data redundancy, complex management, and inconvenient resource release. This is especially true in smart network interface card (NIC) data caching, particularly in scenarios involving large-scale data storage, replication, and forwarding, where bitmap-based methods lead to wasted space and low efficiency.
By employing multiple data linked lists combined with a counter mechanism, data sharing and independent management are achieved through shared data space and counter management. The first and second counters are used to count nodes of shared and non-shared data respectively, simplifying resource release and expansion operations.
It achieves efficient utilization of storage space, improves operational efficiency, reduces register resource consumption, simplifies resource management, and significantly improves performance and scalability, especially in high-frequency operation scenarios.
Smart Images

Figure CN119493742B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of data storage, and particularly relates to a data read-write method and device and an intelligent network card. BACKGROUND
[0002] In data storage, a linked list structure is widely used because it can fully utilize storage space and achieve flexible dynamic management of storage space. In particular, in the aspect of data cache of an intelligent network card, there are cases of large-scale data storage, duplication and forwarding, and in these cases, multiple linked lists share part of the data space. SUMMARY
[0003] The present application aims to provide a data read-write method and device and an intelligent network card, and aims to solve the problems of data redundancy, complex management and resource release in the related art.
[0004] According to a first aspect of the present application, a data read-write method is provided, comprising:
[0005] establishing multiple data linked lists; each data linked list corresponds to a first counter and a second counter;
[0006] receiving a data write request; the data write request carries target data to be written and information of the target data;
[0007] determining whether the target data is shared data according to the information of the target data;
[0008] if the target data is shared data, adding a linked list node corresponding to the target data in each data linked list, and increasing the first counter and the second counter of each data linked list by 1;
[0009] if the target data is not shared data, adding a linked list node corresponding to the target data in a target data linked list corresponding to the target data, and increasing the second counter of the target data linked list by 1.
[0010] In an optional embodiment, the method further comprises:
[0011] after receiving the data write request, writing the target data to a storage unit, and writing a storage address of the storage unit in the linked list node corresponding to the target data.
[0012] In an optional embodiment, the method further comprises:
[0013] receiving a data read request; the data read request carries information of target data to be read;
[0014] determining a target data linked list corresponding to the target data according to the information of the target data;
[0015] determining whether the target data is shared data based on the target data linked list;
[0016] if the target data is shared data, removing a linked list node corresponding to the target data from the target data linked list, releasing a storage address of the target data if a first counter of the target data linked list is greater than a first counter of other data linked lists, and respectively reducing the first counter and a second counter of the target data linked list by 1;
[0017] if the target data is not shared data, removing a linked list node corresponding to the target data from the target data linked list, releasing a storage address of the target data, and reducing a second counter of the target data linked list by 1.
[0018] In an optional implementation, the releasing of the storage address of the target data comprises:
[0019] releasing a storage address of a storage unit of the target data recorded in the linked list node corresponding to the target data.
[0020] In an optional implementation, the target data is a data packet to be sent; the data write request is a packet sending request of the data packet, the information of the target data carried by the data write request comprises a shared identifier of the data packet, the shared identifier being used to identify whether the data packet is shared data; when the data packet is not shared data, the data write request further comprises a packet sending direction of the data packet, and the target data linked list is a data linked list corresponding to the packet sending direction.
[0021] In an optional implementation, the data read request is a packet scheduling request, the information of the target data carried by the data read request comprises a packet sending direction; the target data linked list is a data linked list corresponding to the packet sending direction, and the linked list node corresponding to the target data is a head pointer of the target data linked list.
[0022] According to a second aspect of the present application, a data read-write device is provided, comprising:
[0023] a establishing module, configured to establish a plurality of data linked lists; each data linked list comprises a first counter and a second counter;
[0024] a first receiving module, configured to receive a data write request; the data write request carries target data to be written and information of the target data;
[0025] a first determining module, configured to determine whether the target data is shared data according to the information of the target data;
[0026] a first increasing module, configured to increase a chain table node corresponding to the target data in each of the data chain tables if the target data is shared data, and increase the first counter and the second counter of each of the data chain tables by 1;
[0027] a second increasing module, configured to increase a chain table node corresponding to the target data in the target data chain table corresponding to the target data if the target data is not shared data, and increase the second counter of the target data chain table by 1.
[0028] In an optional implementation, the method further comprises:
[0029] a writing module, configured to write the target data into a storage unit after receiving a data writing request, and write a storage address of the storage unit into the chain table node corresponding to the target data.
[0030] In an optional implementation, the method further comprises:
[0031] a second receiving module, configured to receive a data reading request; the data reading request carries information of target data to be read;
[0032] a second determining module, configured to determine a target data chain table corresponding to the target data according to the information of the target data;
[0033] a third determining module, configured to determine whether the target data is shared data based on the target data chain table;
[0034] a first chain removing module, configured to remove the chain table node corresponding to the target data from the target data chain table if the target data is shared data, release the storage address of the target data when the first counter of the target data chain table is greater than the first counter of other data chain tables, and decrease the first counter and the second counter of the target data chain table by 1 respectively;
[0035] a second chain removing module, configured to remove the chain table node corresponding to the target data from the target data chain table if the target data is not shared data, release the storage address of the target data, and decrease the second counter of the target data chain table by 1.
[0036] In an optional implementation, the releasing of the storage address of the target data in the first chain removing module or the second chain removing module is implemented as:
[0037] releasing the storage address of the storage unit of the target data recorded in the chain table node corresponding to the target data.
[0038] In an optional implementation, the target data is a data packet to be sent; the data write request is a packet sending request of the data packet, the information of the target data carried by the data write request comprises a sharing identifier of the data packet, the sharing identifier is used to identify whether the data packet is shared data; when the data packet is not shared data, the data write request further comprises a packet sending direction of the data packet, and the target data linked list is a data linked list corresponding to the packet sending direction.
[0039] In an optional implementation, the data read request is a packet scheduling request, and the information of the target data carried by the data read request comprises a packet sending direction; the target data linked list is a data linked list corresponding to the packet sending direction, and the linked list node corresponding to the target data is a head pointer of the target data linked list.
[0040] According to a third aspect of the present application, a smart network card is provided, comprising the data read-write device of any one of the second aspect.
[0041] Compared with the related art, the technical solution of the present application has the following advantages:
[0042] 1. Resource sharing is achieved, and storage space usage is reduced. By sharing a data space, multiple linked lists can share the same data storage space, and it is not necessary to create a separate data storage space for each linked list. This can significantly save storage space when processing a large amount of similar data.
[0043] 2. Performance can be improved. In operations such as insertion and deletion, maintaining a shared linked list node counter is much more efficient than frequently creating and destroying linked list nodes, especially in high-frequency operation scenarios.
[0044] 3. Shared data space release is simple. When determining whether a linked list node is idle, only a single counter comparison is required for determination.
[0045] 4. Resources can be saved. Compared with the bitmap method, the number of registers can be effectively saved, and the control logic caused by bitmap management can also be saved.
[0046] 5. Easy to expand. Using a counter to manage shared nodes can make the expansion operation simpler. When new nodes or new linked lists need to share the same data, only the count needs to be increased, rather than creating new nodes.
[0047] Other features and advantages of the present application will be set forth in the specification, and in part will become apparent from the specification, or can be learned by practice of the present application. The objects and other advantages of the present application can be realized and attained by the structure and processes particularly pointed out in the specification as follows. BRIEF DESCRIPTION OF DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the following will briefly introduce the drawings needed to be used in the embodiments or related art description. Obviously, the drawings described below are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without any creative effort based on these drawings.
[0049] Figure 1 is a single linked list and a multi-linked list structure diagram according to the related art.
[0050] Figure 2 is a flow diagram of a data read-write method according to an exemplary embodiment of the present application.
[0051] Figure 3 is a multi-linked list data storage structure diagram according to an exemplary embodiment of the present application.
[0052] Figure 4 is a data write flow diagram according to an exemplary embodiment of the present application.
[0053] Figure 5 is a data read flow diagram according to an exemplary embodiment of the present application.
[0054] Figure 6 is a structure block diagram of a data read-write device according to an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0055] In order to make the purposes, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are some of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without any creative effort fall within the scope of protection of the present application.
[0056] Referring to Figure 1 , there is only one linked list in the single linked list structure, and the multi-linked list shared data space structure includes multiple linked lists, and the multiple linked lists can share data, such as Figure 1 the linked list link list0 and the linked list link List1 shares data dataA. The related technology adopts a bitmap method for the management of a multi-linked list shared data space. This method configures 1-bit effective indication bits for each storage space, such as N storage units, which consumes N register resources. Each data space needs to find the corresponding bit field by calculation when hanging the chain, and update the flag; when the chain is removed, the corresponding bit field is also found by calculation to update the flag, and it is judged whether the data space is valid, so as to realize the recycling of the shared address space. This method has high reliability, but consumes the bit field corresponding to the depth of the data space, and the implementation of the bitmap also needs more control logic, and realizes simultaneous query, simultaneous update and other operations, which increases the complexity of judgment.
[0057] The multi-linked list shared data space management method based on the bitmap technology in the related technology is to use an array to represent the state of each node in the linked list. Each bit of the bitmap represents a corresponding linked list node, for example, a bit of 1 indicates that the node at the position exists, and a bit of 0 indicates that the node does not exist.
[0058] Node data: Each node of the linked list contains the actual stored data and the index or pointer pointing to the next node.
[0059] The schematic structure is as follows:
[0060] Bitmap: 10 110 (indicating that nodes 1, 3 and 4 exist, and node 25 does not exist)
[0061] Index: 0 1234
[0062] Data: A C D (indicating that the data contained in nodes 1, 3 and 4 are A, C and D respectively)
[0063] The implementation operation is as follows:
[0064] Insertion operation: select a bit of 0 in the bitmap, set it to 1, and add data to the corresponding node.
[0065] Deletion operation: find the corresponding node, and set the corresponding bit in the bitmap to 0.
[0066] Traversal: check whether each node exists through the bitmap, and access the existing nodes.
[0067] The multi-linked list shared data space management method based on the bitmap technology in the related technology has the following disadvantages:
[0068] Space efficiency: even if many nodes in the linked list are not occupied, the size of the bitmap is still proportional to the maximum possible size of the linked list, which will cause space waste.
[0069] Dynamicity: Bitmap-based linked lists can be less flexible when dynamically changing, such as frequent insertion and deletion, especially when dealing with unused nodes, which can make bitmap management difficult.
[0070] Access efficiency: When traversing, each bit in the bitmap needs to be checked, which can lead to reduced efficiency, especially when most nodes are not used.
[0071] Unordered node association: Traditional linked lists can easily insert and delete nodes, while bitmap implementation can affect the flexibility of the data structure, especially when there is no order relationship.
[0072] Higher pointer management overhead: For a large number of nodes, additional pointer management can cause performance degradation.
[0073] Based on the above analysis, the core idea of the present application is to effectively solve the problems of data redundancy, complex management and resource release in related technologies by designing a management scheme combining shared data space and non-shared data space. Specifically, by introducing a shared identifier and a statistical counter mechanism, the reference and release of data nodes can be flexibly managed in a broadcast scenario, efficient data sharing between multiple linked lists is achieved, and the utilization rate of storage space is improved.
[0074] Referring to Figure 2 The present application exemplarily proposes a data read-write method, which comprises:
[0075] In step S201, a plurality of data linked lists are established; each data linked list corresponds to a first counter and a second counter;
[0076] In step S202, a data write request is received; the data write request carries target data to be written and information of the target data;
[0077] In step S203, it is determined whether the target data is shared data according to the information of the target data;
[0078] In step S204, if the target data is shared data, a linked list node corresponding to the target data is added in each data linked list, and the first counter and the second counter of each data linked list are incremented by 1;
[0079] In step S205, if the target data is not shared data, a linked list node corresponding to the target data is added in the target data linked list corresponding to the target data, and the second counter of the target data linked list is incremented by 1.
[0080] Referring to Figure 3As shown, exemplarily, some of the nodes of the data chain tables in the application can point to the same storage unit. Among them, the write data data _ in If it is shared data, it will be hung on the data chain table link _ list0 to link _ listN, if it is not shared data, it will be hung on one of the data chain tables.
[0081] The data of the non-shared data in the application refers to the independent data owned by each node, which is not shared with other chain tables or nodes, so the life cycle, storage and access of each node are independent.
[0082] Exemplarily, in the broadcast scenario, each data chain table has a first counter linkN scnt for counting shared data, and a second counter linkN tcnt for counting total data.
[0083] Referring to Figure 4 As shown, exemplarily, the data writing process is as follows:
[0084] After receiving the data writing request, it is judged whether the target data to be written is shared data according to the information of the target data carried by the data writing request; for shared data, it is hung on each data chain table, and the first counter linkN scnt and the second counter linkN tcnt of each data chain table are all increased by 1; for non-shared data, it is hung on the corresponding target data chain table according to the destination of the target data.
[0085] In some optional implementation manners, the method further comprises:
[0086] After receiving the data writing request, the target data is written into the storage unit, and the storage address of the storage unit is written in the chain table node corresponding to the target data.
[0087] Exemplarily, for shared data, although the nodes of multiple data chain tables can all point to the shared data, the shared data is only stored in one copy in the shared storage space. For example, Figure 3 data1 and data2 in the above are not shared data, so they are hung on link _ list1 and link _ list0 respectively, while data3 is shared data, which is hung on link _ list0 to link _data3 is stored only once in the shared storage space as data1 and data2 are on listN.
[0088] In some optional implementations, the method further includes:
[0089] receiving a data read request; the data read request carrying information of target data to be read;
[0090] determining a target data chain list corresponding to the target data according to the information of the target data;
[0091] determining whether the target data is shared data based on the target data chain list;
[0092] if the target data is shared data, removing a chain list node corresponding to the target data from the target data chain list, and releasing a storage address of the target data when a first counter of the target data chain list is greater than first counters of other data chain lists, and respectively reducing the first counter and a second counter of the target data chain list by 1;
[0093] if the target data is not shared data, removing the chain list node corresponding to the target data from the target data chain list, releasing the storage address of the target data, and reducing the second counter of the target data chain list by 1.
[0094] Exemplarily, referring to Figure 5 As shown in the figure, the data read process is as follows:
[0095] After receiving the data read request, since the data read request carries information of target data to be read, the information can indicate a target data chain list where the target data is located. For example, in a broadcast scenario, each data chain list corresponds to a different message sending direction, and the information of the target data carried by the data read request can be the message sending direction, based on which the target data chain list of the target data can be determined. When the target data is written into a chain list node of the target data chain list, a shared identifier used to indicate whether the target data is shared data is written into the corresponding chain list node, so that the shared identifier can be directly read from the chain list node corresponding to the target data in the target data chain list when the target data is read, so as to determine whether the target data is shared data.
[0096] If the target data is shared data, it is determined whether the second counter of the target data list where the target data is located is greater than the second counter of the rest of the data lists before the chain is removed. Only when the second counter of the target data list is greater than the second counter of the rest of the data lists, the storage address of the target data can be released. Otherwise, the storage address of the target data is not released after the chain is removed, but waits for the next data read request until all the chain nodes corresponding to the target data in all the data lists are removed, and then the storage address of the target data is released.
[0097] If the target data is non-shared data, the chain is removed from the corresponding data list, and the storage address of the target data is released after the chain is removed.
[0098] Wherein, when the target data is shared data, the first counter and the second counter of the target data list are both reduced by 1, and when the target data is not shared data, only the second counter is reduced by 1.
[0099] In some optional implementation manners, the storage address of the target data is released, including:
[0100] The storage address of the storage unit of the target data recorded in the chain node of the target data list is released.
[0101] Exemplarily, the chain node of the data list can record the storage address of the storage unit corresponding to the shared data or the non-shared data. As shown in Figure 3 datal_addr, data2_addr and data3_addr all point to the corresponding storage units in the shared storage space.
[0102] In some optional implementation manners, the target data is a data packet to be sent; the data write request is a packet sending request of the data packet, the information of the target data carried by the data write request includes a shared identifier of the data packet, the shared identifier is used to identify whether the data packet is shared data; when the data packet is not shared data, the data write request further includes a packet sending direction of the data packet, and the target data list is a data list corresponding to the packet sending direction.
[0103] Exemplarily, the data read-write method proposed in the application is applicable to the sending process of data packets, for example, the data packet forwarding process of an intelligent network card in a broadcast scenario. The data write request can be a packet sending request received by the intelligent network card, and the target data can be a data packet to be sent received by the intelligent network card. After the intelligent network card receives the data packet, the above method proposed in the application is used to write the data packet into a storage unit of a shared storage space, and a plurality of data linked lists are used for management. The packet sending request received by the intelligent network card can carry a shared identifier to identify whether the data packet is broadcast data. The broadcast data means that the data packet is shared data.
[0104] Exemplarily, the packet sending request can carry a 1-bit shared identifier in addition to the data packet, which is used to mark whether the data packet has multiple egresses (that is, whether it is broadcast data). If there are multiple egresses, they need to be hung on the data linked list corresponding to each egress respectively. The shared identifier can be stored in the linked list node of the target data linked list.
[0105] If the packet sending request carried is not broadcast data, it can also carry the packet sending direction of the data packet. Each data linked list can correspond to a packet sending direction. The data packet that is not broadcast data can be hung on the data linked list corresponding to the packet sending direction, so that the data packet is sent to the egress corresponding to the packet sending direction in the packet scheduling process.
[0106] In some optional implementation manners, the data read request is a packet scheduling request, and the information of the target data carried by the data read request includes a packet sending direction. The target data linked list is a data linked list corresponding to the packet sending direction, and the linked list node corresponding to the target data is a linked list node pointed to by a head pointer of the target data linked list.
[0107] Exemplarily, the intelligent network card buffers the received data packet in the shared data space and manages the same by using a plurality of data linked lists, and can send the buffered data packet out through scheduling of the data packet. The packet scheduling request of the data packet can carry a target data, i.e. the packet sending direction of the data packet to be scheduled, the packet sending direction corresponding to one of the data linked lists, i.e. a target data linked list, and reading the linked list node pointed by the head pointer in the target data linked list corresponding to the packet sending direction can determine the shared identifier of the current data packet to be scheduled. Before reading the target data, a judgment can be made first. If the shared identifier is 0, it indicates that the data packet is non-shared data, and if the shared identifier is 1, it indicates that the data packet is shared data, at which time a comparison needs to be made with the second counter. If the second counter linkM_scnt of the target data linked list, i.e. the data linked list corresponding to the current data packet to be scheduled, is greater than the second counter linkN_scnt (N=0, 1, 2, 3…, and N≠M) of other data linked lists, the storage unit of the read data packet can be released, otherwise, since there still exists a linked list node corresponding to the data packet in the storage unit in other data linked lists, the storage unit cannot be released.
[0108] The above is the data read-write method provided by the present application, which has the following beneficial effects:
[0109] 1. Resource sharing is realized, and storage space usage is reduced. By using the shared data space, a plurality of linked lists can share the same data storage space, and it is not necessary to create a separate data storage space for each linked list. This can significantly save storage space when a large amount of similar data is processed.
[0110] 2. Performance can be improved. In operations such as insertion and deletion, maintaining a shared linked list node counter is much more efficient than frequently creating and destroying linked list nodes, especially in high-frequency operation scenarios.
[0111] 3. Shared data space release is simple. When judging whether a linked list node is idle, only the comparison of the counter is needed to determine.
[0112] 4. Resources can be saved. Compared with the bitmap method, the number of registers can be effectively saved, and the control logic caused by the management of the bitmap can also be saved.
[0113] 5. Easy to extend. Using the counter to manage the shared node can make the extension operation simpler. When a new node or a new linked list needs to share the same data, only the counter needs to be increased, rather than creating a new node.
[0114] Correspondingly, referring to FIG. 1, Figure 6 Exemplarily, the present application provides a data read-write device, which comprises:
[0115] The establishing module 601 is configured to establish a plurality of data chains; each data chain corresponds to a first counter and a second counter;
[0116] The first receiving module 602 is configured to receive a data write request; the data write request carries target data to be written and information of the target data;
[0117] The first determining module 603 is configured to determine whether the target data is shared data according to the information of the target data;
[0118] The first increasing module 604 is configured to, if the target data is shared data, increase a chain table node corresponding to the target data in each data chain, and increase the first counter and the second counter of each data chain by 1;
[0119] The second increasing module 605 is configured to, if the target data is not shared data, increase a chain table node corresponding to the target data in a target data chain corresponding to the target data, and increase the second counter of the target data chain by 1.
[0120] In some optional implementations, the method further includes:
[0121] The writing module is configured to, after receiving the data write request, write the target data to a storage unit, and write a storage address of the storage unit in the chain table node corresponding to the target data.
[0122] In some optional implementations, the method further includes:
[0123] The second receiving module is configured to receive a data read request; the data read request carries information of target data to be read;
[0124] The second determining module is configured to determine a target data chain corresponding to the target data according to the information of the target data;
[0125] The third determining module is configured to determine whether the target data is shared data based on the target data chain;
[0126] The first chain removing module is configured to, if the target data is shared data, remove a chain table node corresponding to the target data from the target data chain, release a storage address of the target data when the first counter of the target data chain is greater than the first counter of other data chains, and decrease the first counter and the second counter of the target data chain by 1 respectively;
[0127] The second chain removing module is configured to remove the chain table node corresponding to the target data from the target data chain table, release the storage address of the target data, and decrease the second counter of the target data chain table by 1, if the target data is not shared data.
[0128] In some optional implementations, the releasing of the storage address of the target data in the first chain removing module or the second chain removing module is implemented as:
[0129] releasing the storage address of the storage unit of the target data recorded in the chain table node corresponding to the target data.
[0130] In some optional implementations, the target data is a data packet to be sent; the data write request is a packet sending request of the data packet, the information of the target data carried by the data write request comprises a shared identifier of the data packet, the shared identifier is used to identify whether the data packet is shared data; when the data packet is not shared data, the data write request further comprises a packet sending direction of the data packet, and the target data chain table is a data chain table corresponding to the packet sending direction.
[0131] In some optional implementations, the data read request is a packet scheduling request, the information of the target data carried by the data read request comprises a packet sending direction; the target data chain table is a data chain table corresponding to the packet sending direction, and the chain table node corresponding to the target data is a chain table node pointed to by a head pointer of the target data chain table.
[0132] The above method can be implemented by the data reading and writing device provided in the above embodiments, and the specific implementation can refer to the description of the data reading and writing method in the above embodiments, which will not be repeated here.
[0133] The application further provides a smart network card comprising the data reading and writing device provided in the above embodiments. The smart network card can further comprise a processor and a memory, the memory stores a plurality of instructions, and the processor is configured to read the instructions and execute any of the methods in the above embodiments. The processor and the memory can be connected through a bus or other manners, and the connection through the bus is taken as an example. The processor can be a central processing unit (CPU). The processor can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or combinations thereof.
[0134] It can be understood that the circuit structures, names and parameters described in the above embodiments are only examples. Those skilled in the art can also easily think of combinations and adjustments of the structural features of the above multiple embodiments according to the use needs, and the concept of the application should not be limited to the specific details of the above examples.
[0135] Although the application is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the application.
Claims
1. A data read / write method, characterized by, The method comprises the following steps: a plurality of data chains are established; each data chain corresponds to a first counter and a second counter; a data write request is received; the data write request carries target data to be written and information of the target data; it is determined whether the target data is shared data according to the information of the target data; if the target data is shared data, a chain table node corresponding to the target data is added in each data chain, and the first counter and the second counter of each data chain are increased by 1; if the target data is not shared data, a chain table node corresponding to the target data is added in a target data chain corresponding to the target data, and the second counter of the target data chain is increased by 1; the method further comprises the following steps: a data read request is received; the data read request carries information of target data to be read; a target data chain corresponding to the target data is determined according to the information of the target data; it is determined whether the target data is shared data based on the target data chain; if the target data is shared data, the chain table node corresponding to the target data is removed from the target data chain, the storage address of the target data is released when the first counter of the target data chain is greater than the first counter of other data chains, and the first counter and the second counter of the target data chain are decreased by 1 respectively; if the target data is not shared data, the chain table node corresponding to the target data is removed from the target data chain, the storage address of the target data is released, and the second counter of the target data chain is decreased by 1.
2. The data read / write method of claim 1, wherein, Further comprising: after receiving the data write request, the target data is written into a storage unit, and the storage address of the storage unit is written into the chain table node corresponding to the target data.
3. The data read / write method of claim 1, wherein, releasing the storage address of the target data comprises: releasing the storage address of the storage unit of the target data recorded in the chain table node corresponding to the target data.
4. The data read / write method according to any one of claims 1 to 3, wherein, The target data is a data packet to be sent; the data write request is a packet sending request of the data packet, the information of the target data carried by the data write request comprises a sharing identifier of the data packet, the sharing identifier is used to identify whether the data packet is shared data; when the data packet is not shared data, the data write request further comprises a packet sending direction of the data packet, and the target data chain is a data chain corresponding to the packet sending direction.
5. The data read / write method according to claim 1 or 3, wherein, The data read request is a packet scheduling request, the information of the target data carried by the data read request comprises a packet sending direction; the target data chain is a data chain corresponding to the packet sending direction, and the chain table node corresponding to the target data is a chain table node pointed to by a head pointer of the target data chain.
6. A data read / write device, characterized by The method comprises the following steps: a plurality of data chains are established; each data chain corresponds to a first counter and a second counter; a data write request is received; the data write request carries target data to be written and information of the target data; The first determining module is configured to determine whether the target data is shared data according to information of the target data; The first increasing module is configured to, if the target data is shared data, add a chain table node corresponding to the target data in each of the data chain tables, and increase the first counter and the second counter of each of the data chain tables by 1; The second increasing module is configured to, if the target data is not shared data, add a chain table node corresponding to the target data in a target data chain table corresponding to the target data, and increase the second counter of the target data chain table by 1; The second receiving module is configured to receive a data reading request; the data reading request carries information of target data to be read; The second determining module is configured to determine a target data chain table corresponding to the target data according to the information of the target data; The third determining module is configured to determine whether the target data is shared data based on the target data chain table; The first chain removing module is configured to, if the target data is shared data, remove the chain table node corresponding to the target data from the target data chain table, release a storage address of the target data when the first counter of the target data chain table is greater than the first counter of other data chain tables, and decrease the first counter and the second counter of the target data chain table by 1 respectively. The second chain removing module is configured to, if the target data is not shared data, remove the chain table node corresponding to the target data from the target data chain table, release the storage address of the target data, and decrease the second counter of the target data chain table by 1.
7. The data reading and writing device according to claim 6, wherein Further comprising: The writing module is configured to, after receiving a data writing request, write the target data into a storage unit, and write a storage address of the storage unit into the chain table node corresponding to the target data.
8. The data reading and writing device according to claim 6, wherein The release of the storage address of the target data in the first chain removing module or the second chain removing module is implemented as: Releasing a storage address of a storage unit of the target data recorded in the chain table node corresponding to the target data.
9. The data reading and writing device according to any one of claims 6 to 8, wherein The target data is a data packet to be sent; the data writing request is a packet sending request of the data packet; the information of the target data carried by the data writing request includes a shared identifier of the data packet, the shared identifier being used to identify whether the data packet is shared data; when the data packet is not shared data, the data writing request further includes a packet sending direction of the data packet, and the target data chain table is a data chain table corresponding to the packet sending direction.
10. The data reading and writing apparatus according to claim 6 or 8, wherein The data reading request is a packet scheduling request; the information of the target data carried by the data reading request includes a packet sending direction; the target data chain table is a data chain table corresponding to the packet sending direction, and the chain table node corresponding to the target data is a head pointer of the target data chain table.
11. An intelligent network adapter, comprising: The data reading and writing device comprises any one of the data reading and writing devices according to claims 6-10.
Citation Information
Patent Citations
Network device shared memory freeing method and system
CN103902464A
A method and apparatus for storing linked list of service data
CN109189793A