Memory access control method and optical network unit router
Shared memory is managed through a proxy mechanism. When the core requests memory space, it obtains and reserves the address range from a specific allocation queue. This solves the problem of memory contention between cores in multi-core network processors, improves overall performance, and reduces waiting time. .
Patent Information
- Application Number
- CN202310160724.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-24
- Publication Date
- 2024-08-27
AI Technical Summary
Contention between cores for shared memory in multi-core network processing units leads to performance degradation. The existing locking mechanism increases the time that cores wait to obtain memory control, reducing overall performance.
The agent mechanism is used to manage the shared resource pool and multiple allocation queues through the central processor. When the core requests memory space, it obtains and reserves the address range from a specific allocation queue, avoiding waiting caused by the locking mechanism and improving the efficiency of concurrent memory access.
It reduces the time that the cores in the network processor wait to obtain random access memory, improves the overall performance of the multi-core network processor, and avoids the performance bottleneck caused by the locking mechanism.
Smart Images

Figure CN118550446A
Abstract
Description
Technical Field
[0001] The present invention relates to memory management technology, and in particular to a memory access control method, a computer-readable storage medium and a device. Background Art
[0002] A network processing unit (NPU) is an integrated circuit that is specifically used in network devices and can be programmed by software. The algorithms executed in the network processing unit mainly include various functions for processing data packets, which are used to continuously receive data packets from one port, and transmit them to another port after decapsulation, data processing, and encapsulation. As network applications become more and more diverse and the amount of transmitted data becomes larger and larger, a single-core NPU cannot meet the requirements of data processing speed, causing more and more network devices to configure multi-core NPUs to specifically perform various data packet processing and forwarding. However, the parallel execution of multi-core NPUs will cause contention between cores for shared memory, resulting in a decrease in the overall performance of network devices. Therefore, how to resolve the conflict of shared memory between multiple cores to improve the overall performance of the system is an important issue at present. Summary of the invention
[0003] In view of this, how to alleviate or eliminate the above-mentioned defects in related fields is indeed a problem to be solved.
[0004] The present specification relates to an embodiment of a memory access control method, which is executed by a central processing unit and includes: obtaining an identification code of a core in a network processor, the core requesting allocation of memory space; determining one from multiple allocation queues based on the identification code of the core; and dequeuing one or more items starting from a slot indicated by an extraction index in a shared resource pool, and enqueuing the items starting from an empty slot indicated by a write index in the determined allocation queue to the determined allocation queue, wherein each item includes a memory address range of a random access memory, which is used to reserve this memory address range for the core.
[0005] The present specification also relates to an embodiment of a computer-readable storage medium, which includes a computer program. When a processing unit loads and executes the computer program, the memory access control method shown above is implemented.
[0006] The specification also relates to an embodiment of an optical network unit (ONU) router, comprising: a network processor, comprising a plurality of cores; a random access memory, comprising a shared resource pool and a plurality of allocation queues; and a central processing unit. The central processing unit is configured to obtain an identification code of a core in the network processor, the core requesting allocation of memory space; determine one from a plurality of allocation queues according to the identification code of the core; and dequeue one or more items from a slot indicated by an extraction index in the shared resource pool, and enqueue the items from an empty slot indicated by a write index in the determined allocation queue to the determined allocation queue, wherein each item comprises a memory address interval of the random access memory, for reserving the memory address interval for the core.
[0007] The present specification also relates to an embodiment of a memory access control method, which is applied to a multi-core network processor, including a first core and a second core. The memory access control method includes: in response to a request from the first core to allocate memory space, providing a first item to the first core from a first allocation queue dedicated to the first core, wherein the first allocation queue is not used by the second core; and the first core accessing the memory space specified by the memory address interval recorded in the first item.
[0008] One of the advantages of the above embodiment is that the time that any core in the network processor waits for obtaining control of the random access memory is reduced through the above method.
[0009] Other advantages of the present invention will be explained in more detail with reference to the following description and accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The drawings described herein are used to provide further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute improper limitations on the present application.
[0011] Figure 1 FIG. 1 is a schematic diagram of memory access control according to some implementation modes.
[0012] Figure 2 is a schematic diagram of a passive optical network according to an embodiment of the present invention.
[0013] Figure 3 4 is a system architecture diagram of an optical network unit router according to an embodiment of the present invention.
[0014] Figure 4 A schematic diagram showing a shared resource pool and three pairs of allocation queues and reclaim queues according to an embodiment of the present invention.
[0015] Figure 5 FIG. 4 is a schematic diagram of a proxy mechanism according to an embodiment of the present invention.
[0016] Figure 6 is a flow chart of a method for allocating memory space according to an embodiment of the present invention.
[0017] Figure 7 FIG. 4 is a schematic diagram of an initialization proxy mechanism according to an embodiment of the present invention.
[0018] Figure 8 It is a schematic diagram of an example of obtaining a memory address range according to an embodiment of the present invention.
[0019] Fig. 9 A schematic diagram of an example of requesting to reserve a memory address range according to an embodiment of the present invention.
[0020] Fig.10 FIG. 4 is a schematic diagram of an example of releasing a memory address range according to an embodiment of the present invention.
[0021] Fig.11 Flow chart of a method for reclaiming memory space according to an embodiment of the present invention.
[0022] Fig.12 It is a schematic diagram of an example of reclaiming an allocated memory address range according to an embodiment of the present invention.
[0023] Among them, the simple description of the symbols in the accompanying drawings is as follows:
[0024] 110: central processing unit; 115: locking mechanism; 120: network processor; 120#0~120#n: core; 130: shared memory; 20: optical network unit router; 210: Internet; 230: optical line terminal; 250: user device; 310: network processor; 310#0~310#n: core; 320: central processing unit; 330: random access memory; 340: media access control for passive optical network; 350: Ethernet media access control; 360: media storage for fast peripheral component interconnection Take control; 370: physical layer; 432: shared resource pool; 436#0~436#n: allocation queue; 438#0~438#n: recovery queue; 500: agent module; 526: allocation event handler; 527: recovery event handler; S610~S630: method steps; 810#0, 830#0, 950, 1010#1, 1030#1, 1250: application program interface; 910: allocation event; S1110~S1160: method steps; 1210: recovery event. DETAILED DESCRIPTION
[0025] The embodiments of the present invention will be described below with reference to the accompanying drawings. In these drawings, the same reference numerals represent the same or similar components or method flows.
[0026] It must be understood that the words "comprise", "include" and the like used in this specification are used to indicate the existence of specific technical features, values, method steps, operation processes, parts and / or components, but do not exclude the addition of more technical features, values, method steps, operation processes, parts, components, or any combination of the above.
[0027] The words "first", "second", "third", etc. used in the present invention are used to modify the components in the claims, and are not used to indicate a priority order, a prior relationship, or that one component precedes another, or a time sequence when executing method steps. They are only used to distinguish components with the same name.
[0028] It should be understood that when a component is described as being "connected" or "coupled" to another component, it may be directly connected or coupled to the other component, and there may be intervening components. Conversely, when a component is described as being "directly connected" or "directly coupled" to another component, there are no intervening components. Other words used to describe the relationship between components can also be interpreted in a similar manner, such as "between" versus "directly between", or "adjacent" versus "directly adjacent", etc.
[0029] refer to Figure 1Schematic diagram of memory access control according to some embodiments shown. Current network devices are usually configured with a central processing unit (CPU) 110 and a network processor (NPU) 120 at the same time, and these two processors are responsible for performing different tasks. NPU 120 is a high-speed programmable processor specifically used to perform packet processing and forwarding, providing a more efficient and flexible packet processing solution. As network applications become more and more diverse, and the amount of transmitted data becomes larger and larger, a single-core NPU cannot meet the requirements of data processing speed, so that more and more network devices are configured with multi-core NPU 120 to specifically perform a variety of packet processing and forwarding. However, the parallel execution of multi-core NPU 120 will cause contention between cores for shared memory 130. Shared memory 130 can be static random access memory (SRAM), dynamic random access memory (DRAM), etc. In order to resolve the contention conflict between cores for the shared memory, in some embodiments, the CPU 110 may execute a lock mechanism 115 to manage the concurrent access of multiple cores 120#0 to 120#n to the shared memory 130. For example, when the lock mechanism 115 permits the core 120#0 to lock the shared memory 130 at time point t1, the core 120#0 can freely read data from the shared memory 130 or store data to the shared memory 130. If the core 120#n requests to lock the shared memory 130 at time point t2, the lock mechanism 115 rejects the core 120#n because the shared memory 130 has been locked by the core 120#0. After the core 120#0 releases the shared memory 130 at time point t3, the lock mechanism 115 allows the shared memory 130 to enter the unlocked state, so that the core 120#n can successfully lock the shared memory 130 at time point t4 to access the data. However, the locking mechanism 115 will cause any core in the network processor 120 to spend time waiting for other cores to release the shared memory 130 before accessing data, thereby reducing the overall performance of the network device.
[0030] To solve the above problems, an embodiment of the present invention proposes a memory access control method to avoid unnecessary waiting time for the cores in the NPU due to the shared memory 130 being locked, thereby improving the overall performance of the multi-core NPU. Although the shortcomings of the above implementation are described in the specification, this is only the original inspiration for the invention embodiment described below. Personnel in the relevant technical field can apply these technical solutions to solve other technical problems, or apply them to other technical environments, and the present invention should not be limited thereto.
[0031] In some embodiments, the memory access control method may be applied in optical network units (ONUs). Figure 2 Schematic diagram of Passive Optical Network (PON) shown in FIG. The passive optical network is composed of an optical line terminal (OLT) 230 in the central control room of the service provider and multiple ONUs, such as an ONU router 20. The OLT 230 provides two main functions: one is to convert between the electrical signals used by the service provider's equipment and the optical fiber signals used by the PON; the other is to integrate the multiplexing between the ONUs and the other end of the PON. The OLT 230 and the ONU router 20 are connected by an optical link. The ONU router 20 is a user-end device of the PON system, which can be set up in the home and is used to interconnect with the user device 250 using an Ethernet link or a wireless link. The user device 250 can be an electronic product such as a personal computer, a laptop PC, a tablet computer, a mobile phone, a digital camera, a digital video camera, a smart TV, a smart air conditioner, a smart refrigerator, and a smart range hood. In conjunction with the OLT 230 , the ONU router 20 can provide various broadband services to the connected user devices 250 , such as Internet surfing, Voice over Internet Protocol (VoIP), high-definition video, etc.
[0032] refer to Figure 3The system architecture diagram of the ONU router 20 shown in FIG. The ONU router 20 includes a multi-core NPU 310, a CPU 320, a random access memory (DRAM) 330, a PON media access control (MAC) 340, an Ethernet MAC 350, and a peripheral component interconnect express (PCIE) MAC 360, which are coupled to each other using a shared bus architecture. The shared bus architecture is used to allow data, addresses, control signals, etc. to be transmitted between the above components. The shared bus includes parallel physical lines and is a shared transmission medium. At any time, only two devices can use these lines to communicate with each other for data transmission. Data and control signals can be transmitted bidirectionally along the data line and the control line respectively between components, but on the other hand, the address signal can only be transmitted unidirectionally along the address line. For example, when the NPU 310 wants to read data at a specific address of the RAM 330, the NPU 310 transmits this address to the RAM 330 on the address line. Then, the data of the address is returned on the data line to the NPU 310. To complete the data read operation, the control signal is transmitted using the control line.
[0033] The CPU 320 can be implemented in a variety of ways, such as using general hardware (e.g., a microcontroller unit, a digital signal processor, a single processor, a multiprocessor with parallel processing capabilities, a graphics processor, or other processors with computing capabilities), and provides specific functions when executing software instructions. The multi-core NPU 310 includes one or more integrated circuits with a set of functions that are specific to the field of network applications. The multi-core NPU 310 is a software programmable device that has general characteristics similar to a general processing unit, but in order to improve the overall performance of the ONU router 20, it is used to process data packets transmitted between different types of networks (e.g., PON, Ethernet, wireless local area network, personal access network, and other networks). The RAM 330 can configure space as a data buffer to temporarily store data packets received from ports corresponding to different types of networks, as well as data packets to be transmitted to ports corresponding to different types of networks. The RAM 330 can also store data required by the multi-core NPU 310 during execution, such as variables, flags, data tables, etc. The PON MAC 340 is coupled to the corresponding circuits in the physical layer 370, and drives the corresponding circuits therein (which may include an optical receiver and an optical transmitter) to generate a series of optical signal interactions with the OLT 230, so as to receive data packets from the OLT 230 through an optical link, and to send data packets to the OLT 230. The Ethernet MAC 350 is coupled to the corresponding circuits in the physical layer 370 (which may include a digital receiver and a digital transmitter), and drives the corresponding circuits therein to generate a series of electrical signal interactions with the user device 250, so as to receive data packets from a specific user device 250 through an Ethernet link, and to send data packets to a specific user device 250. The PCIE MAC 360 is coupled to the corresponding circuits in the physical layer 370 (which may include an RF receiver and an RF transmitter), and drives the corresponding circuits therein to generate a series of RF signal interactions with the user device 250, so as to receive data packets from a specific user device 250 through a wireless link, and to send data packets to a specific user device 250. The wireless link may include a link established using wireless communication protocols such as 802.11x and Bluetooth.
[0034] In order to resolve the contention conflict between cores for the shared memory, the embodiment of the present invention proposes a proxy mechanism, which is different from the locking mechanism described above. Figure 4In order to enable the proxy mechanism to operate, for example, RAM 330 configures space for a shared resource pool 432, and three pairs of allocated queues 436#0 to 436#2 and recycled queues 438#0 to 438#2. Shared resource pool 432 may be implemented as a cyclical queue, including a plurality of slots, each of which may be an empty slot or include an item, the item storing information of an address range, which is used to correspond to the available space allocated to network processor 310 in RAM 330. Each item among all items stored in shared resource pool 432 may be referred to as an available item, and the memory address ranges in any two available items do not overlap.
[0035] For example, in Figure 4 In the shared resource pool 432, the address range of the 0th item is 0x10000000 to 0x1000FFFF (indicated as "A"), the address range of the 1st item is 0x10010000 to 0x1001FFFF (indicated as "B"), the memory address range of the 2nd item is 0x10020000 to 0x1002FFFF (indicated as "C"), and so on. Figure 4 In the example, all slots of shared resource pool 432 contain one item.
[0036] The shared resource pool 432 can use a put index (PI) to complete an enqueue operation and a take index (TI) to complete a dequeue operation. Except when the put index PI and the take index TI point to the same slot, the slot pointed to by the take index TI is a slot containing an item, while the slot pointed to by the put index PI is an empty slot.
[0037] When there are still empty slots in the shared resource pool 432, the CPU 320 may add an entry to the empty slot pointed to by the placement index PI (also called enqueue) in the shared resource pool 432, and point the placement index PI to the next slot. If the next slot is beyond the last slot of the shared resource pool 432, the updated placement index PI points to the first slot of the shared resource pool 432. If the updated placement index PI is the same as the extraction index TI, it means that there are no empty slots in the shared resource pool 432.
[0038] When the shared resource pool 432 is not an empty queue, the CPU 320 may remove the item in the shared resource pool 432 pointed to by the extraction index TI (also called dequeue), and move the extraction index TI to the next slot. If the next slot exceeds the last slot of the shared resource pool 432, the updated extraction index TI points to the first slot of the shared resource pool 432. If the updated extraction index TI is the same as the placement index PI, it means that the shared resource pool 432 has become an empty queue.
[0039] Each pair of allocation queues and recycling queues is set to a corresponding core, so that a pair of allocation queues-recycling queues is used by only one core. For example, allocation queue 436#0 and recycling queue 438#0 are set to core 310#0 (shown in FIG. Figure 5 ), the allocation queue 436#1 and the recycling queue 438#1 are set to the core 310#1 (shown in FIG. Figure 5 ), and so on. Each allocation queue and each reclaim queue can be implemented as a circular queue.
[0040] Allocation queue 436 (representing any one of allocation queues 436#0 to 436#3) includes a plurality of slots, each of which may be an empty slot or include an entry that stores an available address interval reserved for the corresponding core in RAM 330. For example, each entry in allocation queue 436#0 stores an available address interval reserved for core 310#0 in RAM 330, each entry in allocation queue 436#1 stores an available address interval reserved for core 310#1 in RAM 330, and so on.
[0041] Each allocation queue can use a write index (expressed as "WI") and a read index (expressed as "RI") to complete the operations of enqueue and dequeue. Except for the case where the read index RI and the write index WI point to the same slot, the slot pointed to by the read index RI is a slot containing an item, while the slot pointed to by the write index WI is an empty slot. The enqueue and dequeue operations of the allocation queue 436 are similar to the enqueue and dequeue operations of the shared resource pool 432, and will not be repeated for the sake of simplicity.
[0042] The recycling queue 438 (representing any one of the recycling queues 438#0 to 438#3) includes a plurality of slots, each of which may be an empty slot or include an entry that stores the address interval of the RAM 330 released by the corresponding core. For example, each entry in the recycling queue 438#0 stores the address interval of the RAM 330 released by the core 310#0, each entry in the recycling queue 438#1 stores the address interval of the RAM 330 released by the core 310#1, and so on.
[0043] Each recycling queue can use a write index (denoted as "WI") and a read index (denoted as "RI") to complete the enqueue and dequeue operations. Except for the case where the read index RI and the write index WI point to the same slot, the slot pointed to by the read index RI is a slot containing an item, while the slot pointed to by the write index WI is an empty slot. The enqueue and dequeue operations of the recycling queue 438 are similar to the enqueue and dequeue operations of the shared resource pool 432, and will not be repeated for the sake of simplicity.
[0044] In addition to the shared resource pool 432, the allocation queue 436 and the recycling queue 438, reference Figure 5 The CPU 320 executes the program code of the proxy module 500 to manage the shared storage resources. The proxy module 500 can provide an application programming interface (API) for the shared resource pool 432, the allocation queue 436 and the recycling queue 438.
[0045] The APIs provided to the shared resource pool 432 include: "api_ALLOCATE" and "api_FREE". The API "api_ALLOCATE" is used to extract a specified number of items from the shared resource pool 432 starting from the slot pointed to by the extraction index TI, and update the extraction index TI to point to the next slot of the last extracted item. The API "api_FREE" is used to store a specified number of items into the shared resource pool 432 starting from the empty slot pointed to by the placement index PI, and update the placement index PI to point to the next slot of the last stored item.
[0046] The APIs provided to the allocation queue 436 include: "api_GET" and "api_PUT". The API "api_GET" is used to extract a specified number of items from the allocation queue 436 starting from the slot pointed to by the read index RI, and update the read index RI to point to the next slot of the last extracted item. The API "api_PUT" is used to store a specified number of items to the allocation queue 436 starting from the empty slot pointed to by the write index WI, and update the write index WI to point to the next slot of the last stored item.
[0047] The APIs provided to the recycling queue 438 include: "api_GET" and "api_PUT". The API "api_GET" is used to extract a specified number of items from the recycling queue 438 starting from the slot pointed to by the read index RI, and update the read index RI to point to the next slot of the last extracted item. The API "api_PUT" is used to store a specified number of items to the recycling queue 438 starting from the empty slot pointed to by the write index WI, and update the write index WI to point to the next slot of the last stored item.
[0048] The proxy module 500 can uniformly allocate shared storage resources (e.g., available space in the RAM 330 allocated to the network processor 310) to multiple cores 310#0 to 310#n in the network processor 310, where n is the total number of cores minus one. The proxy module 500 includes an allocation event handler 526, and provides an allocation event that can be triggered by other programs in the proxy module 500 or a program executed in any core. In addition to triggering an allocation event, the program can also take in parameters to provide a core identification code and a request number. When the CPU 320 detects an allocation event, the program code of the allocation event handler 526 is executed to migrate one or more items in the shared resource pool 432 to a corresponding one of the allocation queues 436#0 to 436#n indicated by the parameter through the API "api_ALLOCATE" and "api_PUT" according to the input parameter, indicating that a portion of the space in the RAM 330 is reserved for the corresponding core. It should be noted that the memory address interval of any item in the allocation queue 436 is only reserved for the corresponding core in advance so that the corresponding core can use it when needed in other programs after the allocation event handler 526, and it does not mean that it has been used by the corresponding core. If the corresponding core wants to use the memory address interval of the item, it must also execute other programs to extract the item from the allocation queue 436 through the API "api_GET" before it can use the memory address interval of the extracted item. Figure 6 The memory space allocation method shown is implemented when the CPU 320 loads and executes the program code of the allocation event processing program 526, and is described in detail as follows:
[0049] Step S610: Obtain the core identification code and the requested number from the input parameters.
[0050] Step S620: Determine one from the multiple allocation queues according to the core identification code. For example, determine allocation queue 436#0 according to the core identification code of core 310#0, determine allocation queue 436#1 according to the core identification code of core 310#1, and so on.
[0051] Step S630: Migrate the requested number or less items in the shared resource pool 432 to the determined allocation queue. For example, the requested number is 2, but the allocation event handler 526 extracts only one item from the slot indicated by the extraction index TI in the shared resource pool 432 through the API "api_ALLOCATE", for example, extracts the 0th item, and stores the extracted item to the slot indicated by the write index WI in the allocation queue 436#0 through the API "api_PUT", which means that the agent module 500 allocates the address range "0x10000000~0x1000FFFF" of the RAM 330 to the core 310#0. In other words, the cores 310#1 to 310#n cannot see the address range "0x10000000~0x1000FFFF".
[0052] refer to Figure 4 In the initial state shown, all slots of the shared resource pool 432 store items "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q" and "R", and the extraction index TI and placement index PI of the shared resource pool 432 both point to the slot storing item "A", and the RI and WI of 436#0, 436#1 and 436#2 respectively point to the first slot of each. Next, referring to Figure 7 The schematic diagram of the initialization proxy mechanism shown triggers three allocation events, which are used to allow the allocation event handler 526 to migrate items "A", "B", "C" and "D" in the shared resource pool 432 to the allocation queue 436#0, migrate items "E", "F", "G" and "H" in the shared resource pool 432 to the allocation queue 436#1, and migrate items "I", "J", "K" and "L" in the shared resource pool 432 to the allocation queue 436#2. The updated extraction index TI of the shared resource pool 432 points to the slot storing the item "M", the updated WI of the allocation queue 436#0 points to the next slot storing the item "D", the updated WI of the allocation queue 436#1 points to the next slot storing the item "H", and the updated WI of the allocation queue 436#2 points to the next slot storing the item "L".
[0053] When any core needs more space in RAM 330 to access data, it can extract one or more items from the allocation queue to which it belongs through the API "api_GET". After that, the core can freely store data in the specific address range of RAM 330 pointed to by the item, and read data from this address range. By setting up the allocation queues 436#0 to 436#n and running the allocation event handler, the address range of RAM 330 that each core can access is independent of the address range of RAM 330 that other cores can access, so that each core's data access to RAM 330 will not affect other cores, and unnecessary waiting time caused by the locking mechanism described above can be avoided. Reference Figure 8 In the example of obtaining a memory address interval shown, the program running in core 310#0 can request allocation of an available memory address interval through API "api_GET" 810#0. After receiving the request, the module corresponding to API "api_GET" 810#0 extracts item "M" from allocation queue 436#0 and replies to core 310#0, so that the program running in core 310#0 can freely access the memory address interval recorded in item "M". The updated RI is updated from pointing to the 5th slot to pointing to the 6th slot.
[0054] As more and more programs are running on a core, the allocated memory address range in the corresponding allocation queue may not be sufficient to support the execution of the program. Fig. 9 In the example of requesting to reserve a memory address interval, when the program running in the core 310#0 detects that the total number of items stored in the allocation queue 436#0 is lower than a threshold value (for example, the threshold value may be set to half of the total number of slots in the allocation queue 436), an allocation event 910 is triggered to request the agent module 500 to allocate 2 items. In response to the allocation event 910, the allocation event handler 526 obtains the identification code and the request number of the core 310#0 (step S610), and determines the allocation queue 436#0 according to the identification code of the core 310#0 (step S620). The allocation event handler 526 extracts the items "Q" and "R" from the shared resource pool 432 through the API "api_ALLOCATE" 950, and pushes the items "Q" and "R" into the allocation queue 436#0 through the API "api_PUT" 830#0 corresponding to the core 310#0 (step S630). The extraction index TI is updated from pointing to the second to last slot to pointing to the first slot, and the WI is updated from pointing to the first slot to pointing to the third slot.
[0055] In order to optimize the use of memory space, when any core does not need to use the extracted memory address interval in RAM 330, the specified item indicating the extracted memory address interval can be pushed into the recycling queue to which it belongs through the API "api_PUT" to release the memory address interval. Fig.10 In the example of releasing the memory address interval shown, the program running in core 310#1 can request to reclaim items "E" and "F" through API "api_PUT" 1010#1. After receiving the request, the module corresponding to API "api_PUT" 1010#1 pushes items "E" and "F" from core 310#1 into reclaim queue 438#1. WI is updated from pointing to the first slot to pointing to the third slot.
[0056] The proxy module 500 can uniformly recycle shared storage resources from multiple cores 310#0 to 310#n in the network processor 310, where n is the total number of cores minus one. The proxy module 500 includes a recycling event handler 527 (e.g., Figure 5 As shown). In response to the need to recycle shared storage resources, a recycling event (recycling event) is provided that can be triggered by other programs in the agent module 500. In other embodiments, a supervisory program can be executed in any one of the cores 310#0 to 310#n to obtain the items stored in the corresponding recycling queue. When the supervisory program detects that the items stored in the corresponding recycling queue exceed a threshold (for example, half of all the items in the corresponding recycling queue), a recycling event is triggered. When the CPU 320 detects a recycling event, the program code of the recycling event handler 527 is executed to migrate all items in the recycling queues 438#0 to 438#n to the empty slots in the shared resource pool 432 through the APIs "api_GET" and "api_FREE", indicating that the specified space of the RAM 330 is reclaimed from the cores 310#0 to 310#n. Reference Fig.11 The memory space recycling method shown is implemented when the CPU 320 loads and executes the program code of the recycling event processing program 527. This method includes an outer loop (steps S1110 to S1160) that is repeatedly executed to recycle the allocated memory space. The outer loop includes an inner loop (S1120 to S1150) that is repeatedly executed to collect the memory space that has been allocated to the corresponding core from the recycling queue one by one. The detailed description is as follows:
[0057] Step S1110: Set the variable i to 0. The variable i is used to record the number of the recycling queue currently being processed.
[0058] Step S1120: Determine whether the i-th recycling queue is an empty queue. If so, the process proceeds to step S1140. Otherwise, the process proceeds to step S1130.
[0059] Step S1130: Migrate all items in the i-th recycling queue to the shared resource pool 432. For example, extract all items from the recycling queue 438#0 through the API "api_GET", and then push the extracted items into the empty slots in the shared resource pool 432 in sequence through the API "api_FREE".
[0060] Step S1140: Add 1 to the variable i.
[0061] Step S1150: Determine whether the variable i is greater than or equal to the total number of cores in the NPU 310. If so, the process proceeds to step S1160. Otherwise, the process proceeds to step S1120. If the variable i is greater than or equal to the total number of cores, it means that all recycling queues have been changed back to empty queues.
[0062] Step S1160: Wait for a default period of time, or wait for the triggering of a recycling event. In some embodiments, the recycling event handler 527 may set a timer to count the default period of time. When the timer counts to the period of time, the recycling event is triggered. In other embodiments, the recycling event handler 527 may wait for other programs in the agent module 500 to trigger a recycling event. In other embodiments, the recycling event handler 527 may wait for a supervisory program executed in any one of the cores 310#0 to 310#n to trigger a recycling event.
[0063] refer to Fig.12 In the example of reclaiming the allocated memory address interval shown, when the reclaim event 1210 is triggered, the reclaim event handler 527 extracts items "E" and "F" from the reclaim queue 438#17 through the API "api_GET" 1030#1, and pushes items "E" and "F" into the empty slots in the shared resource pool 432 in sequence through the API "api_FREE" 1250 (step S1160). RI is updated from pointing to the first slot of 438#1 to pointing to the third slot, and PI is updated from pointing to the first slot of 432 to pointing to the third slot.
[0064] All or part of the steps in the method described in the present invention can be implemented by a computer program, such as a driver of a hardware, a program code of an application. In addition, it can also be implemented in other types of programs as shown above. A person skilled in the art can write the method of the embodiment of the present invention into a program code, which will not be described for simplicity. The computer program implemented according to the method of the embodiment of the present invention can be stored in an appropriate computer-readable storage medium, or can be placed in a network server that can be accessed through a network (e.g., the Internet, or other appropriate media).
[0065] Computer-readable storage media include volatile and non-volatile, removable and non-removable media that implement the storage of information, such as computer-readable instructions, data structures, program modules, or other data, in any method or technology. Computer-readable storage media include but are not limited to RAM, ROM, EEPROM, flash memory or other memory, CD-ROM, DVD, Blu-ray disc or other optical storage media, magnetic cards, magnetic tapes, hard disks or other magnetic storage media, or other carriers that can be used to store information required and accessed by the instruction execution system. It should be noted that the computer-readable storage medium can be paper or other suitable media for printing program code so that its program code can be obtained electronically, such as by optically scanning paper or other media, and then, if necessary, compiled, interpreted or processed in other suitable ways, and then stored in the computer's memory.
[0066] Although Figures 2 to 3 The components described above are included, but it does not exclude the use of more additional components to achieve better technical effects without violating the spirit of the invention. Figure 6 , Fig.11 The flowchart is executed in a specified order, but without violating the spirit of the invention, a person skilled in the art can modify the order of these steps while achieving the same effect, so the present invention is not limited to using only the order described above. In addition, a person skilled in the art can also integrate several steps into one step, or execute more steps sequentially or in parallel in addition to these steps, and the present invention should not be limited thereto.
[0067] The above description is only a preferred embodiment of the present invention, but it is not intended to limit the scope of the present invention. Any person familiar with the present technology can make further improvements and changes on this basis without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be based on the scope defined by the claims of this application.
Claims
1. A memory access control method, executed by a central processing unit, wherein the central processing unit is coupled to a network processor, the network processor comprising a plurality of cores, characterized in that: The memory access control method comprises: obtaining an identification code of a first core, the first core requesting allocation of memory space; determining a first allocation queue from a plurality of allocation queues according to the identification code of the first core; and Dequeue one or more first items starting from the slot indicated by the extraction index in the shared resource pool, and enqueue the first items to the first allocation queue starting from the empty slot indicated by the write index in the first allocation queue, wherein each of the first items includes a memory address interval of the random access memory, for reserving the memory address interval for the first core.
2. The memory access control method according to claim 1, characterized in that: The shared resource pool is a circular queue, and memory address intervals of any two available items in all available items in the shared resource pool do not overlap.
3. The memory access control method according to claim 1, characterized in that: After the first core dequeues the first item in the first allocation queue through the first application interface, it stores data in the memory address range of the random access memory included in the first item, or reads data from the memory address range of the random access memory included in the first item.
4. The memory access control method according to claim 1, characterized in that: Also includes: enqueueing the second items of each of the plurality of recycling queues into an empty slot of the shared resource pool, Each of the second items includes a memory address interval previously allocated to one of the cores in the network processor.
5. The memory access control method according to claim 4, characterized in that: When the second core does not need to use a memory address interval of the random access memory previously extracted, the corresponding second item is enqueued into the corresponding recycling queue through the second application program interface.
6. The memory access control method according to claim 4, characterized in that: The recycling event handler includes an operation of enqueuing the second items of each of the plurality of recycling queues into the shared resource pool, The memory access control method further includes: executing the recycling event processing program when a recycling event is triggered.
7. The memory access control method according to claim 1, wherein: The allocation event handler includes a first operation of obtaining the identification code of the first core, a second operation of determining the first allocation queue, a third operation of dequeuing the first item from the shared resource pool, and a fourth operation of enqueuing the first item to the first allocation queue, The memory access control method further includes: executing the allocation event processing program when an allocation event is triggered.
8. An optical network unit router, namely an ONU router, characterized in that: include: a network processor comprising a plurality of cores; A random access memory coupled to the network processor and comprising a shared resource pool and a plurality of allocation queues; a central processing unit coupled to the network processor and the random access memory and configured to obtain an identification code of the first core from the first core of the network processor, Among them, the first core requests allocation of memory space; determines the first allocation queue from the multiple allocation queues according to the identification code of the first core; and dequeues one or more first items starting from the slot indicated by the extraction index in the shared resource pool, and enqueues the first items to the first allocation queue starting from the empty slot indicated by the write index in the first allocation queue, wherein each of the first items includes a memory address range of a random access memory, which is used to reserve the memory address range for the first core.
9. The ONU router according to claim 8, characterized in that: The shared resource pool is a circular queue, and memory address intervals of any two available items in all available items in the shared resource pool do not overlap.
10. The ONU router according to claim 8, characterized in that: After the first core dequeues the first item in the first allocation queue through the first application interface, it stores data in the memory address range of the random access memory included in the first item, or reads data from the memory address range of the random access memory included in the first item.
11. The ONU router according to claim 8, characterized in that: The central processor is configured to enqueue a plurality of second items in a plurality of recycling queues into empty slots of the shared resource pool, wherein each of the second items includes a memory address interval previously allocated to one of the cores in the network processor.
12. The ONU router according to claim 11, characterized in that: When the second core does not need to use a memory address interval of the random access memory previously extracted, the corresponding second item is enqueued into the corresponding recycling queue through the second application program interface.
13. The ONU router according to claim 11, characterized in that: The recycling event processing program includes an operation of enqueuing the plurality of second items in the plurality of recycling queues into the shared resource pool, and the central processor is configured to execute the recycling event processing program when a recycling event is triggered.
14. The ONU router according to claim 8, characterized in that: The allocation event handler includes a first operation of obtaining the identification code of the first core, a second operation of determining the first allocation queue, a third operation of dequeuing the first item from the shared resource pool, and a fourth operation of enqueuing the first item to the first allocation queue, The central processor is configured to execute the allocation event handler when an allocation event is triggered.
15. A memory access control method, applied to a multi-core network processor, wherein the multi-core network processor comprises a first core and a second core, characterized in that: The memory access control method comprises: In response to the first core requesting allocation of memory space, providing a first item to the first core from a first allocation queue dedicated to the first core, wherein the first allocation queue is not used by the second core; and The first core accesses a memory space specified by a memory address interval recorded in the first entry.
16. The memory access control method according to claim 15, characterized in that: Also includes: In response to an allocation event, extracting the first item from a shared resource pool; as well as The first item is pushed into the first allocation queue.
17. The memory access control method according to claim 15, characterized in that: Also includes: In response to the first core requesting to release memory space, the second item provided for use by the first core is pushed into a first recycling queue dedicated to the first core, The memory address interval recorded by the second item pushed into the first recycling queue is no longer used by the first core, and The first allocation queue is not used by the second core.
18. The memory access control method according to claim 17, characterized in that: Also includes: In response to a reclaim event, the second item in the first reclaim queue is migrated to an empty slot in a shared resource pool.
