Resource allocation method, electronic device, storage medium, and program product

By dynamically adjusting the processor core resource allocation strategy, background tasks are run on different processor cores according to the background task load status, which solves the problems of power loss and low throughput caused by background tasks running on small cores, and achieves a balance between power consumption and throughput.

CN122132154APending Publication Date: 2026-06-02HONOR DEVICE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-12-02
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

The problem of power consumption loss and low system throughput caused by background tasks running in small cores.

Method used

The processor core resource allocation strategy is dynamically adjusted based on the number of background tasks. Under low load, it runs on the lower-performance first processor core, and under high load, it switches to the higher-performance second processor core, and runs within a reasonable frequency range to avoid power consumption and throughput issues caused by excessive frequency.

Benefits of technology

It reduced the power consumption of the processor core, increased the system throughput, and reduced the complexity of system operation through a reasonable resource allocation strategy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122132154A_ABST
    Figure CN122132154A_ABST
Patent Text Reader

Abstract

This application provides a resource allocation method, electronic device, storage medium, and program product, which are beneficial for reducing system power consumption and improving system throughput. The method includes: determining the number of background tasks; if the number of background tasks is less than or equal to a first threshold, allocating a first CPU and a first frequency point available to the background group, wherein the first CPU only includes the CPU corresponding to a first processor core, and the first frequency point is lower than the highest frequency point of the first processor core; if the number of background tasks is greater than a second threshold, allocating a second CPU and a second frequency point available to the background group, wherein the second CPU includes the CPU corresponding to a second processor core, and the second frequency point is lower than the highest frequency point of the second processor core; wherein the first threshold is less than or equal to the second threshold, and the processing power of the second processor core is higher than the processing power of the first processor core.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of terminals, and more particularly to a resource allocation method, electronic device, storage medium, and program product. Background Technology

[0002] Electronic devices include various types of tasks, such as foreground tasks and background tasks. Foreground tasks have higher priority, and the operating system usually allocates more processing resources to them to ensure a smooth user experience.

[0003] To avoid background tasks affecting the execution of foreground tasks, background tasks are usually restricted to execution on small cores. However, in some scenarios, running background tasks on small cores can lead to power consumption losses and low system throughput. Summary of the Invention

[0004] This application provides a resource allocation method, electronic device, storage medium, and program product, which are beneficial for reducing system power consumption and increasing system throughput.

[0005] In a first aspect, a resource allocation method is provided, comprising: determining the number of background tasks; if the number of background tasks is less than or equal to a first threshold, allocating a first CPU and a first frequency point available to the background group, wherein the first CPU includes only the CPU corresponding to a first processor core, and the first frequency point is lower than the highest frequency point of the first processor core; if the number of background tasks is greater than a second threshold, allocating a second CPU and a second frequency point available to the background group, wherein the second CPU includes the CPU corresponding to a second processor core, and the second frequency point is lower than the highest frequency point of the second processor core; wherein the first threshold is less than or equal to the second threshold, and the processing power of the second processor core is higher than the processing power of the first processor core.

[0006] This application embodiment can allocate appropriate processor resources to background tasks based on the number of background tasks. If the number of background tasks is less than or equal to a first threshold, i.e., the number of background tasks is relatively small, resources can be allocated only to the first processor core for the background tasks. This allows the background tasks to run only on the lower-performance first processor core, and restricts the first processor core from running background tasks at its highest frequency (i.e., at or below the first frequency). This prevents the background tasks from pushing the first processor core's frequency to its maximum. Therefore, the solution in this application embodiment is beneficial for reducing the power consumption of the first processor core.

[0007] If the number of background tasks is less than or equal to a first threshold, meaning there are many background tasks, running them only on the first processor core will affect the system throughput. In this case, embodiments of this application can allocate higher-performance second processor core resources to the background tasks, allowing them to run on the second processor core, thereby improving system throughput. Secondly, when the second processor core runs background tasks, it can run the tasks only on a portion of the CPU's CPU, preventing background tasks from consuming all CPU resources and affecting the execution of other higher-priority tasks. Furthermore, when the second processor core runs background tasks, it can run them at or below the highest frequency point (i.e., the second frequency point or below), thereby reducing the power consumption of the second processor core.

[0008] In some implementations, the step of allocating a first CPU and a first frequency point available to the background group if the number of background tasks is less than or equal to a first threshold includes: marking the load state of the background group as a first state if the number of background tasks is less than or equal to the first threshold; and allocating the first CPU and the first frequency point available to the background group in response to the load state of the background group being in the first state.

[0009] This application embodiment can first determine the load status of the background group based on the number of background tasks, and then determine the resource allocation strategy based on the load status of the background group. The determination of the number of background tasks and the determination of the load status of the background group can be executed at the kernel layer, while the determination of the resource allocation strategy can be executed at the system layer. Through the above scheme, the system layer can directly determine the resource allocation strategy based on the load status of the background group, thereby reducing the complexity of the system layer in determining the resource allocation strategy.

[0010] In some implementations, the electronic device employs a resource management mechanism based on a control group. This mechanism supports a resource management subsystem including a CPU setting subsystem and a CPU subsystem. The step of allocating the first CPU and a first frequency point available to the background group in response to the background group's load state being a first state includes: configuring a first parameter in the CPU setting subsystem to a first value, and configuring the maximum value of the utilization clamping parameter in the CPU subsystem to a second value; wherein the first parameter indicates a list of CPUs allowed for use by the background group, the first value includes only the CPU number corresponding to the first processor core, and the second value is determined based on the first frequency point.

[0011] The first parameter (cpuset.cpus) in the cpuset subsystem is used to indicate the list of CPUs that are allowed to be used by background groups. The parameter (cpu.uclamp.max) in the cpu subsystem is used to limit the frequency points available to task groups. Therefore, by adjusting the values ​​of the cuset.cpus and cpu.uclamp.max parameters, the CPUs and frequency points available to background groups can be managed, thereby reducing the complexity of system operation.

[0012] In some implementations, marking the load state of the background group as the first state if the number of background tasks is less than or equal to a first threshold includes: marking the load state of the background group as the first state if the number of background tasks is less than or equal to the first threshold in multiple consecutive preset periods.

[0013] By determining the load status of background groups based on the number of background tasks within multiple consecutive preset periods, the determined load status of background groups becomes more reasonable and accurate. This allows the system to formulate a more reasonable resource allocation strategy, thereby improving system performance.

[0014] In some implementations, the step of allocating a second CPU and a second frequency point available to the background group if the number of background tasks is greater than a second threshold includes: marking the load state of the background group as a second state if the number of background tasks is greater than the second threshold; and allocating the second CPU and the second frequency point available to the background group in response to the load state of the background group being in the second state.

[0015] This application embodiment can first determine the load status of the background group based on the number of background tasks, and then determine the resource allocation strategy based on the load status of the background group. The determination of the number of background tasks and the determination of the load status of the background group can be executed at the kernel layer, while the determination of the resource allocation strategy can be executed at the system layer. Through the above scheme, the system layer can directly determine the resource allocation strategy based on the load status of the background group, thereby reducing the complexity of the system layer in determining the resource allocation strategy.

[0016] In some implementations, the electronic device employs a resource management mechanism based on a control group. This mechanism supports a resource management subsystem including a CPU setting subsystem and a CPU subsystem. The step of allocating the second CPU and a second available frequency point to the background group in response to its load state being a second state includes: configuring a first parameter in the CPU setting subsystem to a third value, and configuring the maximum value of the utilization clamping parameter in the CPU subsystem to a fourth value; wherein the first parameter indicates a list of CPUs allowed for use by the background group, the third value includes the CPU number corresponding to the second processor core, and the fourth value is determined based on the second frequency point.

[0017] The first parameter (cpuset.cpus) in the cpuset subsystem is used to indicate the list of CPUs that are allowed to be used by background groups. The parameter (cpu.uclamp.max) in the cpu subsystem is used to limit the frequency points available to task groups. Therefore, by adjusting the values ​​of the cuset.cpus and cpu.uclamp.max parameters, the CPUs and frequency points available to background groups can be managed, thereby reducing the complexity of system operation.

[0018] In some implementations, marking the load state of the background group as the second state if the number of background tasks is greater than the second threshold includes: marking the load state of the background group as the second state if the number of background tasks is greater than the second threshold in multiple consecutive preset periods.

[0019] By determining the load status of background groups based on the number of background tasks within multiple consecutive preset periods, the determined load status of background groups becomes more reasonable and accurate. This allows the system to formulate a more reasonable resource allocation strategy, thereby improving system performance.

[0020] In some implementations, the first threshold is less than or equal to a first quantity, and the second threshold is greater than or equal to the first quantity, where the first quantity is the number of CPUs currently allocated to the background group.

[0021] Setting the second threshold to be greater than the first threshold can reduce the frequency of system adjustments to the allocation strategy, thus reducing system complexity. For example, if the number of background tasks is less than or equal to the first threshold, the system executes the first allocation strategy. If the number of background tasks is greater than the first threshold but less than the second threshold, the system can continue to execute the first allocation strategy without adjusting to the second allocation strategy. The system will only execute the second allocation strategy when the number of background tasks exceeds the second threshold, thereby reducing the frequency of system adjustments to the allocation strategy.

[0022] In some implementations, determining the number of background tasks includes: within a preset period, determining a set of background tasks that enter and leave the third CPU running queue, wherein the third CPU is all CPUs corresponding to the first processor core; and determining the number of background tasks based on the runtime of each background task in the set of background tasks within the preset period.

[0023] When calculating the number of background tasks, the number of background tasks can be weighted based on their runtime, making the calculated number of background tasks more reasonable and better reflecting the current load status of the background groups, so that the system can formulate a more reasonable resource allocation strategy.

[0024] In some implementations, the first frequency point is the frequency point corresponding to the optimal energy efficiency ratio of the first processor core, and the second frequency point is the frequency point corresponding to the optimal energy efficiency ratio of the second processor core.

[0025] Limiting the first frequency point to below the frequency point corresponding to the optimal energy efficiency ratio of the first processor core can ensure that the first processor core can balance processing performance and power consumption when running background tasks, which is beneficial to reducing the power consumption of the first processor core.

[0026] Limiting the second frequency point to below the frequency point corresponding to the optimal energy efficiency ratio of the second processor core can ensure that the second processor core can balance processing performance and power consumption when running background tasks, which is beneficial to reducing the power consumption of the second processor core.

[0027] In some implementations, the first processor core is a small core, and the second processor core is a medium core or a large core.

[0028] In a second aspect, an electronic device is provided, comprising a unit consisting of software and / or hardware, the unit being used to perform any one of the methods in the technical solution of the first aspect.

[0029] Thirdly, a chip is provided, including a processor; the processor is used to read and execute a computer program stored in a memory to perform any of the methods described in the first aspect.

[0030] Optionally, the chip further includes a memory, which is connected to the processor via a circuit or wire.

[0031] Optionally, the chip also includes a communication interface.

[0032] Fourthly, an electronic device is provided, comprising: a processor, a memory, and an interface; the processor, memory, and interface cooperate with each other to enable the electronic device to perform any one of the methods described in the first aspect; or to include any one of the chips described in the third aspect.

[0033] Fifthly, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, the processor performs any one of the methods described in the first aspect.

[0034] In a sixth aspect, a computer program product is provided, the computer program product comprising: computer program code, which, when executed on an electronic device, causes the electronic device to perform any one of the methods described in the first aspect. Attached Figure Description

[0035] Figure 1 This is a schematic diagram of the hardware structure of an electronic device 100 provided in an embodiment of this application;

[0036] Figure 2 This is a software system architecture diagram of the electronic device provided in the embodiments of this application;

[0037] Figure 3 This is a schematic diagram of the energy efficiency ratio curves of the large core and the small core in a CPU chip provided in an embodiment of this application;

[0038] Figure 4 This is a schematic diagram of a scenario with a small core and high load provided in an embodiment of this application;

[0039] Figure 5 This is a schematic diagram of another scenario with small cores and high load provided in an embodiment of this application;

[0040] Figure 6 This is a schematic flowchart illustrating a resource allocation method provided in an embodiment of this application;

[0041] Figure 7 This is a schematic diagram illustrating how to determine the optimal energy efficiency ratio frequency point according to an embodiment of this application;

[0042] Figure 8 This is a schematic diagram illustrating how to determine the number of background tasks according to an embodiment of this application;

[0043] Figure 9This is a software architecture diagram of an electronic device provided in an embodiment of this application;

[0044] Figure 10 This is an illustrative process for a decision center to determine the current state, provided in an embodiment of this application.

[0045] Figure 11 This is a schematic block diagram of an electronic device provided in an embodiment of this application;

[0046] Figure 12 This is a schematic diagram of the structure of a device provided in an embodiment of this application. Detailed Implementation

[0047] The solutions in this application relate to scenarios involving resource allocation in electronic devices. The electronic devices will be described first.

[0048] The electronic device in this application embodiment can be an electronic device capable of interacting with a user, such as a mobile phone, tablet computer, computer, or other electronic device.

[0049] For example, Figure 1 This is a schematic diagram of the structure of a device 100 provided in an embodiment of this application. Device 100 can be either the first device mentioned above or the second device. Device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, etc.

[0050] The mobile communication module 150 may include one or more of second-generation (2G), 3G, 4G, and 5G communication modules. The mobile communication module 150 may include one or more of a filter, a switch, a power amplifier, and a low-noise amplifier (LNA).

[0051] The wireless communication module 160 may include one or more of the following: Bluetooth (BT) module, Wireless Local Area Network (WLAN) module, Global Navigation Satellite System (GNSS) module, Near Field Communication (NFC) module, Infrared (IR) module, and Frequency Modulation (FM) module. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering on the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification on them, and then convert them into electromagnetic waves for radiation via antenna 2.

[0052] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on device 100. In other embodiments of this application, device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0053] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the device 100. In other embodiments of this application, the device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0054] The following is combined Figure 2 This application describes the software system architecture of the device (first device, such as a mobile phone) in the embodiments of this application. The software system of the device in the embodiments of this application can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment takes the layered architecture Android system as an example to illustrate the software structure of the device.

[0055] Figure 2This is a software architecture block diagram of the device according to an embodiment of this application. The layered architecture divides the software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system can be divided into four layers, from top to bottom: the application (APP) layer, the application framework layer, the native service layer, and the driver layer. The native layer can also be called the system layer.

[0056] like Figure 2 As shown, the application layer can include a series of application packages, which may include applications such as SMS, calendar, navigation, gallery, and calling.

[0057] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.

[0058] like Figure 2 As shown, the application framework layer may include a window manager, resource manager, view system, phone manager, etc.

[0059] The window manager is used to manage window applications, including managing the window hierarchy and display order. The window manager can obtain the screen size, determine if a status bar is present, lock the screen, and capture the screen, among other things.

[0060] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, etc.

[0061] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface may include the display interface for a text notification icon, and views may include views for displaying text and views for displaying images.

[0062] A phone manager is used to provide communication functions for electronic devices. For example, a phone manager can be used to manage call status (including when a call is connected, when a call is disconnected, etc.).

[0063] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0064] The system layer can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.

[0065] The Surface Manager is used to manage the display subsystem and provides the blending of two-dimensional and three-dimensional layers for multiple applications.

[0066] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.164, MP3, AAC, AMR, JPG, and PNG.

[0067] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0068] A 2D graphics engine is a drawing engine for 2D drawing.

[0069] The kernel layer is the layer between hardware and software. It contains at least display drivers and sensor drivers. The display driver drives the display screen, while the sensor driver drives the sensors.

[0070] The hardware layer includes at least physical devices such as a display screen and sensors. The sensors may include pressure sensors, gyroscopes, accelerometers, distance sensors, proximity sensors, fingerprint sensors, etc. The functions of each sensor are not described in detail in this embodiment.

[0071] To improve the performance of electronic devices, many electronic devices adopt a big.LITTLE architecture. In this architecture, the big core and the little core have different clock speeds, and for the same amount of work, the execution time of the little core is much longer than that of the big core.

[0072] Large cores typically have higher clock frequencies and more execution units, offering higher performance, but also consuming more power. Large cores are suitable for computationally intensive tasks such as gaming and video editing, or tasks that are more noticeable to the user (e.g., user interface-related tasks).

[0073] Small cores have lower clock frequencies, fewer execution units, and lower power consumption, making them suitable for handling lightweight tasks such as background tasks or web browsing.

[0074] Typically, the processor core number corresponding to the big core is higher than the processor core number corresponding to the little core. In other words, the big core is usually configured as a processor core with a later number.

[0075] For example, for an 8-core processor, if the 8-core processor includes 4 big cores and 4 small cores, then processor cores numbered 0-3 can be configured as small cores, and processor cores numbered 4-7 can be configured as big cores.

[0076] The above introduction to processor architecture uses big cores and little cores as examples. In some implementations, processors can also adopt a big-medium-little core architecture, with big cores having the highest processing power and strongest performance, medium cores having the next highest processing power and performance, and little cores having the lowest processing power and weakest performance.

[0077] For example, for an 8-core processor, if the 8 processor cores include 3 small cores, 3 medium cores and 2 large cores, then processor cores numbered 0 to 2 can be configured as small cores, processor cores numbered 3 to 5 as medium cores, and processor cores numbered 6 and 7 as large cores.

[0078] The above description is merely an example of the number of processor cores. The number of processor cores can also be other numbers, and this application does not specifically limit this number.

[0079] The central processing unit (CPU) is part of a system-on-a-chip (SoC). For example, one or more CPUs can form a cluster. An electronic device's SoC includes multiple clusters, which facilitate CPU scheduling to achieve better energy efficiency. Optionally, each cluster may include only one of the following: large cores, medium cores, and small cores.

[0080] For example, for an 8-core processor, if it includes 4 large cores and 4 small cores, then the processor can include 2 clusters: one cluster for the large cores, which can include processor cores numbered 0 to 3, and another cluster for the small cores, which can include processor cores numbered 4 to 7. Of course, a cluster can also include fewer processor cores (e.g., less than 4).

[0081] Operating systems can dynamically allocate resources between big and little cores based on task requirements to optimize the performance and power consumption of electronic devices.

[0082] Electronic devices perform a variety of tasks (such as music playback, web browsing, application execution, and phone calls). The operating system manages and schedules these tasks to ensure they are executed efficiently and systematically. The operating system typically executes tasks through processes, each of which is an independent execution environment with its own memory space and system resources.

[0083] A process is the basic unit of resource allocation in a system and the foundation of the operating system structure. A process is a memory region containing certain resources. The operating system uses processes to divide its work into functional units. One or more execution units contained within a process are called threads. A process also has a private virtual address space, which can only be accessed by its constituent threads.

[0084] A thread can only belong to one process and can only access the resources owned by that process. When the operating system creates a process, that process automatically requests a thread named the main thread or primary thread.

[0085] To facilitate process management and control, operating systems introduce the concept of process groups. A process group is a collection of one or more processes, typically derived from a single process, that share certain attributes or resources. The operating system can allocate and manage resources based on process groups; for example, it can limit the CPU time and total memory available to a process group. Process groups also make it convenient to send signals to all processes within the group; the operating system can send signals to the entire process group instead of sending signals to each individual process.

[0086] In the Android system, tasks can be divided into foreground tasks and background tasks based on whether the process is visible.

[0087] Foreground tasks refer to tasks or applications that the user is currently interacting with, such as an application displaying an interface and waiting for user input. Foreground tasks typically include foreground activities and foreground services. Because these tasks are crucial to user experience, they are given higher priority and more system resources, and the system needs to ensure resource allocation and responsiveness for these processes as much as possible.

[0088] Background tasks include those not directly visible to the user, such as downloading files and syncing data. These tasks have less impact on the user experience, so they typically receive lower resource priority than foreground tasks.

[0089] In complex computer systems, especially in multi-user, multi-tasking environments, different processes or tasks have vastly different resource requirements (such as CPU, memory, input / output, I / O). Without effective resource management, some tasks may excessively consume system resources, thus affecting the processing of other critical tasks. For example, background tasks (such as large-scale data backup tasks) may excessively consume system resources, thereby affecting the processing of foreground tasks (such as web servers responding to user-requested tasks).

[0090] Therefore, in order to allocate system resources more rationally, a resource management mechanism based on control groups (cgroups) has been introduced.

[0091] The main functions of cgroups include resource limiting, priority control, resource isolation, and resource monitoring. For resource limiting, cgroups can restrict the amount of resources a process group can use, such as CPU, memory, and disk I / O. For priority control, cgroups can set process group priorities to ensure that critical tasks receive resources first. For resource isolation, cgroups can isolate the resource usage of different process groups, preventing resource consumption by one process group from affecting other process groups. For resource monitoring, cgroups can monitor and record the resource usage of process groups, facilitating analysis and optimization.

[0092] cgroups use a hierarchical structure, managing resources by organizing nodes into a tree-like structure. Each node can be called a cgroup, with the root node being the system's initial cgroup. Each cgroup can include one or more sub-cgroups, facilitating hierarchical management of processes. A cgroup can include one or more processes (or process groups).

[0093] For example, cgroups can divide processes into different hierarchical structures and impose resource restrictions on different hierarchical structures. cgroups manage and control the behavior of processes using system resources in a grouping manner. In other words, electronic devices can use cgroups to group all processes and then allocate and control resources for the entire group. Within a cgroup, a task is considered a system process.

[0094] In the Android system, task groups (such as foreground and background tasks) correspond to resource management groups within cgroups. For example, resource management groups within cgroups can include the top-level app (ta) group, the foreground (fg) group, the system background (system-background) group, and the background (bg) group. In some implementations, the system background group and the background group can be collectively referred to as the background group; that is, resource management groups within cgroups can include the ta group, the foreground group, and the background group.

[0095] The `ta` group and the foreground group correspond to foreground tasks in the Android system. The `ta` group refers to the top-level application, containing the application the user is currently most active with—the application the user is currently interacting with. It has the highest priority among foreground tasks and enjoys the most system resource allocation permissions to ensure smooth user operation. For example, if a user has both a browser and a music player open, but is currently entering a URL in the browser to search, then the browser application belongs to the `ta` group, while the music player, although also in the foreground, does not belong to the `ta` group.

[0096] The foreground group contains processes that are interacting with the user, and the components of these processes are visible on the screen.

[0097] Background groups and system background groups correspond to background tasks in the Android system. System background groups mainly correspond to background tasks initiated by system processes or system services. These tasks are usually used to maintain the normal operation of the system and provide necessary system services.

[0098] Background groups contain background tasks initiated by user applications. These tasks are typically to perform non-real-time operations that do not directly affect user interaction.

[0099] Each cgroup can be associated with one or more subsystems. A subsystem is a module that manages a collection of processes through the tools and interfaces provided by cgroups. A subsystem can be understood as a "resource controller" used to schedule resources or control the upper limit of resource usage. Once a subsystem is attached to a certain level, all control groups at that level are controlled by that subsystem.

[0100] Typically, a subsystem provides one scheduling strategy, and a cgroup is bound to one or more subsystems. That is, a single cgroup corresponds to the scheduling strategies provided by one or more subsystems. The one or more subsystems bound to a cgroup, i.e. the one or more corresponding scheduling strategies, constitute the cgroup mechanism.

[0101] Table 1 shows several subsystems and their corresponding functions.

[0102] Table 1

[0103] Subsystem effect cpuset Bind cgroup to a specified CPU CPU Limit cgroup CPU utilization cpuacct Statistics on cgroup CPU utilization schedtune Select CPU and boost trigger

[0104] The cpuset subsystem controls the CPU and memory nodes that processes can use. It's a kernel-based resource management mechanism that allows the system's CPU and memory resources to be divided into different sets (or groups), and processes to be assigned to these specific groups. This enables finer-grained control over CPU and memory resources, improving system performance, isolation, and resource utilization.

[0105] The cpuset subsystem is used to indicate the list of CPUs bound to a cgroup. For example, suppose an electronic device has 8 CPU cores, namely cores 0 to 7 (including cores 0, 1, 2, 3, 4, 5, 6, and 7), where cores 0 to 3 are small cores, cores 4 to 6 are medium cores, and core 7 is a large core. The cpuset subsystem can be used to indicate any one or more CPU cores from cores 0 to 7.

[0106] The cpuset subsystem includes the parameter cpuset.cpus, which indicates the list of CPUs allowed for use by the cgroup. The value of cpuset.cpus can be either the processor core number or the CPU number that the cgroup is allowed to use. For example, if the cgroup is bound to the cpuset subsystem, and cpuset.cpus has values ​​of 1 and 2, it means that the cgroup is allowed to use CPU1 and CPU2. CPU1 and CPU2 can be used to schedule the cgroup's processes.

[0107] In some scenarios, the CPU involved in the embodiments of this application may also be referred to as a CPU core.

[0108] The scheduling subsystem is used to select CPUs, which can be understood as the selection of bound CPU cores. As mentioned above, CPUs can be divided into large cores, medium cores, and small cores. The scheduling subsystem can instruct cgroups to be bound to one or more of the large, medium, and small cores to schedule different cgroups with cores that have different processing capabilities.

[0109] The schedtune subsystem is a utilization-driven CPU frequency regulator. The schedtune subsystem includes the parameter schedtune.boost, which, when adjusted, can make an affected cgroup appear heavier (or lighter) than it actually is. For example, if this parameter for a cgroup is increased by 25%, the scheduler expects that process group to use 25% more CPU time than it actually does, and the CPU frequency regulator will accordingly speed up the processor.

[0110] The CPU accounting (cpuacct) subsystem can automatically generate reports to display the CPU resources used by tasks in a cgroup.

[0111] The CPU subsystem is used to limit the CPU usage of cgroups. In other words, the CPU subsystem can be understood as a controller that controls CPU time allocation. The CPU subsystem can control the CPU time slices available to all processes in a cgroup.

[0112] The CPU subsystem includes the parameter `cpu.uclamp`, which is a utilization clamp (uclamp) parameter. `uclamp` is a scheduler feature that allows user space to help manage task performance requirements. `uclamp` is a hint mechanism that allows the scheduler to understand the performance requirements and limitations of tasks, thus helping the scheduler make better decisions. When using the `schedutil cpufreq` scheduler, `uclamp` also affects the selection of CPU frequency.

[0113] Since both the scheduler and schedutil are driven by the per-entity load tracking (PELT) signal (util_avg), the util clamp achieves its goal by clamping this signal. In other words, by clamping utilization, the system can be made to run at a certain performance point.

[0114] `cpu.uclamp` can include `cpu.uclamp.max` and `cpu.uclamp.min`. `cpu.uclamp.max` is the upper limit of `uclamp`, and `cpu.uclamp.min` is the lower limit of `uclamp`. These two boundary values ​​ensure that tasks run within the system's performance range.

[0115] For example, as mentioned above, tasks can include foreground tasks, background tasks, and TA tasks. Utilization clamping can be used to limit the amount of resources consumed by background tasks. By limiting the performance points that background tasks can run, resources can be reserved for important tasks (such as foreground tasks and TA tasks).

[0116] The uClamp mechanism ensures that system resources are used more efficiently, thereby providing a better user experience.

[0117] The utilization rates involved in the embodiments of this application include CPU utilization and task utilization. CPU utilization can also be referred to as CPU load, and task utilization can also be referred to as task load.

[0118] CPU utilization refers to the degree to which the CPU is being used, reflecting how busy the CPU processor is. High CPU utilization indicates that the CPU is being occupied by a large number of tasks, while low utilization indicates that the CPU is idle or does not have enough tasks to process. Runtime also affects CPU utilization.

[0119] The kernel scheduler adjusts CPU frequency based on CPU utilization (when the schedutil governor is in effect). Task utilization indicates how much CPU a task uses, suggesting whether a task is "large" or "small." The kernel scheduler can select processor cores based on task utilization. For example, if the task is "large," a large processor core can be assigned to it or the CPU frequency can be increased; if the task is "small," a small processor core can be assigned to it or the CPU frequency can be decreased.

[0120] Task utilization is related to task runtime and the number of tasks. If a task runs for a long time or there are many tasks, the task utilization obtained using the PELT load tracing algorithm will be relatively large.

[0121] However, the task utility calculated using the PELT load tracing algorithm sometimes differs from the user space's expectations. For example, for control threads or UI threads, PELT might calculate a smaller utility, considering the task as a "small" task, while user space expects the scheduler to treat control threads or UI threads as "large" tasks so that they can be scheduled to run on high-performance cores at high frequencies, allowing the task to be processed faster and more promptly.

[0122] For example, for some long-running background tasks, such as logging, the task util calculated by PELT may be very large, and it may be considered a "big" task. However, from the perspective of user space, such tasks do not have high requirements for completion time and do not need to be regarded as "big" tasks. Running the task on a low-performance processing core at a low frequency can save system power consumption and alleviate heat generation.

[0123] Therefore, the uclamp mechanism was introduced. uclamp provides a mechanism for user space to limit task util. Through this mechanism, user space can restrict task util to the range [util_min, util_max], while cpuutil is determined by the uclamp value of the tasks in its run queue; in other words, cpuutil can be determined based on task util. For some critical tasks, setting util_min to a larger value can make the task appear as a "large" task, causing the CPU to run in a high-performance state, accelerating task processing, and improving system performance. For some background tasks, setting util_max to a smaller value can make the task appear as a "small" task, causing the CPU to run in a high-efficiency state, thus saving system power consumption.

[0124] The uclamp value ranges from 0 to 100, with a value of 100 corresponding to the highest frequency of the large core. For normalization, the capacity value corresponding to the highest frequency of the large core is 1024; that is, a capacity value of 1024 corresponds to an uclamp value of 100. Therefore, a correspondence between capacity values ​​and uclamp values ​​can be established. This correspondence can be stored in the energy efficiency model. In some scenarios, the capacity value can also be a utility value.

[0125] For background tasks, electronic devices use cgroups as a resource management mechanism to limit their resource usage. For example, in the cpuset subsystem, background tasks are typically restricted to small cores to prevent them from consuming excessive CPU resources. Similarly, in processor resource allocation strategies, for a 4+4 big.LITTLE CPU architecture, background tasks are usually limited to four or fewer small cores via the cpuset subsystem. This is to prevent background tasks from selecting large cores, impacting their power consumption, and preempting foreground resources.

[0126] However, restricting background tasks to run only on small cores can lead to power consumption losses and low system throughput in some cases. An example is provided below to illustrate this problem.

[0127] CPU frequency adjustment algorithms are typically calculated based on CPU load, which in turn is calculated from the tasks (or task load) executing on the CPU. If many tasks are executing on the CPU, the CPU frequency will gradually increase, potentially reaching the highest frequency.

[0128] In the design of CPU chips for electronic devices (such as mobile phones), the energy efficiency of small cores at high frequencies is often poor. For CPUs with a big.LITTLE architecture, small cores have low power consumption but poor performance, while large cores have high power consumption but good performance. However, typically, the energy efficiency of small cores at their highest frequencies is relatively poor, inferior to that of large cores at lower frequencies. Energy efficiency ratio refers to the ratio between power consumption and performance.

[0129] Figure 3 This diagram shows the energy efficiency curves for the large and small cores in a CPU chip. The horizontal axis represents performance, and the vertical axis represents power consumption. Figure 3 It can be seen that the energy efficiency ratio of the small core at its highest frequency (A level) is not as good as that of the large core at its lowest frequency (B level).

[0130] Based on the above description, if the small core has a heavy load, it's easy to push its frequency to the highest level. However, the small core's highest frequency has poor energy efficiency, which increases its CPU power consumption, affecting the battery life of electronic devices and thus impacting user experience. Furthermore, if the large core has a relatively small workload, and only the high-frequency small core is used to perform tasks, the system throughput will be low, and the CPU's capabilities will not be fully utilized.

[0131] The following two examples illustrate high-load scenarios for small cores.

[0132] Figure 4 This illustrates a scenario of high load on a small core. Figure 4 The small-core CPUs shown are CPU0 to CPU3, and the large-core CPUs are CPU4 to CPU7. The tasks running in CPU0 include background task 1 and background task 5, the tasks running in CPU1 include background task 2, the tasks running in CPU2 include background task 4, the tasks running in CPU3 include background task 3, the tasks running in CPU5 include foreground task 2, and the tasks running in CPU6 include foreground task 2.

[0133] If a background task is running continuously, it will increase the CPU load. Figure 4 Although the number of tasks on the small core is not large, the background task 2 on CPU1 runs for a long time, which will increase the load of CPU1 to the maximum value, thereby pulling the frequency of the small core to the maximum, resulting in high power consumption of the small core.

[0134] Figure 5 This illustrates another scenario involving small cores under high load. Figure 5The small CPU cores shown are CPU0 to CPU3, and the large CPU cores are CPU4 to CPU7. Each of CPUs 0 to CPU3 has multiple tasks waiting to run. This scenario typically occurs after a user continuously enters and exits multiple applications, causing multiple background applications to queue and execute on the small cores. At this time, the small cores have a heavy workload, easily pushing their frequency to its maximum, resulting in high power consumption. Conversely, if the large cores don't have a heavy workload, the system throughput will be low, and the CPU's capabilities will not be fully utilized.

[0135] Based on this, embodiments of this application provide a resource allocation method that can allocate appropriate processor resources to background tasks according to the number of background tasks. When the number of background tasks is small, restricting background tasks to execute only on small cores and limiting the frequency of small cores can prevent the frequency of small cores from being driven to the maximum, causing high system power consumption. When there are many background tasks, the small core restriction for background tasks is removed, and large cores are used to process background tasks, while limiting the frequency of large cores can improve system throughput and prevent background tasks from preempting foreground resources.

[0136] The following is combined Figure 6 The resource allocation method provided in the embodiments of this application will be described in detail.

[0137] Figure 6 The resource allocation method shown can be applied to electronic devices. These electronic devices can be multi-core processors. The multi-core processor can include large-core processors and small-core processors, or it can include large-core processors, medium-core processors, and small-core processors.

[0138] This application does not limit the number of processor cores included in the electronic device. For example, the electronic device may include 8 processor cores, 6 processor cores, or 4 processor cores, etc.

[0139] Each processor core can correspond to one or more CPUs. For example, an 8-core processor may include four small CPU cores and four large CPU cores. The number of CPUs corresponding to each processor core can be determined by the manufacturer, and this application does not specifically limit this. For example, the number of small CPU cores can be three, and the number of large CPU cores can be five.

[0140] See Figure 6 In step S610, the number of background tasks is determined.

[0141] The number of background tasks can be the number of background tasks to be executed at a certain moment, or it can be the number of background tasks counted over a period of time.

[0142] In some implementations, the number of background tasks can be determined based on the background tasks entering and leaving the CPU run queue.

[0143] In some implementations, in order to determine the number of background tasks more reasonably so that the system can make a more reasonable resource allocation strategy, it can be based on the number of background tasks entering and leaving the CPU run queue, as well as the runtime of each background task within a preset time.

[0144] The following section will provide a detailed explanation of how the number of background tasks is determined.

[0145] In step S620, if the number of background tasks is less than or equal to the first threshold, then the first CPU and the first frequency point available to the background group are allocated to the background group. This resource allocation strategy will also be referred to as the first allocation strategy below.

[0146] The first CPU includes only the CPU corresponding to the first processor core. The first CPU can be some or all of the CPUs corresponding to the first processor core. In other words, if the number of background tasks is less than or equal to the first threshold, the system can allocate all or part of the CPU resources of the small core to the background groups.

[0147] Background tasks run preferentially on the first processor core, which can be a little core, meaning background tasks run preferentially on the little core. The first CPU can refer to some or all of the little cores in the processor.

[0148] For example, assuming that the CPUs corresponding to the first processor core include CPU0 to CPU4, then the first CPU can be any one or more CPUs from CPU0 to CPU4.

[0149] In some implementations, if the number of background tasks is less than or equal to a first threshold, the system can also allocate an available first frequency point to the background group. The first frequency point can refer to the highest frequency point that the first processor core can use when running background tasks. That is, when the first processor core only runs background tasks, the first processor core can only run background tasks at or below the first frequency point.

[0150] The first frequency point is lower than the highest frequency point of the first processor core. By limiting the frequency points available to the background group, it is possible to avoid the problem of the first processor core's frequency point being pulled up to the highest when running background tasks, causing the first processor core to work on a frequency point with poor energy efficiency and resulting in excessive power consumption.

[0151] Taking the first processor core as a small core as an example, when the number of background tasks is small, the background tasks can be restricted to run only in the small core. Furthermore, when the small core is running background tasks, the frequency of the small core will not be increased above the first frequency due to the background tasks, which helps to reduce the power consumption of the small core.

[0152] In some implementations, the first frequency point can be less than or equal to the frequency point corresponding to the optimal energy efficiency ratio of the first processor core. Figure 7 Taking the small core as an example, if level A is the frequency point corresponding to the optimal energy efficiency ratio, then the first frequency point can be the frequency point corresponding to level C. The power consumption of frequency points below level C is low. Running background tasks at frequency points below level C can avoid excessive power consumption of the first processor core.

[0153] The frequency point corresponding to the optimal energy efficiency ratio of the first processor core can be the frequency point with the smallest energy efficiency ratio among all the frequency points of the first processor core.

[0154] In step S630, if the number of background tasks exceeds the second threshold, a second CPU and a second frequency point available to the background group are allocated to the background group. This resource allocation strategy will also be referred to as the second allocation strategy below.

[0155] The second CPU can include the CPU corresponding to the second processor core. In other words, when there are many background tasks, the higher-performance second processor core can be used to run the background tasks to improve the system throughput.

[0156] The second CPU only includes a portion of the CPUs corresponding to the second processor core. This prevents background tasks from occupying all the resources of the second processor core, affecting the execution of other more important tasks (such as foreground tasks), and prevents background tasks from preempting foreground resources.

[0157] For example, assuming the CPU corresponding to the second processor core includes CPU5 to CPU7, then the second CPU can be any one or more CPUs from CPU5 to CPU7.

[0158] The second processor core has a higher processing power than the first processor core, or in other words, the second processor core performs better than the first processor core. For example, the first processor core is a small core, and the second processor core is a medium or large core.

[0159] In some implementations, the second CPU may include not only the CPU corresponding to the second processor core, but also the CPU corresponding to the first processor core, so that background tasks can run simultaneously on the first and second processor cores.

[0160] For example, suppose the CPU corresponding to the first processor core includes CPU0 to CPU4, and the CPU corresponding to the second processor core includes CPU5 to CPU7. The second CPU may include some or all of the CPUs from CPU0 to CPU4, as well as some of the CPUs from CPU5 to CPU7.

[0161] In some implementations, if the number of background tasks exceeds a second threshold, the system can also allocate a second available frequency point to the background group. The second frequency point can refer to the highest frequency point that the second processor core can use when running background tasks; that is, when the second processor core only runs background tasks, it can only run background tasks at or below the second frequency point.

[0162] The second frequency point is lower than the highest frequency point of the second processor core. By limiting the frequency points available to the background group, it is possible to avoid raising the frequency point of the second processor core to the highest level when running background tasks, which would affect the execution of other more important tasks (such as foreground tasks) and prevent background tasks from preempting foreground resources.

[0163] In some implementations, the second frequency can be less than or equal to the frequency corresponding to the optimal energy efficiency ratio of the second processor core. Figure 7 Taking the large core as an example, if level D is the frequency point corresponding to the optimal energy efficiency ratio, then the second frequency point can be the frequency point corresponding to level D. The power consumption of frequencies below level D is low, and the second processor core can run background tasks at frequencies below level D, which can avoid excessive power consumption of the second processor core.

[0164] The frequency point corresponding to the optimal energy efficiency ratio of the second processor core can be the frequency point with the smallest energy efficiency ratio among all the frequency points of the second processor core.

[0165] This application embodiment can allocate appropriate processor resources to background tasks based on the number of background tasks. If the number of background tasks is less than or equal to a first threshold, i.e., the number of background tasks is relatively small, resources can be allocated only to the first processor core for the background tasks. This allows the background tasks to run only on the lower-performance first processor core, and restricts the first processor core from running background tasks at its highest frequency (i.e., at or below the first frequency). This prevents the background tasks from pushing the first processor core's frequency to its maximum. Therefore, the solution in this application embodiment is beneficial for reducing the power consumption of the first processor core.

[0166] If the number of background tasks is less than or equal to a first threshold, meaning there are many background tasks, running them only on the first processor core will affect the system throughput. In this case, embodiments of this application can allocate higher-performance second processor core resources to the background tasks, allowing them to run on the second processor core, thereby improving system throughput. Secondly, when the second processor core runs background tasks, it can run the tasks only on a portion of the CPU's CPU, preventing background tasks from consuming all CPU resources and affecting the execution of other higher-priority tasks. Furthermore, when the second processor core runs background tasks, it can run them at or below the highest frequency point (i.e., the second frequency point or below), thereby reducing the power consumption of the second processor core.

[0167] The first threshold can be less than or equal to the second threshold. In some implementations, the first threshold can be equal to the second threshold. In other implementations, the second threshold can be greater than the first threshold.

[0168] Setting the second threshold to be greater than the first threshold can reduce the frequency of system adjustments to the allocation strategy, thus reducing system complexity. For example, if the number of background tasks is less than or equal to the first threshold, the system executes the first allocation strategy. If the number of background tasks is greater than the first threshold but less than the second threshold, the system can continue to execute the first allocation strategy without switching to the second allocation strategy. The system will only execute the second allocation strategy when the number of background tasks exceeds the second threshold, thereby reducing the frequency of system adjustments to the allocation strategy.

[0169] This application does not specifically limit the values ​​of the first threshold and the second threshold. In some implementations, the first threshold may be less than or equal to the number of CPUs available to the background group. The number of CPUs available to the background group may be determined based on the `cpuset.cpus` parameter. Assuming the number of CPUs available to the background group is 4, the first threshold may be less than or equal to 4.

[0170] In some implementations, the second threshold can be greater than or equal to the number of CPUs available to the background group. The second threshold can be equal to the number of CPUs available to the background group plus a given threshold. For example, if the number of CPUs available to the background group is 4, then the second threshold can be greater than or equal to 4.

[0171] In some implementations, embodiments of this application can first determine the load status of a background group based on the number of background tasks, and then determine a resource allocation strategy based on the load status of the background group. The determination of the number of background tasks and the load status of the background group can be performed at the kernel layer, while the determination of the resource allocation strategy can be performed at the system layer. Through this approach, the system layer can directly determine the resource allocation strategy based on the load status of the background group, thereby reducing the complexity of determining the resource allocation strategy at the system layer. Examples of two resource allocation strategies are given below.

[0172] If the number of background tasks is less than or equal to a first threshold, the load state of the background group is marked as the first state. In response to the background group's load state being in the first state, a first CPU and a first frequency point available to the background group are allocated to the background group. The first state can also be referred to as the background light load state.

[0173] If the number of background tasks exceeds the second threshold, the load state of the background group is marked as the second state. In response to the background group's load state being marked as the second state, a second CPU and a second frequency point available to the background group are allocated to the background group. The second state can also be referred to as the background heavy load state.

[0174] The resource management mechanism used by electronic devices can be any mechanism, as long as it can implement the above-mentioned resource allocation strategy.

[0175] In some implementations, electronic devices employ resource management mechanisms that prioritize allocating small core resources to background tasks. For example, electronic devices may use a cgroup-based resource management mechanism, which typically restricts background tasks to execution within small cores. Of course, in addition to background tasks, small cores can also execute other tasks, such as foreground tasks; that is, small cores can execute both foreground and background tasks simultaneously.

[0176] The resource management subsystems supported by cgroups can include the cpuset subsystem and the CPU subsystem. As mentioned earlier, the cpuset subsystem can be used to limit the CPU available to a resource management group (cgroup), and the CPU subsystem can be used to limit the frequency points available to that group. Therefore, by setting parameters in the cpuset and CPU subsystems, the system can configure the CPU and frequency points available to background groups, thereby managing these resources and reducing the complexity of system operations. An example is provided below.

[0177] If the load status of the background group is in the first state, the system can configure the first parameter in the cpuset subsystem to the first value, and configure the maximum value of the utilization clamping parameter in the CPU subsystem to the second value.

[0178] The first parameter can be `cpuset.cpus`, which indicates the list of CPUs allowed for background tasks. To restrict background tasks to using only the resources of the first processor core, the first value can include only the CPU IDs corresponding to the first processor core. The first value can include the IDs of all CPUs corresponding to the first processor core, or it can include the IDs of some CPUs corresponding to the first processor core. In other words, the number of first values ​​can be less than or equal to the number of CPUs in the first processor core.

[0179] For example, suppose an electronic device has an 8-core processor, consisting of 4 small cores and 4 large cores. The small cores are numbered 0-3, and the large cores are numbered 4-7. The first value can be 0, 1, 2, or 3, or a subset of these values. For instance, the first value can be any three of 0, 1, 2, or 3, such as 1, 2, 3, 0, 1, 2, or 0, 1, 3. Similarly, the first value can be any two of 0, 1, 2, or 3, such as 0, 1, 2, 0, 3, 1, 2, 1, 3, or 2, 3. Of course, the first value can also be any one of 0, 1, 2, or 3, but for simplicity, this will not be elaborated upon here.

[0180] It should be noted that the CPU number mentioned above can also be understood as the processor core number.

[0181] The maximum value of the utilization clamping parameter is cpu.uclamp.max mentioned above. cpu.uclamp.max is used to limit the maximum frequency that background packets can use. The second value is determined based on the first frequency. By determining the second value based on the first frequency, the maximum frequency that background packets can use is the first frequency. That is, the maximum frequency that background packets can use is less than the maximum frequency of the first processor core, thereby reducing the power consumption of the first processor core.

[0182] In some implementations, the first frequency point is equal to the frequency point corresponding to the optimal energy efficiency ratio of the first processor core. Correspondingly, the second value can be determined based on the frequency point corresponding to the optimal energy efficiency ratio. For ease of description, the frequency point corresponding to the optimal energy efficiency ratio will be referred to as the optimal frequency point below.

[0183] For example, by querying an energy efficiency model, the capacity value corresponding to the optimal frequency point can be determined. This energy efficiency model includes the correspondence between frequency points and capacity values. Dividing the capacity value by 1024 and then multiplying it by 100 yields the second value, i.e., second value = capacity value * 100 / 1024.

[0184] If the load status of the background group is in the second state, the system can configure the first parameter in the cpuset subsystem to the third value, and configure the maximum value of the utilization clamping parameter in the CPU subsystem to the fourth value.

[0185] The first parameter can be `cpuset.cpus`, which indicates the list of CPUs allowed for background tasks. To allow background tasks to use better processor resources (i.e., second processor core resources), the third value can include the CPU IDs corresponding to the second processor cores. To prevent background tasks from consuming all the second processor core resources and affecting the processing of other tasks, the third value can include only the CPU IDs corresponding to a portion of the second processor cores.

[0186] For example, suppose an electronic device has an 8-core processor, consisting of 4 small cores and 4 large cores. The small cores are numbered 0-3, and the large cores are numbered 4-7. Then, the third value can include some values ​​from 4, 5, 6, and 7. For instance, the third value can include any three values ​​from 4, 5, 6, and 7, such as 4, 5, and 6; or 5, 6, and 7; or 4, 6, and 7; or 4, 5, and 7. Alternatively, the third value can include any two values ​​from 4, 5, 6, and 7, such as 4 and 5; or 4 and 6; or 4 and 7; or 5 and 6; or 5 and 7; or 6 and 7. Of course, the third value can also include any one value from 4, 5, 6, and 7, but for simplicity, this will not be elaborated upon here.

[0187] If the load status of the background group is in the second state, the background task can use the resources of both the second and first processor cores. Correspondingly, the third value may also include the numbers of some or all of the CPUs corresponding to the first processor core. For example, the third value may also include the first value mentioned above.

[0188] It should be noted that the CPU number mentioned above can also be understood as the processor core number.

[0189] The maximum value of the utilization clamping parameter is cpu.uclamp.max mentioned above. cpu.uclamp.max is used to limit the maximum frequency that background packets can use. The fourth value is determined based on the second frequency. By determining the fourth value based on the second frequency, the maximum frequency that background packets can use is the second frequency, that is, the maximum frequency that background packets can use is less than the maximum frequency of the second processor core, thereby reducing the power consumption of the second processor core.

[0190] In some implementations, the second frequency point is equal to the frequency point corresponding to the optimal energy efficiency ratio of the second processor core. Correspondingly, the fourth value can be determined based on the frequency point corresponding to the optimal energy efficiency ratio. For ease of description, the frequency point corresponding to the optimal energy efficiency ratio will be referred to as the optimal frequency point below.

[0191] For example, by querying an energy efficiency model, the capacity value corresponding to the optimal frequency point can be determined. This energy efficiency model includes the correspondence between frequency points and capacity values. Dividing the capacity value by 1024 and then multiplying it by 100 yields the fourth value, i.e., fourth value = capacity value * 100 / 1024.

[0192] The following section explains how to determine the number of background tasks.

[0193] In some implementations, the set of background tasks entering and leaving the third CPU's execution queue can be determined within a preset period. The third CPU refers to all CPUs corresponding to the first processor core, or in other words, the third CPU refers to the CPUs capable of running background tasks.

[0194] After obtaining the set of background tasks, the number of background tasks can be determined based on the runtime of each background task within a preset period. In this embodiment, the number of background tasks may refer to a weighted number of background tasks. Weighting can refer to weighting the number of background tasks using runtime.

[0195] Figure 8 This illustrates the enqueueing and dequeueing of background tasks within a preset period.

[0196] by Figure 8 For example, at time 0, the CPU run queue contains 1 background task; at time 1, a new background task is added, and the CPU run queue contains 2 background tasks; at time 2, a background task leaves the run queue, and the CPU run queue contains 1 background task; at time 3, another new background task is added, and the CPU run queue contains 2 background tasks; at time 4, a background task leaves the run queue, and the CPU run queue contains 1 background task.

[0197] When calculating the number of background tasks within this preset period, it can be determined based on the runtime of each background task. Figure 8 For example, the runtime of a background task = 1*duration + 2*duration + 1*duration + 2*duration + 1*duration. If duration = 1ms, then the number of background tasks is 7.

[0198] The length of the preset period can be determined according to actual needs. For example, the length of the preset period can be 1 second, or 2 seconds, etc.

[0199] Since background tasks are enqueued and dequeued frequently, such as every 1ms or less, the background tasks in the run queue will change. If statistics are performed every time a background task changes to determine the resource allocation strategy, it will undoubtedly increase the computational complexity of the system. Therefore, this application embodiment determines the resource allocation strategy by counting the number of background tasks within a preset period, which can reduce the computational complexity of the system and also help save system power consumption.

[0200] The following describes how to determine the load status of backend groups.

[0201] In some implementations, the load status of a background group can be determined based on the number of background tasks within a preset period. If the number of background tasks within the preset period is less than or equal to a first threshold, the load status of the background group is marked as the first state. If the number of background tasks within the preset period is greater than a second threshold, the load status of the background group is marked as the second state.

[0202] To ensure that the determined load status of background groups is more reasonable and accurate, and truly reflects the load status of background groups, the load status of background groups can be determined based on the number of background tasks within multiple preset periods. For example, the load status of background groups can be determined based on the number of background tasks within several consecutive preset periods.

[0203] If the number of background tasks is less than or equal to a first threshold for several consecutive preset periods, the load status of the background group is marked as the first state. If the number of background tasks is greater than a second threshold for several consecutive preset periods, the load status of the background group is marked as the second state.

[0204] Based on the solution of the embodiments of this application, it is possible to... Figure 4 The load status of the background group shown is determined to be the first state, and the background tasks are restricted to run below the first frequency point of the first processor core. This can prevent the background tasks from raising the frequency point of the first processor core to the first frequency point, which is beneficial to reducing the power consumption of the first processor core.

[0205] Based on the solution of the embodiments of this application, it is possible to... Figure 5 The background group's load status is determined to be in the second state, allowing resources from the second processor core to be allocated to background tasks. This enables background tasks to execute simultaneously on both the first and second processor cores, improving system throughput. Furthermore, the execution of background tasks on the second processor core can be restricted to below the second frequency point, preventing background tasks from consuming all the resources of the second processor core and affecting the execution of other higher-priority tasks.

[0206] The software architecture diagram of this application embodiment is as follows: Figure 9 As shown. The software modules involved in this application embodiment mainly include a monitoring module, a decision center, and an execution center. The monitoring module and the decision center are located at the kernel layer, and the execution center is located at the system layer.

[0207] The monitoring module can be used to monitor the number of background tasks in the current system. It can monitor the enqueueing and dequeueing of background tasks on the CPU run queue and calculate the number of background tasks on the CPU using a weighted algorithm.

[0208] The monitoring module can send the number of background tasks to the decision center, which can then determine the load status of the background groups based on the number of background tasks.

[0209] The decision-making center can set a preset cycle, and make a decision once in each cycle.

[0210] When the number N of background tasks obtained from the monitoring module is less than or equal to the first threshold, the decision center marks the current state as the background light load (BG-LOW) state, which corresponds to the first state mentioned above.

[0211] When the number N of background tasks obtained from the monitoring module is greater than the second threshold, the decision center marks the current state as the background light load (BG-HIGH) state, which corresponds to the second state mentioned above.

[0212] At the end of each cycle, the decision center transmits the current state to the execution center, which then executes the scheduling and frequency adjustment strategies corresponding to the current state.

[0213] Figure 10 This illustrates a schematic process for a decision center to determine the current state.

[0214] In step S1010, the decision center determines the tasks that enter and leave the CPU run queue.

[0215] In step S1020, the decision center determines whether the task is a background task. If the task is not a background task, it returns to step S1010 and continues to monitor tasks entering and leaving the CPU run queue. If the task is a background task, it continues to execute step S1030.

[0216] In step S1030, the decision center updates the cumulative execution time of the background tasks.

[0217] In step S1040, the decision center performs periodic calculations to calculate the weighted values ​​of background tasks within the current period.

[0218] In step S1050, the decision center determines the load status of the background group based on the weighted value of the background tasks.

[0219] In step S1060, the decision center transmits the load status of the background group to the execution center.

[0220] After the load status of the background group is transmitted to the execution center, the decision center can repeat the above steps to continue calculating the load status of the background group in the next cycle.

[0221] Based on the current CPU architecture, the execution center stores the optimal energy efficiency frequency points for the scheduling domains with the lowest and second lowest performance. Taking common big.LITTLE and big.mcd architectures as examples, for big.LITTLE architectures, the execution center stores an optimal energy efficiency frequency point for the small core and an optimal energy efficiency frequency point for the big core; for big.mcd architectures, the execution center stores an optimal energy efficiency frequency point for the small core and an optimal energy efficiency frequency point for the medium core.

[0222] The optimal energy efficiency ratio frequency can be selected by engineers by calculating the energy efficiency ratio data for each frequency point and then using a curve to determine the optimal frequency based on actual conditions. (See also...) Figure 7 Point C is the optimal energy efficiency frequency for the small core, and point D is the optimal energy efficiency frequency for the large core.

[0223] The execution center can execute the following strategies. When the status is BG-LOW, based on cpuset group control, the execution center configures an available CPU value X1 for the background group. The number of X1 values ​​is usually less than or equal to the number of CPUs in the small core. Based on cpuctl group control, the execution center configures an available uclamp max value Y1 for the background group. Y1 is calculated based on the optimal frequency of the small core. The execution center can obtain the performance value of the optimal frequency of the small core by querying the energy efficiency model, and then divide this performance value by 1024 and multiply by 100 to obtain Y1.

[0224] When the status is BG-HIGH, based on cpuset group control, the execution center configures an available CPU value X2 for the background group. The number of X2 values ​​is usually greater than the number of small cores and less than the number of CPUs in the next cluster's scheduling domain (large cores in a big-small core architecture or medium cores in a big-medium-small core architecture). Based on cpuctl group control, the execution center configures an available uclamp max value Y2 for the background group. Y2 is calculated based on the optimal frequency of the next cluster's scheduling domain. The execution center can obtain the performance value of the optimal frequency of the next cluster's scheduling domain by querying the energy efficiency model, and then divide this performance value by 1024 and multiply by 100 to obtain Y2.

[0225] Simply restricting background tasks to run only on small cores can lead to power consumption loss and low system throughput in some cases. The embodiments of this application can determine the background load status based on the number of background tasks in real time, and dynamically manage the resource usage of background tasks, thereby maximizing the optimization of power consumption and system throughput.

[0226] The above description divides the number of background tasks into two tiers. This application is not limited to this; it can also divide background tasks into three tiers, as illustrated below. Where there is no conflict, the content described below can be used in conjunction with the content described above.

[0227] If the number of background tasks is less than or equal to the first threshold, then a first CPU and a first frequency point available to the background group are allocated to the background group. The first CPU only includes the CPU corresponding to the first processor core, the first frequency point is lower than the highest frequency point of the first processor core, and the first processor core is a small core.

[0228] If the number of background tasks is less than or equal to the first threshold, the load status of the background group can be marked as the first state.

[0229] If the number of background tasks is greater than the second threshold but less than the third threshold, a second CPU and a second frequency point available to the background group are allocated. The second CPU includes the CPU corresponding to the second processor core, but does not include the CPU corresponding to the third processor core. The second frequency point is lower than the highest frequency point of the second processor core, and the second processor core is a medium core.

[0230] If the number of background tasks is less than or equal to the first threshold, the load status of the background group can be marked as the second state.

[0231] The second CPU may include a portion of the CPU corresponding to the second processor core. Alternatively, the second CPU may include part or all of the CPU corresponding to the first processor core, allowing background tasks to run simultaneously on both the small and medium cores.

[0232] If the number of background tasks exceeds the second threshold but is less than the third threshold, background tasks can be restricted to running only on small and / or medium cores, and not on large cores. This avoids consuming large core resources and affecting the execution of other higher-priority tasks. Secondly, when background tasks are executed on medium cores, the number of medium CPUs that can be used can be limited, preventing the use of all medium CPUs and ensuring the rapid execution of other higher-priority tasks. Additionally, when medium CPUs are running background tasks, they can run at frequencies below the second threshold, thereby reducing the power consumption of the medium cores.

[0233] If the number of background tasks exceeds the fourth threshold, a fourth CPU and a third frequency point available to the background group will be allocated. The fourth CPU includes the CPU corresponding to the third processor core, and the third frequency point is lower than the highest frequency point of the third processor core, which is a large core.

[0234] If the number of background tasks exceeds the fourth threshold, the load status of the background group can be marked as the third state.

[0235] The fourth CPU may include a portion of the CPU corresponding to the third processor core. Of course, the fourth CPU may also include a portion or all of the CPU corresponding to the first processor core, as well as a portion or all of the CPU corresponding to the second processor core, so that background tasks can run simultaneously on the small core, medium core, and large core.

[0236] The third threshold is less than or equal to the total number of CPUs corresponding to the first and second processor cores. For example, if there are 2 small CPUs and 3 medium CPUs, then the third threshold is less than or equal to 5.

[0237] The fourth threshold can be greater than or equal to the third threshold. For example, the fourth threshold can be greater than or equal to the total number of CPUs corresponding to the first and second processor cores.

[0238] If the number of background tasks exceeds the fourth threshold, large cores can be used to run these tasks, thereby improving system throughput. Secondly, when background tasks are executed on large cores, the number of large CPU cores that can be used can be limited, preventing the occupancy of all large CPU cores and ensuring the rapid execution of other higher-priority tasks. Additionally, when large CPU cores are running background tasks, they can be run at frequencies below the third frequency, thus reducing the power consumption of the large cores.

[0239] By dividing background tasks into three tiers and allocating corresponding resources to each tier, and dynamically allocating resources to background tasks based on changes in the background task situation, more flexible resource allocation can be achieved.

[0240] The foregoing has detailed examples of the methods provided in this application. It is understood that the corresponding apparatus, in order to achieve the above functions, includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0241] This application can divide the resource allocation device into functional modules based on the above method example. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.

[0242] The resource allocation device in the embodiments of this application can be an electronic device, or the resource allocation device can be a chip or the like used to implement the above method.

[0243] The following is combined Figure 11 and Figure 12 The following describes the device embodiments of this application. It should be noted that the device embodiments correspond to the method embodiments, and any content not described in detail can be found in the method embodiments.

[0244] Figure 11 This is a schematic block diagram of an electronic device provided in an embodiment of this application. The electronic device 1100 includes a monitoring module 1110, a decision center 1120, and an execution center 1130.

[0245] The monitoring module 1110 is used to determine the number of background tasks.

[0246] Execution center 1130 is configured to allocate a first CPU and a first frequency point available to the background group if the number of background tasks is less than or equal to a first threshold, wherein the first CPU includes only the CPU corresponding to the first processor core and the first frequency point is lower than the highest frequency point of the first processor core; and to allocate a second CPU and a second frequency point available to the background group if the number of background tasks is greater than a second threshold, wherein the second CPU includes the CPU corresponding to the second processor core and the second frequency point is lower than the highest frequency point of the second processor core; wherein the first threshold is less than or equal to the second threshold and the processing power of the second processor core is higher than the processing power of the first processor core.

[0247] In some implementations, the decision center 1120 is configured to: mark the load state of the background group as a first state if the number of background tasks is less than or equal to a first threshold. The execution center 1130 is configured to: allocate the first CPU and a first frequency point available to the background group to the background group in response to the background group's load state being in the first state.

[0248] In some implementations, the electronic device employs a resource management mechanism based on a control group. The resource management mechanism supports a resource management subsystem including a CPU setting subsystem and a CPU subsystem. The execution center 1130 is configured to: in response to the background group's load state being a first state, configure a first parameter in the CPU setting subsystem to a first value, and configure the maximum value of the utilization clamping parameter in the CPU subsystem to a second value; wherein the first parameter is used to indicate the list of CPUs allowed for use by the background group, the first value only includes the CPU number corresponding to the first processor core, and the second value is determined based on the first frequency point.

[0249] In some implementations, the decision center 1120 is used to: mark the load state of the background group as the first state if the number of background tasks is less than or equal to the first threshold in multiple consecutive preset periods.

[0250] In some implementations, the decision center 1120 is used to: mark the load state of the background group as a second state if the number of background tasks is greater than a second threshold; the execution center 1130 is used to: allocate a second CPU and a second frequency point available to the background group in response to the load state of the background group being in the second state.

[0251] In some implementations, the electronic device employs a resource management mechanism based on a control group. The resource management mechanism supports a resource management subsystem including a CPU setting subsystem and a CPU subsystem. The execution center 1130 is configured to: in response to the background group's load state being a second state, configure a first parameter in the CPU setting subsystem to a third value, and configure the maximum value of the utilization clamping parameter in the CPU subsystem to a fourth value; wherein the first parameter is used to indicate the list of CPUs allowed for use by the background group, the third value includes the CPU number corresponding to the second processor core, and the fourth value is determined based on the second frequency point.

[0252] In some implementations, the decision center 1120 is used to: mark the load status of the background group as the second status if the number of background tasks is greater than the second threshold in multiple consecutive preset periods.

[0253] In some implementations, the first threshold is less than or equal to a first quantity, and the second threshold is greater than or equal to the first quantity, where the first quantity is the number of CPUs currently allocated to the background group.

[0254] In some implementations, the monitoring module 1110 is used to: determine the set of background tasks that enter and leave the third CPU running queue within a preset period, wherein the third CPU is all CPUs corresponding to the first processor core; and determine the number of background tasks based on the running time of each background task in the set of background tasks within the preset period.

[0255] In some implementations, the first frequency point is the frequency point corresponding to the optimal energy efficiency ratio of the first processor core, and the second frequency point is the frequency point corresponding to the optimal energy efficiency ratio of the second processor core.

[0256] In some implementations, the first processor core is a small core, and the second processor core is a medium core or a large core.

[0257] Figure 12 This is a schematic structural diagram of the device according to an embodiment of this application. Figure 12 The dashed lines indicate that the unit or module is optional. The device 1200 can be used to implement the methods described in the above method embodiments. The device 1200 can be a chip or an electronic device.

[0258] Apparatus 1200 may include one or more processors 1210. The processor 1210 may support apparatus 1200 in implementing the methods described in the preceding method embodiments. The processor 1210 may be a general-purpose processor or a special-purpose processor. For example, the processor may be a central processing unit (CPU). Alternatively, the processor may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.

[0259] The apparatus 1200 may further include one or more memories 1220. The memories 1220 store a program that can be executed by the processor 1210, causing the processor 1210 to perform the methods described in the preceding method embodiments. The memories 1220 may be independent of the processor 1210 or integrated within the processor 1210.

[0260] The device 1200 may also include a transceiver 1230. The processor 1210 can communicate with other devices or chips via the transceiver 1230. For example, the processor 1210 can send and receive data with other devices or chips via the transceiver 1230.

[0261] This application also provides a chip including a processor, which is used to read and execute a computer program stored in a memory to perform the resource allocation method described in any of the above embodiments.

[0262] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to perform the resource allocation described in any of the above embodiments.

[0263] This application also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the resource allocation method described in the above embodiments.

[0264] In this embodiment, the electronic device, computer-readable storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding methods provided above, and will not be repeated here.

[0265] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between devices or units. The replaced units may or may not be physically separate. The component shown as a unit may be one physical unit or multiple physical units, that is, it may be located in one place or distributed in multiple different places. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0266] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0267] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0268] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0269] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A resource allocation method, characterized in that, The method is applied to electronic devices, including: Determine the number of background tasks; If the number of background tasks is less than or equal to the first threshold, then a first CPU and a first frequency point available to the background group are allocated to the background group. The first CPU only includes the CPU corresponding to the first processor core, and the first frequency point is lower than the highest frequency point of the first processor core. If the number of background tasks is greater than the second threshold, then a second CPU and a second frequency point available to the background group are allocated to the background group. The second CPU includes the CPU corresponding to the second processor core, and the second frequency point is lower than the highest frequency point of the second processor core. Wherein, the first threshold is less than or equal to the second threshold, and the processing power of the second processor core is higher than that of the first processor core.

2. The method according to claim 1, characterized in that, The step of allocating a first CPU and a first frequency point available to the background group if the number of background tasks is less than or equal to a first threshold includes: If the number of background tasks is less than or equal to a first threshold, then the load status of the background group is marked as the first state; In response to the background group's load state being in the first state, the first CPU and the first frequency point available to the background group are allocated to the background group.

3. The method according to claim 2, characterized in that, The electronic device employs a control group-based resource management mechanism, which supports resource management subsystems including a CPU setting subsystem and a CPU subsystem. The step of responding to the background packet's load state being a first state by allocating the first CPU and a first frequency point available to the background packet includes: In response to the background group's load state being a first state, the first parameter in the CPU setting subsystem is configured to a first value, and the maximum value of the utilization clamping parameter in the CPU subsystem is configured to a second value. The first parameter is used to indicate the list of CPUs that the background group is allowed to use. The first value includes only the CPU number corresponding to the first processor core, and the second value is determined based on the first frequency point.

4. The method according to claim 2 or 3, characterized in that, The step of marking the load status of the background group as the first state if the number of background tasks is less than or equal to the first threshold includes: If the number of background tasks is less than or equal to the first threshold in multiple consecutive preset periods, the load status of the background group is marked as the first status.

5. The method according to any one of claims 1-4, characterized in that, The step of allocating a second CPU and a second frequency point available to the background group if the number of background tasks is greater than the second threshold includes: If the number of background tasks is greater than the second threshold, then the load status of the background group is marked as the second state; In response to the background packet's load state being in the second state, the second CPU and the second frequency point available to the background packet are allocated to the background packet.

6. The method according to claim 5, characterized in that, The electronic device employs a control group-based resource management mechanism, which supports resource management subsystems including a CPU setting subsystem and a CPU subsystem. The response to the background packet's load state being in a second state, allocating the second CPU and the second frequency point available to the background packet to the background packet, includes: In response to the background group's load state being in the second state, the first parameter in the CPU setting subsystem is configured to a third value, and the maximum value of the utilization clamping parameter in the CPU subsystem is configured to a fourth value. The first parameter is used to indicate the list of CPUs that the background group is allowed to use, the third value includes the number of the CPU corresponding to the second processor core, and the fourth value is determined based on the second frequency point.

7. The method according to claim 5 or 6, characterized in that, The step of marking the load status of the background group as the second state if the number of background tasks is greater than the second threshold includes: If the number of background tasks exceeds the second threshold in multiple consecutive preset periods, the load status of the background group is marked as the second status.

8. The method according to any one of claims 1-7, characterized in that, The first threshold is less than or equal to the first quantity, and the second threshold is greater than or equal to the first quantity, wherein the first quantity is the number of CPUs currently allocated to the background group.

9. The method according to any one of claims 1-8, characterized in that, Determining the number of background tasks includes: Within a preset period, a set of background tasks that enter and leave the third CPU running queue is determined, wherein the third CPU is all CPUs corresponding to the first processor core; The number of background tasks is determined based on the runtime of each background task in the set of background tasks within the preset period.

10. The method according to any one of claims 1-9, characterized in that, The first frequency point is the frequency point corresponding to the optimal energy efficiency ratio of the first processor core, and the second frequency point is the frequency point corresponding to the optimal energy efficiency ratio of the second processor core.

11. The method according to any one of claims 1-10, characterized in that, The first processor core is a small core, and the second processor core is a medium core or a large core.

12. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program executable on the processor, the processor executing the computer program to implement the method as described in any one of claims 1 to 11.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform the method as described in any one of claims 1 to 11.

14. A computer program product, characterized in that, Includes a program that causes a computer to perform the method as described in any one of claims 1-11.