A method, system and device for processing shared data
By directly accessing the shared data link list in a multi-processor multi-core network device and using spin locks to lock and remove links, frequent lock operations are avoided, data reading, writing and processing efficiency is improved, performance bottlenecks caused by frequent lock operations in the prior art are solved, and network equipment performance is improved.
Patent Information
- Application Number
- CN202111437067.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-29
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2041-11-29
Smart Images

Figure CN114117140B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of shared data protection, and more specifically, to a method, system, and device for processing shared data. Background Art
[0002] The throughput of today's network devices is rapidly increasing, posing significant performance challenges. Network device hardware and software are constantly being optimized to improve performance. Multi-core network devices often store large amounts of shared data. These cores add, delete, and modify shared data, and release shared memory when processing packets. Existing shared data processing often requires frequent lock requests and releases to ensure the security of shared data operations. However, in practice, existing methods have found that frequent lock requests and releases reduce the efficiency of data reading, writing, and processing, severely limiting network device performance. Summary of the Invention
[0003] The purpose of the embodiments of the present application is to provide a method, system and device for processing shared data, which can avoid frequent application and release of locks, thereby facilitating the improvement of the efficiency of data reading, writing and processing, and improving the performance of network equipment.
[0004] A first aspect of an embodiment of the present application provides a method for processing shared data, which is used in a data plane core of a multi-processor multi-core network device, comprising:
[0005] Directly access the shared data of the target node in the shared data list;
[0006] When the shared data needs to be deleted, the target node is removed from the shared data linked list;
[0007] Adding the target node to the high-speed processing queue of the data plane core to wait for release;
[0008] Obtaining a global shared periodic variable, and determining whether the global local periodic variable of the data plane core is consistent with the global shared periodic variable;
[0009] If not, the shared data corresponding to the target node in the high-speed processing process queue is released.
[0010] In the above implementation, the data plane core directly accesses the shared data of the target node in the shared data linked list. When the shared data needs to be deleted, the target node is removed from the shared data linked list. The target node is added to the data plane core's high-speed processing queue and awaits release. It then obtains the global shared period variable and determines whether the data plane core's global local period variable is consistent with the global shared period variable. If not, the shared data corresponding to the target node in the high-speed processing queue is released. This method can avoid frequent lock requests and releases, thereby improving the efficiency of data reading, writing, and processing, and enhancing network device performance.
[0011] Furthermore, after releasing the shared data corresponding to the target node in the high-speed processing queue, the method further includes:
[0012] An increment operation is performed on the global local cycle variable to indicate that the data plane core enters the next working cycle.
[0013] Furthermore, the method further comprises:
[0014] When the global local periodic variable is consistent with the global shared periodic variable, the global shared periodic variable is reacquired, and until it is determined that the global local periodic variable is consistent with the reacquired global shared periodic variable, the shared data corresponding to the target node in the high-speed processing process queue is released.
[0015] Furthermore, the adding of the target node to the high-speed processing queue of the data plane core to wait for release includes:
[0016] The preset shared data release function and the shared data of the target node are added to the high-speed processing process queue of the data plane core and wait for release.
[0017] Furthermore, when the shared data needs to be deleted, the target node is removed from the shared data linked list, including:
[0018] When the shared data needs to be deleted, the target node is locked with a spin lock, and then the target node is removed from the shared data linked list, and the spin lock is released.
[0019] A second aspect of an embodiment of the present application provides a shared data processing system, the shared data processing system comprising a plurality of processors, each of the processors comprising a data plane core, wherein:
[0020] The data plane core is used to directly access the shared data of the target node in the shared data linked list; and when the shared data needs to be deleted, the target node is locked with a spin lock, and the spin lock is released; and the target node is added to the high-speed processing queue of the data plane core to wait for release;
[0021] The processor is configured to determine whether a global shared core number variable is a preset value, and if so, decrement the global shared processor number variable by one to indicate that all data plane cores of a processor have completed work in this cycle; and determine whether the global shared processor number variable is the preset value, and if so, increment the preset global shared cycle variable by one to indicate that the processor has entered a next work cycle;
[0022] The data plane core is used to obtain the global shared periodic variable and determine whether the global local periodic variable of the data plane core is consistent with the global shared periodic variable; if not, release the shared data corresponding to the target node in the high-speed processing process queue.
[0023] In the above implementation process, the data plane core can directly access the shared data of the target node in the shared data linked list; and when the shared data needs to be deleted, the target node is locked with a spin lock, and the target node is removed from the shared data linked list and the spin lock is released; and the target node is added to the high-speed processing process queue of the data plane core and waits for release; the processor can, when judging that the global shared core number variable is a preset value, reduce the global shared processor number variable by one to indicate that all data plane cores of a processor have completed the work of this cycle; and when judging that the global shared processor number variable is a preset value, increase the preset global shared cycle variable by one to indicate that the processor enters the next working cycle; further, the data plane core can also obtain the global shared cycle variable, and when judging that the global local cycle variable of the data plane core is inconsistent with the global shared cycle variable, release the shared data corresponding to the target node in the high-speed processing process queue. It can be seen that the implementation of this method can avoid frequent application and release of locks, thereby helping to improve the efficiency of data reading, writing and processing, and improve the performance of network equipment.
[0024] Furthermore, each of the processors further includes a management plane core, wherein:
[0025] The management plane core is used to add one to the global shared core number variable and access the shared data of the target node; and after accessing the shared data of the target node, subtract one from the global shared core number variable.
[0026] A third aspect of an embodiment of the present application provides a shared data processing device for a data plane core in a multi-processor multi-core network device, the shared data processing device comprising:
[0027] An access unit is used to directly access the shared data of a target node in a shared data linked list;
[0028] a link removal unit, configured to remove the target node from the shared data linked list when the shared data needs to be deleted;
[0029] A waiting release unit, configured to add the target node to a high-speed processing queue of the data plane core to wait for release;
[0030] Acquisition unit, used to obtain global shared period variables;
[0031] a judging unit, configured to judge whether the global local periodic variable of the data plane core is consistent with the global shared periodic variable;
[0032] The releasing unit is configured to release the shared data corresponding to the target node in the high-speed processing process queue when it is determined that the global local periodic variable is inconsistent with the global shared periodic variable.
[0033] In the above implementation process, the access unit directly accesses the shared data of the target node in the shared data linked list; when the shared data needs to be deleted, the delinking unit delinks the target node from the shared data linked list; then the waiting release unit adds the target node to the high-speed processing process queue of the data plane core and waits for release; the acquisition unit then obtains the global shared period variable, and the judgment unit determines whether the global local period variable of the data plane core is consistent with the global shared period variable; if not, the release unit releases the shared data corresponding to the target node in the high-speed processing process queue. It can be seen that implementing this method can avoid frequent lock applications and releases, thereby improving the efficiency of data reading, writing and processing, and improving the performance of network equipment.
[0034] A fourth aspect of an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the shared data processing method described in any one of the first aspects of the embodiment of the present application.
[0035] A fifth aspect of an embodiment of the present application provides a computer-readable storage medium storing computer program instructions. When the computer program instructions are read and executed by a processor, the shared data processing method described in any one of the first aspects of the embodiment of the present application is executed. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0037] Figure 1 A flowchart of a method for processing shared data provided in an embodiment of the present application;
[0038] Figure 2 A system architecture diagram of a shared data processing system provided in an embodiment of the present application;
[0039] Figure 3 A schematic diagram of the structure of a shared data processing device provided in an embodiment of the present application;
[0040] Figure 4 A schematic diagram illustrating an RCU implementation mechanism provided in an embodiment of the present application;
[0041] Figure 5 A schematic diagram of a shared data processing mechanism provided in an embodiment of the present application.
[0042] Icons: 200-Processor; 210-Data Core; 220-Management Core. DETAILED DESCRIPTION
[0043] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0044] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and should not be understood as indicating or implying relative importance.
[0045] Example 1
[0046] Please see Figure 1 , Figure 1 A flow chart of a method for processing shared data is provided for an embodiment of the present application. The method for processing shared data is used for a data plane core in a multi-processor multi-core network device, including:
[0047] S101. Directly access the shared data of the target node in the shared data linked list.
[0048] In an embodiment of the present application, the multi-processor multi-core network device includes multiple processors (i.e., CPUs), core0 (core) under each CPU serves as the management plane core (abbreviated as mp) for configuration management, and other cores serve as data planes (abbreviated as dp) for data processing.
[0049] In the embodiment of the present application, in the data plane core, only one process high-speed processing queue (i.e., RCU queue) is run on each core, so only one RCU queue is needed on each core to store shared data waiting to be released.
[0050] S102: When the shared data needs to be deleted, the target node is locked with a spin lock, and then the target node is removed from the shared data linked list, and the spin lock is released.
[0051] In this embodiment, shared data is accessed without locking in the data plane core. When deleting shared data, a spin lock is used to delink the shared data, add the target node of the shared data to the RCU linked list, and then release it after a delay of a safe period. In scenarios where reads are predominant and writes are minimal, lock-free access to shared data on the data plane can significantly improve device performance.
[0052] In the embodiment of the present application, the above step S102 is implemented to remove the target node from the shared data linked list when the shared data needs to be deleted.
[0053] Please also refer to Figure 4 , Figure 4 This is a schematic diagram illustrating an RCU implementation mechanism provided by an embodiment of the present application. Figure 4 As shown, CPU0, CPU1, and CPU2 are three processors in a multi-processor multi-core network device. Suppose at a certain moment, CPU0 can read the data a→b→c→d in the shared data linked list. At the same moment, CPU1 can remove the target node b from the shared data linked list. After removing the link, at the same moment, CPU2 traverses the shared data linked list after the removal operation of CPU1, and can read the data a→c→d in the shared data linked list.
[0054] like Figure 4 As shown, when a CPU is already using the shared data of the target node b before the CPU1 detaches the link, the CPU1 detaches the link without affecting the shared data of the target node b used by the CPU.
[0055] S103: Add the preset shared data release function and the shared data of the target node to the high-speed processing process queue of the data plane core to wait for release.
[0056] In this embodiment of the present application, the data plane core can directly access shared data without locking. When deleting shared data, it is necessary to apply for a spin lock, delete the shared data from the original linked list, and then add the shared data and the written release shared data function to the RCU queue to wait for release.
[0057] In the embodiment of the present application, the above step S103 is implemented to add the target node to the high-speed processing queue of the data plane core to wait for release.
[0058] S104: Obtain a global shared periodic variable.
[0059] Please also refer to Figure 5 , Figure 5 A schematic diagram of a shared data processing mechanism provided in an embodiment of the present application. Figure 5 As shown in the figure, core1, ..., coren are all data plane cores. A global shared period variable global_age is set to represent a period. When all data plane cores have completed their work in this period, global_age++ is executed. The initial value is 0.
[0060] S105 , determining whether the global local periodic variable of the data plane core is consistent with the global shared periodic variable. If not, executing steps S106 to S107 ; if yes, executing step S108 .
[0061] like Figure 5 As shown, each data plane core sets a global local period variable local_age, which represents the current working status of the data plane core and whether it is in the same period as global_age. The initial value is -1;
[0062] In the embodiment of the present application, after each data plane core finishes its work, it will compare local_age and global_age. If the two are not equal, it means that the data plane core and global_age are not in the same cycle. Local_age will lag behind global_age by 1, indicating that the system has started a new cycle. The data plane core has passed a cycle, and the shared data on the RCU queue can be released.
[0063] After step S105, the following steps are further included:
[0064] S106: Release the shared data corresponding to the target node in the high-speed processing queue.
[0065] In an embodiment of the present application, the delayed release of shared data on the RCU queue is to place the action of releasing the shared data within a safe period, that is, the release operation of the shared data will not be actually performed until all visitors have completed their access, thereby achieving lock-free and efficient access to the shared data.
[0066] S107: Increment the global local cycle variable by one to indicate that the data plane core enters the next working cycle, and end this process.
[0067] In the embodiment of the present application, local_age++ is executed after release, indicating that the data plane core begins to enter the next cycle.
[0068] S108 , reacquire the global shared periodic variable until it is determined that the global local periodic variable is consistent with the reacquired global shared periodic variable, release the shared data corresponding to the target node in the high-speed processing queue, and end this process.
[0069] In the embodiment of the present application, if local_age and global_age are equal, it means that this core and global_age are in the same cycle, which means that there are other data plane cores that have not finished their work and need to wait and cannot release resources. Therefore, the shared data on the RCU queue is not released and other tasks continue to be executed.
[0070] In the embodiment of the present application, the multi-processor multi-core network device can be a computing device such as a computer or a server, and no limitation is made in this embodiment.
[0071] In the embodiment of the present application, the multi-processor multi-core network device may also be a smart device such as a smart phone, a tablet computer, etc., and this is not limited in this embodiment.
[0072] In an embodiment of the present application, the method implements a lock-free access method for shared data based on the RCU mechanism, which can greatly improve the performance of network devices and solve the problem that spin locks cannot meet the high performance requirements of network devices.
[0073] It can be seen that implementing the shared data processing method described in this embodiment can avoid frequent lock applications and releases, thereby facilitating improved data reading, writing, and processing efficiency, and enhancing network device performance.
[0074] Example 2
[0075] Please see Figure 2 , Figure 2 This is a flow chart of another data sharing processing system provided in an embodiment of the present application. Figure 2 As shown, the shared data processing system includes multiple processors 200, each processor 200 includes a data plane core 210, wherein,
[0076] The data plane core 210 is used to directly access the shared data of the target node in the shared data linked list; and when the shared data needs to be deleted, it uses a spin lock to lock the target node, removes the target node from the shared data linked list, and releases the spin lock; and adds the target node to the high-speed processing queue of the data plane core to wait for release;
[0077] Processor 200 is configured to determine whether a globally shared core number variable is a preset value. If so, decrement the globally shared processor number variable by one to indicate that all data plane cores of a processor have completed work in the current cycle. Processor 200 is configured to determine whether a globally shared processor number variable is a preset value. If so, increment the preset globally shared cycle variable by one to indicate that the processor has entered a next work cycle.
[0078] like Figure 5 As shown, each processor 200 sets a global shared processor count variable, ongoing_core, which is initialized to the total number of all data plane cores under the CPU. When a data plane core under the CPU completes its work, ongoing_core is reduced by 1, indicating that the data plane core has completed its work cycle. When ongoing_core is reduced to 0, the parent level ongoing_cpu (i.e., the global shared processor count variable) is reduced by 1, indicating that all cores of the CPU have completed their work cycle, and ongoing_core is reset to its initial value.
[0079] In the embodiment of the present application, a global shared processor number variable ongoing_cpu is set. When ongoing_cpu is reduced to 0, it means that all cores under all CPUs have completed their work, and the execution of global_age++ represents the end of a cycle.
[0080] The data plane core 210 is used to obtain the global shared periodic variable and determine whether the global local periodic variable of the data plane core is consistent with the global shared periodic variable; if not, release the shared data corresponding to the target node in the high-speed processing process queue.
[0081] As an optional embodiment, each processor 200 also includes a management plane core 220, wherein the management plane core 220 is used to add one to the global shared core number variable and access the shared data of the target node; and after accessing the shared data of the target node, subtract one from the global shared core number variable.
[0082] In the embodiment of the present application, when the management plane core operates shared data, it is necessary to notify the data plane core to wait for the operation to end before releasing the shared data.
[0083] In an embodiment of the present application, the management plane core may run multiple processes for configuration management, and each process requires an RCU queue. Therefore, the management plane core may have multiple RCU queues.
[0084] In an embodiment of the present application, when the management plane core operates shared data, it is necessary to actively inform the data plane core to let the data plane core know how many visitors are operating the shared data, so as to prevent the shared data from being released before all visitors complete the operation, causing the forwarding device to hang.
[0085] In the embodiment of the present application, the management plane core executes ongoing_core++ before accessing shared data to inform the data plane core to add an operator, and executes ongoing_core-- after the access is completed to indicate that the operator has left.
[0086] In the embodiment of the present application, the operation of the management plane to check the shared data is the same as that of the data plane.
[0087] In the embodiment of the present application, the system is based on the Linux kernel RCU mechanism to achieve lock-free access to shared data, and is suitable for multi-CPU, multi-core network devices to efficiently operate shared data. It solves the defects of spin locks and Linux kernel RCU that cannot meet the high-efficiency and high-performance requirements of shared data operations during high-speed message forwarding of network devices, and produces the beneficial effects of improving the efficiency of operating shared data and improving the performance of network devices.
[0088] It can be seen that the implementation of the shared data processing system described in this embodiment can avoid frequent lock applications and releases, thereby facilitating improved data reading, writing, and processing efficiency, and enhancing network device performance.
[0089] Example 3
[0090] Please see Figure 3 , Figure 3 This is a schematic diagram of a structure of a shared data processing device provided in an embodiment of the present application. Figure 3 As shown, the shared data processing device is used for the data plane core in a multi-processor multi-core network device, including:
[0091] An access unit 310 is used to directly access the shared data of a target node in a shared data linked list;
[0092] The delinking unit 320 is used to delink the target node from the shared data linked list when the shared data needs to be deleted;
[0093] A waiting release unit 330 is configured to add the target node to the high-speed processing queue of the data plane core to wait for release;
[0094] An acquisition unit 340 is configured to acquire a global shared periodic variable;
[0095] A judging unit 350 is configured to judge whether the global local periodic variable of the data plane core is consistent with the global shared periodic variable;
[0096] The releasing unit 360 is configured to release the shared data corresponding to the target node in the high-speed processing process queue when it is determined that the global local periodic variable is inconsistent with the global shared periodic variable.
[0097] As an optional implementation, the accumulation unit 370 is used to add one to the global local cycle variable after releasing the shared data corresponding to the target node in the high-speed processing process queue to indicate that the data plane core enters the next working cycle.
[0098] As an optional implementation, the re-judgment unit 380 is used to re-acquire the global shared periodic variable when the global local periodic variable is consistent with the global shared periodic variable, and release the shared data corresponding to the target node in the high-speed processing process queue until it is determined that the global local periodic variable is consistent with the re-acquired global shared periodic variable.
[0099] As an optional implementation, the waiting release unit 330 is specifically configured to add a preset shared data release function and the shared data of the target node to the high-speed processing queue of the data plane core to wait for release.
[0100] As an optional implementation, the delinking unit 320 is specifically configured to delink the target node from the shared data linked list after locking it with a spin lock and releasing the spin lock when the shared data needs to be deleted.
[0101] In the embodiments of the present application, this method is applicable to multi-CPU, multi-core network devices for efficient shared data operation. All cores maintain their own RCU queues to achieve the function of delayed release of shared data. This delayed release enables data plane cores to access shared data without locks, ensuring the secure operation of shared data and improving network device performance.
[0102] In the embodiments of the present application, the explanation of... can refer to the description in Example 1, and will not be further elaborated in this embodiment.
[0103] It can be seen that the implementation of the shared data processing device described in this embodiment can avoid frequent lock applications and releases, thereby facilitating improved data reading, writing, and processing efficiency, and enhancing network device performance.
[0104] An embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the shared data processing method in embodiment 1 of the present application.
[0105] An embodiment of the present application provides a computer-readable storage medium storing computer program instructions. When the computer program instructions are read and executed by a processor, the method for processing shared data in embodiment 1 of the present application is executed.
[0106] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or can be implemented using a combination of dedicated hardware and computer instructions.
[0107] In addition, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0108] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0109] The foregoing is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included within the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined or explained in subsequent figures.
[0110] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
[0111] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
Claims
1. A method for processing shared data, characterized in that: Data plane cores used in multi-processor multi-core network devices, including: Directly access the shared data of the target node in the shared data list; When the shared data needs to be deleted, the target node is removed from the shared data linked list; Add the target node to the high-speed processing queue of the data plane core to wait for release; the high-speed processing queue is an RCU queue; Obtaining a global shared periodic variable, and determining whether the global local periodic variable of the data plane core is consistent with the global shared periodic variable; If not, releasing the shared data corresponding to the target node in the high-speed processing process queue; Wherein, when the shared data needs to be deleted, removing the target node from the shared data linked list includes: When the shared data needs to be deleted, the target node is locked with a spin lock, and then the target node is removed from the shared data linked list, and the spin lock is released; After releasing the shared data corresponding to the target node in the high-speed processing queue, the method further includes: Incrementing the global local period variable by one to indicate that the data plane core enters the next working cycle; Wherein, the multi-processor multi-core network device includes a plurality of processors, each of which includes the data plane core and the management plane core; The processor is configured to determine whether a global shared core number variable is a preset value, and if so, decrement the global shared processor number variable by one to indicate that all data plane cores of a processor have completed work in this cycle; and determine whether the global shared processor number variable is the preset value, and if so, increment the preset global shared cycle variable by one to indicate that the processor has entered a next work cycle; The management plane core is used to add one to the global shared core number variable and access the shared data of the target node; and after accessing the shared data of the target node, subtract one from the global shared core number variable.
2. The method for processing shared data according to claim 1, characterized in that: The method further comprises: When the global local periodic variable is consistent with the global shared periodic variable, the global shared periodic variable is reacquired, and until it is determined that the global local periodic variable is consistent with the reacquired global shared periodic variable, the shared data corresponding to the target node in the high-speed processing process queue is released.
3. The method for processing shared data according to claim 1, wherein: The adding the target node to the high-speed processing queue of the data plane core to wait for release includes: The preset release shared data function and the shared data of the target node are added to the high-speed processing process queue of the data plane core to wait for release.
4. A shared data processing system, characterized in that: The shared data processing system includes a plurality of processors, each of which includes a data plane core, wherein: The data plane core is used to directly access the shared data of the target node in the shared data linked list; and when the shared data needs to be deleted, after locking with a spin lock, the target node is removed from the shared data linked list and the spin lock is released; and the target node is added to the high-speed processing queue of the data plane core to wait for release; the high-speed processing queue is an RCU queue; The processor is configured to determine whether a global shared core number variable is a preset value, and if so, decrement the global shared processor number variable by one to indicate that all data plane cores of a processor have completed work in this cycle; and determine whether the global shared processor number variable is the preset value, and if so, increment the preset global shared cycle variable by one to indicate that the processor has entered a next work cycle; The data plane core is used to obtain the global shared periodic variable and determine whether the global local periodic variable of the data plane core is consistent with the global shared periodic variable; if not, release the shared data corresponding to the target node in the high-speed processing process queue; Each of the processors further includes a management plane core, wherein: The management plane core is used to add one to the global shared core number variable and access the shared data of the target node; and after accessing the shared data of the target node, subtract one from the global shared core number variable.
5. A shared data processing device, characterized in that: For use in a data plane core of a multi-processor multi-core network device, the shared data processing device includes: An access unit is used to directly access the shared data of a target node in a shared data linked list; a link removal unit, configured to remove the target node from the shared data linked list when the shared data needs to be deleted; A waiting release unit, configured to add the target node to a high-speed processing queue of the data plane core to wait for release; the high-speed processing queue is an RCU queue; Acquisition unit, used to obtain global shared period variables; a judging unit, configured to judge whether the global local periodic variable of the data plane core is consistent with the global shared periodic variable; a releasing unit, configured to release the shared data corresponding to the target node in the high-speed processing process queue when it is determined that the global local periodic variable is inconsistent with the global shared periodic variable; The delinking unit is specifically used to delink the target node from the shared data linked list after locking it with a spin lock and releasing the spin lock when the shared data needs to be deleted. The shared data processing device further includes: The accumulation unit is used to add one to the global local cycle variable after releasing the shared data corresponding to the target node in the high-speed processing process queue, so as to indicate that the data plane core enters the next working cycle; Wherein, the multi-processor multi-core network device includes a plurality of processors, each of which includes the data plane core and the management plane core; The processor is configured to determine whether a global shared core number variable is a preset value, and if so, decrement the global shared processor number variable by one to indicate that all data plane cores of a processor have completed work in this cycle; and determine whether the global shared processor number variable is the preset value, and if so, increment the preset global shared cycle variable by one to indicate that the processor has entered a next work cycle; The management plane core is used to add one to the global shared core number variable and access the shared data of the target node; and after accessing the shared data of the target node, subtract one from the global shared core number variable.
6. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the shared data processing method according to any one of claims 1 to 3.
7. A readable storage medium, characterized in that: The readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a processor, the method for processing shared data according to any one of claims 1 to 3 is executed.
Citation Information
Patent Citations
Network device shared memory freeing method and system
CN103902464A