A method for controlling use of a cache resource and an electronic device
By combining the partition identifier and memory space address of the target object, a fine-grained resource allocation strategy is formulated, which solves the problem of unreasonable utilization of cache resources and improves cache access efficiency.
Patent Information
- Application Number
- CN202411708748.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2044-11-26
AI Technical Summary
In existing technologies, when hardware modules and processes compete for cache resources, it leads to a decrease in cache access efficiency and an inability to make reasonable use of cache resources.
By determining the first and second partition identifiers of the target object and combining them with the memory space address, a fine-grained resource allocation strategy is formulated to allocate cache space for the target object and process the associated data required for access requests within the cache space.
This enables a more rational allocation of cache resources, reduces resource waste, and improves cache access efficiency.
Smart Images

Figure CN119201775B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of resource control, and in particular to a cache resource usage control method and an electronic device. BACKGROUND
[0002] Hardware modules such as processors and embedded controllers and processes in an electronic device need to share various cache resources including cache devices such as memories in the electronic device. Based on this, each hardware module and process may compete for cache resources, thereby affecting the bandwidth and performance of the hardware module and process accessing the cache space, and affecting cache access efficiency.
[0003] In order to reduce the problem of reduced cache access efficiency caused by blind competition for resources, the cache resources can currently be managed by partitioning according to the category of hardware modules or processes. However, even the same hardware module or the same process has different usage requirements for cache resources at different times, so that partition management according to the category of hardware modules or processes still cannot reasonably use cache resources, thereby causing cache resources to be unable to be effectively utilized. SUMMARY
[0004] In one aspect, the present application provides a cache resource usage control method, comprising:
[0005] obtaining an access request initiated by a target object in an electronic device;
[0006] in response to the access request satisfying a first condition, determining a first partition identifier of the target object and a second partition identifier corresponding to a physical address to be accessed by the access request, the second partition identifier being related to a memory space address including the physical address;
[0007] determining a resource allocation strategy based on the first partition identifier and the second partition identifier;
[0008] allocating a corresponding cache space to the target object according to the resource allocation strategy;
[0009] caching associated data required for processing the access request in the cache space.
[0010] In one possible implementation, the determining of the resource allocation strategy based on the first partition identifier and the second partition identifier comprises:
[0011] integrating the first partition identifier and the second partition identifier into a third partition identifier;
[0012] determining a resource allocation strategy corresponding to the third partition identifier.
[0013] In a further possible implementation, the access request includes a target virtual address of a storage space to be accessed.
[0014] The determining of the first partition identifier of the target object and the second partition identifier corresponding to the physical address to be accessed in the access request comprises:
[0015] The first partition identifier corresponding to the target object is determined according to the partition identifier corresponding to different objects.
[0016] Based on the target virtual address, an address mapping relationship group is obtained, and a second partition identifier recorded in the address mapping relationship group is obtained. The address mapping relationship group at least includes a mapping relationship between the target virtual address and a physical address, and the second partition identifier is used to identify a memory space represented by each physical address in the address mapping relationship group.
[0017] In a further possible implementation, the determining of the resource allocation strategy based on the first partition identifier and the second partition identifier comprises:
[0018] The first resource allocation strategy corresponding to the first cache memory is determined based on the first partition identifier and the second partition identifier.
[0019] The allocating of the corresponding cache space for the target object according to the resource allocation strategy comprises:
[0020] The corresponding cache space for the target object is allocated in the first cache memory according to the first resource allocation strategy.
[0021] The caching of the associated data required for processing the access request in the cache space comprises:
[0022] The address mapping relationship group is cached in the cache space.
[0023] In a further possible implementation, the access request satisfying a first condition comprises: according to the target virtual address, the associated data required for processing the access request cannot be found in the first cache memory.
[0024] The use control method of the cache resource further comprises: in response to the access request satisfying a second condition, the associated data required for processing the access request is obtained from the cache space corresponding to the target object, which is allocated based on the resource allocation strategy corresponding to the first partition identifier and the second partition identifier of the target object.
[0025] In a further possible implementation, the determining of the resource allocation strategy based on the first partition identifier and the second partition identifier comprises:
[0026] determine a second resource allocation policy corresponding to the second cache memory based on the first partition identifier and the second partition identifier;
[0027] allocate the corresponding cache space for the target object according to the resource allocation policy, including:
[0028] allocate the corresponding cache space for the target object in the second cache memory according to the second resource allocation policy;
[0029] cache the associated data required for processing the access request in the cache space, including:
[0030] cache the data content to be operated by the access request in the cache space.
[0031] In another possible implementation, the determining the first partition identifier of the target object and the second partition identifier corresponding to the physical address to be accessed by the access request includes:
[0032] obtain the first partition identifier and the second partition identifier of the target object carried in the access request, the first partition identifier and the second partition identifier being determined by a memory management unit, and the second partition identifier being determined by the memory management unit based on a physical address mapped by a target virtual address in the access request, wherein the memory management unit includes a first cache memory.
[0033] In another possible implementation, the caching the data content to be operated by the access request in the cache space includes:
[0034] if the access request is a read request, obtaining first data to be read by the read request from an internal memory of the electronic device and caching the first data in the cache space;
[0035] and / or,
[0036] if the access request is a write request, caching second data to be operated by the write request in the cache space.
[0037] In another aspect, the present application also provides an electronic device, including:
[0038] a cache module and a policy control module in communication connection with the cache module;
[0039] The cache module is configured to obtain an access request initiated by a target object in the electronic device, and in response to the access request satisfying a first condition, determine a first partition identifier of the target object and a second partition identifier corresponding to a physical address to be accessed by the access request, the second partition identifier being related to a memory space address including the physical address.
[0040] determine a resource allocation policy based on the first partition identifier and the second partition identifier;
[0041] allocate a corresponding cache space for the target object according to the resource allocation policy; and cache associated data required for processing the access request in the cache space.
[0042] In a possible implementation, the policy control module comprises a logic unit and a policy management unit.
[0043] The logic unit integrates the first partition identifier and the second partition identifier into a third partition identifier.
[0044] The policy management unit stores at least one candidate resource allocation policy, and determines a resource allocation policy corresponding to the third partition identifier from the at least one candidate resource allocation policy. BRIEF DESCRIPTION OF DRAWINGS
[0045] The above and other features, advantages, and aspects of the present disclosure will become more apparent by describing in detail the following specific embodiments in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals refer to the same or similar elements. It should be understood that the drawings are schematic, and the original and elements are not necessarily drawn according to the scale.
[0046] Figure 1 A flowchart of a cache resource usage control method provided by the present application;
[0047] Figure 2 Another flowchart of a cache resource usage control method provided by the present application;
[0048] Figure 3 An implementation framework diagram of determining a resource allocation policy by a memory management unit in the present application;
[0049] Figure 4 An implementation diagram of determining a resource control policy by a memory management unit and allocating a cache space for a target object;
[0050] Figure 5 Another flowchart of a cache resource usage control method provided by the present application;
[0051] Figure 6 An implementation framework diagram of transmitting an access request initiated by a target object to an SLC storage module through a memory management unit, and performing resource partition management based on the access request by the SLC storage module in the present application;
[0052] Figure 7 A schematic diagram of one of the constituent architectures of the electronic device provided in the present application is shown.
[0053] Figure 8 A schematic diagram of another of the constituent architectures of the electronic device provided in the present application is shown. DETAILED DESCRIPTION
[0054] The embodiments of the present application are described below in conjunction with the accompanying drawings. The terms used in the implementation part of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application. It is known to those skilled in the art that as technology develops and new scenarios appear, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.
[0055] The terms "first", "second", and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged under appropriate circumstances, and this is only a way of distinguishing the objects with the same attributes used in the description of the embodiments of the present application. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, so that the processes, methods, systems, products or devices containing a series of units do not have to be limited to those units, but can include other units not clearly listed or inherent to these processes, methods, products or devices.
[0056] As Figure 1 , a schematic diagram of one of the flow control methods of the cache resources provided by the embodiments of the present application is shown, and the method of the present embodiment can be applied to electronic devices with cache memory. The cache memory can have many possibilities, which are not limited. For example, the cache memory can be a cache memory in a system level cache (SLC) storage module. For another example, the cache memory can be a translation lookaside buffer (TLB) module in a memory management unit (MMU). Of course, the cache memory can also have other possibilities, which are not limited. When the cache resources of the cache memory are used by multiple objects, it is necessary to reasonably allocate resources to improve the use efficiency.
[0057] The method of the present embodiment can include:
[0058] S101, obtaining an access request initiated by a target object in an electronic device.
[0059] The target object can be an application or a process running in the electronic device, or can be various hardware modules capable of initiating an access request, such as a processor, an embedded controller, a display module, or an image processing module.
[0060] The access request can be a read request, a write request, or a request related to a cache resource, and the specific request type and form are not limited.
[0061] In S102, a first partition identifier of the target object and a second partition identifier corresponding to a physical address to be accessed by the access request are determined in response to the access request satisfying a first condition.
[0062] In this application, the access request satisfying the first condition is a trigger condition for caching associated data required for processing the access request in the cache memory. Based on this, the access request satisfying the first condition can be that the associated data required for processing the access request cannot be found in the cache memory.
[0063] The first partition identifier of the target object is used to uniquely identify the target object. The first partition identifier is also an initial identifier used to identify the resource allocation strategy applicable to the target object under the premise of partition management of the cache resources of the cache memory. For example, the control unit corresponding to the cache memory can be preconfigured with partition identifiers corresponding to different objects, based on which the first partition identifier corresponding to the target object can be determined according to the partition identifiers corresponding to different objects. For another example, the control unit corresponding to the cache memory can be configured with a generation strategy for generating a partition identifier corresponding to an object, and the first partition identifier of the target object is generated based on the generation strategy.
[0064] In this application, the second partition identifier is related to a memory space address including the physical address to be accessed by the access request. For example, the second partition identifier can be a unique identifier pre-allocated for the memory space address, or an identifier generated based on the memory space address, which is not limited.
[0065] The physical address to be accessed by the access request is the physical address corresponding to the memory storage space to be accessed by the access request.
[0066] The memory space address including the physical address to be accessed by the access request is an address segment, that is, an address segment corresponding to a memory space, and the size of the memory space corresponding to the memory space address can be set according to actual needs, which is not limited.
[0067] In S103, a resource allocation strategy is determined based on the first partition identifier and the second partition identifier.
[0068] Different from determining the resource allocation strategy based on only the unique partition identifier of the target object, the application determines the resource allocation strategy in combination with the first partition identifier of the target object and the second partition identifier related to the memory space address where the physical address to be accessed by the access request is located, so if the memory space addresses where the physical addresses to be accessed by different access requests initiated by the same target object belong to are different, the determined resource allocation strategies will also be different.
[0069] Based on this, it can be known that the application actually further subdivides different resource allocation strategies according to the memory space addresses where the physical addresses accessed by the access requests initiated by the same target object belong to, so as to realize the partition management of the cache resources according to the address segments for the same target object, and realize more fine-grained resource partition management.
[0070] It can be understood that if the partition management of the cache resources is based on only the first partition identifier of the target object, the target object only corresponds to one kind of resource allocation strategy. However, the access requests initiated by the same process or hardware module at different times have different requirements for the use of cache resources, and if the cache resources are allocated according to the same resource allocation strategy, the limited cache resources may not be used efficiently.
[0071] The application considers that the scenarios in which the target object initiates access requests are different, the memory space addresses where the data accessed are also different, and the required resource allocation strategies are also different, and for the same target object, multiple address segments (i.e. different memory space addresses) each corresponding to a resource allocation strategy can be configured, different resource allocation strategies are matched according to the memory space addresses and the memory space sizes corresponding to the memory space addresses, so as to meet the needs of different access scenarios.
[0072] For example, assuming that five address segments each corresponding to a resource allocation strategy are configured for the target object, then assuming that the target object may initiate 100 access requests, the 100 access requests will also correspond to the five address segments, that is, five different resource allocation strategies, so that the resource allocation strategies can be more reasonably configured according to the access needs, and the cache resources can be naturally allocated more reasonably.
[0073] In the application, the specific implementation of determining the resource allocation strategy can be various. For example, the combinations of different first partition identifiers and second partition identifiers each corresponding to a resource allocation strategy can be pre-configured, and on this basis, after the first partition identifier and the second partition identifier are determined, the resource allocation strategy corresponding to the first partition identifier and the second partition identifier can be queried.
[0074] For example, the first partition identifier and the second partition identifier can be integrated into a third partition identifier, and a resource allocation strategy corresponding to the third partition identifier is determined. For example, based on the candidate resource allocation strategies corresponding to different partition identifiers configured, the resource allocation strategy corresponding to the third partition identifier is queried.
[0075] The third partition identifier can be obtained by combining the first partition identifier and the second partition identifier, for example, the first partition identifier is in front and the second partition identifier is behind.
[0076] The third partition identifier can also be obtained by performing logical operation on the first partition identifier and the second partition identifier. Of course, the third partition identifier can also be obtained by other implementation manners, which are not limited herein.
[0077] In S104, the cache space corresponding to the target object is allocated according to the resource allocation strategy.
[0078] The cache space belongs to the storage space in the cache memory.
[0079] In the present application, the resource allocation strategy at least includes the size of the allocatable cache space, and can also include other cache resource characteristics such as the available bandwidth of the cache space. Based on this, the cache space allocated for the target object is the same as the space size configured in the resource allocation strategy, and the characteristics such as the available bandwidth corresponding to the cache space also match the related characteristics configured in the resource allocation strategy.
[0080] In the present application, the resource allocation strategy can be set according to actual needs, which are not limited herein.
[0081] For example, in a possible implementation manner, the resource allocation strategy can be pre-configured. For each object capable of initiating an access request, based on each memory space address to which the physical address accessed by the access request initiated by the object can belong, combined with the type of the object, the space size and the starting address corresponding to the memory space address, and the demand type of the access request accessing the memory space address, one or more of the information, the resource allocation strategy corresponding to the object and the memory space address is determined.
[0082] Since each object is uniquely identified by a corresponding first partition identifier, and each memory space address is identified by a corresponding second partition identifier, the resource allocation strategy corresponding to the object and the memory space address, that is, the resource allocation strategy corresponding to the first partition identifier of the object and the second partition identifier of the memory space address.
[0083] For example, the resource allocation strategy corresponding to the first partition identifier and the second partition identifier can be determined by the following steps:
[0084] If it is determined that the accesses corresponding to certain physical addresses based on the type of data resource pointed by the physical addresses are generally single accesses or single continuous address accesses, it means that the probability of receiving an access request for the physical addresses again after receiving an access request for the physical addresses is small, and there is no need to allocate too much cache space in the cache memory to store the data required for processing the access request. On this basis, when configuring the resource allocation strategy based on the object and the memory space addresses corresponding to the physical addresses, the size of the allocatable cache space can be configured to be relatively small, or even zero.
[0085] Correspondingly, if it is determined that the object has a high access frequency for certain memory space addresses including physical addresses, in the resource allocation strategy corresponding to the object and the memory space addresses, the allocatable cache space can be configured to be relatively large.
[0086] If certain access requests initiated by an object are not sensitive to access delay and bandwidth, etc., even if the associated data required for processing the access request is not cached in the cache memory, it will not affect the processing effect of the access request. In this case, for the object, when configuring the resource allocation strategy for the memory space addresses corresponding to the access requests, the size of the cache space can be configured to be zero, or the allocatable cache space is relatively small and the access bandwidth is relatively low.
[0087] Correspondingly, if certain access requests initiated by an object are sensitive to access delay or bandwidth, for the object, when configuring the resource allocation strategy for the memory space addresses corresponding to the access requests, the cache space can be configured to be relatively large, and the access bandwidth can be configured to be relatively high.
[0088] It should be noted that for the same target object, the access requests initiated by the target object are different, the memory space addresses where the physical addresses accessed by the access requests are located, and the access requirements of the access requests are also different. Therefore, the size of the allocatable cache space and the bandwidth in the resource allocation strategies corresponding to different address segments configured for the target object in combination with the access requirements of the access requests initiated by the target object can also be different, which can be set according to actual needs, and is not limited.
[0089] As known from the foregoing, the size of the allocatable cache space in the resource allocation strategy can be 0, in which case the cache space allocated to the target object based on the resource allocation strategy is zero, that is, no cache space needs to be allocated to the target object, and naturally there is no need to perform the subsequent step S105 of caching associated data.
[0090] S105, cache the associated data required for processing the access request in the cache space.
[0091] The associated data required for processing the access request can be data required to be acquired for processing the access request and needs to be cached in the cache memory.
[0092] For example, the associated data can be address mapping information required for address mapping of the access request, in which case the address mapping information can be cached in the cache space of the TLB module in the memory management unit.
[0093] For another example, the associated data can be data content required to be accessed or operated by the access request, in which case the data content can be cached in the cache space of the SLC storage module.
[0094] Of course, the associated data can also have other possibilities without limitation.
[0095] From the above, in the present application, in response to the access request initiated by the target object satisfying the first condition, the present application not only determines the first partition identifier of the target object, but also determines the second partition identifier based on the physical address to be accessed by the access request, and determines the resource allocation strategy by comprehensively considering the first partition identifier and the second partition identifier. Since the second partition identifier is related to the memory space address including the physical address to be accessed by the access request, if the physical addresses to be accessed by different access requests initiated by the target object belong to different memory space addresses, the determined resource allocation strategies will also be different, which realizes further subdividing different resource allocation strategies according to different memory space addresses for the same target object, so as to be able to combine the access demand of the target object to more granularly manage the partition of the cache resource, and naturally be able to more reasonably allocate the cache resource and reduce the waste of the cache resource.
[0096] It can be understood that the scheme of the present application can be applied to cache resource management of various cache memories in electronic devices. When the cache memories are different, the specific implementation of determining the resource allocation strategy and caching the associated data corresponding to the access request in the cache memory will also be different. The following will be introduced in combination with several possible cases.
[0097] In the first possible case, the obtained access request can include a target virtual address corresponding to the storage space to be accessed. In this case, the first partition identifier corresponding to the target object can be referred to the previous related introduction, and will not be repeated. Determining the second partition identifier can include: based on the target virtual address, obtaining an address mapping relationship group to obtain the second partition identifier recorded in the address mapping relationship group.
[0098] The address mapping group may include at least one mapping relationship, and each mapping relationship includes corresponding virtual addresses and physical addresses. Specifically, the address mapping group must include at least the mapping relationship between the target virtual address and the physical address.
[0099] In this application, a partition identifier is added to each address mapping group. Based on this, after obtaining the address mapping group containing the target virtual address, the partition identifier recorded in the address mapping group can be obtained. For ease of distinction, the partition identifier in the address mapping group is referred to as the second partition identifier. The second partition identifier in the address mapping group is the second partition identifier corresponding to the physical address to be accessed by the access request.
[0100] The second partition identifier is used to identify a segment of memory space represented by each physical address in the address mapping group, that is, to identify the memory space address including the physical address to be accessed by the access request.
[0101] The address mapping relationship group can be obtained from the internal memory of the electronic device. For example, if it is necessary to obtain the address mapping relationship using the first cache module where the first cache memory is located, and the cache memory storing the associated data (i.e., the cache memory that needs to be managed by cache resource partitioning) can be the first cache memory or a second cache memory other than the first cache memory, then if the address mapping relationship group is not stored in the first cache memory, the address mapping relationship needs to be obtained from the internal memory of the electronic device.
[0102] Obtaining the address mapping relationship group can also be obtaining the address mapping relationship group cached in the first cache memory. For example, if the first cache memory stores the address mapping relationship group corresponding to the target virtual address, and it is necessary to partition the cache resources of the second cache memory, then it is necessary to obtain the address mapping relationship group cached in the first cache memory to obtain the second partition identifier in the address mapping relationship group. Then, based on the second partition identifier and the first partition identifier of the target object, the appropriate resource allocation strategy for allocating cache space for the target object from the second cache memory can be determined.
[0103] The internal memory of this electronic device can be Double Data Rate (DDR) dynamic synchronous random access memory (DDR memory) or other memory memory, without restriction.
[0104] In this first possible scenario, the access request satisfying the first condition may include: the associated data required to process the access request cannot be found in the first cache memory based on the target virtual address.
[0105] The following is an example of determining the first partition identifier and the second partition identifier and allocating the cache space for the target object are both performed by the first cache module where the first cache memory is located, in combination with Figure 2 For example, the case of using the associated data as the address mapping relationship group is illustrated. In this application, the first cache module where the cache memory is located can include the first control unit in addition to the first cache memory. For example, the first cache memory can be a cache memory in a memory management unit, and the first cache module where the first cache memory is located belongs to the memory management unit. The first cache module can include the control unit in the memory management unit and the first cache memory. For example, the first cache memory can be a TLB module.
[0106] For example, Figure 2 Another implementation flowchart of the cache resource usage control method provided by the embodiments of the application is shown. The method of the embodiments can include:
[0107] S201, obtaining an access request initiated by a target object in an electronic device.
[0108] The access request includes a target virtual address corresponding to a storage space to be accessed. The storage space is a storage space pointed to by a physical address to be accessed by the access request. The storage space belongs to a memory storage space.
[0109] S202, if the address mapping relationship group corresponding to the target virtual address cannot be found in the first cache memory, determining a first partition identifier corresponding to the target object according to the partition identifiers corresponding to different objects.
[0110] For example, the first cache memory is a TLB module in a memory management unit. The first partition identifiers of different objects can be configured in the configuration space recognizable by the first control unit corresponding to the first cache memory. The first control unit can determine the first partition identifier corresponding to the target object from the configured first partition identifiers. For example, the first cache memory is a TLB module in a memory management unit. The first partition identifiers of different objects can be configured in the configuration space recognizable by the first control unit corresponding to the first cache memory. The first control unit can determine the first partition identifier corresponding to the target object from the configured first partition identifiers.
[0111] For ease of understanding, this embodiment is illustrated by an example of the access request meeting the first condition. However, the embodiments are also applicable to the other cases mentioned above, without limitation.
[0112] S203, obtaining an address mapping relationship group from the internal memory of the electronic device based on the target virtual address, and obtaining the second partition identifier recorded in the address mapping relationship group.
[0113] The address mapping relationship group at least includes a mapping relationship between the target virtual address and a physical address, and the second partition identifier is used to identify a memory space represented by each physical address in the address mapping relationship group.
[0114] It can be understood that only the address mapping relationship group corresponding to the target virtual address can be obtained in the present application. In order to enable the corresponding address mapping relationship group to be found in the first cache memory after a subsequent access request is received, and to reduce the number of accesses to the internal memory of the electronic device, the present application can also include a plurality of mapping relationship groups including the address mapping relationship group corresponding to the target virtual object. For example, the plurality of mapping relationship groups can include the address mapping relationship group corresponding to the target virtual object, and at least one address mapping relationship group adjacent to the address mapping relationship group corresponding to the target virtual address.
[0115] S204, determining a first resource allocation strategy corresponding to the first cache memory based on the first partition identifier and the second partition identifier.
[0116] The first resource allocation strategy is a resource allocation strategy for allocating cache resources in the first cache memory, which is determined based on the first partition identifier and the second partition identifier.
[0117] For example, the first partition identifier and the second partition identifier are integrated into a third partition identifier, and a resource allocation strategy corresponding to the third partition identifier is determined as the first resource allocation strategy corresponding to the first cache memory.
[0118] It can be understood that the objects that can initiate access requests in the electronic device are limited, and the number of memory space addresses (i.e., address segments) that can be divided is also limited, so the number of third partition identifiers that can be configured is also limited. Based on this, the resource allocation strategy corresponding to each third partition identifier can be determined in advance according to the type of each object and the access demand characteristics of each memory space address, and the resource allocation strategy corresponding to each third partition identifier can be configured in the first control unit corresponding to the first cache memory.
[0119] For example, the first cache memory is a TLB module in a memory management unit, and the memory management unit can configure the resource allocation strategy corresponding to each third partition identifier in a memory partitioning and monitoring (MPAM) control unit.
[0120] S205, allocating a corresponding cache space for the target object in the first cache memory according to the first resource allocation strategy.
[0121] To facilitate understanding, let's take the first cache memory as an example of the cache memory in the memory management unit:
[0122] The memory management unit can be an Input / Output Memory Management Unit (IOMMU), or other types of memory management units, without restriction.
[0123] The first cache memory of the memory management unit can be a TLB module for storing address mapping relationships. After the memory management unit receives an access request initiated by the target object, the memory management unit (such as the control unit in the memory management unit) queries the TLB module to see if it caches an address mapping relationship group containing the target virtual address based on the target virtual address carried in the access request. If there is no address mapping relationship group corresponding to the target virtual address in the TLB, the memory management unit will retrieve the address mapping relationship group corresponding to the target virtual address from the internal memory of the electronic device, such as DDR memory, and retrieve the second partition identifier recorded in the address mapping relationship group.
[0124] For example, page tables can be used in the internal memory of electronic devices to store the mapping relationship between different virtual addresses and physical addresses. Each page table can include at least one page table descriptor, and each page table descriptor can store at least one set of virtual address to physical address mapping relationships. Therefore, each page table descriptor can be regarded as a group of address mapping relationships. In this application, a second partition identifier can be added to the page table descriptor. For example, the page table descriptor can record page-based hardware attribute (PBHA) values. The PBHA values are different in different page table descriptors, so the PBHA values can be used as the second partition identifier.
[0125] like Figure 3 This diagram illustrates an example implementation of how the memory management unit determines resource allocation strategies.
[0126] exist Figure 3 Taking DDR memory as an example of the internal memory of electronic devices, it can be seen that DDR memory caches multiple page tables, and each page table includes multiple page table descriptors, such as... Figure 3 Each row in the page table is a page table descriptor. Figure 3 As can be seen, each page table descriptor records at least one mapping relationship between a virtual address and a physical address. Furthermore, each page table descriptor is populated with a PBHA value. Of course, other information can also be recorded in this page table descriptor; there are no restrictions on this.
[0127] Depend on Figure 3As can be seen, multiple object partition identifiers (PartIDs) can be pre-configured in the memory management unit. The Part ID of an object is also the first partition identifier of the object. After the memory management unit receives an access request initiated by the target object, it can query the Part ID of the target object.
[0128] exist Figure 3 The example given is that the TLB module does not contain a page table descriptor corresponding to the target virtual address carried in the access request. Based on this, the memory management unit will obtain at least the page table descriptor corresponding to the target virtual address from the electronic device's DDR memory, thereby obtaining the PBHA value recorded in that page table descriptor.
[0129] Based on this, the memory management unit can integrate the Part ID of the target object and the PBHA value in the page table descriptor corresponding to the target virtual address into the final partition identifier, namely the third partition identifier.
[0130] Depend on Figure 3 It can also be seen that, for each object that may initiate an access request and the memory space address corresponding to each page table descriptor, the memory management unit can determine the resource allocation strategy corresponding to the Part ID and different PBHA values of different objects through the policy evaluation unit. Since different Part IDs and different PBHA values of different objects correspond to different third partition identifiers, the memory management unit will determine the resource allocation strategy corresponding to different third partition identifiers through the policy evaluation unit.
[0131] The policy evaluation unit can pre-determine the resource allocation policy corresponding to the object and the PBHA value in the corresponding page table descriptor by combining one or more of the following information: the starting address of the memory space corresponding to the page table descriptor, the size of the space, and the possible access modes of the memory space.
[0132] For example, for each object, the memory space address to which the physical address that the object may access belongs is determined. Combined with the size of the memory space corresponding to that address, the number of cache blocks in the TLB module required for the object to reliably access that memory space and effectively avoid TLB flushes is determined. Then, for the third partition identifier corresponding to the object's PartID and the PBHA value corresponding to that memory space address, the corresponding number of cache blocks are configured as available cache resources in the resource allocation strategy. The size of each cache block in the TLB module can be set according to actual needs; for example, the size of each cache block can be the same as the space required by a page table descriptor.
[0133] For example, for each object, if the access request initiated by the object for a certain memory space address can only be a single access, the number of cache blocks in the T LB module that can be allocated can be configured as zero or relatively small in the resource allocation strategy for the third partition identifier corresponding to the object and the memory space address.
[0134] For example, for each object, if the access request initiated by the object for a certain memory space address is sensitive to access delay and bandwidth, the number of cache blocks in the T LB module that can be allocated can be configured as relatively large and the access bandwidth can be configured as relatively large in the resource allocation strategy for the third partition identifier corresponding to the object and the memory space address.
[0135] For convenience of distinction, the pre-configured resource allocation strategies can be referred to as candidate resource allocation strategies. Based on this, the memory management unit can query the resource allocation strategy corresponding to the currently determined third partition identifier based on the at least one configured candidate resource allocation strategy.
[0136] It can be understood that the memory management unit can integrate the Part ID of the target object and the PBHA value in the page table descriptor into the third partition identifier in multiple ways. In one possible implementation, the memory management unit can further include a logic unit and a strategy management unit. The memory management unit can integrate the Part ID of the target object and the corresponding PBHA value into the third partition identifier by means of the logic unit. Figure 4 An implementation example of the memory management unit determining the resource control strategy and allocating the cache space for the target object is shown.
[0137] As can be seen from Figure 4 It can be seen from that the logic unit of the memory management unit is provided with a strategy starting switch 401. The strategy starting switch 401 can be used to control whether the logic unit performs resource partition management on the T LB module based on only the first partition identifier of the target object or based on the first partition identifier of the target object and the second partition identifier corresponding to the access request.
[0138] If the strategy starting switch is turned on, it indicates that the resource partition management on the T LB module needs to be based on the first partition identifier of the target object and the second partition identifier corresponding to the access request. On this basis, the logic unit obtains the partition identifier (Part ID) of the target object and the second partition identifier 1 (PBHA1) corresponding to the target virtual address of an access request from the control unit of the memory management unit. Figure 4 The logic unit integrates the Part ID and the second partition identifier 1 into the third partition identifier 1.
[0139] Meanwhile, in order to facilitate understanding of the identification integration operation performed by the logic unit for different access requests, in Figure 4 , it is also shown that the logic unit obtains the Part ID of the target object and the second partition identification 2 corresponding to the target virtual address of another access request from the control unit (PBHA2 in Figure 4 ). In this case, the logic unit integrates the Part ID of the target object and the second partition identification 2 into a third partition identification 2. However, it can be understood that Figure 4 , the two logic units can be the same.
[0140] For example, taking the first partition identification of the target object occupying bit and the PBHA value corresponding to the access request occupying 4 bits as an example, the operation performed by the logic unit can be represented by the following formula:
[0141]
[0142] wherein, represents the identification integration result output by the logic unit. Among them, , represents not enabled, that is, not integrating the first partition identification and the second partition identification, so as to determine the resource allocation strategy only by the first partition identification; represents enabled, that is, the third partition identification needs to be integrated based on the first partition identification and the second partition identification, so as to determine the resource allocation strategy based on the third partition identification.
[0143] is an integer greater than 1, and the specific value can be set according to actual needs.
[0144] In the above formula, represents the first partition identification, which can also be regarded as the partition identifier of the target object, represents that the first partition identification (from the 0th to the bit) is left shifted by 4 bits. represents the PBHA value as 4-bit data, that is, the PBHA value occupies 4 bits from the 0th bit to the 3rd bit. represents that the first partition identification is left shifted by four bits, and the PBHA value is added to the back of the first partition identification to obtain the third partition identification.
[0145] Of course, the above is an example taking the PBHA value occupying four bits, but the present application does not limit the number of bits occupied by the PBHA value. For example, in actual application, in order to realize more fine-grained partition management, the number of bits occupied by the PBHA value can also be increased.
[0146] After the memory management unit integrates the third partition identifier through the logical unit, the resource allocation strategy corresponding to the third partition identifier can be queried from the strategy management unit, and the resource allocation strategy corresponding to the third partition identifier is obtained from the strategy management unit. Figure 4 It can be seen that the resource allocation strategies corresponding to different third partition identifiers are different. Correspondingly, the number of cache blocks allocated from the TLB based on different resource allocation strategies is also different, and the cache blocks allocated based on different resource allocation strategies are different in the Figure 4 In the figure, white and gray long blocks respectively represent cache blocks allocated based on two different resource allocation strategies.
[0147] In some embodiments, based on the ARM (Advanced RISC Machine) architecture, the strategy management unit can store and query the resource allocation strategy corresponding to each third partition identifier based on the MPAM control unit.
[0148] S206, cache the address mapping relationship group in the cache space.
[0149] For example, still taking the first cache memory as the memory management unit as an example, since the size of the allocatable cache space and the bandwidth and other resource characteristics can be set in the first resource allocation strategy, the memory management unit determines the number of cache blocks and the access bandwidth of the cache blocks in the TLB module that need to be allocated to the target object based on the first resource allocation strategy, and then caches the address mapping relationship group in the allocated cache block according to the access bandwidth corresponding to the cache block.
[0150] It can be understood that if a plurality of address mapping relationship groups (such as page table descriptors) are obtained from the internal memory such as DDR, and the cache space allocated based on the first resource allocation strategy is not enough to store all the plurality of address mapping relationship groups, only part of the plurality of address mapping relationship groups needs to be stored.
[0151] It can be understood that in the embodiment corresponding to the above first possible case, the application can also obtain the associated data required for processing the access request from the cache space corresponding to the target object in response to the access request meeting the second condition.
[0152] In the case where the access request meets the second condition, the cache space corresponding to the target object is allocated based on the resource allocation strategies corresponding to the first partition identifier and the second partition identifier of the target object. The implementation of obtaining the cache space corresponding to the target object can be referred to the above related introduction, and will not be repeated here.
[0153] Wherein, the access request meeting the second condition can be that there is associated data required for processing the access request in the cache memory.
[0154] As described above, in the case that the first cache memory determines the first partition identifier and the second partition identifier, and allocates the cache space for the target object, the access request satisfying the second condition can exist the address mapping relationship group corresponding to the target virtual address in the first cache memory. In this case, in response to the access request satisfying the second condition, the address mapping relationship group corresponding to the target virtual address can be obtained from the cache space allocated for the target object in the first cache memory, so that the address mapping relationship group corresponding to the target virtual address is used to perform address mapping on the access request, and the specific process is not described herein.
[0155] It should be noted that the above is an example of taking the address mapping relationship group corresponding to the target virtual address of the associated data required for processing the access request as an example. However, if the first cache module where the first cache memory is located only determines the first partition identifier and the second partition identifier, and determines the resource allocation strategy corresponding to the second cache memory through the second cache module where the second cache memory is located, after the second cache module determines the cache space to be allocated to the target object in the second cache memory, the data content to be operated by the access request can also be cached in the cache space.
[0156] The second possible implementation of determining the resource allocation strategy and caching the associated data corresponding to the access request will be described below.
[0157] In the second possible implementation, the access request initiated by the target object can be obtained by the second cache module where the second cache memory is located. The second cache module can include the second cache memory and a second control unit. For example, if the second cache memory belongs to an SLC storage module, the second cache module where the second cache memory is located can include an SLC memory and a control unit in the SLC storage module, and correspondingly, the second cache memory can be an SLC memory. Of course, the second cache memory can also belong to other cache modules, which is not limited.
[0158] Correspondingly, based on the first partition identifier and the second partition identifier, the second resource allocation strategy of the second cache memory for allocating cache resources for the target object can be determined, and the corresponding cache space for the target object in the second cache memory can be allocated according to the second resource allocation strategy.
[0159] The second cache memory is different from the first cache memory, so the associated data required for processing the access request stored in the second cache memory will also be different. In an implementation, the cache space allocated to the target object in the second cache memory can be determined, and the data content to be operated by the access request can be cached in the cache space.
[0160] It can be understood that the access request in the electronic device needs to be processed by the memory management unit for address mapping first, and then sent to the cache memory in other cache modules. Based on this, the first cache memory is taken as the cache memory in the memory management unit, and a process of determining a resource allocation strategy for the cache module where the second cache memory is located and caching the data content to be operated by the access request is introduced as an example of an implementation manner.
[0161] As Figure 5 , another flowchart of a cache resource usage control method provided by the application is shown. The method of the embodiment can include:
[0162] S501, obtaining an access request initiated by a target object in an electronic device.
[0163] In this embodiment, the access request initiated by the target object can be obtained by the second cache module where the second cache memory is located, and the access request can be transmitted to the second cache module by the memory management unit where the first cache memory is located. Before the memory management unit transmits the access request to the second cache module, the memory management unit can map the target virtual address in the access request to a physical address according to the Figure 2 The operation of the related embodiments determines the first partition identifier of the target object and the second partition identifier corresponding to the target virtual address in the access request.
[0164] Based on this, the first partition identifier and the second partition identifier can be carried in the access request.
[0165] Of course, the memory management unit can also map the target virtual address in the access request to a physical address, so the access request obtained by the second cache module also carries the physical address corresponding to the target virtual address.
[0166] S502, in response to the access request satisfying the first condition, obtaining the first partition identifier and the second partition identifier of the target object carried in the access request.
[0167] As described above, the first partition identifier and the second partition identifier are determined by the memory management unit, and the second partition identifier is determined based on the physical address mapped by the memory management unit to the target virtual address in the access request.
[0168] In a possible implementation, the first condition is met when the data content to be operated by the access request is not found in the second cache memory. For example, the access request is a read request, and the first condition is met when the first data to be read by the read request is not found in the second cache memory. If the access request is a write request, the first condition is met when the second data to be operated by the write request is not found in the second cache memory. The write request can be used to request modification of data, deletion of data, or writing of data, and therefore, the second data to be operated by the write request can be data to be modified, deleted, or written by the write request.
[0169] In S503, a second resource allocation strategy corresponding to the second cache memory is determined based on the first partition identifier and the second partition identifier.
[0170] The second resource allocation strategy is a resource allocation strategy determined based on the first partition identifier and the second partition identifier.
[0171] For example, the first partition identifier and the second partition identifier are integrated into a third partition identifier, and a resource allocation strategy corresponding to the third partition identifier is determined as the second resource allocation strategy based on a correspondence between different partition identifiers and candidate resource allocation strategies configured in the second cache module.
[0172] In S504, a corresponding cache space is allocated to the target object in the second cache memory according to the second resource allocation strategy.
[0173] As described in the foregoing embodiments, the second resource allocation strategy can specify the size of the allocatable cache space and the available bandwidth, and accordingly, the cache space to be allocated to the target object in the second cache memory can be determined based on the second resource allocation strategy, and the cache space has cache resource characteristics, such as bandwidth, that match the second resource allocation strategy.
[0174] In S505, the data content to be operated by the access request is cached in the cache space.
[0175] For example, if the access request is a read request, the first data to be read by the read request is obtained from an internal storage of the electronic device, and the first data is cached in the cache space. If the access request is a write request, the second data to be operated by the write request is cached in the cache space.
[0176] It can be understood that in the embodiments, in response to the access request meeting the second condition, the data content in the cache space allocated to the target object in the second cache memory can be processed based on the access request. The second condition is met when the second cache memory has the data content to be operated by the access request.
[0177] For example, if the access request is a read request, the first data to be read by the read request can be obtained from the cache space in the second cache memory that has been allocated to the target object; if the access request is a write request, a write operation is performed on the second data cached in the cache space in the second cache memory based on the write request.
[0178] For ease of understanding, the first cache memory is taken as the TLB module in the memory management unit, and the second cache memory is taken as the SLC memory in the SLC storage module. For ease of description and understanding, the first partition identifier is still taken as the Part ID of the target object, and the second partition identifier is taken as the PBHA value corresponding to the physical address to be accessed by the access request. For example, Figure 6 , a schematic diagram of an implementation framework of the access request initiated by the target object being transmitted to the SLC storage module through the memory management unit, and the SLC storage module performing resource partition management based on the access request is shown.
[0179] In Figure 6 , after the memory management unit obtains the access request initiated by the target object, if the page table descriptor corresponding to the target virtual address in the access request does not exist in the TLB module of the memory management unit, the memory management unit can obtain the page table descriptor from the DDR memory according to the related introduction in the foregoing Figure 3 and Figure 4 , and cache the page table descriptor in the TLB module, and details are not repeated. In this case, after obtaining the page table descriptor, the memory management unit can certainly determine the Part ID of the target object and the PBHA value in the page table descriptor, and the memory management unit will transmit the access request carrying the Part ID of the target object and the PBHA value to the SLC storage module.
[0180] If the TLB module of the memory management unit caches the page table descriptor corresponding to the target virtual address in the access request, the memory management unit does not need to obtain the page table descriptor from the DDR memory of the electronic device, and naturally does not involve the operation of determining the resource allocation strategy corresponding to the Part ID and the PBHA value and caching the page table descriptor in the TLB module. In this case, the memory management unit can directly determine the Part ID of the target device, and query the PBHA value from the page table descriptor, and then transmit the access request carrying the Part ID of the target object and the PBHA value to the SLC storage module.
[0181] On the basis of the above, Figure 6It can be seen that the SLC storage module can integrate the Part ID of the target object and the PBHA value carried in the access request through the logical unit in the SLC storage module to obtain the third partition identifier of the target object. The operation performed by the logical unit in the SLC storage module is similar to the operation performed by the logical unit in the memory management unit, and specific operations can be referred to the related description in the foregoing Figure 4 , and will not be described herein.
[0182] Of course, Figure 6 , in actual application, a logical unit connected to the SLC storage module can also be arranged outside the SLC storage module, and the logical unit can transmit the integrated third partition identifier to the SLC storage module.
[0183] After the third partition identifier of the target object is integrated through the logical unit corresponding to the SLC storage module, the SLC storage module can query the resource allocation strategy corresponding to the third partition identifier from the policy management unit corresponding to the SLC storage module. Similar to the memory management unit, the policy management unit in the SLC storage module can also be the MPAM control unit.
[0184] It can be understood that the resource allocation strategy corresponding to the third partition identifier in the policy management unit of the SLC storage module is different from the resource allocation strategy configured for the third partition identifier in the memory management unit.
[0185] In the SLC storage module, the resource allocation strategy corresponding to the Part ID of the target object and the PBHA value can be determined according to one or more of the start address, the space size, and the possible access mode of the memory space corresponding to the page table descriptor of the PBHA value.
[0186] For example, for each object, the memory space address to which the physical address accessed by the object belongs is determined, and the memory space size corresponding to the memory space address is combined to determine the size of the SLC storage space required to be allocated to the object to meet the access demand of the object to the memory space corresponding to the memory space address, and the corresponding size of the allocable storage space is configured in the resource allocation strategy.
[0187] For another example, if the access request initiated by the object to a certain memory space address is insensitive to access delay and bandwidth, the third partition identifier corresponding to the object and the memory space address can be configured with a resource allocation strategy in the policy management unit of the SLC storage module, and less storage space can be configured in the resource allocation strategy, or even the storage space to be allocated in the SLC storage can be configured to be zero.
[0188] In another aspect, the present application also provides an electronic device. As shown in Figure 7 , a schematic diagram of a component structure of the electronic device provided by the present application is shown.
[0189] As can be seen from Figure 7 , the electronic device comprises a cache module 71 and a policy control module 72 in communication connection with the cache module 71.
[0190] The cache module 71 is configured to obtain an access request initiated by a target object in the electronic device, and in response to the access request satisfying a first condition, determine a first partition identifier of the target object and a second partition identifier corresponding to a physical address to be accessed by the access request, the second partition address segment identifier being related to a memory space address including the physical address.
[0191] The policy control module 72 is configured to determine a resource allocation policy based on the first partition identifier and the second partition identifier.
[0192] The cache module 71 is further configured to allocate a corresponding cache space to the target object according to the resource allocation policy, and cache associated data required for processing the access request in the cache space.
[0193] In a possible implementation, the cache module can include a control unit and a cache memory for storing data. As shown in Figure 8 , another schematic diagram of a component structure of the electronic device provided by the present application is shown.
[0194] In Figure 8 , the cache module 71 can include a control unit 711 and a cache memory 712 in communication connection, and the control unit 711 is also in communication connection with the policy control module 72.
[0195] On this basis, the control unit 711 is configured to obtain an access request initiated by a target object in the electronic device, and in response to the access request satisfying a first condition, determine a first partition identifier of the target object and a second partition identifier corresponding to a physical address to be accessed by the access request, and allocate a corresponding cache space to the target object according to the resource allocation policy.
[0196] Correspondingly, the cache memory 712 is configured to cache associated data required for processing the access request in the cache space.
[0197] As shown, the electronic device comprises a memory management unit, the memory management unit comprises the cache module and the policy control module, and the control unit and the cache memory in the cache module are respectively a control unit and a TLB module in the memory management unit.
[0198] For example, the electronic device includes an SLC storage module, the SLC storage module includes the cache module and the policy control module, and the control unit and the memory in the cache module are respectively a control unit and an SLC memory in the SLC storage module.
[0199] Further, in any one of the above embodiments of the electronic device, the policy control module can include a logic unit and a policy management unit.
[0200] For example, in the above embodiment of the electronic device, the policy control module includes a logic unit and a policy management unit. Figure 8 For example, in the above embodiment of the electronic device, the policy control module includes a logic unit and a policy management unit. Figure 8 For example, in the above embodiment of the electronic device, the policy control module includes a logic unit and a policy management unit.
[0201] The logic unit is configured to integrate the first partition identifier and the second partition identifier into a third partition identifier.
[0202] The policy management unit is configured to store at least one candidate resource allocation policy, and determine a resource allocation policy corresponding to the third partition identifier from the at least one candidate resource allocation policy.
[0203] In any one of the above embodiments of the electronic device, the access request obtained by the cache module includes a target virtual address of a storage space to be accessed.
[0204] Correspondingly, when the cache module determines the first partition identifier of the target object and the second partition identifier corresponding to the physical address to be accessed in the access request, the cache module specifically:
[0205] According to the partition identifier corresponding to different objects, the first partition identifier corresponding to the target object is determined.
[0206] Based on the target virtual address, an address mapping relationship group is obtained, and a second partition identifier recorded in the address mapping relationship group is obtained, the address mapping relationship group at least includes a mapping relationship between the target virtual address and a physical address, and the second partition identifier is used to identify a memory space represented by each physical address in the address mapping relationship group.
[0207] Further, the cache module includes a first control unit and a first cache memory having a communication connection.
[0208] The policy control module includes a first policy control module, and the first policy control module has a communication connection with the first control unit.
[0209] The first control unit is configured to obtain an access request initiated by a target object in the electronic device, and determine a first partition identifier corresponding to the target object according to a partition identifier corresponding to a different object in response to the access request satisfying a first condition.
[0210] The first policy control module is configured to determine a first resource allocation policy corresponding to the first cache memory based on the first partition identifier and the second partition identifier.
[0211] The first control unit is further configured to allocate a corresponding cache space for the target object in the first cache memory according to the first resource allocation policy.
[0212] The first cache memory is configured to cache the address mapping relationship group in the cache space.
[0213] In another possible implementation, the access request satisfying the first condition includes that associated data required for processing the access request cannot be found from the first cache memory according to the target virtual address.
[0214] The first control unit is further configured to obtain the associated data required for processing the access request from the cache space corresponding to the target object in response to the access request satisfying a second condition, the cache space being allocated based on a resource allocation policy corresponding to the first partition identifier and the second partition identifier of the target object.
[0215] In another possible implementation, the cache module includes a second control unit and a second cache memory that are communicatively connected. The policy control module includes a second policy control module that is communicatively connected to the second control module.
[0216] The second control unit is configured to obtain an access request initiated by a target object in the electronic device, and determine a first partition identifier of the target object and a second partition identifier corresponding to a physical address to be accessed by the access request in response to the access request satisfying a first condition.
[0217] The second policy control module is configured to determine a second resource allocation policy corresponding to the second cache memory based on the first partition identifier and the second partition identifier.
[0218] The second control unit is further configured to allocate a corresponding cache space for the target object in the second cache memory according to the second resource allocation policy.
[0219] The second cache memory is configured to cache the data content to be operated by the access request in the cache space.
[0220] In a further possible implementation, the second control unit, when determining the first partition identifier of the target object and the second partition identifier corresponding to the physical address to be accessed by the access request, is specifically configured to: obtain the first partition identifier and the second partition identifier of the target object carried in the access request, the first partition identifier and the second partition identifier being determined by a memory management unit, and the second partition identifier being determined by the memory management unit based on the physical address mapped by the target virtual address in the access request, wherein the memory management unit comprises the first cache memory.
[0221] In a further possible implementation, the second cache memory, when caching the data content to be operated by the access request in the cache space, is specifically configured to: if the access request is a read request, obtain first data to be read by the read request from an internal memory of the electronic device, and cache the first data in the cache space; and / or if the access request is a write request, cache second data to be operated by the write request in the cache space.
[0222] The embodiment of the present application further provides a computer program product, which comprises computer readable instructions, and when the computer readable instructions run on an electronic device, the electronic device can implement any one of the cache resource use control methods provided in the embodiments of the present application.
[0223] The embodiment of the present application further provides a computer readable storage medium, which carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement any one of the cache resource use control methods provided in the embodiments of the present application.
[0224] In addition, it should be noted that the apparatus embodiments described above are merely schematic, wherein the units described as separate components can or can not be physically separated, and the components displayed as units can or can not be physical units, that is, they can be located in one place, or can be distributed on multiple network units. According to actual needs, part or all of the modules can be selected to achieve the purpose of the embodiments. In addition, in the apparatus embodiments provided in the present application, the connection relationship between the modules indicates that there is a communication connection between them, which can be implemented as one or more communication buses or signal lines.
[0225] Those skilled in the art can clearly understand that the application can be implemented by means of software plus necessary universal hardware, and of course can also be implemented by means of dedicated hardware including special integrated circuit, special CPU, special memory, special component, etc. Generally, any function completed by computer program can be easily implemented by corresponding hardware, and the specific hardware structure for implementing the same function can also be various, such as analog circuit, digital circuit or special circuit, etc. However, for the application, software program implementation is a better embodiment. Based on such understanding, the technical solution of the application or the part of the application which makes contribution to the prior art can be embodied in the form of software product, which is stored in readable storage medium, such as computer floppy disk, U disk, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a plurality of instructions for making a computer device (which can be personal computer, training device or network device, etc.) execute the method described in various embodiments of the application.
[0226] In the above embodiments, the implementation can be achieved by software, hardware, firmware or any combination thereof, entirely or partially. When implemented by software, the implementation can be achieved in the form of a computer program product, entirely or partially.
[0227] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the flow or function described in the embodiments of the application is generated entirely or partially. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another, for example, the computer instructions can be transmitted from one website, computer, training device or data center to another website, computer, training device or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that can be stored by a computer or a data storage device such as a training device, a data center, etc. integrated with one or more available media sets. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
Claims
1. A method for controlling usage of cache resources, comprising: obtaining an access request initiated by a target object in an electronic device; in response to the access request satisfying a first condition, determining a first partition identifier of the target object and a second partition identifier corresponding to a physical address to be accessed by the access request, the second partition identifier being related to a memory space address including the physical address; combining the first partition identifier and the second partition identifier into a third partition identifier; determining a resource allocation strategy corresponding to the third partition identifier, the resource allocation strategy being a resource allocation strategy according to a subdivision of the memory space address; allocating a corresponding cache space for the target object according to the resource allocation strategy; and caching associated data required for processing the access request in the cache space. 2.The method of claim 1, wherein the access request includes a target virtual address of a storage space to be accessed; and the determining of the first partition identifier of the target object and the second partition identifier corresponding to the physical address to be accessed by the access request comprises: determining the first partition identifier corresponding to the target object according to a partition identifier corresponding to a different object; and obtaining an address mapping relationship group based on the target virtual address to obtain a second partition identifier recorded in the address mapping relationship group, the address mapping relationship group including at least a mapping relationship between the target virtual address and a physical address, the second partition identifier being used to identify a piece of memory space represented by each physical address in the address mapping relationship group. 3.The method of claim 2, wherein the determining of the resource allocation strategy corresponding to the third partition identifier comprises: determining a first resource allocation strategy corresponding to a first cache memory based on the third partition identifier; and the allocating of the corresponding cache space for the target object according to the resource allocation strategy comprises: allocating the corresponding cache space for the target object in the first cache memory according to the first resource allocation strategy; and the caching of the associated data required for processing the access request in the cache space comprises: caching the address mapping relationship group in the cache space. The associated data required for processing the access request cannot be found in the first cache memory according to the target virtual address; and 4. The cache resource usage control method according to claim 2 or 3, the access request satisfying the first condition comprising: the method further comprises: in response to the access request satisfying a second condition, obtaining the associated data required for processing the access request from the cache space corresponding to the target object, the cache space being allocated based on the resource allocation strategy corresponding to the first partition identifier and the second partition identifier of the target object. 5.The method of claim 1, wherein the determining of the resource allocation strategy corresponding to the third partition identifier comprises: determining a second resource allocation strategy corresponding to a second cache memory based on the third partition identifier; and the allocating of the corresponding cache space for the target object according to the resource allocation strategy comprises: According to the second resource allocation strategy, a corresponding cache space is allocated for the target object in the second cache memory; The associated data required for processing the access request is cached in the cache space, including: The data content to be operated by the access request is cached in the cache space.
6. The cache resource usage control method according to claim 5, wherein the first partition identifier of the target object and the second partition identifier corresponding to the physical address to be accessed by the access request are determined, including: The first partition identifier of the target object and the second partition identifier carried in the access request are obtained, the first partition identifier and the second partition identifier are determined by a memory management unit, and the second partition identifier is determined by the memory management unit based on the physical address mapped by the target virtual address in the access request, wherein the memory management unit includes a first cache memory.
7. The cache resource usage control method according to claim 5, wherein the data content to be operated by the access request is cached in the cache space, including: If the access request is a read request, the first data to be read by the read request is obtained from the internal storage of the electronic device, and the first data is cached in the cache space; and / or, If the access request is a write request, the second data to be operated by the write request is cached in the cache space.
8. An electronic device, comprising: a cache module and a policy control module in communication connection with the cache module; The policy control module includes a logic unit and a policy management unit; The cache module is configured to obtain an access request initiated by a target object in an electronic device; in response to the access request satisfying a first condition, determine a first partition identifier of the target object and a second partition identifier corresponding to a physical address to be accessed by the access request, the second partition identifier being related to a memory space address including the physical address; The logic unit is configured to combine the first partition identifier and the second partition identifier into a third partition identifier; The policy management unit is configured to determine a resource allocation strategy corresponding to the third partition identifier, the resource allocation strategy being a resource allocation strategy according to the subdivision of the memory space address; The cache module is further configured to allocate a corresponding cache space for the target object according to the resource allocation strategy, and cache the associated data required for processing the access request in the cache space.
9. The electronic device according to claim 8, The policy management unit is further configured to store at least one candidate resource allocation strategy, and determine the resource allocation strategy corresponding to the third partition identifier from the at least one candidate resource allocation strategy.
Citation Information
Patent Citations
Resource access method applied to computer and computer
CN107783913A
Mapping partition identifiers
CN115407931A
Memory management method and system, processor and electronic equipment
CN117909261A