Data storage method, search method and device based on page coloring technology

By randomly allocating main memory pages and storing data in cache based on pre-configured colors, the method addresses low utilization issues in existing page coloring techniques, enhancing memory and cache efficiency.

CN120066425BActive Publication Date: 2025-07-15INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510560264.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-29
Publication Date
2025-07-15
Estimated Expiration
2045-04-29

AI Technical Summary

Technical Problem

In the prior art, the data storage method based on page shading technology results in low utilization of main memory and cache space and the cache space cannot be fully utilized.

Method used

By randomly allocating the main memory page and pre-configuring the colors of the data to be stored, the data is stored in the cache group corresponding to the colors in the cache, avoiding the shortage of specific color resources.

Benefits of technology

Improve the utilization rate of main memory and cache space and improve the efficiency of data storage and search.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066425B_ABST
    Figure CN120066425B_ABST
Patent Text Reader

Abstract

The present application discloses a data storage method, a search method and a device based on page coloring technology, which relates to the technical field of data storage. The method includes obtaining a virtual address corresponding to the data to be stored. According to the virtual address, if an entry of the virtual address in the main memory is not found in the translation lookaside buffer table, a target main memory page is randomly allocated for the virtual address in the main memory page, and the data to be stored is stored in the target main memory page. Then, according to the color preconfigured for the data to be stored, the data to be stored is stored from the target main memory page to the cache group corresponding to the preconfigured color in the cache. The method of the present application improves the technical effect of the utilization rate of the main memory and the cache space.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data storage, and in particular, to a data storage method, a search method, and a device based on page coloring technology. Background Art

[0002] Page coloring technology divides physical memory pages into different "colors" and maps the "colors" to different regions of the cache, thereby avoiding cache conflicts.

[0003] In related technologies, when storing data, based on page coloring technology, a main memory page of a specific color is allocated according to the data to be stored, and the data is stored in the main memory page with a specific address, and according to the color corresponding to the specific address, the data is stored from the main memory page to the cache group corresponding to the color. However, this method has a low utilization rate of the main memory and cache space. Summary of the Invention

[0004] The present application provides a data storage method, a search method, and a device based on page coloring technology, so as to at least solve the problem of low utilization rate of the main memory space in related technologies.

[0005] The present application provides a data storage method based on page coloring technology, including:

[0006] Obtaining a virtual address corresponding to the data to be stored;

[0007] According to the virtual address, if an entry of the virtual address in the main memory is not found in the translation lookaside buffer table, randomly allocate a target main memory page for the virtual address in the pages of the main memory, and the translation lookaside buffer table is used to store the entry of the main memory corresponding to the virtual address;

[0008] Storing the data to be stored into the target main memory page;

[0009] According to the color pre-configured for the data to be stored, store the data to be stored from the target main memory page into the cache group corresponding to the color.

[0010] The present application provides a data search method based on page coloring technology, including:

[0011] Obtaining a virtual address corresponding to the data to be searched;

[0012] According to the virtual address, query the target entry in the main memory corresponding to the virtual address in the translation lookaside buffer table;

[0013] Obtaining the physical page number, color bit information, and offset within the page in the target entry;

[0014] Search for the data to be searched in the cache or memory according to the physical page number, color bit information, and offset within the page in the target table entry.

[0015] This application also provides an electronic device, including: a memory for storing a computer program; a processor for implementing the steps of the above-mentioned data storage method based on page coloring technology and / or data search method based on page coloring technology when executing the computer program.

[0016] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program implements the steps of the above-mentioned data storage method based on page coloring technology and / or data search method based on page coloring technology when executed by a processor.

[0017] This application also provides a computer program product including a computer program, and the computer program implements the steps of the above-mentioned data storage method based on page coloring technology and / or data search method based on page coloring technology when executed by a processor.

[0018] Through this application, obtain the virtual address corresponding to the data to be stored. According to the virtual address, if the table entry of the virtual address in the main memory is not found in the translation lookaside buffer table, randomly allocate a target main memory page for the virtual address in the main memory page of the main memory, and store the data to be stored in the target main memory page. Then, according to the pre-configured color of the data to be stored, store the data to be stored from the target main memory page into the cache group corresponding to the pre-configured color in the cache. The method of this application, because it randomly allocates the main memory page in the main memory instead of allocating the main memory page with a specific address, and is based on the pre-configured color of the data to be stored, stores the data to be stored from the target main memory page into the cache group corresponding to the pre-configured color in the cache. Therefore, the technical problem of low utilization rate of the main memory space and cache can be solved, and the technical effect of improving the utilization rate of the main memory and cache space can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] To more clearly illustrate the embodiments of this application, the following will briefly introduce the drawings required in the embodiments. Obviously, the drawings in the following description are only some embodiments of this application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0020] Figure 1 A schematic diagram of a cache structure provided by this application;

[0021] Figure 2 A schematic diagram of a main memory address provided by this application;

[0022] Figure 3Schematic diagram of different representation methods of main memory addresses provided by embodiments of this application;

[0023] Figure 4 Hardware architecture diagram for implementing a data storage method based on page coloring technology provided by embodiments of this application;

[0024] Figure 5A Flow schematic diagram of a data storage method based on page coloring technology provided by embodiments of this application;

[0025] Figure 5B Schematic diagram of a page table entry provided by embodiments of this application;

[0026] Figure 6 Flow schematic diagram of a method for determining color bit information in an entry corresponding to a target main memory page provided by embodiments of this application;

[0027] Figure 7 Schematic diagram of a processor accessing data provided by this application;

[0028] Figure 8 Schematic diagram of querying in a translation lookaside buffer table in a related technology provided by this application;

[0029] Figure 9 Flow schematic diagram of a data search method based on page coloring technology provided by embodiments of this application;

[0030] Figure 10 Flow schematic diagram of a method for searching for data to be searched in a cache provided by embodiments of this application;

[0031] Figure 11 Schematic diagram of the structure of a data storage device provided by embodiments of this application;

[0032] Figure 12 Schematic diagram of the structure of a data search device provided by embodiments of this application;

[0033] Figure 13 Schematic diagram of the structure of an electronic device provided by this application. Detailed implementation manners

[0034] Next, the technical solutions in the embodiments of this application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this application.

[0035] It should be noted that in the description of this application, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in this application are used to distinguish similar objects, rather than to describe a specific order or sequence.

[0036] The processor integrates a multi-level cache system internally to store instructions and data that may be frequently accessed, so as to reduce the access to the off-chip main memory, which is also called the main storage. However, due to the limited cache space, cache conflicts are inevitable, that is, newly accessed data will replace the existing data in the cache, which leads to a problem that if a program has a large data access volume, it will squeeze out the data of other programs in the cache space, thus deteriorating the performance of other programs. To reduce the impact of cache conflicts on the performance between programs, a solution is to use page coloring technology to divide the memory pages where the data of different programs are located into different "colors", and map them to different cache spaces, so as to avoid cache conflicts between the data of different programs.

[0037] Page coloring technology is also called cache coloring technology, and its basic principle is as follows: in the virtual memory system of a computer, the virtual address will be mapped to the physical address. Page coloring technology makes use of the mapping relationship between the virtual address and the physical address, as well as the working principle of the cache. Usually, a cache, such as a cache memory Cache, is organized in a set-associative manner. Each physical page can be assigned a "color" according to some bits of its physical address, and the selection of these color bits is based on the structure of the cache, so that pages with the same color will be mapped to the same set in the cache.

[0038] As Figure 1 shown, Figure 1 FIG. is a schematic diagram of a cache structure provided by this application. The cache adopts a set-associative mapping method. The cache is divided into multiple sets, and each set contains the same number of ways, usually a power of 2, such as 8-way or 16-way. Figure 1 It is a 32KB 2-way set-associative cache structure, with a cache line size of 16B and a total of 1024 sets.

[0039] When querying whether the data corresponding to a certain main memory address is in the cache, the cache will divide the main memory address into three parts, as above Figure 1As shown in the figure, the 32-bit main memory address is divided into a word offset, an index, and a tag. First, the set number is determined according to the index. Subsequently, each way included in the set is checked to determine whether the tag corresponding to a certain way is consistent with the tag in the main memory address. If they are consistent, it is determined that the data is in the cache and there is no need to access the main memory again. If they are all inconsistent, it is determined that the data is not in the cache, and then the main memory is accessed to obtain the data. When accessing the main memory to obtain the data, the main memory address is divided into two parts, as Figure 2 shown Figure 2 is a schematic diagram of the main memory address provided by this application, which are the in-page offset and the page number respectively.

[0040] According to Figure 1 and Figure 2 it can be seen that a main memory address has different representations during the process of accessing data in two devices, namely the cache and the main memory, as Figure 3 shown Figure 3 is a schematic diagram of different representations of the main memory address provided by an embodiment of this application. There is a certain area overlap between the page number of the main memory address and the index of the cache. Among them, the overlapping bits (bit) between the page number of the main memory address and the index of the cache are called color bits. The main memory data corresponding to different page numbers with different color bits must be placed in different cache sets in the cache, so as to achieve the effect of isolating different data in the cache.

[0041] In the related art, based on the page coloring technology, a main memory page corresponding to a certain color is allocated for the data to be stored, that is, a main memory page with a specific address is allocated, and the data to be stored is stored through the main memory page with this specific address. Furthermore, according to the mapping relationship between the page address of the allocated main memory page and the cache, the data stored in the main memory page is placed in different sets of the cache space to achieve isolation of different data.

[0042] However, in the above allocation method, when the main memory page resources of the specific color allocated for the data to be stored are in short supply, even if there are free pages of other colors in the main memory, the allocation will fail. Therefore, the above method does not make full use of the main memory space. The data to be stored may not be able to make full use of the cache space to store data because it cannot obtain enough main memory pages, and the overall utilization efficiency of the cache space is not high either.

[0043] Therefore, in view of the above technical problems in the related art, it is found in the research process that when allocating main memory pages for data to be stored, if the page color is not specified, there is no constraint on the page color, so that pages of any color can be allocated for the data to be stored, thereby improving the utilization rate of the main memory space and further improving the utilization rate of the cache space. Therefore, the present application proposes a data storage method, a search method and a device based on page coloring technology. Specifically, a virtual address corresponding to the data to be stored is obtained, and according to the virtual address, if an entry of the virtual address in the main memory is not found in the Translation Lookaside Buffer (TLB) table, a target main memory page is randomly allocated for the virtual address in the pages of the main memory, the data to be stored is stored in the target main memory page, and according to the color preconfigured for the data to be stored, the data to be stored is stored from the target main memory page to the cache group corresponding to the color.

[0044] In order to enable those skilled in the art of the present technology to better understand the solution of the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0045] Combined with the specific application environment architecture or specific hardware architecture on which the execution of the method of the present application depends, the specific application environment architecture or specific hardware architecture is described herein. Refer to Figure 4 , Figure 4 FIG. 10 is a hardware architecture diagram for implementing a data storage method based on page coloring technology provided by an embodiment of the present application, which includes a processor 41, a main memory 42, and a cache 43.

[0046] Among them, the processor 41 is used to obtain a virtual address corresponding to the data to be stored. If an entry of the virtual address in the main memory is not found in the translation lookaside buffer table, a target main memory page is randomly allocated for the virtual address in the pages of the main memory 42, and the data to be stored is stored on the main memory page. In the present application, the above data to be stored in the memory can also be stored from the main memory 42 to the cache 43 to reduce the number of accesses to the main memory.

[0047] Please refer to Figure 5A , Figure 5A FIG. 20 is a flowchart of a data storage method based on page coloring technology provided by an embodiment of the present application. The execution subject of this method can be a data storage device, and the data storage device can be implemented through a computer program; it can also be implemented through a medium storing relevant computer programs, such as a USB flash drive and / or an optical disc, etc., or can also be implemented through an entity device integrated or installed with relevant computer programs, such as an electronic device, etc. The electronic device can be a server, a server cluster, a smart terminal, etc. The method includes:

[0048] S501. Obtain the virtual address corresponding to the data to be stored.

[0049] In this application, the execution entity is taken as an example of a server. After the processor in the server obtains the data to be stored, it obtains the virtual address (Virtual Address, VA) corresponding to the data to be stored. The virtual address includes a virtual page number (Virtual Page Number, VPN) and a page offset.

[0050] S502. According to the virtual address, if the entry of the virtual address in the main memory is not found in the translation lookaside buffer table, randomly allocate a target main memory page for the virtual address in the pages of the main memory.

[0051] Among them, the translation lookaside buffer table is used to store the entries in the main memory corresponding to the virtual addresses.

[0052] The processor goes to the translation lookaside buffer table to query the entry corresponding to the virtual address according to the virtual address. If the entry of the virtual address in the main memory is not found in the translation lookaside buffer table, the processor can also query the main memory page table corresponding to the data to be stored to obtain the page table entry corresponding to the virtual address. The structure composition of the page table entry is as Figure 5B shown Figure 5B which is a schematic diagram of a page table entry provided by an embodiment of this application. It includes a physical page number, a reserved bit, a read / write bit, and a valid bit, etc. If the information contained in the page table entry, that is, the information of the valid bit, indicates that the main memory page is not in the main memory, then among the multiple pages of the main memory, randomly allocate a target main memory page for the virtual address. Therefore, there are no special requirements for the page address.

[0053] S503. Store the data to be stored into the target main memory page.

[0054] The processor stores the data to be stored on the randomly allocated main memory page.

[0055] S504. According to the color pre-configured for the data to be stored, store the data to be stored from the target main memory page into the cache group corresponding to the color in the cache.

[0056] The processor stores the data to be stored from the target main memory page into the cache group corresponding to the color in the cache according to the color pre-configured for the data to be stored.

[0057] Among them, for the structure in the cache, please refer to Figure 1 , there can be multiple cache groups in the cache, which can also be called groups, and the colors configured for each group are different. The processor stores the data to be stored from the target main memory page into the cache group corresponding to the color in the cache according to the color pre-configured for the data to be stored.

[0058] In the above embodiments of the present application, a virtual address corresponding to the data to be stored is obtained. According to the virtual address, if an entry of the virtual address in the main memory is not found in the translation lookaside buffer table, a target main memory page is randomly allocated for the virtual address in the page of the main memory, and the data to be stored is stored in the target main memory page. Then, according to the color preconfigured for the data to be stored, the data to be stored is stored from the target main memory page into the cache group corresponding to the preconfigured color in the cache. In the method of this embodiment, since the main memory page in the main memory is randomly allocated instead of a main memory page with a specific address, and based on the color preconfigured for the data to be stored, the data to be stored is stored from the target main memory page into the cache group corresponding to the preconfigured color in the cache, the technical effect of improving the utilization rate of the main memory and the cache space is achieved.

[0059] In the present application, after the target main memory page is successfully allocated, the page table entry can be updated, and the entry in the translation lookaside buffer table can also be updated, that is, the entry corresponding to the data to be stored is added to the TLB.

[0060] The processor obtains the main memory address corresponding to the target main memory page.

[0061] Among them, the main memory address can also be called a physical address, which includes a physical page number (Physical PageNumber, PPN) and a page offset (Page Offset).

[0062] According to the cache information of the cache group and the capacity of the main memory page supported by the processor, the color bit information in the entry corresponding to the target main memory page is determined.

[0063] Please refer to Figure 6 , Figure 6 which is a schematic flowchart of a method for determining the color bit information in the entry corresponding to the target main memory page provided by an embodiment of the present application. The method may include the following steps:

[0064] S601. Determine the main memory page with the smallest supported capacity according to the capacity of the main memory page supported.

[0065] There are various sizes of the main memory page supported by the processor. For example, an x86_64 type processor can support three main memory pages, namely 4KB, 2MB, and 1GB.

[0066] According to the capacity of the main memory page supported by the processor, the main memory page with the smallest supported capacity can be determined. Taking the above example, the smallest main memory page is 4KB.

[0067] S602. Obtain the reserved bit number included in the page table entry corresponding to the main memory page with the smallest capacity.

[0068] Taking a processor of the x86_64 type as an example, since the total bit width of the page table entry is fixed at 64 bits, this means that the larger the page size corresponding to the page table entry, the fewer bits required for the physical page number in the page table entry, and the larger the bit width occupied by the reserved bits available for other purposes. For example, for a 4KB page table entry, its physical page number needs to occupy 52 bits (64 - 12), while for a 1GB page table entry, its physical page number only needs to occupy 34 bits (64 - 30). Compared with the 4KB page table entry, the 1GB page table entry has 18 more bits for reserved bits. In this embodiment, the reserved bits of the page table entry are selected as the color bits (Cache Region, CR).

[0069] Obtain the number of reserved bits included in the page table entry corresponding to the main memory page with the smallest capacity, that is, Page Reserve, abbreviated as PR.

[0070] S603. Determine the maximum color bit width supported by the cache according to the cache information of the cache group.

[0071] Optionally, the cache information includes, but is not limited to: the number of index bits corresponding to the cache, the number of word offset bits, and the number of bits of the main memory page with the smallest capacity supported by the processor.

[0072] According to the above cache information, to determine the maximum color bit width supported by the cache, a possible implementation is:

[0073] Add the number of index bits corresponding to the cache and the number of word offset bits to obtain the added number of bits.

[0074] Subtract the added number of bits from the number of bits of the main memory page with the smallest capacity supported by the processor, and determine the subtracted number of bits as the maximum color bit width supported by the cache, that is, Cache Color, abbreviated as CC.

[0075] S604. Determine the color bit information in the entry corresponding to the target main memory page according to the number of reserved bits and the maximum color bit width.

[0076] Determine the smaller value min(CC, PR) of the two values of the number of reserved bits PR and the maximum color bit width CC as the color bit information in the entry corresponding to the target main memory page.

[0077] In this embodiment, the reason for the above design is as follows. One reason is that selecting the reserved bits as the color bits of the main memory page does not damage the original structure of the page management system, avoids introducing additional burdens, and is easy to implement. Another reason is that selecting PR as the reference basis is to support all the main memory page sizes supported by the processor, because the larger the main memory page, the more reserved bits its page table entry contains. Another reason is that selecting CC as the reference basis is because the color bit CR cannot exceed CC.

[0078] The processor adds the virtual page number, physical page number, color bit information, and offset within the page of the virtual address as an entry of the target main memory page to the translation lookaside buffer table.

[0079] The translation lookaside buffer table in this embodiment is shown in Table 1:

[0080] Table 1

[0081]

[0082] Among them, the offset within the page can be stored in other information in the table, and other information such as read / write bit information and valid bit information can also be stored, which is not limited in this embodiment.

[0083] In the above embodiment of the present application, the main memory address corresponding to the target main memory page is obtained. The main memory address includes a physical page number and an offset within the page. According to the cache information of the cache group and the capacity of the main memory page supported by the processor, the color bit information in the entry corresponding to the target main memory page is determined. The virtual page number, physical page number, color bit information, and offset within the page of the virtual address are used as the entry of the target main memory page and added to the translation lookaside buffer table. The method of this embodiment facilitates subsequent rapid and convenient data search by determining the color bit information and adding the color bit information to the translation lookaside buffer table, thereby improving the utilization rate of the main memory and cache space while also increasing the data search rate.

[0084] The present application also provides a data search method based on page coloring technology. To facilitate understanding of the data search method based on page coloring technology in the present application, first, the data search method based on page coloring technology in the related art is described. The following will be combined with Figure 7 the content shown Figure 7 which is a schematic diagram of a processor accessing data provided by the present application to describe the data search method based on page coloring technology in the related art.

[0085] The processor obtains the virtual address corresponding to the data to be searched and queries whether there is an entry corresponding to the virtual address in the translation lookaside buffer table. As Figure 8 shown Figure 8 which is a schematic diagram of querying in the translation lookaside buffer table in a related technology provided by the present application. Among them, in the related technology, the translation lookaside buffer table only includes a virtual page number, a physical page number, and other information, and there is no color bit information, as shown in Table 2:

[0086] Table 2

[0087]

[0088] The processor queries the translation lookaside buffer table based on the virtual page number in the virtual address to determine the entry corresponding to the virtual page number. If it exists, it determines the physical page number corresponding to the virtual page number according to the mapping relationship between the virtual page number and the physical page number in the entry. Furthermore, it determines the physical address based on the physical page number and the page offset included in other information in the entry.

[0089] If it does not exist, the processor queries the page table corresponding in the main memory according to the virtual address to obtain the page table entry corresponding to the virtual address. Since the page table entry includes information such as the physical page number, reserved bits, read / write bits, and valid bits, the processor can determine the physical page number and other above-mentioned information corresponding to the virtual address from the page table entry, and add the physical page number and other above-mentioned information corresponding to the virtual address to the translation lookaside buffer table. After the processor obtains the physical page number, it determines the physical address based on the physical page number and the page offset included in other information in the entry.

[0090] After determining the physical address, the processor determines whether the data is in the cache based on the physical address. After the cache obtains the search instruction sent by the processor, the search instruction will include the physical address, and the physical address will be divided into three parts, namely the sub-offset (word offset), index, and tag. The corresponding set number in the cache can be determined according to the index. Subsequently, each memory path included in the set is checked to determine whether the tag corresponding to a certain path is consistent with the tag of the divided physical address. If they are consistent, it is determined that the data is in the cache, and the data to be searched is obtained from this path to complete the data access. If they are all inconsistent, it is determined that the data is not in the cache, and the data to be searched is obtained from the main memory. Among them, the tag is part of the physical page number, not all of it.

[0091] Regarding Figure 7 the content not mentioned in

[0092] Since it does not belong to the focus of this application and at the same time belongs to the publicly known technology, it will not be described in detail in this application.

[0093] Please refer to Figure 9 , Figure 9Schematic flowchart of a data search method based on page coloring technology provided by an embodiment of the present application. The execution subject of this method can be a data search device, which can be implemented by a computer program; it can also be implemented by a medium storing relevant computer programs, such as a USB flash drive and / or an optical disc, etc., or it can also be implemented by an entity device integrated or installed with relevant computer programs, such as an electronic device, etc. The electronic device can be a server, a server cluster, a smart terminal, etc. The method includes:

[0094] S901. Obtain the virtual address corresponding to the data to be searched.

[0095] In this application, the server is taken as an example for the execution subject. The processor in the server obtains the virtual address corresponding to the data to be searched.

[0096] S902. According to the virtual address, query the target entry in the main memory corresponding to the virtual address in the translation lookaside buffer table.

[0097] Since the corresponding entry has been added to the translation lookaside buffer table during data storage, the target entry can be queried in the translation lookaside buffer table according to the virtual address corresponding to the data to be searched.

[0098] S903. Obtain the physical page number, color bit information, and offset within the page in the target entry.

[0099] Among them, the offset within the page can be obtained from other information in the translation lookaside buffer table.

[0100] S904. Search for the data to be searched in the cache or memory according to the physical page number, color bit information, and offset within the page in the target entry.

[0101] Search for the data to be searched in the cache according to the physical page number, color bit information, and offset within the page in the target entry.

[0102] If the data to be searched is not found in the cache, search for the data to be searched in the memory.

[0103] In the above embodiment of the present application, the virtual address corresponding to the data to be searched is obtained. According to the virtual address, the target entry in the main memory corresponding to the virtual address is queried in the translation lookaside buffer table. The physical page number, color bit information, and offset within the page in the target entry are obtained. Furthermore, according to the physical page number, color bit information, and offset within the page in the target entry, the data to be searched is searched in the cache or memory. The method of this embodiment improves the utilization rate of the cache space and the search efficiency by searching in the cache based on the color bit information.

[0104] Further, on the basis of the above embodiments, the following embodiments illustrate the process of searching for the data to be searched in the cache according to the physical page number, color bit information, and offset within the page in the target entry.

[0105] Please refer to Figure 10 , Figure 10 which is a schematic flowchart of a method for searching for data to be searched in a cache provided by an embodiment of the present application. The method may include the following steps:

[0106] S1001. Obtain the bit width of the cache line in the cache.

[0107] Exemplarily, assume that the bit width of the cache line is 64B.

[0108] S1002. Determine the word offset according to the bit width of the cache line in the cache.

[0109] Taking 64B as an example, 64 is equal to the 6th power of 2, so the word offset is 6 bits.

[0110] S1003. Determine the bit width of the high-order part corresponding to the offset within the page according to the word offset and the offset within the page.

[0111] As described above Figure 3 shown, since there is an overlapping part between the offset within the page and the word offset, the non-overlapping part is the high-order part corresponding to the offset within the page. Assume that the offset within the page is 12 bits, then according to the word offset and the offset within the page, the determined bit width of the high-order part corresponding to the offset within the page is 6 bits.

[0112] S1004. Determine the search group number according to the bit width of the high-order part corresponding to the offset within the page and the color bit information.

[0113] For the bit width of the high-order part corresponding to the offset within the page and the color bit information, combine the color bit information as the high order and the bit width of the high-order part corresponding to the offset within the page as the low order to determine the search group number.

[0114] S1005. Search for the data to be searched in the cache according to the search group number and the physical page number. The cache includes multiple groups, and each group includes multiple storage paths for storing data.

[0115] According to the search group number, determine the target group corresponding to the search group number in the cache, and read the tag information corresponding to each storage path in the target group. The tag information is the physical page number. For any storage path, if the physical page number corresponding to the tag of the storage path is the same as the physical page number in the obtained target entry, search for the data to be searched in the storage path corresponding to the identical physical page number.

[0116] It should be noted that, compared with the tags in the related art, the tag in this application is a complete physical page number rather than a part.

[0117] If the data to be searched cannot be found in the cache, then according to the physical page number and the in-page offset in the target entry, search for the data to be searched in the pages of the main memory.

[0118] In the above embodiments of this application, obtain the bit width of the cache line in the cache. According to the bit width of the cache line in the cache, determine the word offset. According to the word offset and the in-page offset, determine the bit width of the high-order part corresponding to the in-page offset, and according to the bit width of the high-order part corresponding to the in-page offset and the color bit information, determine the search group number. Then, according to the search group number and the physical page number, search for the data to be searched in the cache. The method of this embodiment improves the accuracy and efficiency of searching in the cache by determining the search group number according to the color bit information and then searching for the data to be searched in the cache according to the search group number and the physical page number.

[0119] Next, through specific examples, the method in this application will be illustrated. Assume that the cache is the last-level cache with a capacity of 8MB, the cache ways is 16, and the cache line is 64B. Assume that the processor is x86_64, and the main memory page sizes it supports are 4KB, 2MB, and 1GB. Among them, the bit width of the reserved bit PR in the 4KB page table entry is 5. Then, the number of groups included in the last-level cache is 8MB / 16 / 64B = 13, that is, the index Index bit width is 13. Then, the maximum color bit width CC supported by the processor is the word offset bit width 6 + the index bit width 13 - the minimum page bit width 12 = 7. Therefore, the color bit width CR obtained according to the method of this application is min(PR, CC) = 5, and there are 2^5 = 32 cache color regions.

[0120] Assume that the processor stores the data with the virtual address VA of 0x10000FF0. First, query the TLB to determine whether there is an entry corresponding to this VA. If it is the first time, there is no corresponding entry in the TLB. Then query the corresponding main memory page table, and obtain the page table entry corresponding to this VA from the main memory page table. If the information of the valid bit included in the page table entry indicates that this page is not in the main memory, randomly allocate a main memory page. Assume that the allocated main memory address is 0x20000000, that is, the physical page number PPN is 0x20000, and set the color bit CR of the page table entry corresponding to this page, for example, to 0x12. After the page allocation is successful and the page table entry is updated, add the obtained PPN and color bit information such as CR to the TLB to obtain Table 3.

[0121] Table 3

[0122]

[0123] Then, query the cache based on the physical page number 0x20000, color bit information 0x12, and in-page offset 0xFF0 to determine whether the corresponding search data is in the cache. Since the cache line size is 64B, the main memory page size is 4KB, the word offset bit width is 6 bits, and the page offset bit width is 12 bits, according to the word offset and in-page offset, it is determined that the bit width of the high part corresponding to the in-page offset is 12 - 6 = 6 bits.

[0124] Based on the bit width of the high 6-bit part corresponding to the in-page offset and the color bit information, determine the search group number. The binary of the in-page offset 0xFF0 is 111111110000, and the high 6-bit part is 111111, which is converted to binary as 0x3F. The binary of the color bit information 0x12 is 10010, and the binary of the bit width 0x3F corresponding to the high 6-bit part of the in-page offset is 111111. After merging, it is 010010111111, which is converted to hexadecimal as 0x4BF. Therefore, the determined search group number is 0x4BF.

[0125] After determining the search group number, read the physical page numbers in each storage path of the 0x4BF group, compare them with the physical page numbers in the table entry. If the physical page numbers are found to be the same, it means the search data is in the cache and is stored in the storage path with the same physical page number in the cache. If there is no matching situation, it indicates that the search data is not in the cache, and then access the data from the main memory according to the physical page number and in-page offset.

[0126] In the page allocation method in the related art, when wanting to change the main memory page color corresponding to a certain degree of data, not only does it need to write the data corresponding to the program back to the main memory page in the main memory from the cache, but also it needs to copy the data in the main memory page to the page with the target color. This process takes a long time and the user experience is poor.

[0127] In this application, when performing an update, by obtaining update information, where the update information includes the target data already stored in the cache to be updated and the color setting information to be updated, according to the color setting information, update the original color of the target data.

[0128] Optionally, write the target data already stored in the cache back to the corresponding main memory page in the main memory, and update the color bit information in the page table entry in the corresponding main memory page according to the color setting information.

[0129] The update method of this application does not need to copy the data in the main memory page to the page with the target color, only needs to modify the color bit information corresponding to the page, and the update process is more convenient and fast, improving the user experience.

[0130] In this application, a cache coherence protocol message can also be generated, which includes a physical address and color bit information. Suppose there are multiple processors, such as processor A and processor B, and they both cache the same data at the same time. When processor A performs read and write operations on the cache, for example, changing the original data from 0 to 1, if processor B also needs to perform read and write operations on the cache at this time, processor A needs to send a cache coherence protocol message to processor B first, causing processor B to invalidate the previously cached data first, and then processor B performs read and write operations on the cache, so that when multiple processors perform read and write operations on the cache, errors will not occur, improving the accuracy of the data written into the cache.

[0131] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation method.

[0132] Figure 11 It is a schematic structural diagram of a data storage device based on page coloring technology provided by an embodiment of this application. As Figure 11 shown, it includes:

[0133] A first acquisition module 1101, configured to acquire a virtual address corresponding to the data to be stored.

[0134] A first processing module 1102, configured to, according to the virtual address, if an entry of the virtual address in the main memory is not found in the translation lookaside buffer table, randomly allocate a target main memory page for the virtual address in the page of the main memory, and the translation lookaside buffer table is used to store the entry of the virtual address corresponding to the main memory.

[0135] A storage module 1103, configured to store the data to be stored into the target main memory page.

[0136] The storage module 1103 is further configured to store the data to be stored from the target main memory page into the cache group corresponding to the color according to the color pre-configured for the data to be stored.

[0137] A possible implementation manner is that the first processing module 1102 is further configured to:

[0138] Acquire the main memory address corresponding to the target main memory page, where the main memory address includes a physical page number and an offset within the page.

[0139] Determine the color bit information in the entry corresponding to the target main memory page according to the cache information of the cache group and the capacity of the main memory page supported by the processor.

[0140] Use the virtual page number, physical page number, color bit information, and offset within the page of the virtual address as the entry of the target main memory page, and add it to the translation lookaside buffer table.

[0141] One possible implementation is that the first processing module 1102 is further specifically configured to:

[0142] Determine the main memory page with the smallest supportable capacity according to the capacity of the supportable main memory page.

[0143] Obtain the reserved number of bits included in the page table entry corresponding to the main memory page with the smallest capacity.

[0144] Determine the maximum color bit width supported by the cache according to the cache information of the cache group.

[0145] Determine the color bit information in the entry corresponding to the target main memory page according to the reserved number of bits and the maximum color bit width.

[0146] One possible implementation is that the cache information includes the index number of bits corresponding to the cache, the word offset number of bits, and the number of bits of the main memory page with the smallest capacity supported by the processor. The first processing module 1102 is further specifically configured to:

[0147] Add the index number of bits corresponding to the cache and the word offset number of bits to obtain the added number of bits.

[0148] Subtract the added number of bits from the number of bits of the main memory page with the smallest capacity supported by the processor, and determine the subtracted number of bits as the maximum color bit width supported by the cache.

[0149] One possible implementation is that the first processing module 1102 is further specifically configured to:

[0150] Determine the smaller value of the two values of the reserved number of bits and the maximum color bit width as the color bit information in the entry corresponding to the target main memory page.

[0151] For the description of the features in the embodiments corresponding to the data storage device based on the page coloring technology, reference can be made to the relevant descriptions in the embodiments corresponding to the data storage method based on the page coloring technology, which will not be elaborated here one by one.

[0152] Figure 12 This is a schematic structural diagram of a data search device based on the page coloring technology provided by the embodiments of the present application. As Figure 12 shown, it includes:

[0153] The second acquisition module 1201 is configured to acquire the virtual address corresponding to the data to be searched.

[0154] The second processing module 1202 is configured to query a target entry in the main memory corresponding to the virtual address in the translation lookaside buffer table according to the virtual address.

[0155] The second obtaining module 1201 is further configured to obtain the physical page number, color bit information, and intra-page offset in the target entry.

[0156] The second processing module 1202 is further configured to search for data to be searched in the cache or memory according to the physical page number, color bit information, and intra-page offset in the target entry.

[0157] A possible implementation is that the second processing module 1202 is further specifically configured to:

[0158] Search for the data to be searched in the cache according to the physical page number, color bit information, and intra-page offset in the target entry.

[0159] If the data to be searched is not found in the cache, search for the data to be searched in the memory.

[0160] A possible implementation is that the second processing module 1202 is further specifically configured to:

[0161] Obtain the bit width of the cache line in the cache.

[0162] Determine the word offset according to the bit width of the cache line in the cache.

[0163] Determine the bit width of the high-order part corresponding to the intra-page offset according to the word offset and the intra-page offset.

[0164] Determine the search group number according to the bit width of the high-order part corresponding to the intra-page offset and the color bit information.

[0165] Search for the data to be searched in the cache according to the search group number and the physical page number. The cache includes multiple groups, and each group includes multiple storage paths for storing data.

[0166] A possible implementation is that the second processing module 1202 is further specifically configured to:

[0167] Determine the target group corresponding to the search group number in the cache according to the search group number.

[0168] Read the tag information corresponding to each storage path in the target group. The tag information is the physical page number.

[0169] For any storage path, if the physical page number corresponding to the tag information of the storage path is the same as the physical page number in the obtained target entry, search for the data to be searched in the storage path corresponding to the same physical page number.

[0170] One possible implementation is that the second processing module 1202 is further specifically configured to:

[0171] If the data to be searched is not found in the cache, search for the data to be searched in the page of the main memory according to the physical page number and the offset within the page in the target entry.

[0172] One possible implementation is that the second processing module 1202 is further configured to:

[0173] Obtain update information, where the update information includes the target data already stored in the cache to be updated and the color setting information to be updated.

[0174] Update the original color of the target data according to the color setting information.

[0175] One possible implementation is that the second processing module 1202 is further specifically configured to:

[0176] Write the target data already stored in the cache back to the corresponding main memory page in the main memory.

[0177] Update the color bit information in the page table entry in the corresponding main memory page according to the color setting information.

[0178] For the description of the features in the corresponding embodiments of the data search device based on the page coloring technology, reference can be made to the relevant descriptions in the corresponding embodiments of the data search method based on the page coloring technology, which will not be elaborated here one by one.

[0179] Figure 13 This is a schematic structural diagram of the electronic device provided by this application. As Figure 13 shown, the electronic device provided in this embodiment includes: at least one processor 41 and a memory 1301. Optionally, the electronic device further includes a communication component 1302. Among them, the processor 41, the memory 1301, and the communication component 1302 are connected through a bus 1303.

[0180] In the specific implementation process, at least one processor 41 executes the computer execution instructions stored in the memory 1301, so that at least one processor 41 executes the above-mentioned data storage method based on the page coloring technology and / or the embodiments of the data search method based on the page coloring technology.

[0181] For the specific implementation process of the processor 41, reference can be made to the above method embodiments. The implementation principle and technical effects are similar, and will not be elaborated here in this embodiment.

[0182] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in combination with the application can be directly implemented by the execution of the hardware processor, or can be implemented by the combination of hardware and software modules in the processor.

[0183] The memory may include high-speed random access memory (RAM), and may also include non-volatile memory (NVM), such as at least one disk memory.

[0184] The bus may be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the buses in the drawings of this application are not limited to only one bus or one type of bus.

[0185] The embodiments of the present application also provide a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps in any of the above data storage methods based on page coloring technology and / or the embodiments of the data search method based on page coloring technology when running.

[0186] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs, etc., which can store computer programs.

[0187] Embodiments of the present application also provide a computer program product. The computer program product includes a computer program. When the computer program is executed by a processor, it implements the steps in any of the above data storage methods based on page coloring technology and / or data search methods based on page coloring technology embodiments.

[0188] Embodiments of the present application also provide another computer program product, including a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium stores a computer program. When the computer program is executed by a processor, it implements the steps in any of the above data storage methods based on page coloring technology and / or data search methods based on page coloring technology embodiments.

[0189] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods for each specific application to implement the described functions, but such implementation should not be considered to exceed the scope of this application.

[0190] The above has introduced in detail a data storage method, a search method, and a device based on page coloring technology provided by the present application. Specific examples are used in this article to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application. It should be noted that for those of ordinary skill in the art in the technical field, without departing from the principle of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.

Claims

1. A data storage method based on page coloring technology, characterized in that, Including: Obtain a virtual address corresponding to the data to be stored; According to the virtual address, if an entry in the main memory corresponding to the virtual address is not found in the translation lookaside buffer table, randomly allocate a target main memory page for the virtual address in a page of the main memory, where the translation lookaside buffer table is used to store entries in the main memory corresponding to virtual addresses; Store the data to be stored into the target main memory page; According to the color preconfigured for the data to be stored, store the data to be stored from the target main memory page into a cache group corresponding to the color in the cache.

2. The method according to claim 1, wherein Also including: Obtain a main memory address corresponding to the target main memory page, where the main memory address includes a physical page number and an offset within a page; According to the cache information of the cache group and the capacity of the main memory page supported by the processor, determine color bit information in an entry corresponding to the target main memory page; Use the virtual page number of the virtual address, the physical page number, the color bit information, and the offset within a page as an entry of the target main memory page, and add it to the translation lookaside buffer table.

3. The method according to claim 2, wherein The determining the color bit information in the entry corresponding to the target main memory page according to the cache information of the cache group and the capacity of the main memory page supported by the processor includes: According to the capacity of the main memory page supported, determine the main memory page with the smallest supported capacity; Obtain the reserved number of bits included in a page table entry corresponding to the main memory page with the smallest capacity; According to the cache information of the cache group, determine the maximum color bit width supported by the cache; According to the reserved number of bits and the maximum color bit width, determine the color bit information in the entry corresponding to the target main memory page.

4. The method according to claim 3, wherein The cache information includes the index number of bits corresponding to the cache, the word offset number of bits, and the number of bits of the main memory page with the smallest capacity supported by the processor; The determining the maximum color bit width supported by the cache according to the cache information of the cache group includes: Add the index number of bits corresponding to the cache and the word offset number of bits to obtain a sum of the number of bits; Subtract the number of bits of the main memory page with the smallest capacity supported by the processor from the sum of the number of bits, and determine the result of the subtraction as the maximum color bit width supported by the cache.

5. The method according to claim 3, characterized in that The determining the color bit information in the entry corresponding to the target main memory page according to the reserved number of bits and the maximum color bit width includes: Determine the smaller value of the two values of the reserved number of bits and the maximum color bit width as the color bit information in the entry corresponding to the target main memory page.

6. A data search method based on page coloring technology, characterized in that, Including: Obtain a virtual address corresponding to the data to be searched; According to the virtual address, query a target entry in the main memory corresponding to the virtual address in the translation lookaside buffer table; Obtain the physical page number, color bit information, and offset within a page in the target entry; According to the physical page number, color bit information, and offset within a page in the target entry, search for the data to be searched in the cache or memory; the cache stores stored data stored in a target main memory page, and the target main memory page is a main memory page randomly allocated for the virtual address in a page of the main memory.

7. The method according to claim 6, characterized in that Searching for the data to be searched in a cache or memory according to the physical page number, color bit information, and in-page offset in the target entry includes: Searching for the data to be searched in the cache according to the physical page number, color bit information, and in-page offset in the target entry; If the data to be searched is not found in the cache, searching for the data to be searched in the memory.

8. The method according to claim 7, characterized in that, The searching for the data to be searched in the cache according to the physical page number, color bit information, and in-page offset in the target entry includes: Obtaining the bit width of a cache line in the cache; Determining a word offset according to the bit width of the cache line in the cache; Determining the bit width of the high-order part corresponding to the in-page offset according to the word offset and the in-page offset; Determining a search group number according to the bit width of the high-order part corresponding to the in-page offset and the color bit information; Searching for the data to be searched in the cache according to the search group number and the physical page number, where the cache includes multiple groups, and each group includes multiple storage paths for storing data.

9. The method according to claim 8, characterized in that The searching for the data to be searched in the cache according to the search group number and the physical page number includes: Determining a target group in the cache corresponding to the search group number according to the search group number; Reading the tag information corresponding to each storage path in the target group, where the tag information is a physical page number; For any storage path, if the physical page number corresponding to the tag information of the storage path is the same as the physical page number in the obtained target entry, searching for the data to be searched in the storage path corresponding to the identical physical page number.

10. The method according to claim 7, characterized in that, The if the data to be searched is not found in the cache, searching for the data to be searched in the memory includes: If the data to be searched is not found in the cache, searching for the data to be searched in the page of the main memory according to the physical page number and the in-page offset in the target entry.

11. The method according to claim 6, wherein Further includes: Obtaining update information, where the update information includes target data already stored in the cache to be updated and color setting information to be updated; Updating the original color of the target data according to the color setting information.

12. The method according to claim 11, wherein The updating the original color of the target data according to the color setting information includes: Writing the target data already stored in the cache back to the corresponding main memory page in the main memory; Updating the color bit information in the page table entry in the corresponding main memory page according to the color setting information.

13. An electronic device, characterized in that, Includes: A memory for storing a computer program; A processor for implementing the data storage method based on page coloring technology as described in any one of claims 1 to 5, and / or implementing the steps of the data search method based on page coloring technology as described in any one of claims 6 to 12 when executing the computer program.

14. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, wherein when the computer program is executed by a processor, it implements the data storage method based on page coloring technology according to any one of claims 1 to 5, and / or implements the steps of the data search method based on page coloring technology according to any one of claims 6 to 12.

15. A computer program product comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the data storage method based on page coloring technology according to any one of claims 1 to 5, and / or implements the steps of the data search method based on page coloring technology according to any one of claims 6 to 12.

Citation Information

Patent Citations

  • Management method for directory cache of multi-core processor system

    CN104331377A

  • Processor, electronic equipment, address translation method and page table item caching method

    CN115061955A