Cache operation method and device, processor and electronic device
By adopting a consistent directory mechanism in multi-core processors, secondary caches are provided for multiple primary caches, and cache replacement strategy is optimized, which solves the problem of replacement after shared cache data is full, and improves cache hit rate and processor performance.
Patent Information
- Application Number
- CN202411257220.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-12-20
AI Technical Summary
In high-performance multi-core processor design, the data storage capacity of shared cache is limited, resulting in the problem of how to choose to replace data to memory after the data storage is full, resulting in increased latency of processor accessing memory and degradation of overall performance.
The consistency directory mechanism is adopted to provide secondary caches for multiple primary caches. By recording the consistency information of cache items in the primary cache and secondary cache, the cache replacement strategy is optimized, and the cache hit rate and processor performance are improved.
By better managing cache items, improve cache hit rate, reduce processor access memory latency, and improve overall performance.
Smart Images

Figure CN119166549A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to a cache operation method and device, a processor, and an electronic device. Background Art
[0002] In the design of high-performance multi-core processors, due to the time and space limitations of data access, a multi-level cache management method is generally introduced. By storing the data required by the processor core in multi-level caches, the memory access latency of the processor core is reduced, thereby improving the performance of the processor. The latency of accessing memory is several times that of accessing cache. Considering factors such as chip area, power consumption and cost, a processor core generally has a private cache with a smaller storage capacity, and multiple processor cores generally share a shared cache with a larger storage capacity (for example, the last level cache (LLC)). When the processor runs a program, the more data required for memory access operations is stored in the private cache and the shared cache, the fewer times the processor accesses the memory, the lower the overall access latency of the processor, and its performance will be greatly improved.
[0003] However, due to the storage capacity limitations of private cache and shared cache, only part of the data can be stored. This makes it extremely important for the design of multi-core processors how to select data in the shared cache to replace with the memory when the shared cache is full. Summary of the invention
[0004] At least one embodiment of the present disclosure provides a cache operation method, comprising: providing a consistency directory for secondary caches corresponding to multiple primary caches, wherein the multiple primary caches are at a higher level within the processor than the secondary cache, the consistency directory comprising multiple directory entries for recording consistency information of cache items in the corresponding primary cache in the corresponding primary cache and the secondary cache, each directory entry being used to record consistency information of the corresponding cache item and comprising a first field and a second field, the first field being used to record whether the corresponding cache item exists in both the corresponding primary cache and the secondary cache, and the second field being used to record the existence time of the directory item where the second field is located; and in response to a first request for a first cache item, operating a first directory item corresponding to the first cache item in the consistency directory.
[0005] For example, in the cache operation method provided in at least one embodiment of the present disclosure, the consistency directory includes multiple sub-directories, the multiple sub-directories correspond one-to-one to the multiple primary caches, and each of the sub-directories includes the multiple directory entries.
[0006] For example, in the cache operation method provided by at least one embodiment of the present disclosure, the first request is a request to write the first cache item to a first primary cache among the multiple primary caches, and the operation of the first cache item corresponds to the first directory item in the consistency directory, including: creating a first directory item corresponding to the first cache item in a first subdirectory corresponding to the first primary cache; in response to the first cache item existing in both the first primary cache and the secondary cache, setting the first field of the first directory item in the first subdirectory to true, or, in response to the first cache item not existing in the secondary cache, setting the first field of the first directory item in the first subdirectory to false; and setting the second field of the first directory item in the first subdirectory to an initial value, and correspondingly updating the second field of the directory items in the first subdirectory whose first field is true except for the first directory item.
[0007] For example, in the cache operation method provided by at least one embodiment of the present disclosure, the first request is a request to write the first cache item into the secondary cache, and the operation of the first cache item corresponding to the first directory item in the consistency directory includes: in response to the existence of the first cache item in at least one of the multiple primary caches, setting the first field of the first directory item in the subdirectory corresponding to at least one of the multiple primary caches to true.
[0008] For example, in the cache operation method provided by at least one embodiment of the present disclosure, the first request is a request to evict the first cache item from a first primary cache among the multiple primary caches, and the operation of the first cache item corresponding to the first directory item in the consistency directory includes: deleting the first directory item in the first subdirectory corresponding to the first primary cache.
[0009] For example, in the cache operation method provided by at least one embodiment of the present disclosure, in response to the evicted first cache item being written to the secondary cache, the operation of the first cache item corresponding to the first directory item in the consistency directory also includes: setting the first field of the remaining first directory item in the consistency directory to true.
[0010] For example, in the cache operation method provided by at least one embodiment of the present disclosure, the first request is a request to replace the first cache item in the secondary cache, and the operation of the first cache item corresponding to the first directory item in the consistency directory includes: setting the first field of all the first directory items in the consistency directory to false, and setting the second field of all the first directory items to an initial value; and the cache operation method also includes: replacing the first cache item in the secondary cache.
[0011] For example, in the cache operation method provided by at least one embodiment of the present disclosure, before operating the first cache item corresponding to the first directory item in the consistency directory, the cache operation method includes: determining a first cache item for the replacement request from multiple cache items of the secondary cache.
[0012] For example, in the cache operation method provided by at least one embodiment of the present disclosure, the determining of the first cache item for the replacement request from the multiple cache items of the secondary cache includes: determining the first cache item to be replaced from the multiple cache items of the secondary cache according to the consistency information of the multiple cache items recorded in the consistency directory, and generating first replacement information. According to the replacement strategy, determining the second cache item to be replaced from the multiple cache items of the secondary cache, and generating second replacement information; and determining the first cache item according to the first replacement information or the second replacement information.
[0013] For example, in the cache operation method provided in at least one embodiment of the present disclosure, determining the first cache item based on the first replacement information or the second replacement information includes: in response to the first replacement information being valid candidate replacement information, determining the first cache item from the cache item in the secondary cache corresponding to the first replacement information; or in response to the first replacement information being invalid information, determining the first cache item from the cache item in the secondary cache corresponding to the second replacement information.
[0014] For example, in the cache operation method provided by at least one embodiment of the present disclosure, the consistency information also includes address information of the corresponding cache item, the first replacement information is the address information corresponding to the first cache item to be replaced in the secondary cache, and the second replacement information is the address information corresponding to the second cache item to be replaced in the secondary cache.
[0015] For example, in the cache operation method provided by at least one embodiment of the present disclosure, the first cache item to be replaced is determined from the multiple cache items of the secondary cache according to the consistency information of the multiple cache items recorded in the consistency directory, and the first replacement information is generated, including: for each of the sub-directories, according to the first field and the second field of each of the directory items, generating candidate replacement information corresponding to each of the sub-directories; and selecting valid candidate replacement information from the candidate replacement information corresponding to each of the multiple sub-directories as the first replacement information.
[0016] For example, in the cache operation method provided by at least one embodiment of the present disclosure, for each of the sub-directories, candidate replacement information corresponding to each of the sub-directories is generated according to the first field and the second field of each of the directory entries, including: in response to the existence of at least one directory entry with the first field being true in the sub-directory, determining the directory entry with the largest value of the second field among the at least one directory entry with the first field being true as a candidate directory entry, determining the cache entry corresponding to the candidate directory entry as the candidate cache entry corresponding to the sub-directory, and generating valid candidate replacement information corresponding to the sub-directory according to the address information in the candidate directory entry; or in response to the absence of a directory entry with the first field being true in the sub-directory, using invalid information as the candidate replacement information corresponding to the sub-directory.
[0017] For example, the cache operation method provided in at least one embodiment of the present disclosure further includes: in response to the candidate replacement information corresponding to each of the multiple sub-directories being all invalid information, determining the first replacement information as the invalid replacement information.
[0018] At least one embodiment of the present disclosure provides a cache operation device, including: a consistency directory unit, configured to provide a consistency directory for a secondary cache corresponding to a plurality of primary caches, wherein the primary cache is at a higher level within the processor than the secondary cache, the consistency directory includes a plurality of sub-directories, the plurality of sub-directories correspond one-to-one to the plurality of primary caches, and the sub-directories are used to record consistency information of cache items in the corresponding primary cache in the corresponding primary cache and the secondary cache, the sub-directory includes a plurality of directory entries, each directory entry is used to record consistency information of the corresponding cache item and includes a first field and a second field, the first field is used to record whether the corresponding cache item exists in both the primary cache and the secondary cache corresponding to the sub-directory, and the second field is used to record the existence time of the directory item where the second field is located; and a cache control unit, configured to operate a first directory entry corresponding to the first cache item in the consistency directory in response to a first request for the first cache item.
[0019] At least one embodiment of the present disclosure provides a processor, comprising: multiple primary caches; secondary caches corresponding to the multiple primary caches; a consistency directory unit, configured to provide a consistency directory for the secondary cache, wherein the primary cache is at a higher level within the processor than the secondary cache, the consistency directory comprises multiple sub-directories, the multiple sub-directories correspond one-to-one to the multiple primary caches, and the sub-directories are used to record consistency information of cache items in the corresponding primary cache in the corresponding primary cache and the secondary cache, the sub-directory comprises multiple directory entries, each directory entry is used to record consistency information of the corresponding cache item and comprises a first field and a second field, the first field is used to record whether the corresponding cache item exists in both the primary cache and the secondary cache corresponding to the sub-directory, and the second field is used to record the existence time of the directory item where the second field is located; and a cache control unit, configured to operate a first directory entry corresponding to the first cache item in the consistency directory in response to a first request for the first cache item.
[0020] For example, the processor provided in at least one embodiment of the present disclosure further includes: multiple processor cores, wherein the multiple primary caches are private caches of the multiple processor cores, and the secondary caches are shared caches of the multiple processor cores.
[0021] At least one embodiment of the present disclosure provides an electronic device, including the processor provided by any of the above embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly introduced below. Obviously, the drawings in the following description only relate to some embodiments of the present disclosure, but are not intended to limit the present disclosure.
[0023] Figure 1A A multi-processing core architecture is shown;
[0024] Figure 1B A flowchart of a cache operation method provided by at least one embodiment of the present disclosure is shown;
[0025] Figure 2 The information of cache items of the primary cache recorded in the subdirectory provided by at least one embodiment of the present disclosure is shown;
[0026] Figure 3 A schematic diagram showing consistency information of a subdirectory record provided by at least one embodiment of the present disclosure;
[0027] Figure 4 A schematic block diagram of replacing a cache item in a secondary cache provided by at least one embodiment of the disclosure is shown; and
[0028] Figure 5 A structural block diagram of an electronic device provided by at least one embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution of the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings of the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the described embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0030] Unless otherwise defined, the technical terms or scientific terms used in the present disclosure should be understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, similar words such as "one", "one" or "the" do not indicate quantity restrictions, but indicate that there is at least one. Similar words such as "include" or "comprise" mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. Similar words such as "connect" or "connected" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0031] As mentioned earlier, in the design of high-performance multi-core processors, the shared cache can easily be filled with data accessed by multiple processor cores. When the data storage capacity of the shared cache is full and new data needs to be stored, the shared cache will use the replacement strategy for managing its own stored data to select a cache item (cacheline, also called a "cache block") and write the cache item to the memory to free up storage space for the storage of new data.
[0032] The inventor of the present disclosure has noticed that the current replacement strategy does not fully utilize the directory resources of the shared cache. When replacing cache items, only the storage of cache items in the shared cache is considered. When a cache item stored only in the shared cache is written to the memory, if the processor core subsequently accesses the cache item again, it needs to access the memory to obtain the cache item. Since the delay of accessing the memory is significantly greater than the delay of accessing the shared cache or the private cache, the overall performance of the multi-core processor will be reduced.
[0033] In view of the above shortcomings, one or more embodiments of the present disclosure propose a cache operation method and device, a processor and an electronic device. The cache operation method includes: providing a consistency directory for a secondary cache corresponding to a plurality of primary caches, wherein the plurality of primary caches are at a higher level in the processor than the secondary cache, the consistency directory includes a plurality of directory entries, which are used to record the consistency information of the cache items in the corresponding primary cache in the corresponding primary cache and the secondary cache, each directory entry is used to record the consistency information of the corresponding cache item and includes a first field and a second field, the first field is used to record whether the corresponding cache item exists in the corresponding primary cache and the secondary cache at the same time, and the second field is used to record the existence time of the directory item where the second field is located; and in response to a first request for a first cache item, operating the first directory item corresponding to the first cache item in the consistency directory. Based on the consistency information recorded in the consistency directory, the cache operation method can better manage the cache items in the secondary cache, improve the cache hit rate, and improve the overall performance of the processor.
[0034] The present disclosure is described below through several specific embodiments. In order to keep the following description of the embodiments of the present disclosure clear and concise, detailed descriptions of known functions and known components may be omitted. When any component of the embodiments of the present disclosure appears in more than one figure, the component is represented by the same or similar reference numeral in each figure.
[0035] Figure 1A A multi-processing core architecture is shown, and the processor is suitable for the cache processing method of at least one embodiment of the present disclosure. Figure 1A The multi-processing core architecture includes four processing cores, namely core0, core1, core2 and core3. Core0, core1, core2 and core3 have their own private caches, share shared caches, and share the same main memory (memory) and input / output (I / O). The dedicated cache of each processing core may include a first-level cache (L1 Cache) or a second-level cache (L2 Cache).
[0036] Figure 1B A flowchart of a cache operation method provided by at least one embodiment of the present disclosure is shown.
[0037] like Figure 1B As shown, the cache operation method includes steps S102 and S104.
[0038] Step S102: providing a consistency directory for secondary caches corresponding to multiple primary caches.
[0039] Step S104: In response to a first request for a first cache item, operate a first directory item corresponding to the first cache item in the consistency directory.
[0040] In the multi-level cache architecture of the processor, the higher the level of the cache, the closer the cache is to the processor core, and accordingly, the higher the hit rate of the cache and the lower the latency of accessing the cache. In at least one embodiment of the present disclosure, the level of the primary cache in the processor is higher than the secondary cache, for example, the primary cache is the first-level cache (L1), the secondary cache is the second-level cache (L2), or the primary cache is the second-level cache (L2), the secondary cache is the third-level cache (L3)... and so on, and the present disclosure does not limit this. The mapping mode of the cache can be direct associative, fully associative or set associative, and the present disclosure does not limit this, and the following set associative is used as an example for explanation.
[0041] For example, a consistency directory may include multiple sub-directories, each of which corresponds one-to-one to multiple primary caches, and each sub-directory includes multiple directory entries. Each sub-directory is used to record the consistency information of the cache items in the corresponding primary cache in the corresponding primary cache and secondary cache. Each directory entry is used to record the consistency information of the corresponding cache items and includes a first field and a second field. The first field is used to record the status of whether the corresponding cache item exists in the corresponding primary cache and secondary cache at the same time, and the second field is used to record the existence time of the directory item where the second field is located.
[0042] For example, Figure 2 Information of cache items of the primary cache recorded in a subdirectory provided by at least one embodiment of the present disclosure is shown.
[0043] like Figure 2 As shown, according to the mapping method of the primary cache, the subdirectory is divided into M groups, that is, the subdirectory includes M sets. Each set includes N directory entries, corresponding to the N ways of the primary cache, namely Way0-Way(N-1), and data can be stored in the N ways of the primary cache. Each directory entry is used to record the consistency information of the corresponding cache entry, and each directory entry includes a first field Coexist and a second field Age. Here, M and N are integers greater than 0.
[0044] For example, subdirectory 0 corresponds to primary cache 0, and the first field Coexist of directory entry Way1 in subdirectory 0 is used to record whether the cache entry corresponding to directory entry Way1 in primary cache 0 exists in both primary cache 0 and secondary cache. The second field Age is used to record the existence time of the directory entry where the second field is located, and the value of Age can be the actual existence time or a value obtained through a certain operation rule.
[0045] like Figure 2As shown, the directory entry may also include fields such as Address Tag, Status, and Valid. The Address Tag field is a part of the information used to store and identify the data address in the cache item corresponding to the directory item. The Status field indicates the current status of the cache item corresponding to the directory item. For example, the exclusive status indicates that the corresponding cache item only exists in the current primary cache and does not exist in other primary caches; the shared status indicates that the corresponding cache item exists in the current primary cache and other primary caches. The Valid field indicates whether the cache item corresponding to the directory item includes valid data. Here, "valid" means that the data in the cache item is reliable and can be used directly; "invalid" means that the data in the cache item is outdated or does not exist and needs to be retrieved from the memory.
[0046] In the above step S104, there may be multiple first directory entries corresponding to the first cache entry in the consistency directory. For example, when the first cache entry exists in multiple primary caches at the same time, the first directory entries exist in the subdirectories corresponding to the multiple primary caches. For example, if the first cache entry is stored in primary cache 0, primary cache 2, and primary cache 5 at the same time, the consistency directory includes 3 first directory entries, which are located in subdirectory 0, subdirectory 2, and subdirectory 5, respectively.
[0047] In a possible embodiment, the first request may be a request to write the first cache item to a first primary cache among multiple primary caches, and step S104 may include: creating a first directory item corresponding to the first cache item in a first subdirectory corresponding to the first primary cache; in response to the first cache item existing in both the first primary cache and the secondary cache, setting the first field of the first directory item in the first subdirectory to true, or, in response to the first cache item not existing in the secondary cache, setting the first field of the first directory item in the first subdirectory to false; and setting the second field of the first directory item in the first subdirectory to an initial value, and correspondingly updating the second field of the directory items in the first subdirectory whose first fields are true except for the first directory item.
[0048] In specific implementation, writing the first cache item into the first primary cache indicates that the first cache item does not exist in the first primary cache before, and the first directory item corresponding to the first cache item does not exist in the first subdirectory corresponding to the first primary cache. Therefore, it is necessary to first create the first directory item corresponding to the first cache item in the first subdirectory in order to record the consistency information of the first cache item. After writing the first cache item into the first primary cache, if the first cache item exists in both the first primary cache and the secondary cache, the first field of the newly created first directory item in the first subdirectory is set to true, for example, the first field Coexist can be set to 1; if the first cache item does not exist in the secondary cache, the first field of the newly created first directory item in the first subdirectory is set to false, for example, the first field Coexist can be set to 0. Afterwards, since the first directory item in the first subdirectory is newly created, the second field of the first directory item is set to the initial value, and the second fields of other directory items in the first subdirectory except the first directory item are updated accordingly.
[0049] It should be noted that after the first directory entry corresponding to the first cache entry is created in the first subdirectory, the second field of the directory entry in the first subdirectory whose first field is false will not be updated and always maintains the initial value until the first field is updated from false to true.
[0050] For example, before the first directory entry (Way1) is created, the first subdirectory includes four directory entries Way0, Way5, Way2, and Way3, and the first fields Coexist of the four directory entries are 1, 1, 0, and 1 respectively, and the second fields Age are 3, 2, 0, and 0 respectively. Age=0 of Way3 indicates that directory entry Way3 is the most recently created directory entry among the four directory entries. After the first directory entry (Way1) is created, the second field Age of directory entry Way1 is set to the initial value (for example, 0), and then the other directory entries in the first subdirectory are updated accordingly. The second field of the directory entry whose first field is true. For example, except for the newly created first directory entry (Way1), the other directory entries whose first fields are true include Way0, Way5, and Way3. Then, the values of the second field Age of the directory entries Way0, Way5, and Way3 are increased by 1 respectively. The updated first sub-directory includes the five directory entries Way0, Way5, Way2, Way3, and Way1, and the first field Coexist of the five directory entries are 1, 1, 0, 1, and 1 respectively, and the second field Age is 4, 3, 0, 1, and 0 respectively.
[0051] In addition, if the first request also includes writing the first cache item to other primary caches such as the second primary cache, the third primary cache, etc. among multiple primary caches at the same time, it is necessary to create a first directory item corresponding to the first cache item in the subdirectories corresponding to the second primary cache, the third primary cache, etc., respectively, wherein the operation of setting the first field and the second field can refer to the above-mentioned operation of setting the first field and the second field of the first directory item in the first subdirectory, and will not be repeated here.
[0052] In a possible embodiment, the first request may be a request to write the first cache item into the secondary cache, and step S104 may include: in response to the existence of the first cache item in at least one of the multiple primary caches, setting the first field of the first directory item in the subdirectory corresponding to at least one of the multiple primary caches to true.
[0053] In specific implementation, after writing the first cache item into the secondary cache, it is necessary to first determine whether the first cache item exists in multiple primary caches. If the first cache item exists in at least one of the multiple primary caches, for example, the first cache item exists in both the first primary cache and the second primary cache, the first field of the first directory item in the first subdirectory (corresponding to the first primary cache) and the second subdirectory (corresponding to the second primary cache) is set to true respectively; if the first cache item does not exist in multiple primary caches, it means that the first directory item corresponding to the first cache item does not exist in the consistency directory, and there is no need to operate the consistency directory.
[0054] In a possible embodiment, the first request may be a request to evict a first cache item from a first primary cache among the multiple primary caches, and step S104 may include: deleting a first directory item in a first subdirectory corresponding to the first primary cache.
[0055] In a specific implementation, the first cache item is evicted from the first primary cache, that is, the first cache item in the first primary cache is deleted. Since the first cache item does not exist in the first primary cache, the first subdirectory corresponding to the first primary cache does not need to record the consistency information of the first cache item, and therefore the first directory item corresponding to the first cache item in the first subdirectory can be deleted.
[0056] After executing the above step S104, if the evicted first cache entry is written into the secondary cache, the cache operation method provided by the above embodiment further includes: setting the first field of the remaining first directory entry in the consistency directory to true.
[0057] For example, after the first cache item evicted from the first primary cache is written into the secondary cache, if the first directory item corresponding to the first cache item still exists in the consistency directory, that is, after the first directory item in the first subdirectory is deleted, there are still remaining first directory items in the consistency directory, then it means that the first primary cache item still exists in other primary caches other than the first primary cache. Taking the first cache item still existing in the second primary cache as an example, since the first cache item exists in both the second primary cache and the secondary cache, the first field of the first directory item in the second subdirectory is set to true.
[0058] In a possible embodiment, the first request may be a replacement request for the first cache item in the secondary cache, and step S104 may include: setting the first field of all first directory items corresponding to the first cache item in the consistency directory to false, and setting the second field of all first directory items to the initial value.
[0059] In this embodiment, the replacement request may be a request to replace the first cache item in the secondary cache with a new cache item when the data storage capacity of the secondary cache is full. When replacing the first cache item in the secondary cache, if there is at least one first directory item in the consistency directory, it means that there is the first cache item in at least one primary cache. Since there is no first cache item in the secondary cache, it is necessary to set the first field of at least one first directory item to false and set the second field of at least one first directory item to the initial value so as to restart the timing of the existence time of at least one first directory item. After completing the above step S104, the first cache item in the secondary cache is replaced, that is, the first cache item in the secondary cache is replaced with a new cache item, and the replaced first cache item can also be written to the memory or a cache with a lower priority than the secondary cache.
[0060] In a possible embodiment, if the first request is a request to replace the first cache item in the secondary cache, before executing the above step S104, the cache operation method further includes:
[0061] Step S103: Determine a first cache item for replacing the request from a plurality of cache items in the secondary cache.
[0062] In a possible embodiment, the above step S103 may include steps S1031 to S1033.
[0063] Step S1031: According to the consistency information of the multiple cache items recorded in the consistency directory, determine the first cache item to be replaced from the multiple cache items of the secondary cache, and generate first replacement information.
[0064] Step S1032: According to the replacement strategy, determine a second cache item to be replaced from the multiple cache items of the secondary cache, and generate second replacement information.
[0065] Step S1033: Determine the first cache item according to the first replacement information or the second replacement information.
[0066] With respect to the above step S1031, according to the consistency information of each cache item in the multiple primary caches recorded in the consistency directory in the corresponding primary cache and secondary cache, the first cache item to be replaced can be determined from each cache item in the multiple primary caches, wherein the first cache item to be replaced can be any cache item in the secondary cache that exists in at least one primary cache and the secondary cache at the same time. The generated first replacement information is used to indicate the first cache item to be replaced that exists in the secondary cache.
[0067] For example, step S1031 may include S1031 - 1 and S1031 - 2 .
[0068] Step S1031 - 1 : For each sub-directory, generate candidate replacement information corresponding to each sub-directory according to the first field and the second field of each directory entry.
[0069] Step S1031 - 2 : Select valid candidate replacement information from the candidate replacement information corresponding to each of the multiple sub-directories as the first replacement information.
[0070] It should be noted that step S1031 - 1 is for each subdirectory in the consistency directory, and each subdirectory corresponds to a candidate replacement information.
[0071] In a possible embodiment, step S1031-1 may include: in response to the existence of at least one directory entry with a true first field in the sub-directory, determining the directory entry with the largest value of the second field among the at least one directory entry with a true first field as a candidate directory entry, determining the cache item corresponding to the candidate directory item as the candidate cache item corresponding to the sub-directory, and generating valid candidate replacement information corresponding to the sub-directory based on the address information in the candidate directory item; or, in response to the absence of a directory entry with a true first field in the sub-directory, using invalid information as the candidate replacement information corresponding to the sub-directory.
[0072] For example, Figure 3 A schematic diagram of consistency information of a subdirectory record provided for at least one embodiment of the present disclosure.
[0073] like Figure 3As shown, the first subdirectory includes 8 directory entries Way0~Way7, the first column represents the second field Age of the 8 directory entries, and the second column represents the first field Coexist of the 8 directory entries. The directory entries in the first subdirectory whose first field Coexist is true (Coexist=1) include directory entry Way1, directory entry Way2, and directory entry Way5. The second field Age of these three directory entries is 6, 5, and 1, respectively. Among them, the value of the second field Age of directory entry Way1 is the largest. Therefore, directory entry Way1 is the candidate directory entry corresponding to the first subdirectory, and the cache entry corresponding to directory entry Way1 is the candidate cache entry corresponding to the first subdirectory. The valid candidate replacement information corresponding to the first subdirectory is generated according to the address information in directory entry Way1. The valid candidate replacement information can be the address information of the cache entry corresponding to directory entry Way1 in the secondary cache. If the first fields of the directory items Way0~Way7 in the first subdirectory are all false (Coexist=0), invalid information is used as candidate replacement information corresponding to the first subdirectory, where invalid information indicates that there is no cache item that exists in both the secondary cache and the primary cache corresponding to the first subdirectory. Therefore, the candidate replacement information corresponding to each subdirectory may be valid candidate replacement information or invalid candidate replacement information.
[0074] In a possible embodiment, when there is at least one valid candidate replacement information among the candidate replacement information corresponding to each of the multiple subdirectories, one valid candidate replacement information can be selected as the first replacement information; or, a directory number can be assigned to each subdirectory to distinguish different subdirectories, and the valid candidate replacement information can be selected as the first replacement information according to a certain rule. For example, the selection rule can be set as follows: the candidate replacement information corresponding to each subdirectory is checked in sequence according to the order of the directory number. If the candidate replacement information of the current subdirectory is valid candidate replacement information, the valid candidate replacement information is used as the first replacement information, and the directory number of the current subdirectory is recorded; if the candidate replacement information of the current subdirectory is invalid information, the candidate replacement information of the current subdirectory is skipped, and the candidate replacement information of the next subdirectory is checked until the candidate replacement information is valid candidate replacement information. In the process of selecting valid candidate replacement information as the first replacement information in the next round, first check whether the candidate replacement information corresponding to the next subdirectory of the directory number recorded in the previous round is valid candidate replacement information.
[0075] For example, in the case where the consistency directory includes P sub-directories, the P sub-directories are assigned directory numbers 0, 1, 2, ..., P, where P is an integer greater than 0. In the process of selecting valid candidate replacement information as the first replacement information in the first round, the candidate replacement information of sub-directory 0 is checked in sequence in the order of directory numbers. If the candidate replacement information of sub-directory 0 is invalid information, sub-directory 0 is skipped and the candidate replacement information of sub-directory 1 is checked. If the candidate replacement information of sub-directories 1 and 2 are both invalid information, and the candidate replacement information of sub-directory 3 is valid candidate replacement information, the candidate replacement information of sub-directory 3 is used as the first replacement information of the first round, and the directory number 3 is recorded at the same time. In the selection process of the second round, the candidate replacement information is checked in sequence starting from the next sub-directory (i.e., sub-directory 4) of the directory number 3 recorded in the first round. If the candidate replacement information of sub-directory 4 is valid candidate replacement information, the candidate replacement information of sub-directory 4 is used as the first replacement information of the second round, and the directory number 4 is recorded at the same time.
[0076] In another possible embodiment, the candidate replacement information corresponding to each of the multiple sub-directories may all be invalid information, and the invalid information is determined as the first replacement information.
[0077] With respect to the above step S1032, the second cache item to be replaced is directly determined from the secondary cache according to the replacement strategy, and second replacement information indicating the second cache item to be replaced is generated. The replacement strategy is intended to optimize the access efficiency of data. The replacement strategy is a rule or algorithm for selecting which cache item in the secondary cache to replace when the cache space of the secondary cache is full and a new cache item needs to be stored.
[0078] For example, common replacement strategies include Least Recently Used (LRU), Most Recently Used (MRU), Re-Reference Interval Prediction (RRIP), Static Re-Reference Interval Prediction (SRRIP), Dynamic Re-reference Interval Prediction (DRRIP), Bimodal Re-Reference Interval Prediction (BRRIP) or Random Replacement Policy (RRP), and the embodiments of the present disclosure can select any one of the replacement strategies for the cache operation algorithm, and the present disclosure does not impose any restrictions on this.
[0079] For the above step S1033, if the first replacement information is valid, the first replacement information or the second replacement information can be used to determine the first cache item. For example, step S1033 may include: in response to the first replacement information being valid candidate replacement information, determining the cache item in the secondary cache corresponding to the first replacement information as the first cache item; or in response to the first replacement information being invalid information, determining the cache item in the secondary cache corresponding to the second replacement information as the first cache item.
[0080] In a possible embodiment, the consistency information recorded by the directory entry in the consistency directory also includes the address information of the corresponding cache item, the first replacement information is the address information corresponding to the first cache item to be replaced in the secondary cache, and the second replacement information is the address information corresponding to the second cache item to be replaced in the secondary cache. According to the first replacement information or the second replacement information, the first cache item to be replaced or the second cache item to be replaced in the secondary cache can be replaced.
[0081] For example, the address information included in the consistency information can be the above Figure 2 The Address Tag shown in , based on the Address Tag and the index corresponding to the directory entry (for example, Way0), can determine the address information of the cache item corresponding to the directory entry in the secondary cache, for example, determine the address information of the first cache item to be replaced in the secondary cache, that is, the first replacement information.
[0082] According to the cache operation method provided in the above embodiment, based on the consistency information of the cache items in the primary cache recorded in the consistency directory in the corresponding primary cache and secondary cache, the cache items in the secondary cache are selected for replacement operation, so that the secondary cache can store more data not stored in the primary cache, thereby improving the hit rate of the processor hitting the primary cache and the secondary cache, thereby improving the processing performance of the processor.
[0083] Based on the same inventive concept, at least one embodiment of the present disclosure further provides a cache operation device. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned cache operation method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0084] For example, the device includes a consistency directory unit and a cache control unit. The consistency directory unit is configured to provide a consistency directory for a secondary cache corresponding to a plurality of primary caches, wherein the primary cache is at a higher level within the processor than the secondary cache, the consistency directory includes a plurality of sub-directories, the plurality of sub-directories correspond one-to-one to the plurality of primary caches, and the sub-directories are used to record consistency information of cache items in the corresponding primary cache in the corresponding primary cache and the secondary cache, the sub-directories include a plurality of directory entries, each directory entry is used to record consistency information of the corresponding cache item and includes a first field and a second field, the first field is used to record whether the corresponding cache item exists in both the primary cache and the secondary cache corresponding to the sub-directory, and the second field is used to record the existence time of the directory item where the second field is located. The cache control unit is configured to operate the first directory entry corresponding to the first cache item in the consistency directory in response to a first request for the first cache item.
[0085] In a possible embodiment, the consistency directory includes multiple sub-directories, the multiple sub-directories correspond to the multiple primary caches one-to-one, and each sub-directory includes multiple directory entries.
[0086] In a possible embodiment, when the first request is a request to write a first cache item to a first primary cache among multiple primary caches, the cache control unit is configured to: create a first directory item corresponding to the first cache item in a first subdirectory corresponding to the first primary cache; in response to the first cache item existing in both the first primary cache and the secondary cache, set the first field of the first directory item in the first subdirectory to true, or, in response to the first cache item not existing in the secondary cache, set the first field of the first directory item in the first subdirectory to false; and set the second field of the first directory item in the first subdirectory to an initial value, and correspondingly update the second field of the directory items in the first subdirectory whose first field is true except for the first directory item.
[0087] In a possible embodiment, when the first request is a request to write a first cache item into a secondary cache, the cache control unit is configured to: in response to the existence of the first cache item in at least one of the multiple primary caches, set the first field of the first directory item in the subdirectory corresponding to at least one of the multiple primary caches to true.
[0088] In a possible embodiment, when the first request is a request to evict a first cache item from a first primary cache among multiple primary caches, the cache control unit is configured to delete a first directory item in a first subdirectory corresponding to the first primary cache.
[0089] In a possible embodiment, in response to the evicted first cache entry being written into the secondary cache, the cache control unit is further configured to set the first field of the remaining first directory entry in the consistency directory to true.
[0090] In a possible embodiment, when the first request is a replacement request for a first cache item in a secondary cache, the cache control unit is configured to set the first field of all first directory items in the consistency directory to false, and set the second field of all first directory items to an initial value; the cache operation device also includes a replacement unit, which is configured to replace the first cache item in the secondary cache.
[0091] In a possible embodiment, the cache operation device further includes a first cache item determination unit. Before the cache control unit is configured to operate a first directory item corresponding to the first cache item in the consistency directory, the first cache item determination unit is configured to determine a first cache item for the replacement request from a plurality of cache items in the secondary cache.
[0092] In a possible embodiment, the consistency directory unit is also configured to determine a first cache item to be replaced from multiple cache items in the secondary cache based on consistency information of multiple cache items recorded in the consistency directory, and generate first replacement information; the cache operation device also includes a replacement strategy unit, and the replacement strategy unit is configured to determine a second cache item to be replaced from multiple cache items in the secondary cache based on a replacement strategy, and generate second replacement information; the first cache item determination unit is configured to determine the first cache item based on the first replacement information or the second replacement information.
[0093] In a possible embodiment, when determining the first cache item based on the first replacement information or the second replacement information, the consistency directory unit is further configured to: in response to the first replacement information being valid candidate replacement information, determine the cache item in the secondary cache corresponding to the first replacement information as the first cache item; or, in response to the first replacement information being invalid information, determine the cache item in the secondary cache corresponding to the second replacement information as the first cache item.
[0094] In a possible embodiment, the consistency information also includes address information of the corresponding cache item, the first replacement information is the address information corresponding to the first cache item to be replaced in the secondary cache, and the second replacement information is the address information corresponding to the second cache item to be replaced in the secondary cache.
[0095] In a possible embodiment, when determining a first cache item to be replaced from multiple cache items of a secondary cache based on consistency information of multiple cache items recorded in a consistency directory and generating first replacement information, the consistency directory unit is further configured to: for each sub-directory, generate candidate replacement information corresponding to each sub-directory based on the first field and the second field of each directory item; and select valid candidate replacement information as the first replacement information from the candidate replacement information corresponding to each of the multiple sub-directories.
[0096] In a possible embodiment, when generating candidate replacement information corresponding to each subdirectory based on the first field and the second field of each directory entry for each subdirectory, the consistency directory unit is further configured to: in response to the existence of at least one directory entry with the first field being true in the subdirectory, determine the directory entry with the largest value of the second field among the at least one directory entry with the first field being true as a candidate directory entry, determine the cache item corresponding to the candidate directory item as the candidate cache item corresponding to the subdirectory, and generate valid candidate replacement information corresponding to the subdirectory based on the address information in the candidate directory item; or in response to the absence of a directory entry with the first field being true in the subdirectory, use invalid information as the candidate replacement information corresponding to the subdirectory.
[0097] In a possible embodiment, in response to all candidate replacement information corresponding to the multiple sub-directories being invalid information, the consistency directory unit is further configured to determine the invalid replacement information as the first replacement information.
[0098] For example, Figure 4 A schematic block diagram of replacing a cache item in a secondary cache provided by at least one embodiment of the disclosure is shown.
[0099] like Figure 4 As shown, in response to a replacement request for a cache item in the secondary cache, the replacement queue 403 initiates a request to find a cache item for replacement operation to the consistency directory unit 401 and the replacement policy unit 402. The consistency directory unit 401 generates first replacement information based on the consistency information recorded in the consistency directory and returns it to the replacement queue 403. The replacement policy unit 402 generates second replacement information based on the set replacement policy and returns it to the replacement queue 403. The replacement queue 403 determines the cache item to be replaced in the secondary cache 404 by judging whether the first replacement information is valid. If the first replacement information is valid, the cache item corresponding to the first replacement information is selected as the cache item to be replaced; if the first replacement information is invalid, the cache item corresponding to the second replacement information is selected as the cache item to be replaced. Afterwards, the determined cache item to be replaced is evicted from the secondary cache 404, and the information related to the cache item to be replaced in the consistency directory unit 401 and the replacement policy unit 402 is updated. For example, the cache control unit (not shown in the figure) can operate the directory item corresponding to the cache item to be replaced in the consistency directory to update the consistency directory unit 401. The evicted cache items to be replaced may be first stored in the replacement cache 405 and then written into the memory unit 406, wherein the replacement cache 405 is configured to temporarily store cache items evicted from the secondary cache 404, and may also temporarily store cache items evicted from the primary cache, which is not limited in the present disclosure.
[0100] Based on the same technical concept, at least one embodiment of the present disclosure also provides a processor, which includes multiple primary caches, secondary caches corresponding to the multiple primary caches, a consistency directory unit and a cache control unit, wherein the description and technical effects of the consistency directory unit and the cache control unit can refer to the above-mentioned device embodiments and will not be repeated here.
[0101] In a possible embodiment, the processor may further include multiple processor cores, wherein the multiple primary caches are private caches of the multiple processor cores, and the secondary caches are shared caches of the multiple processor cores. The private cache is a cache exclusively used by a single processor core, and other processor cores cannot directly access the private cache.
[0102] At least one embodiment of the present disclosure further provides an electronic device, which includes the processor provided by any of the above embodiments.
[0103] Figure 5 A structural block diagram of an electronic device provided by at least one embodiment of the present disclosure is shown.
[0104] The electronic devices in the embodiments of the present disclosure can be implemented as but not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The electronic device 500 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0105] like Figure 5 As shown, the electronic device 500 includes a processor 501, which may include a processor of any of the above embodiments, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 to a random access memory (RAM) 503. Various programs and data required for the operation of the computer system are also stored in the RAM 503. The processor 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0106] For example, the following components may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509 which may also include, for example, a network interface card such as a LAN card, a modem, etc. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data, and perform communication processing via a network such as the Internet. The drive 510 is also connected to the I / O interface 505 as needed. Removable media 511, such as magnetic disks, optical disks, magneto-optical disks, semiconductor memories, etc., are installed on the drive 510 as needed, so that the computer program read therefrom can be installed into the storage device 508 as needed. Although Figure 5 The electronic device 500 is shown to include various devices, but it should be understood that it is not required to implement or include all the devices shown. More or fewer devices may be implemented or included instead.
[0107] For example, the electronic device 500 may further include a peripheral interface (not shown in the figure), etc. The peripheral interface may be various types of interfaces, such as a USB interface, a lightning interface, etc. The communication device 509 may communicate with a network and other devices through wireless communication, such as the Internet, an intranet and / or a wireless network such as a cellular phone network, a wireless local area network (LAN) and / or a metropolitan area network (MAN). Wireless communication may use any of a variety of communication standards, protocols, and techniques, including, but not limited to, Global System for Mobile Communications (GSM), Enhanced Data GSM Environment (EDGE), Wideband Code Division Multiple Access (W-CDMA), Code Division Multiple Access (CDMA), Time Division Multiple Access (TDMA), Bluetooth, Wi-Fi (e.g., based on IEEE 802.11a, IEEE 802.11b, IEEE 802.11g, and / or IEEE 802.11n standards), Voice over Internet Protocol (VoIP), Wi-MAX, protocols for email, instant messaging, and / or Short Message Service (SMS), or any other suitable communication protocol.
[0108] In addition to the above exemplary descriptions, there are a few points that need to be explained:
[0109] (1) The drawings of the embodiments of the present disclosure only relate to the structures related to the embodiments of the present disclosure. Other structures may refer to the general design.
[0110] (2) In the absence of conflict, the embodiments of the present disclosure and the features therein may be combined with each other to obtain new embodiments.
[0111] The above description is merely an exemplary embodiment of the present disclosure and is not intended to limit the protection scope of the present disclosure. The protection scope of the present disclosure is determined by the appended claims.
Claims
1. A cache operation method, include: Providing a consistency directory for a secondary cache corresponding to a plurality of primary caches, wherein the plurality of primary caches are at a higher level within the processor than the secondary cache, the consistency directory comprising a plurality of directory entries for recording consistency information of cache items in a corresponding primary cache in the corresponding primary cache and the secondary cache, each directory entry for recording consistency information of a corresponding cache item and comprising a first field and a second field, the first field for recording a state of whether the corresponding cache item exists in both the corresponding primary cache and the secondary cache, and the second field for recording an existence time of the directory item where the second field is located; and In response to a first request for a first cache item, a first directory item corresponding to the first cache item in the consistency directory is operated.
2. The cache operation method according to claim 1, in, The consistency directory includes a plurality of sub-directories, the plurality of sub-directories correspond to the plurality of primary caches one by one, and each of the sub-directories includes the plurality of directory entries.
3. The cache operation method according to claim 2, in, The first request is a request to write the first cache item into a first primary cache among the plurality of primary caches. The operating the first cache item corresponding to the first directory item in the consistency directory includes: Create a first directory entry corresponding to the first cache entry in a first subdirectory corresponding to the first primary cache; In response to the first cache item being present in both the first primary cache and the secondary cache, setting a first field of the first directory item in the first subdirectory to true, or, in response to the first cache item not being present in the secondary cache, setting a first field of the first directory item in the first subdirectory to false; and The second field of the first directory entry in the first subdirectory is set to an initial value, and the second field of the directory entry in the first subdirectory other than the first directory entry whose first field is true is correspondingly updated.
4. The cache operation method according to claim 2, in, The first request is a request to write the first cache item into the secondary cache, The operating the first cache item corresponding to the first directory item in the consistency directory includes: In response to the existence of the first cache entry in at least one of the plurality of primary caches, a first field of the first directory entry in a subdirectory corresponding to at least one of the plurality of primary caches is set to true.
5. The cache operation method according to claim 2, in, The first request is a request to evict the first cache item from a first primary cache among the plurality of primary caches, The operating the first cache item corresponding to the first directory item in the consistency directory includes: The first directory entry in the first subdirectory corresponding to the first primary cache is deleted.
6. The cache operation method according to claim 5, in, In response to the evicted first cache item being written into the secondary cache, the operating the first directory item corresponding to the first cache item in the consistency directory further includes: The first field of the first remaining directory entry in the consistency directory is set to true.
7. The cache operation method according to claim 1, in, The first request is a request to replace a first cache item in the secondary cache, The operating the first cache item corresponding to the first directory item in the consistency directory includes: Setting the first fields of all the first directory entries in the consistency directory to false, and setting the second fields of all the first directory entries to initial values; and The cache operation method also includes: The first cache entry in the secondary cache is replaced.
8. The cache operation method according to claim 7, in, Before operating the first cache item corresponding to the first directory item in the consistency directory, the cache operation method includes: A first cache entry for the replacement request is determined from a plurality of cache entries in the secondary cache.
9. The cache operation method according to claim 8, in, The determining, from the plurality of cache items in the secondary cache, a first cache item for the replacement request comprises: According to the consistency information of the multiple cache items recorded in the consistency directory, determine a first cache item to be replaced from the multiple cache items of the secondary cache, and generate first replacement information; According to the replacement strategy, determining a second cache item to be replaced from the plurality of cache items of the secondary cache, and generating second replacement information; and Determine the first cache item according to the first replacement information or the second replacement information.
10. The cache operation method according to claim 9, wherein the first cache item is determined according to the first replacement information or the second replacement information, include: In response to the first replacement information being valid candidate replacement information, determining the first cache item from the cache item in the secondary cache corresponding to the first replacement information; or In response to the first replacement information being invalid information, the cache item in the secondary cache corresponding to the second replacement information is determined as the first cache item.
11. The cache operation method according to claim 9, in, The consistency information also includes address information of the corresponding cache item. The first replacement information is address information corresponding to the first cache item to be replaced in the secondary cache, and The second replacement information is address information corresponding to the second cache item to be replaced in the secondary cache.
12. The cache operation method according to claim 9, in, The determining, according to the consistency information of the multiple cache items recorded in the consistency directory, a first cache item to be replaced from the multiple cache items of the secondary cache, and generating first replacement information, comprises: For each of the sub-directories, generating candidate replacement information corresponding to each of the sub-directories according to the first field and the second field of each of the directory entries; and Select valid candidate replacement information from the candidate replacement information corresponding to each of the multiple sub-directories as the first replacement information.
13. The cache operation method according to claim 12, in, The step of generating, for each of the sub-directories, candidate replacement information corresponding to each of the sub-directories according to the first field and the second field of each of the directory entries includes: In response to the existence of at least one directory entry whose first field is true in the subdirectory, determining a directory entry with the largest value of the second field among the at least one directory entry whose first field is true as a candidate directory entry, determining a cache entry corresponding to the candidate directory entry as a candidate cache entry corresponding to the subdirectory, and generating valid candidate replacement information corresponding to the subdirectory based on address information in the candidate directory entry; or In response to the absence of a directory entry in the sub-directory whose first field is true, invalid information is used as candidate replacement information corresponding to the sub-directory.
14. The cache operation method according to claim 13, further comprising: include: In response to the fact that all candidate replacement information corresponding to each of the plurality of sub-directories is the invalid information, the invalid replacement information is used to determine the first replacement information.
15. A cache operation device, include: a consistency directory unit, configured to provide a consistency directory for a secondary cache corresponding to a plurality of primary caches, wherein the primary cache is at a higher level within the processor than the secondary cache, the consistency directory comprises a plurality of sub-directories, the plurality of sub-directories correspond to the plurality of primary caches one-to-one, and the sub-directories are used to record consistency information of cache items in the corresponding primary cache in the corresponding primary cache and the secondary cache, the sub-directories comprise a plurality of directory entries, each directory entry is used to record consistency information of the corresponding cache item and comprises a first field and a second field, the first field is used to record whether the corresponding cache item exists in both the primary cache and the secondary cache corresponding to the sub-directory, and the second field is used to record the existence time of the directory entry where the second field is located; and The cache control unit is configured to operate a first directory entry corresponding to the first cache item in the consistency directory in response to a first request for the first cache item.
16. A processor, include: Multiple primary caches; a secondary cache corresponding to the plurality of primary caches; a consistency directory unit, configured to provide a consistency directory for the secondary cache, wherein the primary cache is at a higher level within the processor than the secondary cache, the consistency directory comprises a plurality of sub-directories, the plurality of sub-directories correspond one-to-one to the plurality of primary caches, and the sub-directories are used to record consistency information of cache items in the corresponding primary cache in the corresponding primary cache and the secondary cache, the sub-directory comprises a plurality of directory entries, each directory entry is used to record consistency information of the corresponding cache item and comprises a first field and a second field, the first field is used to record whether the corresponding cache item exists in both the primary cache and the secondary cache corresponding to the sub-directory, and the second field is used to record the existence time of the directory entry where the second field is located; as well as The cache control unit is configured to operate a first directory entry corresponding to the first cache item in the consistency directory in response to a first request for the first cache item.
17. The processor of claim 16, further comprising: include: A plurality of processor cores, wherein the plurality of primary caches are private caches of the plurality of processor cores respectively, and the secondary cache is a shared cache of the plurality of processor cores.
18. An electronic device comprising the processor according to claim 16 or 17.
