A CPU resource dynamic allocation method to improve the overall system throughput

By collecting and analyzing the CPU resource usage information of the process on edge devices, dynamically adjusting the weight and resource allocation of the process, the problem of low CPU resource utilization efficiency on resource-constrained devices is solved, and the overall system throughput is improved.

CN114153612BActive Publication Date: 2025-05-13HANGZHOU DIANZI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111483344.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-07
Publication Date
2025-05-13
Estimated Expiration
2041-12-07

AI Technical Summary

Technical Problem

In edge scenarios, on devices with limited resources, it is difficult for the existing technology to effectively utilize CPU resources, resulting in a decrease in the overall system throughput.

Method used

By collecting the CPU resource usage status information of the process, using the scheduling entity data structure to affect the weight of the process, dynamically adjusting the CPU resource allocation of the process to ensure the rational allocation and utilization of resources.

Benefits of technology

It realizes efficient utilization of CPU resources on edge devices, improves the overall system throughput, and adapts to different stages of task operation through periodic monitoring.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114153612B_ABST
    Figure CN114153612B_ABST
Patent Text Reader

Abstract

The present invention relates to a method for dynamically allocating CPU resources for improving the overall throughput of a system. The process CPU resource demand perception module in the present invention can measure the CPU resource demand of a process in real time and quantify the consumption of CPU resources when the process is running. The CPU resource partitioning module can reasonably allocate CPU resources within and between process groups according to the different CPU demands of ready processes in the system, ensuring that processes with higher CPU demands are processed with higher priority. At each moment of system operation, the ready process information of the system at the current moment is detected in real time, and the adjustment of the next stage is prepared to reasonably allocate CPU resources at each moment of the operation of the process, thereby improving the overall throughput of the system while ensuring real-time performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of operating systems, and in particular to a resource allocation method for dynamically adjusting CPU resource allocation between and within task groups on a resource-constrained device in an edge scenario to improve the overall throughput of the system. Background Art

[0002] With the rapid development of network and communication technologies, the Internet of Everything is no longer out of reach. Edge computing gives full play to its characteristics of being close to the data generation side, and has the advantages of low latency and high reliability. It is widely used in the field of Internet of Things, such as smart homes and smart cities.

[0003] Compared with cloud devices, edge devices often face the problem of limited resources. If conventional resource allocation strategies are continued, system resources may not be fully utilized and may even cause performance degradation. How to make full use of limited resources on edge devices to improve system throughput is an issue that must be considered when designing edge systems. However, the different organizational forms between processes and various resource allocation constraints such as real-time and fairness have brought many problems to the setting of resource allocation schemes. There are two core issues in how to maximize the use of limited CPU resources and improve the overall throughput of the system: (1) Process CPU resource demand prediction, obtaining quantitative values ​​of the different CPU resource demands of different processes, and then dividing CPU resources for the purpose of improving throughput. (2) The demand for CPU resources by tasks is not static. The operating system needs to detect the different demands of tasks in different time periods in real time and adjust the resource allocation for the next stage. Summary of the invention

[0004] In order to solve the problem of rational utilization of resources on resource-constrained devices in edge scenarios, the present invention proposes a method for dynamic allocation of CPU resources to improve the overall throughput of the system.

[0005] The present invention collects the CPU resource usage status information of the process and records it in the process scheduling entity data structure, uses the data to influence the weight of the process in the scheduling group to modify the CPU resource allocation of the process, and modifies the weight of the scheduling entity corresponding to the scheduling group to modify the CPU resource allocation between different scheduling groups, while controlling the minimum threshold of group resource allocation to reduce the impact of excessive group load differences.

[0006] The method of the present invention involves the following three modules:

[0007] (1) Process CPU resource demand perception module

[0008] The function of this module is to periodically obtain the relevant metadata of the process in the system process ready queue. It obtains the CPU resource usage snapshot information of the process by accessing the process descriptor. After calculation and processing, it obtains the quantitative index of the degree of CPU resource demand of the process.

[0009] (2) CPU resource partition module

[0010] This module aims to balance resource allocation within and between process groups by obtaining CPU resource demand information. CPU resource allocation is mainly divided into two parts. The first is to adjust the priority of processes within the process group and divide the CPU resources within the group by using the quantitative indicators of the degree of demand obtained above. The second is to adjust the CPU ratio between groups by using the quantitative indicators of the CPU resource demand of the processes within the group as the demand indicators of the group and combining the minimum threshold of the group resources.

[0011] (3) Process Scheduling Module

[0012] This module controls the selection of running processes. It is responsible for taking out the highest priority process from the process ready queue and putting it into operation each time, and determining whether it needs to rejoin the ready queue each time the process time slice expires.

[0013] The method comprises the following steps:

[0014] Step 1: The process CPU resource demand perception module periodically accesses the scheduling entity corresponding to the process to obtain the resource usage snapshot information such as the process execution time, and obtains the number of instructions executed by the process by reading the PMU hardware.

[0015] Step 2: Calculate the actual running time of the process in each cycle and the IPS (Instructions per second) indicator of the process through the snapshot information and the number of executed instructions collected in step 1, and fill them in the newly added field IPS of the scheduling entity corresponding to the process;

[0016] Step 3: The CPU resource allocation module adjusts the CPU resource allocation within and between process groups through the IPS information in the process scheduling entity. It traverses the process ready queue and performs corresponding processing on the CPU resource allocation within and between process groups.

[0017] Step 3.1: For the processes in the same scheduling group, calculate the IPS weight of each process (the ratio of the process IPS to the sum of the IPS of all processes in the group), scale the process IPS weight, calculate the weight again, and then modify the priority of the process based on the weight;

[0018] Step 3.2: For the process groups at the same level, first process the resource allocation within each group according to step 3 and obtain the average IPS within the group, and then calculate the resource allocation proportion of each group based on this. At the same time, set the minimum threshold of the group share to 2 / 3 of the equal division value. If the group share is less than this value, set the group share to this minimum threshold, and modify the total amount of remaining resources. For other groups, allocate resources according to the proportion as usual;

[0019] Step 4: The process scheduling module selects the process with the highest priority from the process ready queue for execution. If the process has not finished executing after the time slice allocated to it expires, it will be put back into the process ready queue;

[0020] Step 5: Repeat steps 1, 2, 3, and 4 until finished.

[0021] The beneficial effects of the present invention are as follows: the present invention dynamically adjusts the allocation of CPU resources according to the different utilization efficiencies of CPU resources by different processes in the system to improve the overall throughput; and performs periodic monitoring to realize the allocation adjustment in the next stage to adapt to each stage of task operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 It is the structural diagram of the model components;

[0023] Figure 2 Overall diagram of process CPU resource demand perception;

[0024] Figure 3 Schematic diagram of the specific process of CPU resource demand perception;

[0025] Figure 4 It is a schematic diagram of the overall division of CPU resources;

[0026] Figure 5 Execute the overall flow chart for the method;

[0027] Figure 6 Perform detailed steps for the method. DETAILED DESCRIPTION

[0028] The present invention will be further described below in conjunction with the accompanying drawings.

[0029] The present invention proposes a method for dynamically allocating CPU resources to improve the overall throughput of the system. It measures the utilization efficiency of CPU resources by different processes in each time interval in real time and dynamically allocates corresponding CPU resources to the processes in the next time interval. It dynamically provides higher CPU resource allocation to the processes that can use CPU resources more efficiently, thereby improving the overall throughput of the system in each time interval. The present invention mainly includes three modules: 1) process CPU resource demand perception module; 2) CPU resource division module; 3) process scheduling module.

[0030] Figure 1 This is the structural diagram of the model components of this method.

[0031] The process CPU resource demand perception module is responsible for collecting and processing the CPU resource utilization efficiency information of the processes in the system and saving it for future allocation reference. This step is the basis for subsequent allocation, and in order to realize dynamic allocation adjustment during system operation, the module needs to output information regularly as a reference for allocation in the next stage. The CPU resource partitioning module uses the IPS data collected earlier to first divide the resources within the group, and then allocate resources between groups. This is because the IPS data of the processes within the group can be obtained while dividing the CPU resources of the processes within the group, and finally the IPS mean is returned upward as a reference for allocation between groups. Finally, the process scheduling module realizes the selection of the processes to be scheduled and the process switching.

[0032] Figure 2 and Figure 3 This is a schematic diagram of the process CPU resource demand perception module.

[0033] in Figure 2 It is the overall process of demand perception. Figure 3 It is a part of the specific calculation process, including some calculation formulas and related functions. The core significance of the CPU resource demand perception module is to find the degree of demand for CPU computing power of different processes, so as to serve as a reference for subsequent CPU resource division. The definition of CPU demand refers to the IPS (instructions per second) value. The higher the IPS of the process, the more fully the system runs when running the task, and it also shows that the process has a higher CPU utilization rate. The present invention opens the hardware counting event of the number of instructions executed by the process through the system call sys_perf_event_open, and then reads the PMU hardware to obtain the number of instructions executed by the process, and then combines the process scheduling entity sched_entity to obtain the process running time to calculate the IPS value of the process, and fills it into the newly added field IPS of the scheduling entity corresponding to the process to provide a reference for subsequent modification of resource allocation.

[0034] Figure 4 This is an overall diagram of the CPU resource allocation.

[0035] In the system that introduces group scheduling, there are two types of grouping relationships between processes. One is in the same group, such as tasks initiated by the same terminal, and the other is in different groups, such as tasks initiated by different users. Due to the emergence of group scheduling, if you want to modify the resource division between processes, you must consider their positional relationship. Processes in the same group can affect the load weight of the process by modifying the priority, thereby achieving different virtual running time growth rates of tasks and different selection frequencies to achieve the effect of resource division; resource division of processes in different groups is more complicated. In order to improve the overall throughput of the system, a suitable indicator is needed to represent the degree of CPU resource demand between different groups, while taking into account that the CPU resource allocation of some groups will not be squeezed to too low by other groups. At the same time, the resource allocation between groups will affect the resource allocation of processes within the group. In order to improve the overall throughput of the system, it is necessary to ensure that when the group share is increased, the resource utilization efficiency within the group will not be diluted to an excessive extent by different process structures. At the same time, it should be noted that only groups at the same level have the meaning of resource division.

[0036] Figure 5 and Figure 6 It is a flowchart of the execution of this method.

[0037] in Figure 5 is the overall flow chart of the method. Figure 6 It is the detailed steps of method execution. The overall process can be divided according to different modules. First, the IPS information of the process is obtained through the process resource demand perception module. Then, the CPU resources are divided according to the IPS of the process, mainly including the CPU resource division within the process group and between process groups. Finally, the process scheduling module maintains the process switching. The specific execution steps are as follows: first, obtain the scheduling entity in the process ready queue, and judge in turn. If the scheduling entity is not a process, that is, a process group, then go deep into the process group until the process is found. Monitor the processes encountered during the traversal process, obtain the process weight, virtual running time, PID, and read the PMU hardware to obtain the number of instructions of the process. Then calculate the IPS of the process and fill it into the newly added field ips of the scheduling entity. Then, perform CPU resource division according to the IPS of the process.

[0038] The specific execution calculation process of this method is described in the following algorithm.

[0039] Algorithm 1 describes a method for obtaining process CPU resource demand information. The present invention provides an interface to the user space, thereby achieving flexible switching between the normal mode and the CPU resource allocation process in the present invention.

[0040]

[0041]

[0042] The core function of this algorithm can be briefly summarized as providing IPS data support for subsequent allocation plans. Specifically, it periodically monitors the hardware to obtain information on the number of executed instructions and calculates the IPS of the process based on the virtual running time of the process, and updates the data to the newly added field of the process scheduling entity.

[0043] Algorithm 2 describes the specific process of resource allocation within the group:

[0044]

[0045]

[0046] The CPU resource division within the same group refers to the proportion of each process IPS. A type ratio division is performed by calculating the proportion of process IPS. First, the proportion of process IPS in the total IPS in the group is calculated, and then this data is scaled to a certain extent. Finally, the priority of the process is adjusted according to the IPS proportion information of different processes.

[0047] Algorithm 3 describes the CPU resource allocation between groups

[0048]

[0049]

[0050] The allocation of CPU resources between process groups is relatively complicated because the number of groups and the number of processes within a group are uncertain. At the same time, in order to protect the basic rights and interests of the group, some thresholds need to be set. After comprehensively considering various factors and actual conditions, the present invention selects the resource allocation between groups and performs proportional allocation based on the average IPS value within the group as a whole. First, the proportion of the average IPS value of each group in all groups is calculated, which is used as the proportion of allocation between groups. At the same time, during the modification process, the group's allocation minimum threshold is matched (the group minimum threshold is set to 2 / 3 of the average value) to divide the CPU resources between groups.

[0051] The specific steps of the method of the present invention are:

[0052] Step 1: The process CPU resource demand perception module periodically accesses the scheduling entity corresponding to the process to obtain the resource usage snapshot information such as the process execution time, and obtains the number of instructions executed by the process by reading the PMU hardware.

[0053] Step 2: Calculate the actual running time of the process in each cycle and the IPS (Instructions per second) indicator of the process through the snapshot information and the number of executed instructions collected in step 1, and fill them in the newly added field IPS of the scheduling entity corresponding to the process;

[0054] Step 3: The CPU resource allocation module adjusts the CPU resource allocation within and between process groups through the IPS information in the process scheduling entity. It traverses the process ready queue and performs corresponding processing on the CPU resource allocation within and between process groups.

[0055] Step 3.1: For the processes in the same scheduling group, calculate the IPS weight of each process (the ratio of the process IPS to the sum of the IPS of all processes in the group), scale the process IPS weight, calculate the weight again, and then modify the priority of the process based on the weight;

[0056] Step 3.2: For the process groups at the same level, first process the resource allocation within each group according to step 3 and obtain the average IPS within the group, and then calculate the resource allocation proportion of each group based on this. At the same time, set the minimum threshold of the group share to 2 / 3 of the equal division value. If the group share is less than this value, set the group share to this minimum threshold, and modify the total amount of remaining resources. For other groups, allocate resources according to the proportion as usual;

[0057] Step 4: The process scheduling module selects the process with the highest priority from the process ready queue for execution. If the process has not finished executing after the time slice allocated to it expires, it will be put back into the process ready queue;

[0058] Step 5: Repeat steps 1, 2, 3, and 4 until finished.

Claims

1. A method for dynamically allocating CPU resources to improve overall system throughput, characterized in that: According to the different requirements of different processes in the system for CPU resources, the allocation of CPU resources is dynamically adjusted between and within groups to improve the overall throughput; the resource requirements of the process are periodically monitored and the allocation adjustment for the next stage is made to adapt to each stage of task operation. This method involves the following three modules: (1) Process CPU resource demand perception module The function of this module is to periodically obtain the relevant metadata of the processes in the system process ready queue, including the process running time, weight and IPS of the process; (2) CPU resource partitioning module This module aims to balance resource allocation within and between process groups by obtaining CPU resource demand information. CPU resource allocation is mainly divided into two parts: one is to adjust the priority of processes within the process group by using the IPS information of the processes after corresponding processing; the other is to adjust the CPU ratio between groups by combining the difference in the average IPS values ​​of different groups with the minimum threshold of group resources; (3) Process Scheduling Module This module controls the selection of running processes. It is responsible for taking out the highest priority process from the process ready queue and putting it into operation each time. It also determines whether it needs to rejoin the ready queue each time the process time slice expires. The method comprises the following steps: Step 1: The process CPU resource demand perception module periodically accesses the scheduling entity corresponding to the process to obtain the resource usage snapshot information of the process, and obtains the number of instructions executed by the process by reading the PMU hardware; Step 2: Calculate the actual running time of the process in each cycle and the IPS of the process through the resource usage snapshot information and the number of executed instructions collected in step 1, and fill them in the newly added field ips of the scheduling entity corresponding to the process; Step 3: The CPU resource allocation module adjusts the CPU resource allocation within and between process groups through the IPS information in the process scheduling entity; traverses the process ready queue to perform corresponding processing on the CPU resource allocation within and between process groups; Step 4: The process scheduling module selects the process with the highest priority from the process ready queue for execution; if the process has not finished executing after the time slice allocated to it expires, it will be put back into the process ready queue; Step 5: Repeat steps 1 to 4 until the end.

2. The method for dynamically allocating CPU resources to improve overall system throughput according to claim 1, characterized in that: Step 3 specifically includes: Step 3.1: For the processes in the same scheduling group, calculate the IPS ratio of each process, scale the IPS ratio of the process, calculate the ratio again, and then modify the priority of the process based on the ratio; Step 3.2: For process groups at the same level, first process the resource allocation within each group according to step 3 and obtain the average IPS within the group, and calculate the resource allocation proportion of each group based on this. At the same time, set the minimum threshold of the group share to 2 / 3 of the equal-division value. If the group proportion is less than this value, set the group share to this minimum threshold, and modify the total amount of remaining resources. For other groups, allocate them as usual based on the proportion.