Resource allocation method, device and equipment, storage medium and computer program product

By dynamically allocating and switching processor cores, and adjusting the performance mode and frequency of the core according to task priority and core load, the balance problem between CPU resource utilization and performance is solved, and efficient resource management and low power consumption are achieved.

CN118349362BActive Publication Date: 2024-09-13LANGCHAO ELECTRONIC INFORMATION IND CO LTD
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202410766549.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-09-13
Estimated Expiration
2044-06-14

AI Technical Summary

Technical Problem

In the existing technology, it is difficult to achieve a balance between CPU resource utilization and performance. The fixed core-binding solution fails to adaptively handle core load changes, resulting in resource utilization and performance imbalance.

Method used

Through a resource allocation method, according to the task priority and the availability and load of the processor core, the fixed core with the maximum or minimum availability is dynamically allocated, and when necessary, the shared core is converted into a fixed core to realize adaptive core binding and adjust the core. Performance modes and frequencies to balance resource utilization and performance.

Benefits of technology

It achieves a balance between CPU resource utilization and performance in different task scenarios, improves task service quality and CPU resource utilization, and reduces power consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118349362B
    Figure CN118349362B
Patent Text Reader

Abstract

The present application discloses a resource allocation method, device and equipment, storage medium and computer program product, which relates to the technical field of central processing unit core binding. The method includes: when receiving a target task, determining the task load of the target task, and obtaining the availability and available load of the fixed core of the processor; if the target task belongs to the first type of task, allocating a target fixed core with maximum availability and an available load greater than the task load to the target task; wherein the first type of task is a task with a priority higher than a first preset level; if the target task belongs to the second type of task, allocating a target fixed core with minimum availability and an available load greater than the task load to the target task; wherein the second type of task is a task with a priority lower than a second preset level. The present application realizes adaptive core binding and achieves a balance between resource utilization and performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of central processing unit core binding, and more specifically, to a resource allocation method, device and equipment, storage medium and computer program product. Background Art

[0002] The CPU (Central Processing Unit) includes multiple processing cores and can process multiple tasks at the same time. Tasks need to be scheduled to the processing cores for execution. In order to meet the task scheduling requirements in different application scenarios, the Linux kernel implements multiple types of schedulers, such as the Completely Fair Scheduler (CFS), the Real-time Scheduler (RT), and the Deadline Scheduler (DS).

[0003] In the related art, a fixed core binding solution is generally adopted, which does not consider the impact of the load changes of each processing core during the actual operation of the task on the CPU core binding strategy, and cannot achieve a balance between CPU resource utilization and performance through adaptive core binding.

[0004] Therefore, how to implement adaptive core binding and thus achieve a balance between CPU resource utilization and performance is a technical problem that those skilled in the art need to solve. Summary of the invention

[0005] The purpose of the present application is to provide a resource allocation method, apparatus and device, storage medium and computer program product, which realize adaptive core binding and thus achieve a balance between CPU resource utilization and performance.

[0006] To achieve the above objectives, the present application provides a resource allocation method, comprising:

[0007] When receiving the target task, determining the task load of the target task, and obtaining the availability and available load of the fixed cores of the processor;

[0008] If the target task belongs to the first category of tasks, a target fixed core with maximum availability and an available load greater than the task load is allocated to the target task; wherein the first category of tasks are tasks with a priority higher than a first preset level;

[0009] If the target task belongs to the second category of tasks, a target fixed core with minimum availability and an available load greater than the task load is allocated to the target task; wherein the second category of tasks are tasks with a priority lower than a second preset level.

[0010] The first preset level is greater than the second preset level.

[0011] The fixed cores include fixed large cores and fixed small cores, and allocating a fixed core with a maximum availability and an available load greater than the task load to the target task includes:

[0012] A fixed large core with maximum availability and an available load greater than the task load is allocated to the target task.

[0013] The fixed cores include fixed large cores and fixed small cores, and allocating a fixed core with a minimum availability and an available load greater than the task load to the target task includes:

[0014] A fixed small core with minimum availability and an available load greater than the task load is allocated to the target task.

[0015] Among them, it also includes:

[0016] If there is no fixed core with an available load greater than the task load, the shared core is converted into a new fixed core, and the new fixed core is allocated to the target task.

[0017] The fixed core includes a fixed large core and a fixed small core. If there is no fixed core with an available load greater than the task load, the shared core is converted into a new fixed core, and the new fixed core is allocated to the target task, including:

[0018] If the target task belongs to the first type of tasks, when there is no fixed large core with an available load greater than the task load, converting the shared large core into a new fixed large core, and allocating the new fixed large core to the target task;

[0019] If the target task belongs to the second type of tasks, when there is no fixed small core with an available load greater than the task load, the shared small core is converted into a new fixed small core, and the new fixed small core is allocated to the target task.

[0020] After allocating the target fixed core to the target task, the method further includes:

[0021] Affinity binding is performed on the target task and the target fixed core.

[0022] The availability and available load of the fixed cores of the processor are obtained, including:

[0023] Obtain the availability and available load of fixed cores from a processor usage table; wherein the processor usage table includes basic information and current usage of the processor core, the basic information includes any one or a combination of several of the core type, core attributes, and performance modes, the core type includes large cores and small cores, the core attributes include fixed cores and shared cores, the performance mode includes any one or a combination of several of the user space mode, on-demand mode, power saving mode, conservative mode, and maximum frequency mode, and the current usage includes availability and available load.

[0024] After allocating the target fixed core to the target task, the method further includes:

[0025] The processor usage table is updated.

[0026] The performance mode of the fixed core running the first type of tasks is an on-demand mode, and the performance mode of the fixed core running the second type of tasks is a user space mode.

[0027] After allocating a target fixed core with a minimum availability and an available load greater than the task load to the target task, the method further includes:

[0028] Obtaining the load of the target fixed core within a preset time period;

[0029] If the load of the target fixed core within a preset time period is greater than a first preset value, increasing the frequency of the target fixed core;

[0030] If the load of the target fixed core within a preset time period is less than a second preset value, the frequency of the target fixed core is reduced; wherein the first preset value is greater than the second preset value.

[0031] After increasing the frequency of the target fixed core, the method further includes:

[0032] Determining whether the temperature of the target fixed core is greater than a temperature threshold;

[0033] If so, the frequency of the target fixed core is reduced.

[0034] Among them, it also includes:

[0035] Obtaining the load and availability of a fixed core in the processor within a preset time period;

[0036] If the fixed core runs the first type of tasks, when the availability of the fixed core in a preset time period is greater than an upper limit of availability, the shared core is converted into a new fixed core; when the availability of the fixed core in the preset time period is less than a lower limit of availability, the tasks running on the fixed core to be converted are transferred to other fixed cores for execution, and the fixed core to be converted is converted into a shared core;

[0037] If the fixed core runs the second type of tasks, then when the availability of the fixed core within a preset time period is greater than an availability upper limit or the load of the fixed core within a preset time period is greater than a load upper limit, the shared core is converted to a new fixed core; when the availability of the fixed core within the preset time period is less than an availability lower limit, the tasks running on the fixed core to be converted are transferred to other fixed cores for execution, and the fixed core to be converted is converted to a shared core.

[0038] Wherein, if the fixed core runs the first type of tasks, when the availability of the fixed core in a preset time period is greater than the upper limit of availability, the shared core is converted into a new fixed core; when the availability of the fixed core in the preset time period is less than the lower limit of availability, the tasks running on the fixed core to be converted are transferred to other fixed cores for execution, and the fixed core to be converted is converted into a shared core, including:

[0039] If the fixed core runs the first type of tasks, then when the availability of the fixed core within a preset time period is greater than the upper limit of availability, the shared large core is converted into a new fixed large core; when the availability of the fixed core within the preset time period is less than the lower limit of availability, the tasks running on the fixed large core to be converted are transferred to other fixed large cores for execution, and the fixed large core to be converted is converted into a shared large core.

[0040] Wherein, if the fixed core runs the second type of tasks, when the availability of the fixed core in a preset time period is greater than the upper limit of the availability or the load of the fixed core in a preset time period is greater than the upper limit of the load, the shared core is converted to a new fixed core; when the availability of the fixed core in the preset time period is less than the lower limit of the availability, the tasks running on the fixed core to be converted are transferred to other fixed cores for execution, and the fixed core to be converted is converted to a shared core, including:

[0041] If the fixed core runs the second type of task, then when the availability of the fixed core within the preset time period is greater than the upper limit of availability or the load of the fixed core within the preset time period is greater than the upper limit of load, the shared small core is converted into a new fixed small core; when the availability of the fixed core within the preset time period is less than the lower limit of availability, the task running on the fixed small core to be converted is transferred to other fixed small cores to run, and the fixed small core to be converted is converted into a shared small core.

[0042] Among them, it also includes:

[0043] Obtaining the availability of a shared core within a preset time period;

[0044] If the availability of the shared core within a preset time period is greater than an availability upper limit, improving the performance mode of the shared core;

[0045] If the availability of the shared core within a preset time period is less than a lower limit of availability, the performance mode of the shared core is reduced.

[0046] Among them, the performance modes of the shared core include, from high to low, a maximum frequency mode, a conservative mode, and a power saving mode.

[0047] To achieve the above objectives, the present application provides a resource allocation device, comprising:

[0048] A first acquisition module is used to determine the task load of the target task when receiving the target task, and to acquire the availability and available load of the fixed core of the processor;

[0049] A first allocation module is used to allocate a target fixed core with maximum availability and an available load greater than the task load to the target task when the target task belongs to a first category of tasks; wherein the first category of tasks are tasks with a priority higher than a first preset level;

[0050] The second allocation module is used to allocate a target fixed core with minimum availability and an available load greater than the task load to the target task when the target task belongs to the second category of tasks; wherein the second category of tasks are tasks with a priority lower than a second preset level.

[0051] To achieve the above objectives, the present application provides an electronic device, including:

[0052] Memory for storing computer programs;

[0053] A processor is used to implement the steps of the resource allocation method as described above when executing the computer program.

[0054] To achieve the above objectives, the present application provides a non-volatile storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the resource allocation method as described above are implemented.

[0055] It can be seen from the above scheme that a resource allocation method provided by the present application includes: when a target task is received, determining the task load of the target task, and obtaining the availability and available load of the fixed core of the processor; if the target task belongs to the first category of tasks, allocating to the target task a target fixed core with maximum availability and an available load greater than the task load; wherein the first category of tasks are tasks with a priority higher than a first preset level; if the target task belongs to the second category of tasks, allocating to the target task a target fixed core with minimum availability and an available load greater than the task load; wherein the second category of tasks are tasks with a priority lower than a second preset level.

[0056] The beneficial effect of the present application is that when there are first-class tasks with a priority higher than the first preset level and second-class tasks with a priority lower than the second preset level, adaptive core binding is performed according to the load and usage of the fixed core. For the first-class tasks with a priority higher than the first preset level, since they are critical tasks, they are bound to the target fixed core with an available load greater than the task load and the maximum availability. For the second-class tasks with a priority lower than the second preset level, since they are non-critical tasks, they are bound to the target fixed core with an available load greater than the task load and the minimum availability. Adaptive core binding is achieved based on the principle of satisfying the Quality of Service (QoS) of the tasks and high CPU resource utilization, thereby achieving a balance between CPU resource utilization and performance. The present application also discloses a resource allocation device, an electronic device, a non-volatile storage medium, and a computer program product, which can also achieve the above technical effects.

[0057] It should be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. The drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific implementation methods, they are used to explain the present disclosure, but do not constitute a limitation to the present disclosure. In the drawings:

[0059] Figure 1 is a flow chart of a resource allocation method according to an exemplary embodiment;

[0060] Figure 2 is a flow chart of another resource allocation method according to an exemplary embodiment;

[0061] Figure 3 is a flow chart of another resource allocation method according to an exemplary embodiment;

[0062] Figure 4 A flowchart of an application embodiment provided by the present application;

[0063] Figure 5 is a structural diagram of a resource allocation device according to an exemplary embodiment;

[0064] Figure 6The figure is a structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0065] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying 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 of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In addition, in the embodiments of the present application, "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0066] The embodiment of the present application discloses a resource allocation method, which realizes adaptive core binding and further achieves a balance between CPU resource utilization and performance.

[0067] See also Figure 1 , a flowchart of a resource allocation method according to an exemplary embodiment is shown, such as Figure 1 As shown, including:

[0068] S101: When a target task is received, determining a task load of the target task, and obtaining availability and available load of a fixed core of a processor;

[0069] The purpose of this embodiment is to allocate processing cores to target tasks. The target tasks include first-class tasks with a priority higher than a first preset level, i.e., critical tasks (e.g., high real-time tasks), and second-class tasks with a priority lower than a second preset level, i.e., non-critical tasks (e.g., offline tasks). As a preferred implementation, the first preset level is greater than the second preset level. The processing cores in the processor include fixed cores and shared cores. If a task has affinity to a certain processing core, the task will be fixed to the core for execution during runtime, and such a core is called a fixed core. If all tasks have no affinity to a certain processing core, such a core is called a shared core. In this embodiment, the fixed core is the processing core that processes the first and second class tasks, that is, the range of processing cores allocated to the target task is the fixed core.

[0070] In a specific implementation, a target fixed core is allocated to a target task according to the load and usage of the fixed core. When a target task exists, the task load of the target task is determined, and the current availability and available load of each fixed core of the processor are obtained.

[0071] As a feasible implementation method, obtaining the availability and available load of a fixed core of a processor includes: obtaining the availability and available load of a fixed core from a processor usage table; wherein the processor usage table includes basic information and current usage of the processor core, the basic information includes any one or a combination of several of the core type, core attributes, and performance modes, the core type includes large cores and small cores, the core attributes include fixed cores and shared cores, the performance mode includes any one or a combination of several of the user space mode, on-demand mode, power saving mode, conservative mode, and maximum frequency mode, and the current usage includes availability and available load.

[0072] In a specific implementation, the dynamic load and usage of each processing core can be recorded in real time through the processor usage table. The processing cores in the processor are numbered. If the processor contains homogeneous cores, they are uniformly numbered according to the core number. If the processor contains heterogeneous cores, that is, the processing cores include large cores and small cores, they are grouped and numbered according to the core type. For example, there are 8 processing cores in the processor, including 4 large cores and 4 small cores. The grouped large and small cores are renumbered. The large cores are: core 1 (fixed core), core 2 (shared core), core 3 (shared core), core 4 (shared core); the small cores are: core 1 (fixed core), core 2 (fixed core), core 3 (shared core), core 4 (shared core). Generally speaking, the large cores are used to process the first type of tasks, and the small cores are used to process the second type of tasks.

[0073] The processor usage table records the basic information and current usage of each processing core. The basic information may include core type, core attributes, performance mode, etc. Core type refers to large core and small core, core attributes refers to fixed core and shared core, and performance mode may include powersave mode, userspace mode, ondemand mode, conservative mode and performance mode. In order to reduce power consumption, shared cores use three performance modes: powersave mode, conservative mode and performance mode. Fixed cores running the first type of tasks use the ondemand mode, and fixed cores running the second type of tasks use the userspace mode. Current usage may include availability and available load. Availability can be expressed by utilization rate. The availability of cores with low current utilization rate is greater than that of cores with high utilization rate.

[0074] Therefore, in the processor usage table, the information (KernelInfo) that needs to be recorded for each processing core can be defined as the following five-tuple form: KernelInfo=〈Type, Number, Usage, UtilizationRate, UsePattern〉, where Type represents the core type, Number represents the number, Usage represents the core attribute, UtilizationRate represents the utilization rate, and UsePattern represents the performance mode used.

[0075] According to the processor usage table, each fixed core is sorted according to its availability. If the processor has heterogeneous cores, each fixed core is grouped according to the core type and sorted according to availability within the group. It can be seen that the processor usage table can clearly record the relevant information of each processing core, which improves the efficiency of obtaining the availability and available load of the fixed core.

[0076] S102: If the target task belongs to the first category of tasks, allocating a target fixed core with maximum availability and an available load greater than the task load to the target task; wherein the first category of tasks are tasks with a priority higher than a first preset level;

[0077] In a specific implementation, for the first type of tasks, it is determined in descending order of availability whether the available load of each fixed core is greater than the task load of the target task. If so, the fixed core is allocated to the target task as the target fixed core.

[0078] As a feasible implementation mode, the fixed core includes a fixed large core and a fixed small core, and a fixed core with maximum availability and an available load greater than the task load is allocated to the target task, including: allocating a fixed large core with maximum availability and an available load greater than the task load to the target task.

[0079] In a specific implementation, if there are heterogeneous cores in the processor, the available load of each fixed large core is determined in descending order of availability to determine whether it is greater than the task load of the target task. If so, the fixed large core is allocated to the target task.

[0080] S103: If the target task belongs to the second category of tasks, a target fixed core with minimum availability and an available load greater than the task load is allocated to the target task; wherein the second category of tasks are tasks with a priority lower than a second preset level.

[0081] In a specific implementation, for the second type of tasks, it is determined in order from low to high availability whether the available load of each fixed core is greater than the task load of the target task. If so, the fixed core is allocated to the target task as the target fixed core.

[0082] As a feasible implementation mode, the fixed core includes a fixed large core and a fixed small core, and a fixed core with minimum availability and an available load greater than the task load is allocated to the target task, including: allocating a fixed small core with minimum availability and an available load greater than the task load to the target task.

[0083] In a specific implementation, if there are heterogeneous cores in the processor, the available load of each fixed small core is determined in order from low to high in terms of availability to determine whether it is greater than the task load of the target task. If so, the fixed small core is allocated to the target task.

[0084] As a feasible implementation, it further includes: if there is no fixed core with an available load greater than the task load, converting the shared core into a new fixed core, and allocating the new fixed core to the target task. In a specific implementation, if there is no fixed core with an available load greater than the task load of the target task, converting the shared core into a new fixed core, and allocating the fixed core to the target task.

[0085] As a feasible implementation mode, the fixed core includes a fixed large core and a fixed small core. If there is no fixed core with an available load greater than the task load, the shared core is converted into a new fixed core, and the new fixed core is allocated to the target task, including: if the target task belongs to the first category of tasks, then when there is no fixed large core with an available load greater than the task load, the shared large core is converted into a new fixed large core, and the new fixed large core is allocated to the target task; if the target task belongs to the second category of tasks, then when there is no fixed small core with an available load greater than the task load, the shared small core is converted into a new fixed small core, and the new fixed small core is allocated to the target task.

[0086] In a specific implementation, if there are heterogeneous cores in the processor, for the first type of task, if there is no fixed large core whose available load is greater than the task load of the target task, the shared large core will be converted into a new fixed large core, and the fixed large core will be assigned to the target task. For the second type of task, if there is no fixed small core whose available load is greater than the task load of the target task, the shared small core will be converted into a new fixed small core, and the fixed small core will be assigned to the target task. It should be noted that after converting the shared large core into a new fixed large core, adjusting the fixed large core to ondemand mode, and converting the shared small core into a new fixed small core, the performance mode of the fixed small core will be adjusted to userspace mode.

[0087] As a feasible implementation, after allocating a target fixed core to the target task, the method further includes: affinity binding the target task and the target fixed core. In a specific implementation, after selecting a target fixed core for the target task, affinity binding is automatically completed.

[0088] As a feasible implementation method, after allocating the target fixed core to the target task, the method further includes: updating the processor usage table. In a specific implementation, after completing the affinity binding between the target task and the target fixed core, the relevant information of the target fixed core in the processor usage table is updated, which may include core attributes, performance mode, available load, availability, etc.

[0089] The resource allocation method provided in the embodiment of the present application performs adaptive core binding according to the load and usage of the fixed cores when there are first-category tasks with a priority higher than a first preset level and second-category tasks with a priority lower than a second preset level. For the first-category tasks with a priority higher than the first preset level, since they are critical tasks, they are bound to the target fixed cores with an available load greater than the task load and maximum availability. For the second-category tasks with a priority lower than the second preset level, since they are non-critical tasks, they are bound to the target fixed cores with an available load greater than the task load and minimum availability. Adaptive core binding is achieved based on the principle of meeting the service quality of the tasks and high CPU resource utilization, thereby achieving a balance between CPU resource utilization and performance.

[0090] On the basis of the above embodiment, as a preferred implementation manner, after allocating a target fixed core with a minimum availability and an available load greater than the task load to the target task, it also includes: obtaining the load of the target fixed core within a preset time period; if the load of the target fixed core within the preset time period is greater than a first preset value, increasing the frequency of the target fixed core; if the load of the target fixed core within the preset time period is less than a second preset value, reducing the frequency of the target fixed core; wherein the first preset value is greater than the second preset value.

[0091] In the specific implementation, for the fixed cores running the second type of tasks, that is, the fixed cores with the performance mode of userspace mode, the decision-making power of the frequency change strategy is handed over to the user-mode application. First, the usage rate of the target fixed core in the preset time period is examined. If the load on the target fixed core is too high and the current frequency is lower than the preset CPU core maximum frequency, the frequency of the target fixed core is increased. If the current frequency is already the highest frequency, no operation is performed. If the load on the target fixed core is too low and the current frequency is higher than the preset CPU core minimum frequency, the frequency of the target fixed core is reduced. If the current frequency is already the lowest frequency, no operation is performed.

[0092] As a preferred implementation, after increasing the frequency of the target fixed core, the method further includes: determining whether the temperature of the target fixed core is greater than a temperature threshold; if so, reducing the frequency of the target fixed core.

[0093] It should be noted that since continuous frequency increase may cause the temperature of the target fixed core to be too high, the corresponding frequency reduction operation can be used to ensure that the target fixed core works in a normal temperature environment. In order to avoid frequency modulation jitter, the frequency modulation management can be performed by setting a suitable historical time range as the inspection object according to the system task situation. When the temperature of the target fixed core within the historical time range is greater than the temperature threshold, the frequency of the target fixed core is reduced.

[0094] It can be seen that adaptive frequency adjustment is performed on fixed cores in userspace mode according to load conditions and temperature, achieving a balance between CPU resource utilization and performance. In addition, frequency adjustment management is not used for fixed cores in ondemand mode to avoid the impact of frequency reduction on task real-time performance.

[0095] The present application discloses a resource allocation method. Figure 2 , a flowchart of another resource allocation method according to an exemplary embodiment is shown, such as Figure 2 As shown, including:

[0096] S201: Obtaining the load and availability of a fixed core in the processor within a preset time period;

[0097] In the specific implementation, a preset time period is selected to monitor the usage status of all fixed cores in the system. In order to avoid jitter, the time range of the preset time period should not be too small. Define the threshold value of the fixed core, including the load upper limit and the upper / lower limit of availability. The load upper limit can be expressed by the percentage of time that the task is blocked on the CPU resource.

[0098] S202: If the fixed core runs the first type of tasks, when the availability of the fixed core in a preset time period is greater than the upper availability limit, convert the shared core into a new fixed core; when the availability of the fixed core in the preset time period is less than the lower availability limit, transfer the tasks running on the fixed core to be converted to other fixed cores for execution, and convert the fixed core to be converted into a shared core;

[0099] In the specific implementation, since the first type of tasks are critical tasks, in order to avoid blocking as much as possible, the fixed cores bound to the first type of tasks only use the availability threshold (upper / lower limit of availability). When the availability of the fixed cores in the preset time period is greater than the upper limit of availability, the QoS performance of the tasks in the system may be lost, and it is necessary to increase the supply of CPU resources. At this time, one or more shared cores are converted to new fixed cores. For the fixed cores bound to the critical tasks, as long as the upper limit of availability is triggered, the strategy of increasing CPU resources is adopted, that is, the shared cores are enabled to ensure the QoS of the critical tasks. When the availability of the fixed cores in the preset time period is less than the lower limit of availability, it means that there is an excess of CPU resources in the system, and the supply of CPU resources should be reduced. At this time, if multiple fixed cores trigger the lower limit of CPU resource utilization, these tasks can be integrated into a small number of fixed cores for operation. This can be achieved by dynamically adjusting task affinity and task migration, adjusting the redundant fixed cores to shared cores, and adjusting the performance mode to powersave mode, and updating the CPU usage table.

[0100] As a feasible implementation mode, if the fixed core runs the first type of tasks, then when the availability of the fixed core within a preset time period is greater than the upper limit of availability, the shared core is converted into a new fixed core; when the availability of the fixed core within the preset time period is less than the lower limit of availability, the tasks running on the fixed core to be converted are transferred to other fixed cores for execution, and the fixed core to be converted is converted into a shared core, including: if the fixed core runs the first type of tasks, then when the availability of the fixed core within the preset time period is greater than the upper limit of availability, the shared large core is converted into a new fixed large core; when the availability of the fixed core within the preset time period is less than the lower limit of availability, the tasks running on the fixed large core to be converted are transferred to other fixed large cores for execution, and the fixed large core to be converted is converted into a shared large core.

[0101] In a specific implementation, when the availability of a fixed large core in a preset time period is greater than the upper availability limit, a shared large core is enabled as a new fixed large core. When the availability of a fixed large core in a preset time period is less than the lower availability limit, tasks are integrated on cores of the same type, that is, for fixed large cores running the first type of tasks, the first type of tasks running on the fixed large cores that trigger the lower availability limit are integrated onto a small number of fixed large cores, and the redundant fixed large cores are adjusted to shared large cores.

[0102] S203: If the fixed core runs the second type of task, then when the availability of the fixed core within the preset time period is greater than the upper limit of the availability or the load of the fixed core within the preset time period is greater than the upper limit of the load, the shared core is converted to a new fixed core; when the availability of the fixed core within the preset time period is less than the lower limit of the availability, the task running on the fixed core to be converted is transferred to other fixed cores for execution, and the fixed core to be converted is converted to a shared core.

[0103] In the specific implementation, the fixed cores bound to the second type of tasks use two types of load thresholds (load upper limit) and availability thresholds (availability upper / lower limits). When the availability of a fixed core in a preset time period is greater than the availability upper limit or the load is greater than the load upper limit, the QoS performance of the tasks in the system may be lost, and it is necessary to increase the supply of CPU resources. At this time, one or more shared cores are converted to new fixed cores. For fixed cores bound to critical tasks, as long as the availability upper limit is triggered, the strategy of increasing CPU resources is adopted, that is, shared cores are enabled to ensure the QoS of critical tasks. When the availability of a fixed core in a preset time period is less than the availability lower limit, it means that there is an excess of CPU resources in the system and the CPU resource supply should be reduced. At this time, if multiple fixed cores trigger the lower limit of CPU resource utilization, these tasks can be integrated into a small number of fixed cores for operation. This can be achieved by dynamically adjusting task affinity and task migration, adjusting the redundant fixed cores to shared cores, and adjusting the performance mode to powersave mode, and updating the CPU usage table.

[0104] As a feasible implementation mode, if the fixed core runs the second type of task, then when the availability of the fixed core within a preset time period is greater than the upper limit of availability or the load of the fixed core within the preset time period is greater than the upper limit of load, the shared core is converted into a new fixed core; when the availability of the fixed core within the preset time period is less than the lower limit of availability, the tasks running on the fixed core to be converted are transferred to other fixed cores for execution, and the fixed core to be converted is converted into a shared core, including: if the fixed core runs the second type of task, then when the availability of the fixed core within the preset time period is greater than the upper limit of availability or the load of the fixed core within the preset time period is greater than the upper limit of load, the shared small core is converted into a new fixed small core; when the availability of the fixed core within the preset time period is less than the lower limit of availability, the tasks running on the fixed small core to be converted are transferred to other fixed small cores for execution, and the fixed small core to be converted is converted into a shared small core.

[0105] In a specific implementation, when the availability of a fixed small core in a preset time period is less than the upper availability limit, a shared small core is enabled as a new fixed small core. When the availability of a fixed small core in a preset time period is less than the lower availability limit, tasks are integrated on cores of the same type, that is, for fixed small cores running the first type of tasks, the first type of tasks running on the fixed small cores that trigger the lower availability limit are integrated into a small number of fixed small cores for running, and the redundant fixed small cores are adjusted to shared small cores.

[0106] It can be seen that during the task running process, this embodiment monitors the overall CPU usage of the system in real time and dynamically adjusts the CPU supply in the system. By dynamically adjusting the task affinity, the tasks on the fixed core with greater CPU pressure are bound to the new core (the shared core becomes a fixed core) to achieve load sharing. If the CPU utilization on the overall fixed core in the system is low, multiple low-load tasks are integrated into one fixed core to run, reducing the number of CPU cores used in the system. This embodiment can dynamically adjust the supply of CPU resources in the system, actively intervene in the problems of resource utilization and poor performance caused by unreasonable scheduling and improper CPU resource allocation, and use the least CPU resources and reduce power consumption while ensuring the task Qos performance.

[0107] The present application discloses a resource allocation method. Figure 3 , a flowchart of another resource allocation method according to an exemplary embodiment is shown, such as Figure 3 As shown, including:

[0108] S301: Obtaining the availability of a shared core within a preset time period;

[0109] S302: If the availability of the shared core within a preset time period is greater than an availability upper limit, improving the performance mode of the shared core;

[0110] S303: If the availability of the shared core within a preset time period is less than a lower limit of availability, lowering the performance mode of the shared core.

[0111] The purpose of this embodiment is to optimize the resources of the shared core, use the upper / lower limits of the availability as the trigger threshold, and optimize the resources of the shared core by adjusting the performance mode of the shared core. The performance modes of the shared core include the highest frequency mode, conservative mode, and power saving mode from high to low. If the availability of the shared core within a preset time period is greater than the upper limit of the availability, the QoS performance of the task may be impaired, and the CPU resource supply can be increased by improving the performance mode, such as adjusting the conservative mode to the performance mode. If the availability of the shared core within a preset time period is less than the lower limit of the availability, there may be a waste of CPU resources. At this time, the performance mode is reduced, such as adjusting the conservative mode to the powersave mode, or adjusting the performance mode to the conservative mode.

[0112] It can be seen that this embodiment can make corresponding performance mode adjustments according to the resource utilization on the shared core, adaptively adjust the performance mode to improve performance or reduce power consumption, and achieve a balance between performance and power consumption.

[0113] The following describes an application embodiment provided by the present application. The overall architecture of the CPU resource allocation method based on adaptive core binding frequency modulation mainly includes two parts:

[0114] (1) Core binding before task execution: For newly appeared tasks or tasks being scheduled between cores in the system, if they need to be bound to a core for execution, core selection and binding are performed based on the real-time recording of the dynamic usage of CPU resources. After binding, the task is fixedly executed on the specified core.

[0115] (2) In-core frequency adjustment and CPU resource adjustment during runtime: During the task execution, the balance between QoS performance and CPU resource utilization is ensured to the greatest extent through two levels of operations: in-core adjustment (local) and system-wide optimization (overall). For in-core adjustment, the corresponding frequency increase and frequency decrease operations are mainly based on two factors: the current core load and its own temperature. For system-wide optimization, by analyzing the current system-level load and according to the set threshold value, it is decided to increase or decrease the CPU resource supply. Task loads are integrated by dynamically adjusting task affinity, task migration, and adjusting the CPU core working mode, reducing unnecessary CPU resource supply.

[0116] The specific flow chart is as follows Figure 4 As shown, establish a processor usage table, processor resource management, determine the tasks to be bound to the core, select the core for the task, and update the processor usage table in real time after the task is bound to the core. During the task running, perform core load analysis and core temperature collection to perform frequency modulation management and update the processor usage table in real time. Analyze the system load, set thresholds, adjust task affinity, manage task migration, re-bind the core, adjust processor resources, and update the processor usage table in real time.

[0117] Taking the CPU resources of an 8-core heterogeneous architecture (4 large cores and 4 small cores) as an example, the specific implementation process includes:

[0118] Step 1: Initialize the CPU usage table structure. According to the CPU type and number, build 8 table entries (such as core s1=<small core, number 1, fixed core, 0%, userspace mode>, such as core b1=<large core, number 1, fixed core, 0%, ondemand mode>, such as core b2=<large core, number 2, fixed core, 0%, ondemand mode>, and the others are shared cores). Initially, the usage rate of these CPU fixed cores is 0.

[0119] Step 2: Set the task priority range that does not require core binding, such as [10,30]. Then when the task priority is greater than 10 or less than 30 (the smaller the value, the higher the priority), it is necessary to bind the core before running.

[0120] Step 3: Select cores for tasks that need to be bound to cores. For example, T1 is an offline task with a priority of 35, and T2 is a critical task with a priority of 5. Since all cores have not been started, assign small core s1 No. 1 to T1 and large core b1 No. 1 to T2.

[0121] Step 4: Bind the core through the sched_setaffinity interface provided by Linux.

[0122] Step 5: Update the CPU usage table, for example, core s1=<small core, number 1, used, 30%, userspace mode>, core b1=<large core, number 1, used, 3%, ondemand mode>.

[0123] Step 6: Check whether frequency adjustment is needed. Analyze the current frequency of the CPU core, the maximum and minimum frequencies supported, and the usage rate within a period of time (for example, 60 seconds). Check the current, maximum, and minimum frequencies through cpuinfo_cur_freq, cpuinfo_max_freq, and cpuinfo_min_freq in the cpufreq module. For example, if the current frequency of core s1 is 2.5GHz, the minimum main frequency is 1.5GHz, and the usage rate is 30%, which means the load is too low, then adjust the frequency to 2.0GHz.

[0124] Step 7: Get the CPU core temperature through the Sysfs kernel interface. If the temperature is too high, reduce the frequency.

[0125] Step 8: Set the CPU core usage threshold in the system (for example, the upper limit of core s1 is 80%, the lower limit is 40%; the upper limit of core b1 is 60%, the lower limit is 5%; the upper limit of shared cores is 70%) and the upper limit of CPU fixed core pressure (for example, 10% for core s1).

[0126] Step 9: Get the pressure information on the CPU core in the system. For example, in addition to T1, there are other tasks (with a priority less than 30) running on core s1 in the system. Through the psi interface, the CPU blocking time of task T1 in the 100-second time range accounts for 15%.

[0127] Step 10: Adjust the CPU resources in the system that exceed the upper pressure limit. For example, if the upper pressure limit of core s1 is 10%, start the shared core, such as core s2=<small core, number 2, shared core, 0%, powersave mode>, change s2 to a fixed core s2=<small core, number 2, fixed core, 0%, userspace mode>, and bind task T1 to core s2 to share the pressure.

[0128] Step 11: Adjust resources when the CPU usage in the system triggers the threshold. For example, in addition to core b1 (usage rate 3%), other large cores (such as core b2) are also running in the system, and the usage rate of core b2 is 4%. Then bind task T2 on core b1 to core b2 to run, that is, integrate the underloaded cores on the two cores into one core.

[0129] Step 12: During system operation, dynamically monitor the system status to adjust CPU frequency or allocate resources, and execute the above steps 3-11 in a loop.

[0130] A resource allocation device provided in an embodiment of the present application is introduced below. The resource allocation device described below and the resource allocation method described above can be referenced to each other.

[0131] See also Figure 5 , according to an exemplary embodiment, a structural diagram of a resource allocation device is shown, such as Figure 5 As shown, including:

[0132] A first acquisition module 501 is used to determine the task load of the target task when receiving the target task, and to acquire the availability and available load of the fixed core of the processor;

[0133] A first allocation module 502 is used to allocate a target fixed core with maximum availability and an available load greater than the task load to the target task when the target task belongs to a first type of task; wherein the first type of task is a task with a priority higher than a first preset level;

[0134] The second allocation module 503 is used to allocate a target fixed core with minimum availability and an available load greater than the task load to the target task when the target task belongs to the second category of tasks; wherein the second category of tasks are tasks with a priority lower than a second preset level.

[0135] The resource allocation device provided in the embodiment of the present application performs adaptive core binding according to the load and usage of the fixed cores when there are first-category tasks with a priority higher than a first preset level and second-category tasks with a priority lower than a second preset level. For the first-category tasks with a priority higher than the first preset level, since they are critical tasks, they are bound to the target fixed cores with an available load greater than the task load and maximum availability. For the second-category tasks with a priority lower than the second preset level, since they are non-critical tasks, they are bound to the target fixed cores with an available load greater than the task load and minimum availability. Adaptive core binding is achieved based on the principle of meeting the service quality of the tasks and high CPU resource utilization, thereby achieving a balance between CPU resource utilization and performance.

[0136] Based on the above embodiment, as a preferred implementation mode, the fixed core includes a fixed large core and a fixed small core, and the first allocation module 502 is specifically used to allocate a fixed large core with maximum availability and an available load greater than the task load to the target task.

[0137] Based on the above embodiment, as a preferred implementation mode, the fixed core includes a fixed large core and a fixed small core, and the second allocation module 503 is specifically used to allocate a fixed small core with minimum availability and an available load greater than the task load to the target task.

[0138] Based on the above embodiment, as a preferred implementation, it also includes:

[0139] The first conversion module is used to convert the shared core into a new fixed core when there is no fixed core with an available load greater than the task load, and allocate the new fixed core to the target task.

[0140] On the basis of the above embodiments, as a preferred implementation mode, the fixed core includes a fixed large core and a fixed small core, and the conversion module is specifically used to: if the target task belongs to the first category of tasks, then when there is no fixed large core with an available load greater than the task load, the shared large core is converted into a new fixed large core, and the new fixed large core is allocated to the target task; if the target task belongs to the second category of tasks, then when there is no fixed small core with an available load greater than the task load, the shared small core is converted into a new fixed small core, and the new fixed small core is allocated to the target task.

[0141] Based on the above embodiment, as a preferred implementation, it also includes:

[0142] A binding module is used to perform affinity binding between the target task and the target fixed core.

[0143] On the basis of the above embodiments, as a preferred implementation mode, the first acquisition module 501 is specifically used to: obtain the availability and available load of the fixed core from the processor usage table; wherein the processor usage table includes basic information and current usage of the processor core, the basic information includes any one or a combination of several of the core type, core attributes, and performance mode, the core type includes large cores and small cores, the core attributes include fixed cores and shared cores, the performance mode includes any one or a combination of several of the user space mode, on-demand mode, power saving mode, conservative mode, and maximum frequency mode, and the current usage includes availability and available load.

[0144] Based on the above embodiment, as a preferred implementation, it also includes:

[0145] An updating module is used to update the processor usage table after allocating a target fixed core to the target task.

[0146] Based on the above embodiment, as a preferred implementation mode, the performance mode of the fixed core running the first type of tasks is an on-demand mode, and the performance mode of the fixed core running the second type of tasks is a user space mode.

[0147] Based on the above embodiment, as a preferred implementation, it also includes:

[0148] A second acquisition module is used to acquire the load of the target fixed core within a preset time period after allocating a target fixed core with a minimum availability and an available load greater than the task load to the target task;

[0149] A first boosting module, configured to boost the frequency of the target fixed core when the load of the target fixed core within a preset time period is greater than a first preset value;

[0150] The first reduction module is used to reduce the frequency of the target fixed core when the load of the target fixed core within a preset time period is less than a second preset value; wherein the first preset value is greater than the second preset value.

[0151] Based on the above embodiment, as a preferred implementation, it also includes:

[0152] The judging module is used to judge whether the temperature of the target fixed core is greater than a temperature threshold after the frequency of the target fixed core is increased; if so, reduce the frequency of the target fixed core.

[0153] Based on the above embodiment, as a preferred implementation, it also includes:

[0154] A third acquisition module, used to acquire the load and availability of the fixed core in the processor within a preset time period;

[0155] a second conversion module, configured to, if the fixed core runs the first type of tasks, convert the shared core into a new fixed core when the availability of the fixed core within a preset time period is greater than an availability upper limit, and when the availability of the fixed core within the preset time period is less than an availability lower limit, transfer the tasks running on the fixed core to be converted to other fixed cores for execution, and convert the fixed core to be converted into a shared core;

[0156] The third conversion module is used for converting the shared core into a new fixed core if the fixed core runs the second type of task, when the availability of the fixed core within a preset time period is greater than an availability upper limit or the load of the fixed core within a preset time period is greater than a load upper limit, and when the availability of the fixed core within the preset time period is less than an availability lower limit, transferring the task running on the fixed core to be converted to other fixed cores for execution, and converting the fixed core to be converted into a shared core.

[0157] Based on the above embodiments, as a preferred implementation mode, the second conversion module is specifically used for: if the fixed core runs the first type of task, then when the availability of the fixed core within a preset time period is greater than the upper limit of availability, the shared large core is converted into a new fixed large core; when the availability of the fixed core within a preset time period is less than the lower limit of availability, the task running on the fixed large core to be converted is transferred to other fixed large cores for execution, and the fixed large core to be converted is converted into a shared large core.

[0158] On the basis of the above embodiments, as a preferred implementation mode, the third conversion module is specifically used for: if the fixed core runs the second type of task, then when the availability of the fixed core within a preset time period is greater than the upper limit of the availability or the load of the fixed core within a preset time period is greater than the upper limit of the load, the shared small core is converted into a new fixed small core; when the availability of the fixed core within the preset time period is less than the lower limit of the availability, the task running on the fixed small core to be converted is transferred to other fixed small cores to run, and the fixed small core to be converted is converted into a shared small core.

[0159] Based on the above embodiment, as a preferred implementation, it also includes:

[0160] A fourth acquisition module, used to acquire the availability of the shared core within a preset time period;

[0161] A second improving module, configured to improve the performance mode of the shared core when the availability of the shared core within a preset time period is greater than an availability upper limit;

[0162] The second reducing module is used to reduce the performance mode of the shared core when the availability of the shared core within a preset time period is less than an availability lower limit.

[0163] Based on the above embodiment, as a preferred implementation mode, the performance modes of the shared core include, from high to low, a maximum frequency mode, a conservative mode, and a power saving mode.

[0164] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0165] Based on the hardware implementation of the above program module, and in order to implement the method of the embodiment of the present application, the embodiment of the present application also provides an electronic device, Figure 6 FIG. 1 is a structural diagram of an electronic device according to an exemplary embodiment. Figure 6 As shown, the electronic equipment includes:

[0166] Communication interface 1, capable of exchanging information with other devices such as network devices;

[0167] The processor 2 is connected to the communication interface 1 to implement information exchange with other devices and is used to execute the resource allocation method provided by one or more technical solutions when running a computer program. The computer program is stored in the memory 3.

[0168] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 4. It can be understood that the bus system 4 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 4 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 6 Various buses are labeled as bus system 4.

[0169] The memory 3 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.

[0170] It can be understood that the memory 3 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAMbus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 3 described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memories.

[0171] The method disclosed in the above embodiment of the present application can be applied to the processor 2, or implemented by the processor 2. The processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 2 or the instruction in the form of software. The above processor 2 may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a storage medium, which is located in the memory 3, and the processor 2 reads the program in the memory 3 and completes the steps of the above method in combination with its hardware.

[0172] When the processor 2 executes the program, the corresponding processes in the various methods of the embodiments of the present application are implemented, which will not be repeated here for the sake of brevity.

[0173] In an exemplary embodiment, the present application also provides a non-volatile storage medium storing a computer program, which can be executed by the processor 2 to complete the steps of the aforementioned method.

[0174] In an exemplary embodiment, the present application also provides a computer program product, including a computer program, which is executed by the processor 2 to complete the steps of the aforementioned method.

[0175] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to computer program instructions, and the aforementioned computer program can be stored in a non-volatile storage medium. When the computer program is executed, it executes the steps of the above-mentioned method embodiment. Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product, which is stored in a non-volatile storage medium and includes a number of instructions for an electronic device (which can be a personal computer, a server, a network device, etc.) to execute all or part of the methods described in each embodiment of the present application.

[0176] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A resource allocation method, characterized in that: include: When a target task is received, the task load of the target task is determined, and the availability and available load of a fixed core of the processor are obtained; wherein the availability of the fixed core is used to describe the utilization rate of the fixed core, and the availability is negatively correlated with the utilization rate; if a task has affinity to a certain processing core, the task is fixed to the core for execution at runtime, and such a core is called a fixed core; If the target task belongs to the first category of tasks, a target fixed core with maximum availability and an available load greater than the task load is allocated to the target task; wherein the first category of tasks are tasks with a priority higher than a first preset level; If the target task belongs to the second category of tasks, a target fixed core with minimum availability and an available load greater than the task load is allocated to the target task; wherein the second category of tasks are tasks with a priority lower than a second preset level, and the first preset level is greater than the second preset level; If there is no fixed core with an available load greater than the task load, the shared core is converted into a new fixed core, and the new fixed core is allocated to the target task; wherein, if all tasks have no affinity to a certain processing core, such a core is called a shared core.

2. The resource allocation method according to claim 1, characterized in that: The fixed cores include a fixed large core and a fixed small core, and allocating a fixed core with a maximum availability and an available load greater than the task load to the target task includes: A fixed large core with maximum availability and an available load greater than the task load is allocated to the target task.

3. The resource allocation method according to claim 1, characterized in that: The fixed cores include a fixed large core and a fixed small core, and allocating a fixed core with a minimum availability and an available load greater than the task load to the target task includes: A fixed small core with minimum availability and an available load greater than the task load is allocated to the target task.

4. The resource allocation method according to claim 1, characterized in that: The fixed cores include fixed large cores and fixed small cores. If there is no fixed core with an available load greater than the task load, converting the shared core into a new fixed core and allocating the new fixed core to the target task includes: If the target task belongs to the first type of tasks, when there is no fixed large core with an available load greater than the task load, converting the shared large core into a new fixed large core, and allocating the new fixed large core to the target task; If the target task belongs to the second type of tasks, when there is no fixed small core with an available load greater than the task load, the shared small core is converted into a new fixed small core, and the new fixed small core is allocated to the target task.

5. The resource allocation method according to claim 1, characterized in that: After allocating the target fixed core to the target task, the method further includes: Affinity binding is performed on the target task and the target fixed core.

6. The resource allocation method according to claim 1, characterized in that: Get the availability and available load of the processor's fixed cores, including: Obtain the availability and available load of fixed cores from a processor usage table; wherein the processor usage table includes basic information and current usage of the processor core, the basic information includes any one or a combination of several of the core type, core attributes, and performance modes, the core type includes large cores and small cores, the core attributes include fixed cores and shared cores, the performance mode includes any one or a combination of several of the user space mode, on-demand mode, power saving mode, conservative mode, and maximum frequency mode, and the current usage includes availability and available load.

7. The resource allocation method according to claim 6, characterized in that: After allocating the target fixed core to the target task, the method further includes: The processor usage table is updated.

8. The resource allocation method according to claim 1, characterized in that: The performance mode of the fixed core running the first type of tasks is the on-demand mode, and the performance mode of the fixed core running the second type of tasks is the user space mode.

9. The resource allocation method according to claim 8, characterized in that: After allocating the target fixed core with the minimum availability and the available load greater than the task load to the target task, the method further includes: Obtaining the load of the target fixed core within a preset time period; If the load of the target fixed core within a preset time period is greater than a first preset value, increasing the frequency of the target fixed core; If the load of the target fixed core within a preset time period is less than a second preset value, the frequency of the target fixed core is reduced; wherein the first preset value is greater than the second preset value.

10. The resource allocation method according to claim 9, characterized in that: After increasing the frequency of the target fixed core, the method further includes: Determining whether the temperature of the target fixed core is greater than a temperature threshold; If so, the frequency of the target fixed core is reduced.

11. The resource allocation method according to claim 1, characterized in that: Also includes: Obtaining the load and availability of a fixed core in the processor within a preset time period; If the fixed core runs the first type of tasks, when the availability of the fixed core in a preset time period is greater than an upper limit of availability, the shared core is converted into a new fixed core; when the availability of the fixed core in the preset time period is less than a lower limit of availability, the tasks running on the fixed core to be converted are transferred to other fixed cores for execution, and the fixed core to be converted is converted into a shared core; If the fixed core runs the second type of tasks, then when the availability of the fixed core within a preset time period is greater than an availability upper limit or the load of the fixed core within a preset time period is greater than a load upper limit, the shared core is converted to a new fixed core; when the availability of the fixed core within the preset time period is less than an availability lower limit, the tasks running on the fixed core to be converted are transferred to other fixed cores for execution, and the fixed core to be converted is converted to a shared core.

12. The resource allocation method according to claim 11, characterized in that: If the fixed core runs the first type of tasks, when the availability of the fixed core in a preset time period is greater than the upper limit of availability, the shared core is converted to a new fixed core; when the availability of the fixed core in the preset time period is less than the lower limit of availability, the tasks running on the fixed core to be converted are transferred to other fixed cores for execution, and the fixed core to be converted is converted to a shared core, including: If the fixed core runs the first type of tasks, then when the availability of the fixed core within a preset time period is greater than the upper limit of availability, the shared large core is converted into a new fixed large core; when the availability of the fixed core within the preset time period is less than the lower limit of availability, the tasks running on the fixed large core to be converted are transferred to other fixed large cores for execution, and the fixed large core to be converted is converted into a shared large core.

13. The resource allocation method according to claim 11, characterized in that: If the fixed core runs the second type of task, when the availability of the fixed core in a preset time period is greater than the upper limit of the availability or the load of the fixed core in a preset time period is greater than the upper limit of the load, the shared core is converted to a new fixed core; when the availability of the fixed core in the preset time period is less than the lower limit of the availability, the task running on the fixed core to be converted is transferred to another fixed core for execution, and the fixed core to be converted is converted to a shared core, including: If the fixed core runs the second type of task, then when the availability of the fixed core within the preset time period is greater than the upper limit of availability or the load of the fixed core within the preset time period is greater than the upper limit of load, the shared small core is converted into a new fixed small core; when the availability of the fixed core within the preset time period is less than the lower limit of availability, the task running on the fixed small core to be converted is transferred to other fixed small cores to run, and the fixed small core to be converted is converted into a shared small core.

14. The resource allocation method according to claim 1, characterized in that: Also includes: Obtaining the availability of a shared core within a preset time period; If the availability of the shared core within a preset time period is greater than an availability upper limit, improving the performance mode of the shared core; If the availability of the shared core within a preset time period is less than a lower limit of availability, the performance mode of the shared core is reduced.

15. The resource allocation method according to claim 14, characterized in that: The performance modes of the shared core include, from high to low, a maximum frequency mode, a conservative mode, and a power saving mode.

16. A resource allocation device, characterized in that: include: A first acquisition module is used to determine the task load of the target task when receiving the target task, and to acquire the availability and available load of the fixed core of the processor; wherein the availability of the fixed core is used to describe the utilization rate of the fixed core, and the availability is negatively correlated with the utilization rate; if a task has affinity to a certain processing core, the task is fixed to the core for execution during runtime, and such a core is called a fixed core; A first allocation module is used to allocate a target fixed core with maximum availability and an available load greater than the task load to the target task when the target task belongs to a first category of tasks; wherein the first category of tasks are tasks with a priority higher than a first preset level; A second allocation module is used for allocating, when the target task belongs to a second type of task, a target fixed core with a minimum availability and an available load greater than the task load to the target task; wherein the second type of task is a task with a priority lower than a second preset level, and the first preset level is greater than the second preset level; The first conversion module is used to convert the shared core into a new fixed core when there is no fixed core with an available load greater than the task load, and allocate the new fixed core to the target task; wherein, if all tasks have no affinity to a certain processing core, such a core is called a shared core.

17. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the resource allocation method according to any one of claims 1 to 15 when executing the computer program.

18. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, and when the computer program is executed, the steps of the resource allocation method according to any one of claims 1 to 15 are implemented.

19. A computer program product, characterized in that The method comprises a computer program, which implements the steps of the resource allocation method according to any one of claims 1 to 15 when the computer program is executed by a processor.

Citation Information

Patent Citations

  • CPU resource allocation method and device, storage medium and equipment

    CN112068960A

  • Dynamic core scheduling method and device for multi-core system

    CN115686800A

  • Core scheduling method and device for multi-core system

    CN115686873A

  • Task scheduling method and related equipment

    CN117666755A

  • Event scheduling method and system and storage medium

    CN117667782A