Method for sharing cache space among multi-priority queues
By dynamically adjusting the shared cache space allocation rules of multi-priority queues, the problem of high-priority queues being preempted by low-priority queues in the shared cache space is solved, thus achieving efficient utilization of cache space.
Patent Information
- Application Number
- CN202511940053.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-22
- Publication Date
- 2026-01-20
- Estimated Expiration
- 2045-12-22
AI Technical Summary
When multiple priority queues compete for shared cache space, high-priority queues are prone to congestion and packet loss due to low-priority queues preempting cache space. Existing technologies cannot effectively improve the utilization rate of shared cache space.
Based on the caching requirements and priorities of each priority queue, the allocation rules of the shared cache space are dynamically adjusted to ensure the cache space requirements of high-priority queues. The use of cache space is optimized by the shared cache space occupancy rules between high-priority queues and low-priority queues.
While ensuring the cache space for high-priority queues, the utilization rate of shared cache space is improved, avoiding cache space waste and congestion.
Smart Images

Figure CN121365015A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to a method for sharing cache space among multiple priority queues, belonging to the technical field of the use method of chip shared cache. BACKGROUND
[0002] In PCIe (a high-speed serial computer expansion bus standard), Ethernet and other switching chips, cache technology is used to receive data traffic. Data traffic packets are usually divided into different data queues to enter the cache space for caching. The cache space in the chip is divided into non-shared cache space and shared cache space. The non-shared cache space is small, and if the received data volume is large, the shared cache space needs to be used to store the data traffic of each queue. The queues are usually divided into different priorities so that the shared cache space can be allocated to high-priority queues first.
[0003] When the system load is heavy, some high-priority traffic queues are easily deprived of sufficient cache space by low-priority queues with large traffic, resulting in congestion and even packet loss.
[0004] Therefore, when multiple queues compete for shared cache space, if the priority and actual use of cache demand of each queue are fully considered for adjustment, the utilization of shared cache space can be effectively improved while ensuring the cache of high-priority queues.
[0005] One of the existing technologies: a shared cache use method based on priority queues.
[0006] The shared cache space is divided into different priority blocks, and high-priority queues can use the same or low-priority cache blocks.
[0007] This use method can ensure that the cache space of high-priority queues will not be occupied by low-priority queues, but when the cache space of high-priority queues is idle, it cannot be used by low-priority queues, resulting in low utilization of shared cache.
[0008] Another existing technology: a shared cache use method based on the number of queues that need to be allocated shared cache space.
[0009] The traffic data packets are divided into multiple queues, and each queue that needs to share cache space is allocated cache space, and the corresponding queue is allocated cache space according to the change of the number of demand queues.
[0010] The shared cache usage method can automatically adjust and allocate the cache space according to network traffic, save hardware resources, and improve cache space utilization. However, this method does not divide the priority of the queue, does not guarantee that the more important queue can obtain sufficient shared cache space, is not conducive to the storage of higher level data content, and reduces the cache efficiency. SUMMARY
[0011] In the application, when queues with different priorities compete for the same shared cache space, the size of the shared cache space of the priority queue is adjusted according to the current cache demand of each priority queue and the queue priority, which is a mechanism and method for sharing the same cache by multiple priority corresponding queues to improve the utilization efficiency of the cache space under the premise of guaranteeing the cache space of the high priority corresponding queue.
[0012] The application allocates shared cache according to different demands of different priority queues, sets rules for each priority queue to occupy the shared cache space of other priority corresponding queues, dynamically adjusts the usage mechanism and mode of the cache, guarantees the cache space of the high priority queue, and improves the utilization rate of the cache space.
[0013] The specific technical solutions of the application are as follows:
[0014] A method for sharing cache space among multiple priority queues, comprising the following steps:
[0015] S1, by dividing the data packets entering and exiting the cache into multiple queues, the queues are divided according to priority according to the importance of the queues, different amounts of shared cache space are allocated to different priorities, and the allocation principle first guarantees the demand of the high priority queue for the shared cache space;
[0016] S2, according to the demand of each priority queue for the shared cache, the corresponding shared cache space is allocated;
[0017] S3, the high priority queue can occupy the idle shared cache space of the low priority queue, and the occupation is performed according to the priority from low to high according to the principle of priority from low to high;
[0018] S4, a constraint condition is set, when the constraint condition is met, the low priority queue can occupy the shared cache space of the high priority queue, and the amount of shared cache space occupied by the low priority queue is subject to constraints.
[0019] Further improvement, in step S1, the allocation mode of allocating different amounts of shared cache space to different priorities includes:
[0020] The number of queues with shared cache demand in each priority is directly used to allocate the shared cache space.
[0021] If there is no priority sharing cache requirement, no shared cache space is allocated for it.
[0022] Further improvement, in step S1, it is judged whether the shared cache space allocated to the priority is sufficient to accommodate the queue data packet, if it is sufficient to accommodate the queue data packet, the remaining shared cache space of the priority is calculated; if it is not sufficient to accommodate the queue data packet, according to the shared cache occupation rule between priority queues, the shared cache space of other priorities is occupied.
[0023] Further improvement, the shared cache occupation rule between priority queues: high priority queue can use the shared cache space of the priority queue and the shared cache space of the low priority queue, and the use rule is set as follows:
[0024] The idle area of the shared cache space of the lowest priority queue with free shared cache space is used.
[0025] The low priority queue can also use the shared cache space of the high priority queue, and the use rule is set as follows: when the shared cache space of the high priority queue is not used more than a predetermined condition, the low priority queue can use the free shared cache space of the high priority queue; the low priority queue uses the shared cache space of the lowest priority queue from the shared cache space of the high priority queue that meets the use rule.
[0026] Further improvement, in step S1, the process of allocating shared cache space between each priority queue is as follows:
[0027] First, the demand of each priority queue for shared cache space is counted, then, according to the principle from high to low, starting from the high priority queue, the corresponding shared cache space is allocated to each priority queue in order of priority.
[0028] Further improvement, the method for each priority queue to occupy shared cache space includes the following steps:
[0029] The size of the shared cache space and the non-shared cache space corresponding to the priority of the queue is checked, it is judged whether the currently allocated shared cache space can meet the cache demand of the queue, if it can meet the cache demand of the queue, the data packet in the queue is stored in the shared cache space corresponding to the priority, and the size of the remaining shared cache space is calculated;
[0030] If the queue cache requirement cannot be met, it is judged whether there is a low priority with remaining shared cache space, if there is, the lowest priority remaining shared cache space is occupied; if there is not, it is judged whether there is a high priority idle shared cache space that meets the use rule; if there is a case that meets, the lowest priority remaining shared cache space that can be occupied by the low priority queue is occupied, and if there is no case that meets, the queue cache space occupation fails.
[0031] Further improvement, if the remaining shared cache space of the priority of the queue is insufficient to store the data packet content of the queue, the idle shared cache space of other priority queues can be occupied;
[0032] It is judged whether there is idle cache space of the low priority queue, if there is such a low priority queue, the shared cache space of the lowest priority queue is selected from all priority queues that meet the condition to be occupied.
[0033] Further improvement, in step S4, the constraint condition is that the use of the shared cache space of the high priority queue corresponding to the priority does not exceed the set condition;
[0034] In all high priority queues that meet the occupation rule, the idle shared cache space of the queue with the lowest priority is selected to be occupied;
[0035] The contents of the constraint on the number of shared cache spaces occupied by the low priority queue include:
[0036] The number of idle shared cache spaces of the high priority queue occupied by the low priority queue cannot exceed the specified number of idle shared cache spaces of the high priority queue.
[0037] The beneficial effects of the present application are:
[0038] The present application divides the queues received by the chip into different priorities, fully considers the cache requirement of each priority, allocates corresponding shared cache spaces to each priority according to the cache requirement of each priority queue, adjusts the specific use of each priority queue according to the idle condition of the shared cache space of each priority, and sets the shared cache space occupation rule between each priority. On the basis of ensuring the cache space of the high priority queue, the utilization rate of the shared cache space is further improved. BRIEF DESCRIPTION OF DRAWINGS
[0039] Figure 1 The flowchart of the method for sharing cache space between multiple priority queues described in the present application;
[0040] Figure 2 It is a schematic diagram of the shared cache occupation rule between priority queues. Detailed Implementation
[0041] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0042] Example 1
[0043] This invention proposes dividing incoming and outgoing data packets into multiple queues. Based on the importance of each queue, these queues are further divided according to priority, resulting in queues of different priorities with varying cache space requirements. Different shared cache spaces are allocated to different priorities based on their shared cache requirements. Furthermore, depending on the queue priority and shared space usage, the shared cache space of lower-priority queues can be used. Conversely, in certain situations, the shared cache space of higher-priority queues can be used. By prioritizing queues and allocating shared cache space according to the shared cache requirements of different priority queues, and by setting shared cache space allocation rules, the cache space for high-priority queues can be guaranteed, while simultaneously improving cache space utilization.
[0044] This invention allocates a corresponding shared cache space to each priority queue based on the cache requirements of each priority queue. Then, based on the current usage of the cache space of each priority queue, it occupies the remaining cache space of other priority queues or accommodates data packets of other priority queues, thereby dynamically adjusting the specific use of the shared cache space by each priority queue.
[0045] This invention divides data packets into queues with different priorities, and simultaneously collects information on the shared cache requirements of each priority queue, allocating corresponding shared cache space for each priority. Since the allocation and specific usage of cache space by priority differ, this invention considers queue priorities and their specific usage of shared cache space, setting methods and strategies for using shared cache between priority queues to improve the utilization rate of shared cache space.
[0046] I. For example Figure 1 As shown, the allocation process in the shared cache space includes:
[0047] The queues are divided into multiple priority levels: the chip's internal cache space includes two types: non-shared cache space and shared cache space. The queues received by the chip are divided into multiple priority levels, and corresponding shared cache space is allocated to different priorities. Different priorities correspond to different non-shared cache spaces and shared cache spaces.
[0048] Priority shared cache space allocation: statistics of different priority queue's demand for shared cache, and allocate corresponding shared cache space for priority. Various allocation methods can be used, such as directly according to the number of queues with shared cache demand in each priority, to allocate shared cache space, if there is no shared cache demand for this priority, do not allocate shared cache space for it.
[0049] That is, to determine whether the shared cache space allocated to the priority at the moment is sufficient to accommodate the queue data packet, if it is sufficient to accommodate the queue data packet, calculate the remaining shared cache space of the priority; if it is insufficient to accommodate the queue data packet, according to the shared cache occupation rule between priority queues, occupy the shared cache space of other priorities.
[0050] Priority queue shared cache occupation rule: high priority queue can use the shared cache space of high priority queue and low priority queue, set the use rule:
[0051] Use the idle area of the shared cache space of the lowest priority queue with free shared cache space;
[0052] Low priority queue can also use high priority queue shared cache space, set the use rule: when the shared cache space of high priority queue is not more than half (or other conditions), low priority queue can use the idle shared cache space of high priority queue; low priority queue uses the shared cache space of the lowest priority queue from the shared cache space of high priority queue that meets the use rule.
[0053] II. Priority division of queue
[0054] n is the number of queues, and s is the number of priorities.
[0055] The queues are divided into different priorities. Multiple queues can be in the same priority. Obviously, n≤s. Different priorities correspond to different non-shared cache space and shared cache space.
[0056] III. Allocation strategy of shared cache space of each priority queue
[0057] According to the application, the process of allocating shared cache space between each priority queue is as follows:
[0058] First, statistics of the demand of each priority queue for shared cache space, then according to the principle from high to low, starting from high priority queue, allocate corresponding shared cache space for each priority queue in turn according to priority.
[0059] IV. Strategy of each priority queue occupying shared cache space
[0060] For example Figure 2As shown, the shared cache space and the non-shared cache space size corresponding to the priority of the queue are viewed, it is judged whether the current allocated shared cache space can satisfy the cache requirement of the queue, if the cache requirement of the queue can be satisfied, the data packets in the queue are stored in the shared cache space corresponding to the priority, the remaining shared cache space size is calculated;
[0061] If the cache requirement of the queue cannot be satisfied, it is judged whether there is a low priority with remaining shared cache space, if there is, the lowest priority remaining shared cache space is occupied; if there is not, it is judged whether there is idle shared cache space of a high priority which meets the use rule; if there is a case which meets, the lowest priority remaining shared cache space which can be occupied by the low priority queue is occupied, if there is no case which meets, the queue cache space occupation fails.
[0062] If the shared cache space of some priority queue is idle, and the shared cache space of other priority queues is completely occupied, there is no more idle shared cache space to accommodate the data of the queue corresponding to the priority, and the shared cache space of other priorities cannot be occupied, which causes the waste of shared cache space. Therefore, the shared cache occupation rule between priority queues is set in the application, which aims to improve the utilization efficiency of shared cache space under the premise of ensuring the high priority queue.
[0063] According to the flow, Figure 2 After the shared cache space is allocated to different priorities, the method for a queue to use the shared cache space is as follows: if the remaining shared cache space of the priority where the queue is located is insufficient to store the data packet content of the queue, the idle shared cache space of other priority queues can be occupied.
[0064] In order to ensure that the high priority queue can obtain the shared cache space in priority, the rule for the queue to occupy the shared cache space of the corresponding queue of other priorities is set as follows:
[0065] Firstly, it is judged whether there is idle cache space of a low priority queue, if there is such a low priority queue, the shared cache space of the lowest priority queue is selected from all priority queues which meet the conditions to be occupied;
[0066] Meanwhile, the low priority queue can also occupy the high priority queue, but the low priority queue is preferentially occupied. The rule for the low priority queue to occupy the idle shared cache space of the high priority queue is as follows:
[0067] 1) The rule for judging whether the low priority queue can occupy the idle shared cache space of the high priority queue can be set in multiple ways. For example, the shared cache space corresponding to the priority for the high priority queue is not more than half.
[0068] 2) The space size occupied by the low priority queue to the high priority queue can be multiple settings; such as the requirement of low priority queue to occupy the free shared cache space number of high priority queue, can not exceed half of the free shared cache space of the high priority queue.
[0069] 3) In all high priority queues that meet the occupation rules, the free shared cache space of the queue with the lowest priority is selected for occupation.
[0070] In this way, the shared cache resources can be maximally utilized while ensuring the use of cache space by high priority queues.
[0071] Embodiment 2
[0072] Shared cache space allocation example
[0073] C1 is the total capacity of non-shared cache space, C2 is the total capacity of shared cache space, {N1, N2, … Nn} is the set of all queues, and {S1, S2, … Ss} is the set of all priority queues.
[0074] First, the n queues are divided into s priorities. Assuming n = 10, s = 5, the 5 priority queues are S1 = {n1, n2}, S2 = {n3, n4, n5}, S3 = {n6, n7}, S4 = {n8, n9}, and S5 = {n10}. C1 is 10 kB, and C2 is 70 kB. Each of the 5 priority queues has 2 kB of non-shared cache space. In this example, the shared cache space allocation rule is used, and the shared cache space is allocated to each priority according to the number of queues requesting shared cache for each priority. The shared cache space sizes of the 5 priority queues are 14 kB, 21 kB, 14 kB, 14 B, and 7 KB, respectively.
[0075] Embodiment 3
[0076] Each priority queue occupies cache example
[0077] Example 1: If the shared cache requirements of the n queues are 4 kB, 4 kB, 4 kB, 4 kB, 8 kB, 12 kB, 8 kB, 4 kB, 4 kB, and 5 kB, respectively, the shared cache usage of the 5 priority queues is as follows:
[0078] S1 priority queue remaining 8 kB, S2 priority queue remaining 7 kB, S3 priority queue additionally requiring 4 kB space, S4 priority queue remaining 8 kB, S5 priority queue remaining 4 kB. In the S3 priority queue, queue n7 cannot store all the contents, so the priority occupation strategy of the application is used to utilize the idle shared cache space in other priority queues to store the queue contents. Through observation of the S4 and S5 priority queues, it can be seen that the remaining idle cache space of the S4 and S5 priority queues can accommodate the remaining data packets of queue n7. In order to ensure the use of shared cache space by high-priority queues as much as possible, the remaining data of queue n7 is stored in the shared cache allocated by the S5 priority queue.
[0079] Example 2: If the shared cache requirements of n queues are 4 kB, 4 kB, 4 kB, 4 kB, 8 kB, 12 kB, 8 kB, 8 kB, 8 kB, and 9 kB, respectively, the shared cache usage of 5 priorities is as follows:
[0080] S1 priority queue remaining 8 kB, S2 priority queue remaining 7 kB, S3 priority queue additionally requiring 4 kB space, S4 priority queue remaining 0 kB, S5 priority queue remaining 0 kB. At this moment, the cache space of the S3 priority queue is not enough, and the remaining shared cache space of other priority queues is checked, and it is found that the cache space of the low-priority queue is all occupied, and the cache space of the high-priority S1 and S2 queues is idle and can accommodate the remaining data amount of queue n7. The idle shared cache space of the S1 priority queue is 8 kB, and the total shared cache space is 14 kB, and the idle shared cache space exceeds half of the total shared cache space, so the idle cache space of the S1 priority queue can be occupied by the low-priority queue by up to 4 kB. The idle shared cache space of the S2 priority queue is 7 kB, and the total shared cache space is 21 kB, and the remaining shared cache space is less than half of the total shared space, so it does not meet the condition of being occupied by the low-priority queue, so only the idle cache space in the S1 priority queue can be occupied by queue n7. 4 kB of the S1 priority queue is allocated to queue n7, and the data of all queues is stored in the cache under the shared cache space allocation rule set by the application.
[0081] Example 3: If the shared cache requirements of n queues are 4kB, 4kB, 2kB, 2kB, 2kB, 12kB, 8kB, 8kB, 8kB, 9kB respectively, the cache usage of 5 priority queues is: S1 priority queue remaining 8kB, S2 priority queue remaining 17kB, S3 priority queue requiring 4kB extra space, S4 priority queue remaining 0kB, S5 priority queue remaining 0kB. The idle shared cache space of S2 priority queue is 17kB, the total shared cache space is 21kB, the idle shared cache space exceeds half of the total shared cache space, and the idle cache space of S2 priority queue can also be occupied by a low priority queue, which can be occupied by a maximum of 8.5kB. The idle shared cache space of S1 and S2 priority queues can both be occupied by a low priority queue, so the idle shared cache space of the lower level S2 priority queue is occupied by queue n7. At this moment, S2 priority queue remaining 13kB, and only 4.5kB idle shared cache space can be occupied by a low priority queue. All queue data is stored in the cache under the shared cache space allocation rule set by the present application.
[0082] The above description is merely preferred embodiments of the present application, but not to limit the present application. Any modification, equivalent replacement and improvement made in the spirit and principle of the present application shall fall within the scope of the present application.
Claims
1. A method of sharing a buffer space among multiple priority queues, characterized by, The method comprises the following steps: S1, by dividing the data packets in and out of the cache into multiple queues, the queues are divided according to the importance of the queues, and different priority queues are obtained, different priority is allocated different number of shared cache space, the allocation principle first guarantees the demand of high priority queue for shared cache space; S2, according to the demand of each priority queue for shared cache, the corresponding shared cache space is allocated; S3, high priority queue can occupy the idle shared cache space of low priority queue, according to the principle from low to high, the priority is from low to high; S4, set the constraint condition, when the constraint condition is met, the low priority queue can occupy the shared cache space of the high priority queue, and the number of shared cache space occupied by the low priority queue is restricted.
2. The method of sharing buffer space among multiple priority queues of claim 1, wherein: In step S1, the allocation of different number of shared cache space for different priority includes: Directly according to the number of queues with shared cache demand in each priority, the shared cache space is allocated; If there is no shared cache demand in the priority, no shared cache space is allocated.
3. The method of sharing buffer space among multiple priority queues of claim 1, wherein: In step S1, it is judged whether the shared cache space allocated to the priority is sufficient to accommodate the queue data packet, if it is sufficient to accommodate the queue data packet, the remaining shared cache space of the priority is calculated; If it is not sufficient to accommodate the queue data packet, according to the shared cache occupation rule between priority queues, the shared cache space of other priority is occupied.
4. The method of sharing buffer space among multiple priority queues of claim 3, wherein: The shared cache occupation rule between priority queues: high priority queue can use the shared cache space of this priority queue and low priority queue, set the use rule: Use the idle area of the shared cache space of the lowest priority queue with idle shared cache space; Low priority queue can also use high priority queue shared cache space, set the use rule: if the shared cache space of high priority queue is used no more than the predetermined condition, low priority queue can use the idle shared cache space of the high priority queue; Low priority queue uses the shared cache space of the lowest priority queue from the shared cache space of the high priority queue that meets the use rule.
5. The method of sharing buffer space among multiple priority queues of claim 1, wherein: In step S1, the flow of allocating shared cache space between each priority queue is as follows: First, the demand of each priority queue for shared cache space is counted, then, according to the principle from high to low, starting from high priority queue, the corresponding shared cache space is allocated to each priority queue according to the priority.
6. The method of sharing buffer space among multiple priority queues of claim 1, wherein: The method for each priority queue to occupy shared cache space includes the following steps: Check the size of shared cache space and non-shared cache space corresponding to the priority of the queue, judge whether the currently allocated shared cache space can meet the cache demand of the queue, if it can meet the cache demand of the queue, store the data packet in the queue into the shared cache space corresponding to the priority, and calculate the size of the remaining shared cache space; If the queue cache requirement cannot be met, it is determined whether there is a low-priority queue with remaining shared cache space, and if so, the lowest-priority remaining shared cache space is occupied. If there is no such queue, it is determined whether there is a high-priority idle shared cache space that meets the use rules, and if so, the lowest-priority remaining shared cache space that can be occupied by a low-priority queue is occupied. If there is no such queue, the queue cache space occupation fails.
7. The method of sharing buffer space among multiple priority queues of claim 1, wherein: If the remaining shared cache space of the priority of the queue is insufficient to store the data packet content of the queue, the idle shared cache space of other priority queues can be occupied. It is determined whether there is an idle cache space of a low-priority queue, and if there is such a low-priority queue, the shared cache space of the lowest-priority queue is selected from all priority queues that meet the conditions for occupation.
8. The method of sharing buffer space among multiple priority queues of claim 1, wherein: In step S4, the constraint condition is that the use of the shared cache space of the corresponding priority by the high-priority queue does not exceed a set condition. In all high-priority queues that meet the occupation rules, the idle shared cache space of the queue with the lowest priority is selected for occupation. The contents of the constraint on the number of shared cache spaces occupied by a low-priority queue include: The number of idle shared cache spaces of a high-priority queue occupied by a low-priority queue cannot exceed the specified number of idle shared cache spaces of the high-priority queue.
Citation Information
Patent Citations
Method and device of realizing queue sharing memory space
CN101183319A
Method and device for carrying out distribution control on cache space with multiple queues
CN104426790A
Shared cache distribution method and device
CN106330770A
Shared cache space management method and device
CN107347039A
Caching method and device
CN110493145A