Data reading and writing method and device and intelligent network card
By establishing multiple data link lists in the smart network card and using counters to manage shared and non-shared data spaces, the problems of data redundancy, complex management and resource release are solved, and the effects of resource sharing, performance improvement and storage space saving are achieved.
Patent Information
- Application Number
- CN202411554023.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2044-11-01
Smart Images

Figure CN119493742A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of data storage, and in particular, relates to a data reading and writing method, device and smart network card. Background Art
[0002] When storing data, the linked list structure is widely used because it can make full use of the storage space and realize flexible dynamic management of the storage space. Especially in the data cache of smart network cards, when there is large-scale data storage, replication, and forwarding, it is common for multiple linked lists to share part of the data space. Summary of the invention
[0003] The purpose of this application is to provide a data reading and writing method, device and intelligent network card, aiming to solve the problems of data redundancy, complex management and resource release existing in related technologies.
[0004] According to a first aspect of the present application, a data reading and writing method is provided, comprising:
[0005] Establish multiple data linked lists; each data linked list correspondingly includes a first counter and a second counter;
[0006] receiving a data writing request; the data writing request carries target data to be written and information of the target data;
[0007] Determining whether the target data is shared data according to information of the target data;
[0008] If the target data is shared data, a linked list node corresponding to the target data is added to each of the data linked lists, and the first counter and the second counter of each of the data linked lists are both increased by 1;
[0009] If the target data is not shared data, a linked list node corresponding to the target data is added to the target data linked list corresponding to the target data, and a second counter of the target data linked list is incremented by 1.
[0010] In an optional embodiment, it also includes:
[0011] After receiving a data write request, the target data is written into a storage unit, and a storage address of the storage unit is written into the linked list node corresponding to the target data.
[0012] In an optional embodiment, it also includes:
[0013] receiving a data read request; the data read request carries information of target data to be read;
[0014] Determine, according to the information of the target data, a target data linked list corresponding to 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, the linked list node corresponding to the target data is removed from the target data linked list, and when the first counter of the target data linked list is greater than the first counter of other data linked lists, the storage address of the target data is released, and the first counter and the second counter of the target data linked list are respectively reduced by 1;
[0017] If the target data is not shared data, the linked list node corresponding to the target data is removed from the target data linked list, the storage address of the target data is released, and the second counter of the target data linked list is reduced by 1.
[0018] In an optional implementation manner, releasing the storage address of the target data includes:
[0019] Release the storage address of the storage unit of the target data recorded in the linked list node corresponding to the target data.
[0020] In an optional embodiment, the target data is a data message to be sent; the data write request is a message sending request for the data message, and the information of the target data carried by the data write request includes a sharing identifier of the data message, and the sharing identifier is used to identify whether the data message is shared data; when the data message is not shared data, the data write request also includes a message sending direction of the data message, and the target data linked list is a data linked list corresponding to the message sending direction.
[0021] In an optional implementation, the data read request is a message scheduling request, and the target data information carried by the data read request includes the message sending direction; the target data linked list is a data linked list corresponding to the message sending direction, and the linked list node corresponding to the target data is the linked list node pointed to by the head pointer of the target data linked list.
[0022] According to a second aspect of the present application, a data reading and writing device is provided, comprising:
[0023] An establishing module, used for establishing a plurality of data linked lists; each data linked list correspondingly includes a first counter and a second counter;
[0024] A first receiving module is used to receive a data writing request; the data writing request carries the target data to be written and the information of the target data;
[0025] A first determining module, configured to determine whether the target data is shared data according to information of the target data;
[0026] A first adding module, configured to add a linked list node corresponding to the target data in each of the data linked lists if the target data is shared data, and to add 1 to the first counter and the second counter of each of the data linked lists;
[0027] The second adding module is used for adding a linked list node corresponding to the target data in the target data linked list corresponding to the target data if the target data is not shared data, and adding 1 to the second counter of the target data linked list.
[0028] In an optional embodiment, it also includes:
[0029] The writing module is used to write the target data into the storage unit after receiving a data writing request, and write the storage address of the storage unit into the linked list node corresponding to the target data.
[0030] In an optional embodiment, it also includes:
[0031] A second receiving module is used to receive a data reading request; the data reading request carries information of target data to be read;
[0032] A second determination module, used to determine a target data linked list corresponding to the target data according to information of the target data;
[0033] A third determination module, configured to determine whether the target data is shared data based on the target data linked list;
[0034] a first link removal module, configured to remove the linked list node corresponding to the target data from the target data linked list if the target data is shared data, and release the storage address of the target data when the first counter of the target data linked list is greater than the first counter of other data linked lists, and reduce the first counter and the second counter of the target data linked list by 1 respectively;
[0035] The second link removal module is used for removing the link table node corresponding to the target data from the target data link table if the target data is not shared data, releasing the storage address of the target data, and reducing the second counter of the target data link table by 1.
[0036] In an optional implementation manner, releasing the storage address of the target data in the first link removal module or the second link removal module is implemented as follows:
[0037] Release the storage address of the storage unit of the target data recorded in the linked list node corresponding to the target data.
[0038] In an optional embodiment, the target data is a data message to be sent; the data write request is a message sending request for the data message, and the information of the target data carried by the data write request includes a sharing identifier of the data message, and the sharing identifier is used to identify whether the data message is shared data; when the data message is not shared data, the data write request also includes a message sending direction of the data message, and the target data linked list is a data linked list corresponding to the message sending direction.
[0039] In an optional implementation, the data read request is a message scheduling request, and the target data information carried by the data read request includes the message sending direction; the target data linked list is a data linked list corresponding to the message sending direction, and the linked list node corresponding to the target data is the linked list node pointed to by the 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 reading and writing device described in any one of the second aspects.
[0041] Compared with the related art, the technical solution of this application has the following advantages:
[0042] 1. Realize resource sharing and reduce storage space usage. By sharing data space, multiple linked lists can share the same data storage space without having 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. It can improve performance. In operations such as insertion and deletion, maintaining a shared counter of linked list nodes is much more efficient than frequently creating and destroying linked list nodes, especially in high-frequency operation scenarios.
[0044] 3. The shared data space is easy to release. When judging whether a linked list node is free, it is only necessary to compare the counters separately.
[0045] 4. It can save resources. Compared with the bitmap method, it can effectively save the number of registers and the control logic brought by the management bitmap.
[0046] 5. Easy to expand. Using counters to manage shared nodes can make expansion operations easier. When a new node or a new linked list needs to share the same data, just increase the count instead of creating a new node.
[0047] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained through the structures and processes indicated in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. It is obvious that the drawings described below are certain embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0049] Figure 1 It is a schematic diagram of a single linked list and a multi-linked list structure according to related technology.
[0050] Figure 2 is a flowchart of a data reading and writing method according to an exemplary embodiment of the present application.
[0051] Figure 3 It is a schematic diagram of a multi-linked list data storage structure according to an exemplary embodiment of the present application.
[0052] Figure 4 4 is a schematic diagram of a data writing process according to an exemplary embodiment of the present application.
[0053] Figure 5 4 is a schematic diagram of a data reading process according to an exemplary embodiment of the present application.
[0054] Figure 6 is a structural block diagram of a data reading and writing device according to an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part 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 ordinary technicians in this field without creative work are within the scope of protection of this application.
[0056] See also Figure 1 As shown, there is only one linked list in the single linked list structure, while the multi-linked list shared data space structure includes multiple linked lists, and multiple linked lists can share data, such as Figure 1 Linked list in list0 and linked listlink list1 shares data dataA. The related technology uses a bitmap method for the management of shared data space of multiple linked lists. This method configures a 1-bit valid indicator bit for each storage space. For example, N storage units require N register resources. When each data space is linked, it is necessary to find the corresponding bit field through calculation and update the flag; when the link is removed, it is also necessary to find the corresponding bit field update flag through calculation and determine whether the data space is valid, so as to realize the recovery of the shared address space. This method has high reliability, but it consumes the bit field of the corresponding depth of the data space. The implementation of the bitmap also requires more control logic, and realizes operations such as simultaneous query and simultaneous update, which increases the complexity of judgment.
[0057] In the related art, the management method of multi-linked list shared data space based on bitmap technology refers to using 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 that position exists, and a bit of 0 indicates that the node does not exist.
[0058] Node data: Each node of a linked list contains the actual data stored and an index or pointer to the next node.
[0059] The schematic structure is as follows:
[0060] Bitmap: 10 110 (indicates that nodes 1, 3, and 4 exist, but node 25 does not exist)
[0061] Index: 0 1234
[0062] Data: ACD (indicates that nodes 1, 3, and 4 contain data A, C, and D respectively)
[0063] The implementation operations are as follows:
[0064] Insert operation: select a bit that is 0 in the bitmap, set it to 1, and add data to the corresponding node.
[0065] Delete operation: Find the corresponding node and set the corresponding bit in the bitmap to 0.
[0066] Traversal: Check if each node exists through the bitmap and visit the existing nodes.
[0067] The management method of multi-linked list shared data space based on bitmap technology in related technologies has the following disadvantages:
[0068] Space efficiency: Even if many nodes in the linked list are unoccupied, the size of the bitmap is still proportional to the maximum possible size of the linked list, which results in wasted space.
[0069] Dynamicity: Bitmap-based linked lists may not be flexible enough when dynamic changes occur (such as frequent insertions and deletions), especially when dealing with unused nodes, which can make the bitmap difficult to manage.
[0070] Access efficiency: When traversing, each bit in the bitmap needs to be checked, which may 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 the implementation of bitmaps may 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, the additional pointer management may degrade performance.
[0073] Based on the above analysis, the core concept of this application is to effectively solve the problems of data redundancy, complex management and resource release in related technologies by designing a management solution that combines shared data space with non-shared data space. Specifically, by introducing a shared identifier and statistical counter mechanism, it is possible to flexibly manage the reference and release of data nodes in a broadcast scenario, realize efficient data sharing between multiple linked lists, and improve the utilization of storage space.
[0074] See also Figure 2 As shown, the present application exemplarily proposes a data reading and writing method, including:
[0075] In step S201, multiple data linked lists are established; each data linked list correspondingly includes 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 about the target data;
[0077] In step S203, determining 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 to each of the data linked lists, and the first counter and the second counter of each of the data linked lists are both increased 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 to 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] See also Figure 3As shown, illustratively, some of the linked list nodes in the multiple data linked lists of the present application may point to the same storage unit. _ If in is shared data, it will be linked to the data list link at the same time _ list0 to link _ If it is not shared data, it will be hung on one of the data linked lists.
[0081] The non-shared data in this application refers to the data that each node has independent and is not shared with other linked lists or nodes, so the life cycle, storage and access of each node are independent.
[0082] For example, in a broadcast scenario, each data linked list has a first counter linkN for counting shared data. scnt, and a second counter linkN for total data tcnt.
[0083] See also Figure 4 As shown, illustratively, the data writing process is as follows:
[0084] After receiving a data write request, it is determined whether the target data to be written is shared data according to the target data information carried in the data write request; for shared data, each data linked list is linked, and the first counter linkN of each data linked list is scnt and second counter linkN tcnt is incremented by 1; for non-shared data, it is linked to the corresponding target data linked list according to the destination of the target data.
[0085] In some optional implementations, the method further includes:
[0086] After receiving a data write request, the target data is written into a storage unit, and a storage address of the storage unit is written into the linked list node corresponding to the target data.
[0087] For example, for shared data, although multiple linked list nodes of multiple data linked lists can point to the shared data, only one copy of the shared data is stored in the shared storage space. Figure 3 Data1 and data2 in the table are not shared data, so they are respectively linked to the link _ list1 and link _ list0, and data3 is shared data, and is also linked to link _ list0 to link _listN, but data3 is the same as data1 and data2, and only one copy is stored in the shared storage space.
[0088] In some optional implementations, the method further includes:
[0089] receiving a data read request; the data read request carries information of target data to be read;
[0090] Determine, according to the information of the target data, a target data linked list corresponding to the target data;
[0091] Determining whether the target data is shared data based on the target data linked list;
[0092] If the target data is shared data, the linked list node corresponding to the target data is removed from the target data linked list, and when the first counter of the target data linked list is greater than the first counter of other data linked lists, the storage address of the target data is released, and the first counter and the second counter of the target data linked list are respectively reduced by 1;
[0093] If the target data is not shared data, the linked list node corresponding to the target data is removed from the target data linked list, the storage address of the target data is released, and the second counter of the target data linked list is reduced by 1.
[0094] For example, see Figure 5 As shown, the data reading process is as follows:
[0095] After receiving a data read request, since the data read request carries information about the target data to be read, the information can indicate the target data linked list where the target data is located. For example, in a broadcast scenario, each data linked list corresponds to a different message sending direction, and the information about the target data carried by the data read request can be the message sending direction, and the target data linked list of the target data can be determined based on the message sending direction. When the target data is written to the linked list node of the target data linked list, a shared identifier for indicating whether it is shared data is written to the corresponding linked list node. Therefore, when reading, the shared identifier can be directly read from the linked list node corresponding to the target data in the target data linked list, thereby determining whether the target data is shared data.
[0096] If it is shared data, before unlinking, first determine whether the second counter of the target data linked list where the target data is located is greater than the second counters of the other data linked lists. Only when the second counter of the current target data linked list is greater than the second counters of other data linked lists, the storage address of the target data can be released. Otherwise, the storage address of the target data is not released after unlinking, but waits for the next data read request until the linked list nodes corresponding to the target data in all data linked lists are removed, and then the storage address of the target data is released.
[0097] If it is non-shared data, the corresponding data linked list will be unlinked, and the storage address of the target data can be released after unlinking.
[0098] When the target data is shared data, the first counter and the second counter of the target data linked list are both reduced by 1, and when it is not shared data, the second counter is reduced by 1.
[0099] In some optional implementations, releasing the storage address of the target data includes:
[0100] Release the storage address of the storage unit of the target data recorded in the linked list node corresponding to the target data.
[0101] Exemplarily, the linked list nodes of the data linked list may record the storage addresses of the storage units corresponding to the shared data or the non-shared data. Figure 3 As shown, data1_addr, data2_addr and data3_addr all point to corresponding storage units in the shared storage space.
[0102] In some optional implementations, the target data is a data packet to be sent; the data write request is a packet sending request for the data packet, and the information of the target data carried by the data write request includes a shared identifier of the data packet, and 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 also includes 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.
[0103] Exemplarily, the data reading and writing method proposed in the present application is applicable to the data message sending process, such as the data message forwarding process of the smart network card in a broadcast scenario. The data write request can be a message sending request received by the smart network card, and the target data can be a data message to be sent received by the smart network card. After the smart network card receives the data message, the above method proposed in the present application is used to write the data message into the storage unit of the shared storage space, and multiple data linked lists are used for management. The message sending request received by the smart network card can carry a shared identifier to identify whether the data message is broadcast data. If it is broadcast data, it means that the data message is shared data.
[0104] Exemplarily, in addition to the data message, the message sending request may also carry a 1-bit shared identifier to mark whether the data message has multiple exits (i.e., whether it is broadcast data). If there are multiple exits that need to be connected to the data linked list corresponding to each exit, the shared identifier may be stored in the linked list node of the target data linked list.
[0105] If the message sending request does not carry broadcast data, it can also carry the message sending direction of the data message. Each data linked list can correspond to a message sending direction. The data message that is not broadcast data can be linked to the data linked list of the corresponding message sending direction, so that during the message scheduling process, the data message is sent to the exit corresponding to the message sending direction.
[0106] In some optional implementations, the data read request is a message scheduling request, and the information of the target data carried by the data read request includes the message sending direction; the target data linked list is a data linked list corresponding to the message sending direction, and the linked list node corresponding to the target data is the linked list node pointed to by the head pointer of the target data linked list.
[0107] Exemplarily, the smart network card caches the received data message in a shared data space and manages it with multiple data linked lists, and can send out the cached data message through the scheduling of the data message. The message scheduling request of the data message can carry the target data, that is, the message sending direction of the data message to be scheduled. The message sending direction corresponds to one of the data linked lists, that is, the target data linked list. The linked list node pointed to by the head pointer is read from the target data linked list corresponding to the message sending direction, that is, the first linked list node in the data linked list to determine the shared identifier of the currently scheduled data message. Before reading the data message, that is, the target data, a judgment can be made first. If the sharing flag is 0, it means that the data message is non-shared data. If the sharing flag is 1, it means that the data message is shared data. At this time, it is necessary to compare the second counter. If the second counter 1inkM_scnt of the target data linked list, that is, the data linked list corresponding to the data message currently to be scheduled, is greater than the second counter linkN_scnt of other data linked lists (N=0, 1, 2, 3..., and N≠M), then the storage unit of the read data message can be released. Otherwise, since there are still linked list nodes corresponding to the data message in the storage unit in other data linked lists, it cannot be released.
[0108] The above is the data reading and writing method proposed in this application, which has the following beneficial effects:
[0109] 1. Realize resource sharing and reduce storage space usage. By sharing data space, multiple linked lists can share the same data storage space without having 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.
[0110] 2. It can improve performance. In operations such as insertion and deletion, maintaining a shared counter of linked list nodes is much more efficient than frequently creating and destroying linked list nodes, especially in high-frequency operation scenarios.
[0111] 3. The shared data space is easy to release. When judging whether a linked list node is free, it is only necessary to compare the counters separately.
[0112] 4. It can save resources. Compared with the bitmap method, it can effectively save the number of registers and the control logic brought by the management bitmap.
[0113] 5. Easy to expand. Using counters to manage shared nodes can make expansion operations easier. When a new node or a new linked list needs to share the same data, just increase the count instead of creating a new node.
[0114] Accordingly, see Figure 6 As shown, the present application exemplarily provides a data reading and writing device, including:
[0115] Establishing module 601, used to establish multiple data linked lists; each data linked list correspondingly includes a first counter and a second counter;
[0116] The first receiving module 602 is used to receive a data writing request; the data writing request carries the target data to be written and the information of the target data;
[0117] A first determination module 603, configured to determine whether the target data is shared data according to information of the target data;
[0118] A first adding module 604 is configured to add a linked list node corresponding to the target data in each of the data linked lists if the target data is shared data, and to increase the first counter and the second counter of each of the data linked lists by 1;
[0119] The second adding module 605 is used for adding a linked list node corresponding to the target data in the target data linked list corresponding to the target data if the target data is not shared data, and increasing the second counter of the target data linked list by 1.
[0120] In some optional implementations, the method further includes:
[0121] The writing module is used to write the target data into the storage unit after receiving a data writing request, and write the storage address of the storage unit into the linked list node corresponding to the target data.
[0122] In some optional implementations, the method further includes:
[0123] A second receiving module is used to receive a data reading request; the data reading request carries information of target data to be read;
[0124] A second determination module, used to determine a target data linked list corresponding to the target data according to information of the target data;
[0125] A third determination module, configured to determine whether the target data is shared data based on the target data linked list;
[0126] a first link removal module, configured to remove the linked list node corresponding to the target data from the target data linked list if the target data is shared data, and release the storage address of the target data when the first counter of the target data linked list is greater than the first counter of other data linked lists, and reduce the first counter and the second counter of the target data linked list by 1 respectively;
[0127] The second link removal module is used for removing the link table node corresponding to the target data from the target data link table if the target data is not shared data, releasing the storage address of the target data, and reducing the second counter of the target data link table by 1.
[0128] In some optional implementations, releasing the storage address of the target data in the first link removal module or the second link removal module is implemented as follows:
[0129] Release the storage address of the storage unit of the target data recorded in the linked list 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 for the data packet, and the information of the target data carried by the data write request includes a shared identifier of the data packet, and 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 also includes 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.
[0131] In some optional implementations, the data read request is a message scheduling request, and the information of the target data carried by the data read request includes the message sending direction; the target data linked list is a data linked list corresponding to the message sending direction, and the linked list node corresponding to the target data is the linked list node pointed to by the head pointer of the target data linked list.
[0132] The above method can be implemented by the data reading and writing device provided in the above embodiment. The specific implementation method can refer to the description of the data reading and writing method in the above embodiment, which will not be repeated here.
[0133] The present application also provides a smart network card, including the data reading and writing device provided in the above embodiment. The smart network card may also include a processor and a memory, wherein the memory stores a plurality of instructions, and the processor is used to read the instructions and execute any one of the methods in the foregoing embodiments. The processor and the memory may be connected via a bus or other means, taking the bus connection as an example. The processor may be a central processing unit (CPU). The processor may 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 gates or transistor logic devices, discrete hardware components and other chips, or a combination of the above-mentioned types of chips.
[0134] It is understood that the circuit structures, names and parameters described in the above embodiments are only examples. Those skilled in the art can also easily combine and adjust the structural features of the above embodiments according to the use requirements, and should not limit the concept of the present application to the specific details of the above examples.
[0135] Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that he or she may still modify the technical solutions described in the aforementioned embodiments, or make equivalent substitutions for some of the technical features therein; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A data reading and writing method, characterized in that: include: Establish multiple data linked lists; each data linked list correspondingly includes a first counter and a second counter; Receive data writing request; The data writing request carries the target data to be written and information about the target data; Determining whether the target data is shared data according to information of the target data; If the target data is shared data, a linked list node corresponding to the target data is added to each of the data linked lists, and the first counter and the second counter of each of the data linked lists are both increased by 1; If the target data is not shared data, a linked list node corresponding to the target data is added to the target data linked list corresponding to the target data, and a second counter of the target data linked list is incremented by 1.
2. The data reading and writing method according to claim 1, characterized in that: Also includes: After receiving a data write request, the target data is written into a storage unit, and a storage address of the storage unit is written into the linked list node corresponding to the target data.
3. The data reading and writing method according to claim 1, characterized in that: Also includes: receiving a data read request; the data read request carries information of target data to be read; Determine, according to the information of the target data, a target data linked list corresponding to the target data; Determine whether the target data is shared data based on the target data linked list; If the target data is shared data, the linked list node corresponding to the target data is removed from the target data linked list, and when the first counter of the target data linked list is greater than the first counter of other data linked lists, the storage address of the target data is released, and the first counter and the second counter of the target data linked list are respectively reduced by 1; If the target data is not shared data, the linked list node corresponding to the target data is removed from the target data linked list, the storage address of the target data is released, and the second counter of the target data linked list is reduced by 1.
4. The data reading and writing method according to claim 3, characterized in that: Releasing the storage address of the target data includes: Release the storage address of the storage unit of the target data recorded in the linked list node corresponding to the target data.
5. The data reading and writing method according to any one of claims 1 to 4, characterized in that: The target data is a data message to be sent; the data write request is a message sending request for the data message, and the information of the target data carried by the data write request includes a sharing identifier of the data message, and the sharing identifier is used to identify whether the data message is shared data; when the data message is not shared data, the data write request also includes a message sending direction of the data message, and the target data linked list is a data linked list corresponding to the message sending direction.
6. The data reading and writing method according to any one of claims 3 and 4, characterized in that: The data read request is a message scheduling request, and the information of the target data carried by the data read request includes the message sending direction; the target data linked list is a data linked list corresponding to the message sending direction, and the linked list node corresponding to the target data is the linked list node pointed to by the head pointer of the target data linked list.
7. A data reading and writing device, characterized in that: include: An establishing module, used for establishing a plurality of data linked lists; each data linked list correspondingly includes a first counter and a second counter; A first receiving module, used for receiving a data writing request; The data writing request carries the target data to be written and information about the target data; A first determining module, configured to determine whether the target data is shared data according to information of the target data; A first adding module, configured to add a linked list node corresponding to the target data in each of the data linked lists if the target data is shared data, and to add 1 to the first counter and the second counter of each of the data linked lists; The second adding module is used for adding a linked list node corresponding to the target data in the target data linked list corresponding to the target data if the target data is not shared data, and adding 1 to the second counter of the target data linked list.
8. The data reading and writing device according to claim 7, characterized in that: Also includes: The writing module is used to write the target data into the storage unit after receiving a data writing request, and write the storage address of the storage unit into the linked list node corresponding to the target data.
9. The data reading and writing device according to claim 7, characterized in that: Also includes: A second receiving module is used to receive a data reading request; the data reading request carries information of target data to be read; A second determination module, used to determine a target data linked list corresponding to the target data according to information of the target data; A third determination module, configured to determine whether the target data is shared data based on the target data linked list; a first link removal module, configured to remove the linked list node corresponding to the target data from the target data linked list if the target data is shared data, and release the storage address of the target data when the first counter of the target data linked list is greater than the first counter of other data linked lists, and reduce the first counter and the second counter of the target data linked list by 1 respectively; The second link removal module is used for removing the link table node corresponding to the target data from the target data link table if the target data is not shared data, releasing the storage address of the target data, and reducing the second counter of the target data link table by 1.
10. The data reading and writing device according to claim 9, characterized in that: The storage address of releasing the target data in the first link removal module or the second link removal module is implemented as follows: Release the storage address of the storage unit of the target data recorded in the linked list node corresponding to the target data.
11. The data reading and writing device according to any one of claims 7 to 10, characterized in that: The target data is a data message to be sent; the data write request is a message sending request for the data message, and the information of the target data carried by the data write request includes a sharing identifier of the data message, and the sharing identifier is used to identify whether the data message is shared data; when the data message is not shared data, the data write request also includes a message sending direction of the data message, and the target data linked list is a data linked list corresponding to the message sending direction.
12. The data reading and writing device according to any one of claims 9 and 10, characterized in that: The data read request is a message scheduling request, and the information of the target data carried by the data read request includes the message sending direction; the target data linked list is a data linked list corresponding to the message sending direction, and the linked list node corresponding to the target data is the linked list node pointed to by the head pointer of the target data linked list.
13. A smart network card, characterized in that: It comprises a data reading and writing device as described in any one of claims 7 to 12.
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
Data caching method for network interface to support multi-link and retransmission
CN111538694A
Shared data processing method, system and device
CN114117140A
Multi-queue RDMA request recording and retransmission method based on shared cache structure
CN118069046A