Equipment command processing method and device, electronic equipment and readable storage medium
By obtaining load information and historical scheduling weights in device command processing, calculating scheduling weights and sorting the command queues, the problem of insufficient flexibility in the device command arbitration mechanism in the prior art is solved, and more flexible and fair device command scheduling is achieved, and system performance is fully utilized.
Patent Information
- Application Number
- CN202510379948.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-27
- Publication Date
- 2025-06-20
AI Technical Summary
Existing device command arbitration mechanisms, such as RR and WRR, have flexibility limitations and cannot perform device command processing based on the actual situation of each command queue, resulting in the inability to fully utilize the system performance and the "starvation" phenomenon of low-priority queues being ignored.
By obtaining the load information of each target device and the historical scheduling weights of each command queue during the current scheduling cycle, calculate the load information adjustment coefficient, determine the current scheduling weight, and process each command queue in the order of the scheduling weight from large to small.
It realizes more flexible and reasonable equipment command scheduling, fully utilizes the overall performance of the system, avoids the problem of low-priority queues being ignored, and improves the fairness and response speed of the system.
Smart Images

Figure CN120179294A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technologies, and in particular, to a method for processing device commands, and also relates to a device command processing apparatus, an electronic device, and a computer-readable storage medium. Background Art
[0002] A device command arbitration mechanism is an arbitration mechanism used to determine from which submission queue (SQ) a controller starts processing device commands. Taking an NVMe (Non-Volatile Memory Express, a communication standard protocol) device as an example, it mainly adopts two device command arbitration mechanisms, namely, the RR (Round Robin) mechanism and the WRR (Weighted Round Robin) mechanism. Among them, the RR mechanism sets the same level for all SQs, and it is only necessary to cycle through each SQ to fetch device commands for processing. Obviously, this mechanism has flexibility limitations and cannot process device commands according to the actual situation of each SQ, so the system performance cannot be fully exerted; the WRR mechanism sets different levels for each SQ, but the levels of each type of SQ are fixed, and there are also flexibility limitations, and the system performance cannot be fully exerted. Moreover, when a high-priority SQ continuously receives device commands, the low-priority SQ will be ignored for a long time, resulting in a "starvation" phenomenon, lacking serious fairness.
[0003] Therefore, how to achieve a more flexible and reasonable device command scheduling to fully exert the overall system performance is an urgent problem to be solved by those skilled in the art. Summary of the Invention
[0004] The purpose of this application is to provide a method for processing device commands, which realizes a more flexible and reasonable device command scheduling and can fully exert the overall system performance; another purpose of this application is to provide a device command processing apparatus, an electronic device, a computer-readable storage medium, and a computer program product, all of which have the above beneficial effects.
[0005] In a first aspect, this application provides a method for processing device commands, including:
[0006] In the current scheduling cycle, obtain the load information of each target device and the historical scheduling weights of each command queue in each of the target devices in the previous scheduling cycle;
[0007] Allocate a load information adjustment coefficient for each target device according to the load information of each target device;
[0008] Determine the current scheduling weights of each command queue in each of the target devices according to each of the load information, each of the load information adjustment coefficients, and each of the historical scheduling weights;
[0009] Process the device commands for each of the command queues in the order from the largest to the smallest of the current scheduling weights.
[0010] Optionally, within the current scheduling period, obtain the load information of each target device and the historical scheduling weights of each command queue in each of the target devices in the previous scheduling period, including:
[0011] When the current scheduling period is the initial scheduling period, obtain the load information of each of the target devices, and allocate initial scheduling weights to each of the command queues in the corresponding target devices according to the load information, so as to use the initial scheduling weights as the historical scheduling weights;
[0012] When the current scheduling period is not the initial scheduling period, obtain the load information of each of the target devices and the historical scheduling weights of each of the command queues in each of the target devices in the previous scheduling period.
[0013] Optionally, allocating initial scheduling weights to each of the command queues in the corresponding target devices according to the load information includes:
[0014] Count the total number of commands of all the command queues in all the target devices;
[0015] For each command queue in each target device, determine the initial scheduling weight of the command queue according to the number of commands of the command queue and the total number of commands.
[0016] Optionally, allocating load information adjustment coefficients to each of the target devices according to the load information of each of the target devices includes:
[0017] Obtain the device information of each of the target devices;
[0018] Allocate load information adjustment coefficients to each of the target devices according to the device information and load information of each of the target devices.
[0019] Optionally, processing the device commands for each of the command queues in the order from the largest to the smallest of the current scheduling weights includes:
[0020] When the values of each of the current scheduling weights are all positive, process the device commands for each of the command queues in the order from the largest to the smallest of the current scheduling weights;
[0021] When there are negative values among the values of the current scheduling weights, calculate the absolute values of the current scheduling weights with negative values to obtain the adjusted scheduling weights, and process the device commands for each of the command queues in the order from the largest to the smallest of the adjusted scheduling weights.
[0022] Optionally, obtain the load information of each target device, including:
[0023] Obtain the queue idle status, the number of queue commands, and the queue waiting time of each of the command queues in the target device;
[0024] Correspondingly, allocate load information adjustment coefficients for each of the target devices according to the load information of each of the target devices, including:
[0025] Allocate a queue idle status adjustment coefficient, a queue command quantity adjustment coefficient, and a queue waiting time adjustment coefficient for each of the target devices according to the load information of each of the target devices;
[0026] Correspondingly, determine the current scheduling weights of each of the command queues in each of the target devices according to the load information, the load information adjustment coefficients, and the historical scheduling weights, including:
[0027] For each command queue in each target device, adjust the queue idle status of the command queue according to the queue idle status adjustment coefficient to obtain the adjusted queue idle status, adjust the number of queue commands of the command queue according to the queue command quantity adjustment coefficient to obtain the adjusted number of queue commands, and adjust the queue waiting time of the command queue according to the queue waiting time adjustment coefficient to obtain the adjusted queue waiting time;
[0028] Determine the current scheduling weight of the command queue according to the adjusted queue idle status, the adjusted number of queue commands, the adjusted queue waiting time, and the historical scheduling weight.
[0029] Optionally, before obtaining the load information of each target device and the historical scheduling weights of each command queue in each target device in the current scheduling cycle, it further includes:
[0030] Determine the current device command processing method; wherein, the device command processing method includes a device command processing method based on a cyclic arbitration mechanism, a device command processing method based on a weighted cyclic arbitration mechanism, and a device command processing method based on a dynamic weighted cyclic arbitration mechanism;
[0031] If the current device command processing method is the device command processing method based on the dynamic weighted round-robin arbitration mechanism, then execute the step of obtaining the load information of each target device and the historical scheduling weights of each command queue in each of the target devices in the previous scheduling cycle within the current scheduling cycle.
[0032] In a second aspect, the present application also discloses a device command processing apparatus, including:
[0033] An acquisition module, configured to obtain the load information of each target device and the historical scheduling weights of each command queue in each of the target devices in the previous scheduling cycle within the current scheduling cycle;
[0034] An allocation module, configured to allocate a load information adjustment coefficient to each of the target devices according to the load information of each of the target devices;
[0035] A determination module, configured to determine the current scheduling weights of each command queue in each of the target devices according to each of the load information, each of the load information adjustment coefficients, and each of the historical scheduling weights;
[0036] A processing module, configured to process device commands for each of the command queues in descending order of the current scheduling weights.
[0037] In a third aspect, the present application also discloses an electronic device, including:
[0038] A memory, configured to store a computer program;
[0039] A processor, configured to implement the steps of any of the above-mentioned device command processing methods when executing the computer program.
[0040] In a fourth aspect, the present application also discloses a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of any of the above-mentioned device command processing methods.
[0041] In a fifth aspect, the present invention also discloses a computer program product, including a computer program / instructions, and the computer program / instructions, when executed by a processor, implement the steps of any of the above-mentioned device command processing methods.
[0042] The present application provides a method for processing device commands, including: within the current scheduling period, obtaining the load information of each target device and the historical scheduling weights of each command queue in each of the target devices in the previous scheduling period; allocating a load information adjustment coefficient for each target device according to the load information of each target device; determining the current scheduling weights of each command queue in each target device according to each load information, each load information adjustment coefficient, and each historical scheduling weight; and processing device commands for each command queue in the order from largest to smallest of the current scheduling weights.
[0043] Applying the technical solution provided by the present application, through dividing the scheduling period, a dynamic weighted round-robin arbitration mechanism based on the scheduling period is implemented, and then device command processing is realized. Within each scheduling period, a load information adjustment coefficient is allocated for each target device according to the load information of each target device to be used for load information adjustment. At the same time, in combination with the historical scheduling weights of each command queue within each target device in the previous scheduling period, the calculation of the scheduling weights of each command queue in the current scheduling period is realized. Thus, within the current scheduling period, device commands can be processed for each command queue in the order from largest to smallest of the current scheduling weights. It can be seen that the present technical solution realizes a dynamic weighted round-robin arbitration mechanism based on the scheduling period, and within each scheduling period, the scheduling weights of each command queue in each target device can be recalculated by comprehensively considering the current load situation and the historical scheduling situation to achieve device command processing. Compared with the traditional round-robin scheduling mechanism and weighted round-robin scheduling mechanism, the present technical solution realizes a more flexible and reasonable device command scheduling and can give full play to the overall performance of the system.
[0044] In an embodiment of the present application, for the initial scheduling period in which the historical scheduling weights in the previous scheduling period cannot be obtained, the load information of each target device can be directly obtained to allocate an initial scheduling weight for each command queue within the corresponding target device as the historical scheduling weight, so as to determine the actual scheduling weights of each command queue in each target device in the initial scheduling period, ensure that the scheduling weights of each command queue in each target device can be calculated by comprehensively considering the device load situation in the initial scheduling period to achieve device command processing, and further give full play to the overall performance of the system.
[0045] The device command processing device, electronic device, computer-readable storage medium, and computer program product provided by the present application also have the above technical effects, and the present application will not elaborate herein. Description of the Drawings
[0046] To more clearly illustrate the prior art and the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the prior art and the embodiments of the present application. Of course, the following drawings related to the embodiments of the present application only describe a part of the embodiments in the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained according to the provided drawings, and the other obtained drawings also fall within the protection scope of the present application.
[0047] Figure 1 It is a schematic diagram of the principle of the round-robin arbitration mechanism in the prior art;
[0048] Figure 2 It is a schematic diagram of the principle of the weighted round-robin arbitration mechanism in the prior art;
[0049] Figure 3 It is a schematic flowchart of a device command processing method provided by the present application;
[0050] Figure 4 It is a schematic structural diagram of a device command processing device provided by the present application;
[0051] Figure 5 It is a schematic structural diagram of an electronic device provided by the present application. Detailed implementation manners
[0052] The core of the present application is to provide a device command processing method, which realizes a more flexible and reasonable device command scheduling and can give full play to the overall performance of the system; another core of the present application is to provide a device command processing device, an electronic device, a computer-readable storage medium, and a computer program product, all of which have the above beneficial effects.
[0053] In order to more clearly and completely describe the technical solutions in the embodiments of the present application, the following will introduce the technical solutions in the embodiments of the present application in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present application.
[0054] The embodiments of the present application provide a device command processing method.
[0055] First, please refer to Figure 1 and Figure 2 , Figure 1 which is a schematic diagram of the principle of the round-robin arbitration mechanism (RR mechanism) in the prior art, Figure 2Schematic diagram of the principle of the Weighted Round Robin (WRR) arbitration mechanism in the prior art. Among them, in the RR mechanism, all SQs, including the ASQ (Admin Command SQ) and the IO SQ (IO Command SQ), will be executed because all SQs are set to the same level, and the controller sequentially fetches device commands from all SQs for processing in order. In the WRR mechanism, it defines 3 absolute priorities (ASQ, USQ, WRR SQ) and 3 weighted priorities (High, Medium, Low). The ASQ has the highest priority, the USQ (Urgent Command SQ) has the second highest priority, and the WRR SQ has the lowest priority. For the three weighted priorities included in the WRR SQ, the user can use the set feature command to control the weight of each priority in the weighted priorities, that is, each time a device command is executed, and the RR arbitration mechanism is executed inside each weighted priority. Obviously, neither the RR mechanism nor the WRR mechanism can achieve flexible and reasonable device command scheduling, and thus cannot fully utilize the overall system performance.
[0056] Further, please refer to Figure 3 , Figure 3 Schematic diagram of the flow of a device command processing method provided by the present application. The device command processing method may include the following S101 to S104.
[0057] S101: In the current scheduling cycle, obtain the load information of each target device and the historical scheduling weights of each command queue in each target device in the previous scheduling cycle.
[0058] This step aims to obtain relevant information in the current scheduling cycle. Specifically, in each scheduling cycle, taking the current scheduling cycle as an example, obtain the load information of each target device (current load situation) and the historical scheduling weights of each command queue inside each target device in the previous scheduling cycle (historical scheduling situation). Among them, the number of target devices is not unique, and the number of command queues inside different target devices is also not unique. Based on this information, it aims to calculate the scheduling weights of each command queue inside each target device in the current scheduling cycle, so as to process each command queue in order according to the value of the scheduling weight, and thus realize device command processing. That is to say, in each scheduling cycle, the current load situation of the system and the historical scheduling requests are comprehensively considered to calculate the scheduling weights of each command queue in each target device, so as to realize the dynamic weighted round robin arbitration mechanism based on the scheduling cycle. It should be noted that the specific duration of a scheduling cycle does not affect the implementation of this technical solution. For example, it can be one hour or one day, etc., and the present application does not limit this.
[0059] Among them, the load information of the target device refers to the load condition of the target device in the current scheduling period. In a possible implementation, its content may include, but is not limited to, the idle state, the number of commands, the waiting duration, etc. of each command queue in the target device.
[0060] In an embodiment of the present application, in the current scheduling period, obtaining the load information of each target device and the historical scheduling weights of each command queue in each target device in the previous scheduling period may include:
[0061] When the current scheduling period is the initial scheduling period, obtain the load information of each target device, and allocate initial scheduling weights to each command queue in the corresponding target device according to the load information, so as to use the initial scheduling weights as the historical scheduling weights;
[0062] When the current scheduling period is not the initial scheduling period, obtain the load information of each target device and the historical scheduling weights of each command queue in each target device in the previous scheduling period.
[0063] The embodiments of the present application provide an implementation method for obtaining various types of data information in the current scheduling period. It can be understood that the current scheduling period is divided into an initial scheduling period and a non-initial scheduling period. Among them, the initial scheduling period is the first scheduling period. Obviously, it is an initial scheduling period that cannot obtain the historical scheduling weights in the previous scheduling period because there is no previous scheduling period for the initial scheduling period. In view of this situation, the load information of each target device can be directly obtained to allocate initial scheduling weights to each command queue inside the corresponding target device as the historical scheduling weights, so as to determine the actual scheduling weights of each command queue in each target device during the initial scheduling period; for the non-initial scheduling period, the current load condition and the historical scheduling condition can be normally obtained.
[0064] It can be seen that in the embodiments of the present application, for the initial scheduling period that cannot obtain the historical scheduling weights in the previous scheduling period, the load information of each target device can be directly obtained to allocate initial scheduling weights to each command queue inside the corresponding target device as the historical scheduling weights, so as to determine the actual scheduling weights of each command queue in each target device during the initial scheduling period, ensuring that the scheduling weights of each command queue in each target device can be calculated by integrating the device load condition during the initial scheduling period to implement device command processing, so as to further give full play to the overall performance of the system.
[0065] Among them, allocating initial scheduling weights to each command queue in the corresponding target device according to the load information may include:
[0066] Count the total number of commands of all command queues in all target devices;
[0067] For each command queue in each target device, determine the initial scheduling weight of the command queue according to the number of commands in the command queue and the total number of commands.
[0068] The embodiment of the present application provides a method for calculating the initial scheduling weight. For each command queue in each target device, the quotient of the number of internal commands and the total number of commands can be used as the initial scheduling weight. Here, the total number of commands refers to the total number of commands in all command queues in all target devices.
[0069] S102: Allocate load information adjustment coefficients for each target device according to the load information of each target device.
[0070] The purpose of this step is to realize the allocation of the load information adjustment coefficient, which can be specifically realized with reference to the actual load information of each target device. It can be understood that by allocating a suitable load information adjustment coefficient for the target device, its load information can be appropriately adjusted, so as to further combine the historical scheduling weight to determine the current scheduling weight.
[0071] In an embodiment of the present application, allocating load information adjustment coefficients for each target device according to the load information of each target device may include: obtaining the device information of each target device; allocating load information adjustment coefficients for each target device according to the device information and load information of each target device. That is to say, in the embodiment of the present application, in addition to the load information of the target device, the device information (such as device type) of the target device can be further comprehensively considered to determine the load information adjustment coefficient.
[0072] It should be noted that the load information corresponds to the load information adjustment coefficient, and the number of types of the load information corresponds to the number of the load information adjustment coefficients. Taking the "load information of the target device includes the idle state, the number of commands, and the waiting duration of each command queue in the target device" described in the foregoing embodiment as an example, the corresponding load information adjustment coefficients may include an idle state adjustment coefficient, a command number adjustment coefficient, and a waiting duration adjustment coefficient.
[0073] Among them, the idle state adjustment coefficient is used to balance the impact of the idle state of the command queue on the scheduling weight. A higher idle state adjustment coefficient means that the idle state of the command queue contributes more to the scheduling weight, and the command queue of the idle device is suitable for obtaining a higher scheduling weight; the command quantity adjustment coefficient is used to balance the impact of the number of commands in the command queue on the scheduling weight. A higher command quantity adjustment coefficient means that the number of commands in the command queue contributes more to the scheduling weight, and the command queue with a large number of commands is suitable for obtaining a higher scheduling weight; the waiting duration adjustment coefficient is used to balance the impact of the waiting duration of the command queue on the scheduling weight. A higher waiting duration adjustment coefficient means that the waiting duration of the command queue contributes more to the scheduling weight, and the command queue with a long waiting time is suitable for obtaining a higher scheduling weight.
[0074] Based on this, the embodiment of the present application also proposes a setting rule for the load information adjustment coefficient: the number of queue commands is positively correlated with the command quantity adjustment coefficient and negatively correlated with the idle state adjustment coefficient; the queue waiting duration is positively correlated with the waiting duration adjustment coefficient. It can be understood that when the number of queue commands is large, increasing the command quantity adjustment coefficient can ensure that the command queue with stronger processing capabilities obtains a higher scheduling weight, and reducing the idle state adjustment coefficient can ensure that the command queue of the idle device can process device commands in a timely manner; when the queue waiting time is long, increasing the waiting duration adjustment coefficient can reduce the scheduling weight of the command queue with a long waiting time, thereby improving the overall response speed.
[0075] On this basis, it can be obtained that when determining the load information adjustment coefficient by integrating the device information of the target device, for I / O-intensive devices, the command quantity adjustment coefficient can be increased; for compute-intensive devices, the idle state adjustment coefficient can be increased.
[0076] S103: Determine the current scheduling weight of each command queue in each target device according to each load information, each load information adjustment coefficient, and each historical scheduling weight.
[0077] This step aims to calculate the current scheduling weight of each command queue in each target device. It can be understood that each load information can be effectively adjusted by using each load information adjustment coefficient, and then the calculation of each current scheduling weight can be achieved by combining each historical scheduling weight.
[0078] Taking the above "the load information of the target device includes the idle state, the number of commands, and the waiting duration of each command queue in the target device" as an example, in an embodiment of the present application, obtaining the load information of each target device may include: obtaining the queue idle state, the queue command quantity, and the queue waiting time of each command queue in the target device;
[0079] Correspondingly, allocating load information adjustment coefficients for each target device according to the load information of each target device may include: allocating a queue idle state adjustment coefficient, a queue command quantity adjustment coefficient, and a queue waiting time adjustment coefficient for each target device according to the load information of each target device;
[0080] Correspondingly, determining the current scheduling weight of each command queue in each target device according to each load information, each load information adjustment coefficient, and each historical scheduling weight may include: for each command queue in each target device, adjusting the queue idle state of the command queue according to the queue idle state adjustment coefficient to obtain the adjusted queue idle state, adjusting the queue command quantity of the command queue according to the queue command quantity adjustment coefficient to obtain the adjusted queue command quantity, and adjusting the queue waiting time of the command queue according to the queue waiting time adjustment coefficient to obtain the adjusted queue waiting time; determining the current scheduling weight of the command queue according to the adjusted queue idle state, the adjusted queue command quantity, the adjusted queue waiting time, and the historical scheduling weight.
[0081] In a possible implementation manner, the determination method of the current scheduling weight can be calculated according to the following formula:
[0082] ;
[0083] where, represents the scheduling weight of the jth command queue of the ith target device in the current scheduling period t, represents the historical scheduling weight of the jth command queue of the ith target device in the previous scheduling period (t - 1), represents the queue idle state of the jth command queue of the ith target device, and α represents the queue idle state adjustment coefficient, represents the queue command quantity of the jth command queue of the ith target device, and β represents the queue command quantity adjustment coefficient, represents the queue waiting duration of the jth command queue of the ith target device, and γ represents the queue waiting duration adjustment coefficient.
[0084] S104: Process the device commands for each command queue in the order from the largest to the smallest of the current scheduling weights.
[0085] This step aims to implement the processing of command queues based on the current scheduling weight. Obviously, the higher the value of the current scheduling weight, the corresponding command queue will be preferentially executed; the lower the value of the current scheduling weight, the corresponding command queue will be executed last. It should be noted that within the current scheduling cycle, the device commands of each command queue are processed in the order of the current scheduling weight from large to small. When the current scheduling cycle ends and enters the next scheduling cycle, regardless of whether all command queues have been executed, the current command queue execution order will be stopped, and a new current scheduling weight will be recalculated starting from S101, and then the device commands of each command queue will be processed according to the new current scheduling weight.
[0086] In an embodiment of the present application, processing the device commands of each command queue in the order of the current scheduling weight from large to small may include:
[0087] When the values of each current scheduling weight are all positive numbers, the device commands of each command queue are processed in the order of the current scheduling weight from large to small;
[0088] When there are negative numbers among the values of each current scheduling weight, the absolute value of the current scheduling weight with a negative value is calculated to obtain each adjusted scheduling weight, and the device commands of each command queue are processed in the order of the adjusted scheduling weight from large to small.
[0089] It can be understood that, based on the calculation method of the current scheduling weight of the foregoing calculation formula, a situation where the value is negative may occur. For this situation, the absolute value calculation can be performed first, and then the processing of each command queue can continue in the order of the value from large to small.
[0090] It can be seen that the device command processing method provided by the embodiment of the present application realizes a dynamic weighted round-robin arbitration mechanism based on the scheduling cycle by dividing the scheduling cycle, and then realizes the device command processing. In each scheduling cycle, a load information adjustment coefficient is allocated to each target device according to the load information of each target device to be used for load information adjustment. At the same time, in combination with the historical scheduling weight of each command queue inside each target device in the previous scheduling cycle, the scheduling weight of each command queue in the current scheduling cycle is calculated. Thus, within the current scheduling cycle, the device commands of each command queue can be processed in the order of the current scheduling weight from large to small. It can be seen that this technical solution realizes a dynamic weighted round-robin arbitration mechanism based on the scheduling cycle, and in each scheduling cycle, the scheduling weight of each command queue inside each target device can be recalculated comprehensively according to the current load situation and historical scheduling situation to realize the device command processing. Compared with the traditional round-robin scheduling mechanism and weighted round-robin scheduling mechanism, this technical solution realizes a more flexible and reasonable device command scheduling, and can give full play to the overall performance of the system.
[0091] Based on the above embodiments:
[0092] In an embodiment of the present application, before obtaining the load information of each target device and the historical scheduling weights of each command queue in each target device in the previous scheduling cycle within the current scheduling cycle, it may further include:
[0093] Determine the current device command processing method; wherein, the device command processing method includes a device command processing method based on a round-robin arbitration mechanism, a device command processing method based on a weighted round-robin arbitration mechanism, and a device command processing method based on a dynamic weighted round-robin arbitration mechanism;
[0094] If the current device command processing method is a device command processing method based on a dynamic weighted round-robin arbitration mechanism, then execute the step of obtaining the load information of each target device and the historical scheduling weights of each command queue in each target device in the previous scheduling cycle within the current scheduling cycle.
[0095] In the embodiments of the present application, the system can simultaneously support a device command processing method based on a round-robin arbitration mechanism (RR mechanism), a device command processing method based on a weighted round-robin arbitration mechanism (WRR mechanism), and a device command processing method based on a dynamic weighted round-robin arbitration mechanism. For users, they can select a suitable device command processing method according to their actual needs, further improving the user experience.
[0096] Based on the above embodiments, taking the NVMe device as an example, the embodiments of the present application provide another device command processing method. The implementation process of the device command processing method provided by the embodiments of the present application is as follows:
[0097] 1. At the beginning of the scheduling cycle, count the load conditions of each NVMe device, including the idle status, the number of commands, the waiting duration, etc. of each command queue; and obtain the historical scheduling weights (if any) of each command queue in each NVMe device in the previous scheduling cycle.
[0098] 2. Set appropriate adjustment coefficients α, β, and γ for balancing the influence of the idle status, the number of commands, and the waiting duration on the scheduling weight.
[0099] 3. (If it is the initial scheduling cycle) Considering the above statistical situation and adjustment coefficients comprehensively, allocate initial scheduling weights to each command queue.
[0100] Among them, the calculation formula of the initial scheduling weight is as follows:
[0101] ;
[0102] represents the initial scheduling weight of the jth command queue of the ith NVMe device in the initial scheduling cycle t0, represents the number of queue commands of the j-th command queue of the i-th NVMe device within the initial scheduling period t0, N represents the number of NVMe devices, and M represents the number of command queues in each NVMe device.
[0103] 4. According to the above initial scheduling weights, with the help of the scheduling weight calculation formula, allocate physical resources for each command queue to process device commands.
[0104] Among them, the calculation formula for the current scheduling weight is as follows:
[0105] ;
[0106] Among them, represents the scheduling weight of the j-th command queue of the i-th target device in the current scheduling period t, represents the historical scheduling weight of the j-th command queue of the i-th target device in the previous scheduling period (t - 1), represents the queue idle state of the j-th command queue of the i-th target device, α represents the queue idle state adjustment coefficient, represents the number of queue commands of the j-th command queue of the i-th target device, β represents the queue command number adjustment coefficient, represents the queue waiting duration of the j-th command queue of the i-th target device, γ represents the queue waiting duration adjustment coefficient.
[0107] 5. Offload the device command scheduling function to the Nvme device, thereby reducing the CPU overhead of the three steps of submission, arbitration, and distribution performed by the traditional scheduler in the operating system block layer.
[0108] Among them, in the case of multiple NVMe devices, device command scheduling needs to consider global weight calculation and information sharing, and its processing method is: establish a centralized scheduling module. By establishing a centralized scheduling module, it is responsible for collecting the load conditions of all NVMe devices and calculating the weights of each command queue on each NVMe device based on this information. This module can run on the host side or an independent controller, and it can globally grasp the operating states of all NVMe devices, thereby performing unified scheduling weight calculation and scheduling decisions.
[0109] In addition, when there is a situation where the scheduling weights of command queues in different NVMe devices are equal, the following scheduling strategy can be adopted:
[0110] (1) Queue waiting time scheduling: In the case of equal scheduling weights, compare the waiting durations of each command queue and preferentially schedule the command queue with a longer waiting time;
[0111] (2) Polling scheduling: When the queue waiting duration and the scheduling weight are equal, select one from the command queues with equal scheduling weights in sequence according to the NVMe device number order or the command queue number order for scheduling.
[0112] 6. Each Nvme device uses the above weight value as the priority and makes full use of the I / O scheduling function provided by the NVMe device itself to complete the "submit and distribute immediately" device command mechanism, avoiding the arbitration stage of multiple queues and simplifying the three steps into one step, that is, the device command directly changes from submission to distribution, which can save CPU cycles and improve the read and write performance.
[0113] Finally, the following example can be referred to:
[0114] Suppose there is an NVMe device with 5 queues (j = 1, 2, 3, 4, 5), and the initial queue command numbers are N 11 = 3, N 12 = 2, N 13 = 1, N 14 = 4, N 15 = 5, and the adjustment coefficients are set as α = 0.1, β = 0.2, γ = 0.3. In the initial scheduling period, the device idle states are S 11 = 0.8, S 12 = 0.5, S 13 = 0.6, S 14 = 0.7, S 15 = 0.4, and the command queue waiting times are t 11 = 5, t 12 = 3, t 13 = 2, t 14 = 4, t 15 = 6, then there are:
[0115] Calculate the initial scheduling weight:
[0116] ;
[0117] Update the scheduling weight of queue 1 for the command in the current scheduling period:
[0118] W 11 (1) = 0.15 + 0.1×0.8 - 0.2×3 - 0.3×5 = 0.15 + 0.08 - 0.6 - 1.5 = -1.87;
[0119] Update the scheduling weight of queue 2 for the command in the current scheduling period:
[0120] W 12 (1) = 0.10 + 0.1×0.5 - 0.2×2 - 0.3×3 = 0.10 + 0.05 - 0.4 - 0.9 = -1.15;
[0121] Update the scheduling weight of queue 3 when updating the commands in the current scheduling period:
[0122] W 13 (1) = 0.05 + 0.1×0.6 − 0.2×1 − 0.3×2 = 0.05 + 0.06 − 0.2 − 0.6 = −0.69;
[0123] Update the scheduling weight of queue 4 when updating the commands in the current scheduling period:
[0124] W 14 (1) = 0.20 + 0.1×0.7 − 0.2×4 − 0.3×4 = 0.20 + 0.07 − 0.8 − 1.2 = −1.73;
[0125] Update the scheduling weight of queue 5 when updating the commands in the current scheduling period:
[0126] W 15 (1) = 0.25 + 0.1×0.4 − 0.2×5 − 0.3×6 = 0.25 + 0.04 − 1.0 − 1.8 = −2.51;
[0127] Thus, by calculating the absolute values of the scheduling weights, we have W 15 (1) > W 11 (1) > W 14 (1) > W 12 (1) > W 13 (1), and then process each command queue in this order.
[0128] It can be seen that the device command processing method provided by the embodiments of the present application realizes a dynamic weighted round-robin arbitration mechanism based on the scheduling period by dividing the scheduling period, and then realizes device command processing. In each scheduling period, according to the load information of each target device, a load information adjustment coefficient is allocated to each target device to achieve load information adjustment. At the same time, combined with the historical scheduling weights of each command queue inside each target device in the previous scheduling period, the scheduling weight calculation of each command queue in the current scheduling period is realized. Thus, in the current scheduling period, the device commands of each command queue can be processed in the order of the current scheduling weights from large to small. It can be seen that the present technical solution realizes a dynamic weighted round-robin arbitration mechanism based on the scheduling period, and in each scheduling period, the scheduling weights of each command queue in each target device can be recalculated by comprehensively considering the current load situation and historical scheduling situation to achieve device command processing. Compared with the traditional round-robin scheduling mechanism and weighted round-robin scheduling mechanism, the present technical solution realizes a more flexible and reasonable device command scheduling, and can give full play to the overall performance of the system.
[0129] An embodiment of the present application provides a device command processing device.
[0130] Please refer to Figure 4 , Figure 4 , which is a schematic structural diagram of a device command processing device provided by the present application. The device command processing device may include:
[0131] An acquisition module 1, configured to acquire the load information of each target device and the historical scheduling weights of each command queue in each target device in the previous scheduling period during the current scheduling period;
[0132] An allocation module 2, configured to allocate a load information adjustment coefficient for each target device according to the load information of each target device;
[0133] A determination module 3, configured to determine the current scheduling weights of each command queue in each target device according to the load information, the load information adjustment coefficients, and the historical scheduling weights;
[0134] A processing module 4, configured to process device commands for each command queue in descending order of the current scheduling weights.
[0135] It can be seen that the device command processing device provided by the embodiment of the present application realizes a dynamic weighted round-robin arbitration mechanism based on the scheduling period by dividing the scheduling period, and further realizes device command processing. In each scheduling period, a load information adjustment coefficient is allocated for each target device according to the load information of each target device to be used for load information adjustment. At the same time, in combination with the historical scheduling weights of each command queue in each target device in the previous scheduling period, the scheduling weights of each command queue in the current scheduling period are calculated. Thus, in the current scheduling period, device commands can be processed for each command queue in descending order of the current scheduling weights. It can be seen that the technical solution realizes a dynamic weighted round-robin arbitration mechanism based on the scheduling period, and in each scheduling period, the scheduling weights of each command queue in each target device can be recalculated by comprehensively considering the current load situation and the historical scheduling situation to realize device command processing. Compared with the traditional round-robin scheduling mechanism and weighted round-robin scheduling mechanism, the technical solution realizes a more flexible and reasonable device command scheduling, and can give full play to the overall performance of the system.
[0136] In an embodiment of the present application, the above-mentioned acquisition module 1 may include:
[0137] A first acquisition unit, configured to acquire the load information of each target device when the current scheduling period is the initial scheduling period, and allocate initial scheduling weights for each command queue in the corresponding target device according to the load information, so as to use the initial scheduling weights as the historical scheduling weights;
[0138] A second obtaining unit, configured to obtain the load information of each target device and the historical scheduling weights of each command queue in each target device in the previous scheduling period when the current scheduling period is not the initial scheduling period.
[0139] In an embodiment of the present application, the above-mentioned first obtaining unit may specifically be configured to count the total number of commands of all command queues in all target devices; for each command queue in each target device, determine the initial scheduling weight of the command queue according to the number of commands in the command queue and the total number of commands.
[0140] In an embodiment of the present application, the above-mentioned allocation module 2 may specifically be configured to obtain the device information of each target device; and allocate a load information adjustment coefficient to each target device according to the device information and load information of each target device.
[0141] In an embodiment of the present application, the above-mentioned processing module 4 may specifically be configured to, when the values of the current scheduling weights are all positive, perform device command processing on each command queue in descending order of the current scheduling weights; when there are negative values among the values of the current scheduling weights, calculate the absolute values of the current scheduling weights with negative values to obtain the adjusted scheduling weights, and perform device command processing on each command queue in descending order of the adjusted scheduling weights.
[0142] In an embodiment of the present application, the above-mentioned obtaining module 1 may specifically be configured to obtain the queue idle status, the number of queue commands, and the queue waiting time of each command queue in the target device;
[0143] Correspondingly, the above-mentioned allocation module 2 may specifically be configured to allocate a queue idle status adjustment coefficient, a queue command number adjustment coefficient, and a queue waiting time adjustment coefficient to each target device according to the load information of each target device;
[0144] The above-mentioned determination module 3 may specifically be configured to, for each command queue in each target device, adjust the queue idle status of the command queue according to the queue idle status adjustment coefficient to obtain the adjusted queue idle status, adjust the number of queue commands of the command queue according to the queue command number adjustment coefficient to obtain the adjusted number of queue commands, adjust the queue waiting time of the command queue according to the queue waiting time adjustment coefficient to obtain the adjusted queue waiting time; determine the current scheduling weight of the command queue according to the adjusted queue idle status, the adjusted number of queue commands, the adjusted queue waiting time, and the historical scheduling weight.
[0145] In one embodiment of the present application, the device command processing apparatus may further include a selection module, configured to determine the current device command processing method before obtaining the load information of each target device and the historical scheduling weights of each command queue in each target device in the previous scheduling cycle within the current scheduling cycle; wherein, the device command processing methods include a device command processing method based on a cyclic arbitration mechanism, a device command processing method based on a weighted cyclic arbitration mechanism, and a device command processing method based on a dynamic weighted cyclic arbitration mechanism; if the current device command processing method is the device command processing method based on the dynamic weighted cyclic arbitration mechanism, then execute the step of obtaining the load information of each target device and the historical scheduling weights of each command queue in each target device in the previous scheduling cycle within the current scheduling cycle.
[0146] For the introduction of the apparatus provided in the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate herein.
[0147] Embodiments of the present application provide an electronic device.
[0148] Please refer to Figure 5 , Figure 5 which is a schematic structural diagram of an electronic device provided by the present application. The electronic device may include:
[0149] A memory 11, configured to store a computer program;
[0150] A processor 10, configured to execute the computer program to implement the steps of any of the above device command processing methods.
[0151] As Figure 5 shown, which is a schematic diagram of the composition structure of an electronic device. The electronic device may include: a processor 10, a memory 11, a communication interface 12, and a communication bus 13. The processor 10, the memory 11, and the communication interface 12 all complete communication with each other through the communication bus 13.
[0152] In the embodiments of the present application, the processor 10 may be a central processing unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array, or other programmable logic devices, etc.
[0153] The processor 10 may call the program stored in the memory 11. Specifically, the processor 10 may execute the operations in the embodiments of the device command processing method.
[0154] The memory 11 is used to store one or more programs. The program may include program code, and the program code includes computer operation instructions. In the embodiments of the present application, the memory 11 stores at least a program for implementing the following functions:
[0155] In the current scheduling cycle, obtain the load information of each target device and the historical scheduling weights of each command queue in each target device in the previous scheduling cycle;
[0156] Allocate a load information adjustment coefficient for each target device according to the load information of each target device;
[0157] Determine the current scheduling weights of each command queue in each target device according to the load information, the load information adjustment coefficients, and the historical scheduling weights;
[0158] Process the device commands for each command queue in descending order of the current scheduling weights.
[0159] In a possible implementation, the memory 11 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, as well as application programs required for at least one function, etc.; the data storage area may store the data created during use.
[0160] In addition, the memory 11 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device or other volatile solid-state storage devices.
[0161] The communication interface 12 may be an interface of a communication module for connecting to other devices or systems.
[0162] Of course, it should be noted that Figure 5 the structure shown does not limit the electronic device in the embodiments of the present application. In actual applications, the electronic device may include more or fewer components than Figure 5 those shown, or combine some components.
[0163] The embodiments of the present application provide a computer-readable storage medium.
[0164] The computer-readable storage medium provided by the embodiments of the present application stores a computer program. When the computer program is executed by a processor, the steps of any of the above device command processing methods can be implemented.
[0165] Among them, the computer-readable storage medium may be any available medium that a computer can store, or a data storage device such as a server or a data center that integrates one or more available media. For example, it may be various media that can store computer program codes, such as magnetic media (such as floppy disks, hard disks, magnetic tapes, etc.), optical media (such as DVDs), or semiconductor media (such as solid-state hard drives).
[0166] For the introduction of the computer-readable storage medium provided by the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate here.
[0167] An embodiment of the present application provides a computer program product.
[0168] The computer program product provided by the embodiment of the present application includes computer programs / instructions. When the computer programs / instructions are executed by a processor, the steps of any of the above device command processing methods can be implemented.
[0169] Specifically, in the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in the form of a computer program product in whole or in part.
[0170] Among them, the computer program product may include one or more computer programs / instructions. When the computer programs / instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application can be generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line, etc.) or a wireless manner (such as infrared, wireless, microwave, etc.).
[0171] For the introduction of the computer program product provided by the embodiment of the present application, please refer to the above method embodiments, and the present application will not elaborate here.
[0172] The various embodiments in the specification are described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. The same or similar parts among the various embodiments can be referred to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method part.
[0173] Those skilled in the art can further realize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0174] The steps of the methods or algorithms described in connection with the embodiments disclosed herein may be implemented directly in hardware, in software modules executed by a processor, or in a combination thereof. The software modules may be located in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium well-known in the art.
[0175] The technical solutions provided in this application have been introduced in detail above. Specific examples are used herein to illustrate the principles and implementation manners of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application. It should be noted that for those of ordinary skill in the art, without departing from the principle of this application, several improvements and modifications can be made to this application, and these improvements and modifications also fall within the protection scope of this application.
Claims
1. A device command processing method, characterized in that: include: In the current scheduling cycle, the load information of each target device and the historical scheduling weight of each command queue in each target device in the previous scheduling cycle are obtained; Allocating a load information adjustment coefficient to each of the target devices according to the load information of each of the target devices; Determine the current scheduling weight of each command queue in each target device according to each load information, each load information adjustment coefficient, and each historical scheduling weight; Device command processing is performed on each of the command queues in descending order of the current scheduling weights.
2. The device command processing method according to claim 1, characterized in that: In the current scheduling cycle, the load information of each target device and the historical scheduling weight of each command queue in each target device in the previous scheduling cycle are obtained, including: When the current scheduling period is an initial scheduling period, obtaining load information of each of the target devices, and assigning an initial scheduling weight to each of the command queues in the corresponding target device according to the load information, so as to use the initial scheduling weight as the historical scheduling weight; When the current scheduling period is not the initial scheduling period, the load information of each of the target devices and the historical scheduling weight of each of the command queues in each of the target devices in the previous scheduling period are obtained.
3. The device command processing method according to claim 2, characterized in that: Allocating an initial scheduling weight to each of the command queues in the corresponding target device according to the load information includes: Counting the total number of commands in all the command queues in all the target devices; For each command queue in each target device, an initial scheduling weight of the command queue is determined according to the number of commands in the command queue and the total number of commands.
4. The device command processing method according to claim 1, characterized in that: Allocating a load information adjustment coefficient to each of the target devices according to the load information of each of the target devices includes: Acquire device information of each of the target devices; A load information adjustment coefficient is allocated to each of the target devices according to the device information and load information of each of the target devices.
5. The device command processing method according to claim 1, characterized in that: Processing device commands for each of the command queues in descending order of the current scheduling weights includes: When the values of the current scheduling weights are all positive numbers, device command processing is performed on the command queues in descending order of the current scheduling weights; When the value of each current scheduling weight is a negative number, the absolute value of the negative current scheduling weight is calculated to obtain each adjusted scheduling weight, and device commands are processed for each command queue in descending order of the adjusted scheduling weights.
6. The device command processing method according to claim 1, characterized in that: Obtain the load information of each target device, including: Obtaining a queue idle state, a queue command quantity, and a queue waiting time of each of the command queues in the target device; Accordingly, allocating a load information adjustment coefficient to each of the target devices according to the load information of each of the target devices includes: Allocate a queue idle state adjustment coefficient, a queue command quantity adjustment coefficient and a queue waiting time adjustment coefficient to each of the target devices according to the load information of each of the target devices; Accordingly, determining the current scheduling weight of each command queue in each target device according to each load information, each load information adjustment coefficient, and each historical scheduling weight includes: For each command queue in each target device, adjusting the queue idle state of the command queue according to the queue idle state adjustment coefficient to obtain an adjusted queue idle state, adjusting the number of queue commands of the command queue according to the queue command quantity adjustment coefficient to obtain an adjusted queue command quantity, and adjusting the queue waiting time of the command queue according to the queue waiting time adjustment coefficient to obtain an adjusted queue waiting time; The current scheduling weight of the command queue is determined according to the idle state of the adjusted queue, the number of commands in the adjusted queue, the waiting time of the adjusted queue, and the historical scheduling weight.
7. The device command processing method according to claim 1, characterized in that: In the current scheduling cycle, before obtaining the load information of each target device and the historical scheduling weight of each command queue in each target device in the previous scheduling cycle, the method further includes: Determine the current device command processing mode; wherein the device command processing mode includes a device command processing mode based on a round-robin arbitration mechanism, a device command processing mode based on a weighted round-robin arbitration mechanism, and a device command processing mode based on a dynamic weighted round-robin arbitration mechanism; If the current device command processing method is the device command processing method based on the dynamic weighted round-robin arbitration mechanism, then execute the step of obtaining the load information of each target device and the historical scheduling weight of each command queue in each target device in the previous scheduling cycle within the current scheduling cycle.
8. A device command processing apparatus, characterized in that: include: An acquisition module, used to acquire, in a current scheduling cycle, load information of each target device and a historical scheduling weight of each command queue in each target device in a previous scheduling cycle; An allocating module, configured to allocate a load information adjustment coefficient to each of the target devices according to the load information of each of the target devices; A determination module, configured to determine a current scheduling weight of each command queue in each target device according to each load information, each load information adjustment coefficient, and each historical scheduling weight; The processing module is used to process device commands for each of the command queues in descending order of the current scheduling weight.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the device command processing method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the device command processing method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Task adjustment method and device, storage medium, electronic equipment and computer program product
CN120448078A
Data scheduling method and system and switch equipment
CN121334077A
A data scheduling method, system and switch device
CN121334077B