Resource scheduling method, device and electronic equipment
By dynamically allocating target resource partitions to processes in smart terminal electronic devices, the problem of reduced hit rate caused by cache resource competition is solved, and system performance and user experience are improved.
Patent Information
- Application Number
- CN202411803238.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2044-12-09
AI Technical Summary
In smart terminal electronic devices, different types of application processes are prone to resource competition when accessing cache resources, resulting in a reduced hit rate.
By allocating target resource partitions to target processes, the target partition identifier is related to the target events and resource scheduling priority changes of the process, and the corresponding relationship between the process and the partition identifier is dynamically adjusted, and the resource allocation strategy is used to meet the resource calling needs of the process.
It improves the calling efficiency of cache resources, enhances the system's responsiveness and user experience, and reduces resource competition and miss issues between processes.
Smart Images

Figure CN119271420B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and more specifically to a resource scheduling method, device, and electronic device. Background Art
[0002] Currently, the processing systems of electronic devices add a high-speed cache memory (cache for short) between the processor and the memory. By setting up the cache, the speed difference between the processor and the memory can be compensated. That is, the information that the processor needs to use is transferred to the cache, so that the processor can obtain the information directly from the cache, thereby improving the access speed.
[0003] However, for electronic devices such as smart terminals that are closely related to user interaction, different types of application processes in the electronic devices are prone to resource competition and reduced hit rate when accessing cache resources. Summary of the Invention
[0004] In view of this, this application provides the following technical solutions:
[0005] A resource scheduling method, comprising:
[0006] In response to a resource call request of a target process of an electronic device, obtaining a target partition identifier corresponding to the target process;
[0007] Allocate a corresponding target resource partition to the target process based on the target partition identifier, where the target resource partition is one of the multiple cached resource partitions;
[0008] The target partition identifier is assigned to the target process when a target event occurs in the process, and the target event is related to a change in resource scheduling priority of the process.
[0009] Optionally, allocating a corresponding target resource partition to the target process based on the target partition identifier includes:
[0010] Determine a target partition identifier corresponding to the target process;
[0011] According to the resource configuration policy corresponding to the target partition identifier, the corresponding target resource partition is allocated to the target process, the resource configuration policy includes a correspondence between partition identifiers and resource partitions, and the target partition identifier is one of the partition identifiers.
[0012] Optionally, it also includes:
[0013] In response to a target event occurring in a process, a corresponding partition identifier is updated for the process.
[0014] Optionally, in response to a target event occurring in a process, updating a corresponding partition identifier for the process includes:
[0015] Obtain the first process identifier of the first process in which the target event occurs;
[0016] Selecting a first partition identifier from the plurality of partition identifiers, where the resource configuration policy corresponding to the first partition identifier corresponds to the resource scheduling priority of the first process;
[0017] The corresponding information of the first process identifier is written into the first partition identifier.
[0018] Optionally, writing the corresponding information of the first process identifier into the first partition identifier includes:
[0019] Parsing the first process identifier to obtain first thread identifiers corresponding to the first process;
[0020] All first thread identifiers corresponding to the first process are written into the first partition identifier.
[0021] Optionally, the plurality of partition identifiers are respectively configured with different resource allocation strategies, the resource allocation strategies comprising at least: resource partitions corresponding to the partition identifiers;
[0022] The multiple partition identifiers include at least two types of partition identifiers, and the two types of partition identifiers correspond to resource allocation strategies with at least two different resource call priorities.
[0023] Optionally, it also includes:
[0024] In response to a target process being updated from the first process group to the second process group, it is determined that a target event occurs in the target process.
[0025] A resource scheduling device, comprising:
[0026] an acquiring unit, configured to acquire a target partition identifier corresponding to a target process in response to a resource calling request of a target process of an electronic device;
[0027] an allocating unit, configured to allocate a corresponding target resource partition to the target process based on the target partition identifier, where the target resource partition is one of the plurality of cached resource partitions;
[0028] The target partition identifier is assigned to the target process when a target event occurs in the process, and the target event is related to a change in resource scheduling priority of the process.
[0029] An electronic device, comprising:
[0030] a cache, the cache comprising at least one resource partition;
[0031] A scheduling component, wherein the scheduling component is used to execute the resource scheduling method as described in any one of the above.
[0032] Optionally, it also includes:
[0033] The configuration module is used to store resource configuration strategies, wherein the resource configuration strategies include corresponding relationships between partition identifiers and resource partitions. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.
[0035] Figure 1 A schematic diagram of a resource scheduling method provided in an embodiment of the present application;
[0036] Figure 2 A schematic diagram of the information format of a resource configuration policy provided in an embodiment of the present application;
[0037] Figure 3 A flowchart of a resource scheduling method based on update events of process groups provided in an embodiment of the present application;
[0038] Figure 4 A flowchart of a partition identification updating method provided in an embodiment of the present application;
[0039] Figure 5 A schematic diagram of a resource processing module of an electronic device provided in an embodiment of the present application;
[0040] Figure 6 A schematic diagram of an initialization process provided in an embodiment of the present application;
[0041] Figure 7 A schematic diagram of a process for dynamically allocating partition identifiers to processes provided in an embodiment of the present application;
[0042] Figure 8 A schematic diagram of the structure of a resource scheduling device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0044] The terms "first," "second," and the like in the embodiments of the present application are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. In addition, the terms "including," "having," and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to the process, method, product, or apparatus.
[0045] An embodiment of the present application provides a resource scheduling method, which is applied to an application scenario of scheduling cache resources corresponding to electronic devices. The electronic devices may be various types of devices with information processing functions, such as smart phones, tablet computers, wearable devices, portable computers, all-in-one computers, desktop computers, vehicle-mounted terminals, servers, and server clusters. An electronic device may include a variety of storage modules, such as memory, cache, and external storage modules. Adding a cache (cache memory) between the CPU (central processing unit) and memory of an electronic device can reduce data access time and improve system performance. In a computer system, cache is usually divided into multiple levels, from CPU cache (such as L1, L2, L3 cache) to main memory (RAM), and then to disk cache. In the embodiment of the present application, efficient calling of cache resources can be achieved, thereby improving the processing performance of the system.
[0046] See also Figure 1 , is a flow chart of a resource scheduling method provided in an embodiment of the present application, which may include the following steps:
[0047] S101: In response to a resource call request of a target process of an electronic device, obtain a target partition identifier corresponding to the target process.
[0048] S102: Allocate a corresponding target resource partition to the target process based on the target partition identifier.
[0049] An electronic device will execute multiple processes in the running state. A process is the execution flow of a program in the electronic device regarding a data set. It is the unit for resource allocation and scheduling of the system and represents the running instance of the program. The process that currently needs to call cache resources in the electronic device is determined as the target process, that is, the resource call request is a cache resource call request. The resource configuration strategy executed by the electronic device includes the correspondence between partition identifiers and resource partitions. Resource partitions refer to the divided areas in the cache. For example, the partition identifiers include 01, 02, and 03. Correspondingly, partition identifier 01 can correspond to resource partition 001; partition identifier 02 can correspond to resource partition 002; partition identifier 03 can correspond to resource partition 003, etc. The correspondence between partition identifiers and resource partitions can be configured when the cache system is initialized.
[0050] The target partition identifier corresponding to the target process is the identification information assigned to the target process when the target event occurs in the process. The target event is related to the change in the resource scheduling priority of the process. For example, the target event can be a switching event of the response priority of the current process. Specifically, the target event can be a switching event of an application in an electronic device. When the electronic device switches from running a first application to a second application, the response priority corresponding to the second application will be higher than the priority of the first application. Further, the response priority of each process corresponding to the second application will be higher than the priority of each process corresponding to the first application. Therefore, when the application running in the electronic device is switched, a switching event of the response priority of the process will be triggered, and the update of the partition identifier of the target process can be further triggered according to the event. In the embodiment of the present application, the target partition identifier corresponding to the target process is the partition identifier currently configured by the target process. The cache resources of the target resource partition corresponding to the target partition identifier can meet the resource call request of the target process, and the cache resources of the target resource partition can further meet the response requirements of the target process.
[0051] After obtaining the target resource partition corresponding to the target partition identifier, the target process will be assigned to the target resource partition so that the target process can call the cache resources in the target resource partition. In the embodiment of the present application, the correspondence between the partition identifiers and the resource partitions pre-stored in the electronic device is pre-configured. Each resource partition can correspond to a cache resource with different characteristics, so that the cache resources corresponding to each partition identifier can be different. Specifically, the resource partitions corresponding to each partition identifier can all be resource partitions with different characteristics, such as the resource storage capacity of the resource partitions corresponding to each partition identifier is different, or some of the resource partitions corresponding to each partition identifier are the same and others are different. It is also possible to divide each resource partition into different levels according to its characteristics, and the resource partitions under each level can be one or more. For example, the storage capacity range of the resource partitions corresponding to different levels is different, such as the storage capacity of each resource partition of the first level is greater than the storage capacity of each resource partition of the second level. Specifically, the characteristics of each resource partition can be pre-configured according to real-time application needs, and the correspondence between the partition identifier and each resource partition can be further configured.
[0052] However, the correspondence between processes and partition identifiers in an electronic device is not fixed. When a resource call request is received from a target process, the current target partition identifier corresponding to the target process is determined, allowing the target process to be assigned to the target resource partition that best matches it. For example, a target event may be an application switching event in an electronic device. When the target process is running a first application on the electronic device, it may be a background process, corresponding to the first partition identifier. When the electronic device is currently switching to a second application, the target process may be a foreground process, in which case the partition identifier of the target process may be determined to be the second partition identifier. The second resource partition corresponding to the second partition identifier has more available cache resources than the first resource partition corresponding to the first partition identifier, which can better meet the cache resource call requirements of the target process as a foreground process, improving the process resource call requirements and system responsiveness. In this application, information included in the cache resource can be determined based on the attribute information corresponding to the cache resource, such as the storage space size, cache granularity, and cache data synchronization configuration mechanism. For example, cache space is typically allocated in units of portions (portions can be unit data blocks in the cache space), and cache partitions with more cache resources include more cache data blocks (portions).
[0053] The resource scheduling method of the embodiment of the present application is described below in conjunction with specific application scenarios.
[0054] In one implementation of an embodiment of the present application, based on the target partition identifier, a corresponding target resource partition is allocated to the target process, including: determining the target partition identifier corresponding to the target process; and allocating the corresponding target resource partition to the target process according to the resource configuration policy corresponding to the target partition identifier.
[0055] The resource allocation strategy includes a correspondence between partition identifiers and resource partitions, and the target partition identifier is one of the partition identifiers, that is, the cache resources in the target resource partition corresponding to the target partition identifier can match the resource call requirements of the target thread. In order to quickly determine the resource partition that meets the process requirements, a resource allocation strategy can be pre-generated and stored in an electronic device, such as a scheduling component that executes a resource call method in the electronic device. In this way, the target resource partition can be determined based on the target partition identifier corresponding to the target process and the resource allocation strategy, and the target resource partition can be configured, such as bandwidth configuration, cache data reading configuration, etc.
[0056] Specifically, when generating the resource configuration strategy, different resource partitions can be determined for different partition identifiers. For example, the number of cache resources in some resource partitions can be larger, or the corresponding cache resources can have stronger real-time update synchronization characteristics, so as to meet different cache resource call requirements. Figure 2 , is a schematic diagram of the information format of a resource configuration strategy provided in an embodiment of the present application. Figure 2 In the figure, PARTID is used to represent the partition identifier, and CPBM is used to represent the cache strategy. The figure lists the corresponding resource partition locations in the cache strategy. Figure 2 The corresponding resource partition is identified in hexadecimal format. Specifically, the resource partition can correspond to multiple resource blocks in the L3 cache (i.e., shared cache) corresponding to the DSU. The resource allocation policy can determine the resource block corresponding to a partition identifier. The DSU is part of the ARM DynamIQ technology, a CPU cluster design that allows different types and numbers of CPU cores (including large and small cores) to be combined to share resources and communicate. The mapping between partition identifiers and resource partitions can be stored as a configuration file in the corresponding area. When a resource is called, the resource partition corresponding to the current partition identifier can be retrieved based on the configuration file. For example, the configuration file can be an embedded management unit (MSC) file. To meet the resource call requirements of different processes, some partition identifiers can be assigned a larger number of resource blocks, while others can be assigned a smaller number of resource blocks. For example, if a foreground process has a high response requirement, it can be assigned to a partition identifier corresponding to a larger number of resource blocks to meet its resource call requirements. This allows the foreground process to respond to user operations promptly, improving the user experience.
[0057] To ensure that the cache resource call requirements of the corresponding process are met in real time, the correspondence between the process and the partition identifier in the embodiment of the present application is not fixed. Instead, the correspondence between the process and the partition identifier is updated according to changes in resource scheduling priorities. Specifically, in response to the occurrence of a target event in the process, the corresponding partition identifier is updated for the process, and the target resource partition of the process is dynamically adjusted to meet performance requirements.
[0058] The target event is related to the change in resource scheduling priority of the process. For example, the target event can be a switching event of an application currently running on the electronic device, or a user-triggered operation event. Correspondingly, the target event can also be generated when configuring or adjusting the process.
[0059] Switching events can be monitored by capturing key system-related signals. For example, it can be combined with the change information of the usual process grouping, that is, whether a target event is generated is determined based on the update of the process grouping. In this way, the monitoring process of the target event in the embodiment of the present application can be combined with the update event of the process grouping, which is easier to implement in technology. At the same time, the use of relevant information allocated by the general process grouping can make it more convenient to distinguish different processes, and it is also convenient to reuse existing technologies, thereby improving the efficiency of resource call processing.
[0060] In one embodiment, a flow chart of a method for resource scheduling based on update events of process groups is also provided. Figure 3 , the method may include the following steps:
[0061] S301: In response to a target process being updated from a first process group to a second process group, determining that a target event occurs in the target process.
[0062] S302: Determine a target partition identifier corresponding to the target process based on the target event.
[0063] S303: Allocate a corresponding target resource partition to the target process based on the target partition identifier.
[0064] In order to facilitate the response and management of processes, processes can be grouped. For example, in an operating system, process grouping can be used to allocate different resource limits to processes in different groups, such as CPU time, memory or other storage resource usage, I / O bandwidth, etc. Processes can also be grouped according to their priority to ensure that high-priority processes can obtain more resources and respond faster. Different process groups can correspond to different partition identifiers, and thus correspond to different resource partitions. It should be noted that in the embodiments of the present application, the processes in each process group are not fixed. The processes in each process group will be updated based on the operating status, response mode, and the influence of the running application of the electronic device. When a process group update is detected, a corresponding target event will be generated, and the partition identifier corresponding to the process will also be updated after the target event is detected. For example, in the previous process monitoring cycle, the target process belongs to the background process, which is in the first process group, and the first process group corresponds to the first partition identifier. At this time, the target process corresponds to the first partition identifier. When the response state of an application in an electronic device changes, the corresponding process group is updated. If the target process is a foreground process, the target process can be updated to the second process group corresponding to the foreground process. The second process group corresponds to the second partition identifier. At this time, the target partition identifier corresponding to the target process is the second partition identifier, and the target process can call the cache resources of the second resource partition corresponding to the second partition identifier. This allows the process in the electronic device to be matched with the optimal cache resources in real time, meeting its cache resource call requirements and improving response efficiency.
[0065] In this embodiment, the general process management technology of Control Groups (CGroups) can be combined to isolate physical resources between processes, thereby reducing mutual interference between processes and improving the system's response speed and stability. For example, CGroup technology can be used to group processes, such as assigning foreground processes to corresponding foreground process groups and background processes to corresponding background process groups. This technology can also be used to dynamically adjust process information, such as dynamically changing the information related to each process in a process group. For example, based on the current operating state of the electronic device, the corresponding process can be added to the relevant process group, or the processes in the relevant process group can be adjusted. For example, if the current application is switched, some processes in the background process group can be adjusted to the foreground process group. Correspondingly, in an embodiment of the present application, a scheduling component that executes the resource scheduling method can be data-connected with a component that executes CGroup process group allocation information. In this way, the scheduling component can obtain updated information about the process group and, based on this updated information, determine whether to adjust the partition identifier of the corresponding process. This achieves the reuse of existing technology, making the technology more convenient to implement and improving the efficiency of resource scheduling processing.
[0066] Furthermore, an implementation of the embodiment of the present application also includes a partition identification updating method, which is used to update the corresponding partition identification for the process in response to a target event occurring in the process. Figure 4 , the method may include the following steps:
[0067] S401: Obtain a first process identifier of a first process in which a target event occurs.
[0068] S402: Select a first partition identifier from multiple partition identifiers.
[0069] S403: Write the corresponding information of the first process identifier into the first partition identifier.
[0070] The resource allocation policy corresponding to the first partition identifier corresponds to the resource scheduling priority of the first process. Specifically, the first process where the target event occurs may be the process that generated the target event, such as a newly started process. Correspondingly, the first process may also be the process affected by the target event. For example, if the target event is the user of an electronic device launching an audio application, the corresponding audio-related process is the first process. The first process can then be analyzed to determine process characteristic information corresponding to the first process. This process characteristic information may include process response requirements, frequency of process resource calls, amount of cache resource calls by the process, number of threads corresponding to the process, and so on. Based on the process characteristic information corresponding to the first process, a first partition identifier matching the first process is determined. During the process of determining the first partition identifier, the resource allocation policy corresponding to the partition identifier can also be obtained. Based on the correspondence between the resource allocation policy and the resource scheduling priority, the first partition identifier corresponding to the first process is determined. Correspondingly, after determining the first process where the target event occurs, first grouping information including the first process identifier can also be determined. Based on the first grouping information, a suitable partition identifier is determined, thereby obtaining the first partition identifier. Process grouping is typically implemented using CGroup technology, which controls CPU (central processing unit) resources. CGroup technology takes into account process priorities and other factors when grouping processes. Therefore, a pre-established correspondence between partition identifiers and CGroup grouping information is established. When a process is updated and assigned to a process group, it is assigned the matching partition identifier. This CGroup-based management leverages existing mechanisms, making it easier to implement. Furthermore, subsequent cache allocations to processes in the group align with CPU resource control, ensuring more accurate resource allocation and improving subsequent process efficiency.
[0071] Among them, the resource configuration strategy includes the correspondence between the partition identifier and the resource partition, so that the resource partition that can meet the resource scheduling priority of the first process can be determined through the resource configuration strategy, thereby determining the partition identifier corresponding to the resource partition as the first partition identifier. For example, the first process needs to call cache resources frequently, that is, its corresponding resource scheduling priority is higher, and the partition identifier corresponding to the resource partition with higher response efficiency can be determined as the first partition identifier to improve the efficiency of cache resource calling. After the first partition identifier is determined, the first process identifier will be written into the first partition identifier to realize the allocation of the partition identifier to the first process, so that the cache resource calling needs of the first process can be met based on the first partition identifier. Among them, the first process identifier can represent the process information of the first process, such as the thread information and configuration information included in the first process.
[0072] Furthermore, in an embodiment of the present application, the corresponding information of the first process identifier is written into the first partition identifier, including: parsing the first process identifier, obtaining each first thread identifier corresponding to the first process, and writing all first thread identifiers corresponding to the first process into the first partition identifier.
[0073] During the operation of an electronic device, a thread is an instance of a process, a unit invoked and executed by the CPU, and a smaller, independently executable unit. Threads rely on the existence of processes and are scheduled by the operating system. Therefore, it is necessary to parse the first process identifier to obtain the identifiers of each first thread corresponding to the first process. Then, all first thread identifiers are written to the first partition identifier. This allows each first thread corresponding to the first process to be executed, and the cache resources of the corresponding target resource partition to be obtained based on the first partition identifier, ensuring the accuracy of cache resource invocation and the efficiency of resource response.
[0074] In an embodiment of the present application, when determining the correspondence between each partition identifier and a resource partition, different resource partitions can be configured to meet different resource call requirements. In one embodiment, the multiple partition identifiers in the embodiment of the present application are each configured with a different resource allocation strategy, which at least includes: a resource partition corresponding to the partition identifier. The multiple partition identifiers include at least two types of partition identifiers, and the two types of partition identifiers correspond to resource allocation strategies with at least two different resource call priority levels.
[0075] In this embodiment, the resource allocation strategy includes at least a resource partition corresponding to a partition identifier, i.e., it can guarantee which resource partition is allocated to the corresponding partition identifier. To meet the resource call requirements of different processes, multiple partition identifiers can be divided into at least two categories, such as first-category partition identifiers and second-category partition identifiers. Different categories of partition identifiers correspond to resource allocation strategies with different resource call priorities. For example, first-category partition identifiers correspond to resource allocation strategies with higher resource call priorities, while second-category partition identifiers correspond to resource allocation strategies with lower resource call priorities. Specifically, a resource allocation strategy with a higher resource call priority may allocate the corresponding partition identifier to a resource partition with first-level cache resource characteristics, where cache resource characteristics may refer to characteristics such as the partition size, number of resources, resource update rate, and resource response efficiency of the corresponding resource partition. Taking the cache resource characteristic of resource partition size as an example, the first-level cache resource characteristics refer to resource partitions with larger resource partitions. Correspondingly, a resource allocation strategy with a lower resource call priority may allocate the corresponding partition identifier to a resource partition with second-level cache resource characteristics, where the second-level cache resource characteristics may refer to smaller resource partitions. For example, the first type of partition identifier could be the partition identifier for the foreground process, which could correspond to a resource partition with a large number of cache resource blocks; the second type of partition identifier could be the partition identifier for the background process, which could correspond to a resource partition with a relatively small number of cache resource blocks. This allows more cache resources to be allocated to the background process, reducing cache resource misses for the foreground process and enabling timely responses to user actions during user interaction, thereby improving the user experience.
[0076] The above method can be performed at the operating system level of the electronic device and implemented through interaction between the operating system and the underlying cache management module.
[0077] Taking a Linux-based electronic device with an Android operating system as an example, the resource calling method of an embodiment of the present application is described. In order to more efficiently complete the call to cache resources, the resource scheduling method can be executed by a scheduling component in the electronic device. Specifically, the scheduling component is determined according to the characteristics of the current electronic device. For example, the scheduling component can be an MPAM module provided by the ARM architecture, wherein MPAM (Memory System Resource Partitioning and Monitoring) is used to divide and monitor memory system resources and supports memory system partitioning. Thus, the use of corresponding cache resources by processes in the electronic device is controlled by MPAM.
[0078] See also Figure 5 , is a schematic diagram of a resource processing module of an electronic device provided in an embodiment of the present application. Figure 5As shown in Figure 1, user space and kernel space are the two main system layers in an electronic device operating system. User space is the operating system's environment for application programs. Within this space, programs can only access limited resources and are managed by the operating system. Kernel space is the core of the operating system. It has direct control over the hardware and is responsible for managing system resources, including the CPU, memory, disks, and I / O devices.
[0079] Before executing a task, you can also pre-generate a resource configuration strategy, that is, pre-generate the corresponding relationship between each partition identifier and the corresponding resource partition. Figure 6 , is a schematic diagram of an initialization process provided in an embodiment of the present application. The initialization process corresponds to a process of pre-configuring the correspondence between each partition identifier and the resource partition. Specifically, the initialization process includes the following steps:
[0080] S601. Call Android-MPAM (monitoring component) when the core dynamic library registers the JNI method by registering the Android operating system process.
[0081] When libandroid_runtime (a core dynamic library in the Android system that provides multiple functions and interfaces for applications to interact with the underlying Android system) registers JNI methods through register_android_os_Process (registering the Android operating system process), it calls the initialization method of Android-MPAM (Android's memory system resource partitioning and monitoring module, also known as the monitoring component) for initialization. libandroid_runtime provides an interface for interaction between the Java layer and the native layer (C / C++ code) through the Java Native Interface (JNI). JNI allows Java code to call native library functions and vice versa.
[0082] S602: Based on the initialization method of Android-MPAM, determine the cache partition corresponding to each partition identifier.
[0083] Among them, the configuration principle of the initialization method of Android-MPAM is that the foreground process is configured with more cache resources than the background process. For example, the cache space can be divided to obtain multiple cache partitions. Specifically, the cache space can be based on data cache blocks, and the number of data cache blocks in each cache partition is different. For example, the number of data cache blocks in the first-level cache partition is greater than the number of data cache blocks in the second-level cache partition. For example, the cache partition corresponding to the partition identifier of the foreground process can be configured with more data cache blocks than the cache partition corresponding to the partition identifier of the background process.
[0084] S603: Determine the correspondence between the partition identifier and the cache partition, and configure the correspondence into the scheduling component.
[0085] Among them, the scheduling component is used to execute the resource scheduling method and allocate the corresponding cache partition for the process. Usually, the correspondence between each partition identifier and the resource partition is determined according to the priority of the resource call. For example, the foreground process will be configured with more resource blocks than the background process, that is, the partition identifier corresponding to the foreground process will match the resource partition with a larger number of resources, and the partition identifier corresponding to the background process will match the resource partition with a smaller number of resources. Taking the cache resources corresponding to the DSU as an example, the shared cache area L3 can be divided into multiple resource blocks. At the same time, the scheduling component MPAM will support the call of resource partitions corresponding to multiple partition identifiers. Each partition identifier uses the resource block of the corresponding resource partition according to the correspondence with the resource partition included in the resource configuration strategy. In this way, since the foreground process is configured with more resource blocks of the resource partition, the problem of cache resource misses of the foreground process can be reduced. When interacting with the user, it can respond to the user's operation more promptly, thereby improving the user experience.
[0086] See also Figure 7 , is a schematic diagram of a process for dynamically allocating partition identifiers to a process provided by an embodiment of the present application, wherein the process includes:
[0087] S701. In response to the switching of the electronic device application, the upper-layer AMS component updates the priority of the electronic device process calling cache resources by adjusting the component.
[0088] In the user space, applications that interact with the user are monitored. When an application switch is detected, such as the current user opens application 2 (represented by APP2) and closes application 1 (represented by APP1), this is equivalent to generating an application switch event, which will cause APP1 to return to the background and APP2 to enter the foreground. At this time, the upper-layer AMS component will update the process priority of the electronic device through the adjustment component. Among them, the AMS component can be a system server in the Android system that interacts with the upper-layer application, which is mainly responsible for the startup, switching, scheduling, and application process management and scheduling of related components in the Android system. The adjustment component can be a component in the Android system, such as the OoM Adjuster component, which is used to dynamically adjust the memory usage priority of the process according to the priority and memory usage of the process. In an embodiment of the present application, the adjustment component can adjust the priority of the process's call to the cache resource in response to the switching of the application. For example, when APP2 is detected to enter the foreground, the process corresponding to APP2 can be determined as the foreground process, thereby adjusting the priority of its corresponding cache resource call to a high priority, that is, the cache resource is scheduled first.
[0089] S702. In response to the priority update of the process calling the cache resource, the processing component adjusts the grouping update information of the target process, and sends the updated grouped target process to the monitoring component, so that the monitoring component can respond to the update grouping event and determine the updated target partition identifier corresponding to the target process.
[0090] The target process refers to a process whose resource scheduling priority changes after the current application is switched. After the cached resource call priority of the process is updated in response to the application switch, the process grouping of the corresponding target process can be adjusted through the corresponding processing component, and the updated process group can be added to the code library, such as libandroid_runtime in the Android system (which is a core dynamic library in the Android system and contains the core code of the Android Runtime Environment (ART), including class loaders, virtual machines, JIT compilers, etc.). The code library then passes the updated process group to a dynamic link library (such as libprocessgroup), which is responsible for managing process groups. Specifically, the processing component can be a functional component that performs process grouping changes, such as a component that performs CGroup functions. CGroup can organize processes into tree-structured groups and apply specific resource limits and policies to each group. In embodiments of the present application, this technology can be used to implement grouping updates for target processes, such as adjusting the target process from a background process group to a foreground process group, thereby determining the partition identifier corresponding to the target process that meets the foreground process resource call pattern. When the process grouping is updated, the monitoring (such as Android-MPAM) will also be notified to pass the partition identifier corresponding to the target process after the grouping change to the scheduling component, so that the scheduling component can determine the resource partition of the corresponding thread based on the partition identifier.
[0091] In an embodiment of the present application, a monitoring component (such as Android-MPAM) is added to the user space (User Space). In this way, when the upper-layer AMS performs process grouping updates or switches, the monitoring component can transmit the partition identifier or related information corresponding to the updated target process to the scheduling component (such as DSU / SLC MPAM), so that the scheduling component can accurately allocate the corresponding cache resources and improve the efficiency and performance of process processing in the system.
[0092] S703: Obtain thread identification information of all threads corresponding to the target process, and write each thread identification information into a target partition identifier corresponding to the target process.
[0093] S704: The target partition identifier written into the thread identifier information is passed to the scheduling component, so that the scheduling component determines the cache partition of the corresponding process based on the partition identifier.
[0094] For example, the thread identifiers (e.g., represented by TIDs) of all threads of the process corresponding to the target partition identifier are obtained and written to the partition identifier of the kernel space cache scheduling component MPAM. The cache can be the cache corresponding to the DSU (DynamIQ Shared Unit), which is part of the ARM DynamIQ technology. The DSU is a new CPU cluster design that allows different types and numbers of CPU cores (including large and small cores) to be combined to share resources and communication. The cache can also be an SLC (System Level Cache), a system-level cache that serves as the next level of cache for all connected CPUs and is typically implemented in a memory interconnect based on the AMBA Coherent Hub Interconnect (CHI) protocol.
[0095] Taking the scheduling component MPAM for DSU as an example, when the CPU needs to execute the corresponding task, the scheduling component will be configured into the CPU register according to the resource allocation policy of the partition identifier corresponding to the task. In this way, when the task is executed, the resource access of each thread of the process corresponding to the task can be restricted to the resource partition corresponding to the partition identifier in the resource allocation policy, thereby realizing efficient calling of cache resources.
[0096] In the embodiment of the present application, a resource scheduling device is also provided. Figure 8 , the device comprises:
[0097] An acquiring unit 801 is configured to acquire a target partition identifier corresponding to a target process in response to a resource call request of the target process of the electronic device;
[0098] An allocating unit 802 is configured to allocate a corresponding target resource partition to the target process based on the target partition identifier, where the target resource partition is one of the plurality of cached resource partitions.
[0099] The target partition identifier is assigned to the target process when a target event occurs in the process, and the target event is related to a change in resource scheduling priority of the process.
[0100] Optionally, the allocation unit includes:
[0101] A first determining subunit, configured to determine a target partition identifier corresponding to the target process;
[0102] The first allocation subunit is used to allocate the corresponding target resource partition to the target process according to the resource allocation strategy corresponding to the target partition identifier, the resource allocation strategy includes the correspondence between the partition identifier and the resource partition, and the target partition identifier is one of the partition identifiers.
[0103] Optionally, it also includes:
[0104] The updating unit is configured to update a corresponding partition identifier for a process in response to a target event occurring in the process.
[0105] Optionally, the updating unit includes:
[0106] A first acquiring subunit, configured to acquire a first process identifier of a first process in which a target event occurs;
[0107] A selection subunit is configured to select a first partition identifier from a plurality of partition identifiers, wherein the resource configuration policy corresponding to the first partition identifier corresponds to the resource scheduling priority of the first process;
[0108] The first writing subunit is configured to write the corresponding information of the first process identifier into the first partition identifier.
[0109] Optionally, the first writing subunit is configured to:
[0110] Parsing the first process identifier to obtain first thread identifiers corresponding to the first process;
[0111] All first thread identifiers corresponding to the first process are written into the first partition identifier.
[0112] Optionally, the plurality of partition identifiers are respectively configured with different resource allocation strategies, the resource allocation strategies comprising at least: resource partitions corresponding to the partition identifiers;
[0113] The multiple partition identifiers include at least two types of partition identifiers, and the two types of partition identifiers correspond to resource allocation strategies with at least two different resource call priorities.
[0114] Optionally, it also includes:
[0115] The target event determining unit is configured to determine that a target event occurs in the target process in response to the target process being updated from the first process group to the second process group.
[0116] It should be noted that the specific implementation of each unit and sub-unit in this embodiment can refer to the corresponding content in the previous text and will not be described in detail here.
[0117] In another embodiment of the present application, a readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the resource scheduling method as described in any one of the above items is implemented.
[0118] In another embodiment of the present application, an electronic device is provided, which may include:
[0119] a cache, the cache comprising at least one resource partition;
[0120] A scheduling component, which is used to implement:
[0121] In response to a resource call request of a target process of an electronic device, obtaining a target partition identifier corresponding to the target process;
[0122] Allocate a corresponding target resource partition to the target process based on the target partition identifier, where the target resource partition is one of the multiple cached resource partitions;
[0123] The target partition identifier is assigned to the target process when a target event occurs in the process, and the target event is related to a change in resource scheduling priority of the process.
[0124] Optionally, allocating a corresponding target resource partition to the target process based on the target partition identifier includes:
[0125] Determine a target partition identifier corresponding to the target process;
[0126] According to the resource configuration policy corresponding to the target partition identifier, the corresponding target resource partition is allocated to the target process, the resource configuration policy includes a correspondence between partition identifiers and resource partitions, and the target partition identifier is one of the partition identifiers.
[0127] Optionally, it also includes:
[0128] In response to a target event occurring in a process, a corresponding partition identifier is updated for the process.
[0129] Optionally, in response to a target event occurring in a process, updating a corresponding partition identifier for the process includes:
[0130] Obtain the first process identifier of the first process in which the target event occurs;
[0131] Selecting a first partition identifier from the plurality of partition identifiers, where the resource configuration policy corresponding to the first partition identifier corresponds to the resource scheduling priority of the first process;
[0132] The corresponding information of the first process identifier is written into the first partition identifier.
[0133] Optionally, writing the corresponding information of the first process identifier into the first partition identifier includes:
[0134] Parsing the first process identifier to obtain first thread identifiers corresponding to the first process;
[0135] All first thread identifiers corresponding to the first process are written into the first partition identifier.
[0136] Optionally, the plurality of partition identifiers are respectively configured with different resource allocation strategies, the resource allocation strategies comprising at least: resource partitions corresponding to the partition identifiers;
[0137] The multiple partition identifiers include at least two types of partition identifiers, and the two types of partition identifiers correspond to resource allocation strategies with at least two different resource call priorities.
[0138] Optionally, it also includes:
[0139] In response to a target process being updated from the first process group to the second process group, it is determined that a target event occurs in the target process.
[0140] Optionally, the electronic device further includes:
[0141] The configuration module is used to store resource configuration strategies, wherein the resource configuration strategies include corresponding relationships between partition identifiers and resource partitions.
[0142] It should be noted that the specific implementation of the scheduling component in this embodiment can refer to the corresponding content in the previous text and will not be described in detail here.
[0143] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.
[0144] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may 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.
[0145] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0146] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A resource scheduling method, comprising: In response to a resource call request of a target process of an electronic device, obtaining a target partition identifier corresponding to the target process; Allocate a corresponding target resource partition to the target process based on the target partition identifier, where the target resource partition is one of the multiple cached resource partitions; Among them, the target partition identifier is assigned to the target process when a target event occurs in the process, and the target event is related to the change of resource scheduling priority of the process. In response to the target event occurring in the process, the corresponding partition identifier is updated for the process, and the target event includes a switching event of the response priority of the process.
2. The method according to claim 1, allocating a corresponding target resource partition to the target process based on the target partition identifier, comprising: Determine a target partition identifier corresponding to the target process; According to the resource configuration policy corresponding to the target partition identifier, the corresponding target resource partition is allocated to the target process, the resource configuration policy includes a correspondence between partition identifiers and resource partitions, and the target partition identifier is one of the partition identifiers.
3. The method according to claim 1, wherein in response to a target event occurring in a process, updating a corresponding partition identifier for the process comprises: Obtain the first process identifier of the first process in which the target event occurs; Selecting a first partition identifier from the plurality of partition identifiers, where the resource configuration policy corresponding to the first partition identifier corresponds to the resource scheduling priority of the first process; The corresponding information of the first process identifier is written into the first partition identifier.
4. The method according to claim 3, wherein writing the corresponding information of the first process identifier into the first partition identifier comprises: Parsing the first process identifier to obtain first thread identifiers corresponding to the first process; All first thread identifiers corresponding to the first process are written into the first partition identifier.
5. The method according to claim 1, wherein the plurality of partition identifiers are respectively configured with different resource allocation strategies, wherein the resource allocation strategies include at least: The resource partition corresponding to the partition identifier; The multiple partition identifiers include at least two types of partition identifiers, and the two types of partition identifiers correspond to resource allocation strategies with at least two different resource call priorities.
6. The method according to claim 1, further comprising: In response to a target process being updated from the first process group to the second process group, it is determined that a target event occurs in the target process.
7. A resource scheduling device, comprising: an acquiring unit, configured to acquire a target partition identifier corresponding to a target process in response to a resource calling request of a target process of an electronic device; an allocating unit, configured to allocate a corresponding target resource partition to the target process based on the target partition identifier, where the target resource partition is one of the plurality of cached resource partitions; Among them, the target partition identifier is assigned to the target process when a target event occurs in the process, and the target event is related to the change of resource scheduling priority of the process. In response to the target event occurring in the process, the corresponding partition identifier is updated for the process, and the target event includes a switching event of the response priority of the process.
8. An electronic device comprising: a cache, the cache comprising at least one resource partition; A scheduling component, wherein the scheduling component is used to execute the resource scheduling method according to any one of claims 1 to 6.
9. The electronic device according to claim 8, further comprising: The configuration module is used to store resource configuration strategies, wherein the resource configuration strategies include corresponding relationships between partition identifiers and resource partitions.
Citation Information
Patent Citations
Shared resource allocation method, device and equipment
CN110879748A
Resource management based on a process identifier
US20160179580A1
Controlling allocation of entries in a partitioned cache
US20210124694A1