Page table entry merging method, device and electronic device

By saving the page table entries of the target thick page in TLB and configuring sub-table entries to record the effective mapping relationship, the problem of low merging of existing page table entries merging technology is solved, the merging degree and utilization of TLB are improved, and the query is enhanced efficiency.

CN111949572BActive Publication Date: 2024-11-26HYGON INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010860820.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-24
Publication Date
2024-11-26
Estimated Expiration
2040-08-24

AI Technical Summary

Technical Problem

The existing page table entry merging technology has a low degree of merging in actual applications, making it difficult to achieve a high degree of merging, which limits the utilization rate of TLB.

Method used

By saving the page table entries of the target thick page in TLB and configuring subtable entries to record the correspondence between the virtual address and the physical address of the page with effective mapping, non-continuous page table entries are allowed to merge, and the merge degree and utilization rate of TLB is improved. .

Benefits of technology

It improves the merging degree of page table entries in TLB, reduces the limitations of page table entries merging, and enhances the practical application applicability and query efficiency of TLB.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111949572B_ABST
    Figure CN111949572B_ABST
Patent Text Reader

Abstract

The present application provides a method, device and electronic device for merging page table entries, the method comprising: sending a data query request to a memory; obtaining page table entries for multiple pages queried for the data query request; determining whether there are at least two page table entries in the page table entries that have valid mappings within the virtual address range of the target coarse page; if so, saving the target page table entry of the target coarse page into the TLB, identifying the page size corresponding to the target page table entry, and configuring the sub-table entry of the target page table entry; the sub-table entry records the correspondence between the virtual address of the page with a valid mapping and the corresponding physical address. The scheme of the embodiment of the present application enables page table entries to be merged when there are at least two page table entries with valid mappings. The limitations on page table entry merging are reduced, the applicability of page table entry merging technology in practical applications is improved, the degree of merging of page table entries in the TLB is improved, and thus the utilization rate of the TLB is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a page table entry merging method, device and electronic device. Background Art

[0002] In a computer, the CPU (Central Processing Unit / Processor) first receives the virtual address sent by the program, so the CPU must find the actual physical address corresponding to the virtual address before it can perform the corresponding data access operation.

[0003] Virtual addresses and physical addresses are managed through page tables. The CPU will first fetch the page table from the physical memory, then determine the page number based on the virtual address sent by the program, find the corresponding physical page number in the table, and finally access the actual physical memory address. In other words, the CPU must access the physical memory twice during the entire process. In order to reduce the number of times the CPU accesses physical memory, the TLB (Translation Lookaside Buffer) technology is introduced.

[0004] TLB can be understood as a cache of the page table, which stores the page table entries that are most likely to be accessed at the moment, and the content is a copy of some page table entries. After the introduction of TLB, after receiving the virtual address sent by the application, the CPU first searches the TLB for the corresponding page table data. Only when the required page table is not found in the TLB (called TLB failure or TLB Miss), will it query the page table in the memory, thus reducing the performance degradation of the processor caused by page table query.

[0005] The data stored in the TLB is actually consistent with the data in the memory page table area. In the memory page table area, each record that records the correspondence between the virtual page and the physical page frame is called a Page Entry. Similarly, the TLB also caches page table entries of the same size. Obviously, the larger the capacity of the TLB, the more page table entries it can store, which means an increase in the TLB hit rate (a TLB hit (also called a TLB hit) refers to the situation where the required page table is found in the TLB).

[0006] However, the capacity of the TLB is usually much smaller than that of the memory. Therefore, in order to maximize the utilization of the TLB, relevant technicians currently provide a page table entry merging technology.

[0007] The page table entry merging technology can merge multiple page table entries in the TLB, and can merge adjacent virtual pages mapped to adjacent physical pages into a coarse page, and use a page table entry to find this coarse page in the TLB. For example, on a 64-bit system, 8 adjacent virtual 4K pages mapped to adjacent physical pages can be merged into a 32K page, so that 8 page table entries can be merged in the TLB, thereby improving the utilization of the TLB and reducing the traversal delay caused by the TLB capacity limitation.

[0008] However, the current page table entry merging technology requires that n (the value of n is limited by the number of bits of the operating system, for example, in a 32-bit system, n is 4, and in a 64-bit system, n is 8) adjacent virtual pages mapped to adjacent physical pages can be merged. In actual applications, it is rare to encounter situations where n consecutively accessed page table entries correspond to adjacent virtual pages mapped to adjacent physical pages. This results in great limitations in the actual application of page table entry merging technology, making it difficult to achieve a high degree of merging. Summary of the invention

[0009] The purpose of the embodiments of the present application is to provide a page table entry merging method, device and electronic device to solve the problem of low merging degree of page table entries in the related art.

[0010] An embodiment of the present application provides a page table entry merging method, comprising: sending a data query request to a memory; obtaining page table entries for multiple pages queried for the data query request; determining whether at least two page table entries among the page table entries have valid mappings within the virtual address range of a target coarse page; if so, saving a target page table entry of the target coarse page into a TLB, identifying a page size corresponding to the target page table entry, and configuring a sub-table entry of the target page table entry; the sub-table entry records a correspondence between a virtual address of a page with a valid mapping and a corresponding physical address.

[0011] In the above implementation process, when there are at least two page table entries in the page table entries of the returned multiple pages that have valid mappings within the virtual address range of the target coarse page, the target page table entry of the target coarse page can be saved in the TLB, and the correspondence between the virtual address of the page with the valid mapping and the corresponding physical address is recorded. In this way, when the TLB is actually used for physical address search, the first stage of page table entry search can be implemented through the target page table entry of the target coarse page, and then the physical address of the corresponding page can be found through the sub-table entry of the target page table entry, thereby realizing the search of the physical address. The scheme of the embodiment of the present application no longer limits the page table entry merge to the case where the n consecutively accessed page table entries are mapped to adjacent virtual pages of adjacent physical pages. By recording the correspondence between the virtual address of the page with valid mapping and the corresponding physical address through the sub-table entry, when there are at least two page table entries with valid mapping within the virtual address range of the target coarse page, the page table entry merging can also realize the conversion of the virtual address to the physical address of the page with valid mapping, thereby reducing the limitation of page table entry merging, improving the applicability of page table entry merging technology in practical applications, improving the degree of page table entry merging in the TLB, and thus improving the TLB utilization.

[0012] Further, sending a data query request to the memory includes: sending a data query request to the memory when a TLB failure occurs; the page table entry requested to be queried by the data query request includes a page table entry corresponding to the virtual address of the TLB failure.

[0013] It should be understood that the TLB is equivalent to the cache of the page table. When performing a page table query, the query is first performed in the TLB. When the corresponding page table entry cannot be found in the TLB (i.e., when a TLB failure occurs), the memory will be further queried, and the page table entry queried in the memory will be written into the TLB for subsequent queries. Therefore, in the embodiment of the present application, when a TLB failure occurs, a data query request is sent to the memory, which can maintain consistency with the existing page query mechanism and improve the compatibility of the solution.

[0014] Further, determining whether there are at least two page table entries among the page table entries that have valid mappings within the virtual address range of the target coarse page includes: determining whether, among the remaining page table entries except the page table entry corresponding to the virtual address of the TLB failure, there is at least one page table entry corresponding to the virtual address of the TLB failure that has a valid mapping within the virtual address range of the target coarse page.

[0015] It should be understood that the page table entry corresponding to the virtual address of the TLB failure is the page table entry actually required to be queried this time, so the page table entry added to the TLB should include the page table entry corresponding to the virtual address of the TLB failure. In the above implementation process, by judging whether there is at least one page table entry corresponding to the virtual address of the TLB failure among the remaining page table entries except the page table entry corresponding to the virtual address of the TLB failure, which has a valid mapping within the virtual address range of the target coarse page, and then deciding whether to save the target page table entry of the target coarse page into the TLB, it can be ensured that the target page table entry and sub-table entries saved in the TLB can record the mapping relationship between the virtual address of the TLB failure and the corresponding physical address.

[0016] Further, it is determined whether, among the remaining page table entries except the page table entry corresponding to the virtual address of the TLB failure, there is at least one page table entry corresponding to the virtual address of the TLB failure that has a valid mapping within the virtual address range of the target coarse page, including: determining the target coarse page frame based on the page table entry corresponding to the virtual address of the TLB failure; and determining whether there are page frames corresponding to at least two page table entries in the page table entries that are located within the target coarse page frame.

[0017] In the above implementation process, the target coarse page frame is determined according to the page table entry corresponding to the virtual address of the TLB failure. The page frame corresponding to the page table entry corresponding to the virtual address of the TLB failure must be located in the target coarse page frame. Therefore, when there are at least two page table entries corresponding to the page frames located in the target coarse page frame, there must be a page table entry corresponding to the virtual address of the TLB failure in at least two page table entries, thereby ensuring that the target page table entry and sub-table entries saved in the TLB can record the mapping relationship between the virtual address of the TLB failure and the corresponding physical address.

[0018] Furthermore, saving the target page table entry of the target coarse page into the TLB includes: using the virtual address of the page table entry of any page that can be merged to obtain the target coarse page as the virtual address in the target page table entry of the target coarse page, and saving the target page table entry into the TLB.

[0019] In actual application, the data length stored in the virtual address part of the page table entry in the TLB is usually specified. For example, in the case where the computer system mainly queries 4K pages, the address of the highest bit to the 12th bit of the virtual address of the corresponding page needs to be recorded in the page table entry stored in the TLB. Usually in a coarse page, the virtual address of each page constituting the coarse page can only ensure that the first m bits are the same (the value of m is determined according to the size of the coarse page). For example, for a coarse page of 32K size, the virtual address of the 8 4K pages constituting the 32K page, the virtual address of the highest bit to the 15th bit must be the same, but there is a difference in the subsequent address. Therefore, in an embodiment of the present application, in order to meet the virtual address preservation specification of the TLB, the virtual address of any page of the target coarse page can be taken and combined as the virtual address in the target page table entry of the target coarse page. In this way, the preservation of the target page table entry by the TLB can be realized while meeting the virtual address preservation specification of the TLB.

[0020] Furthermore, the method also includes: when a virtual address to be queried is received and the page size corresponding to the current page table entry to be compared in the TLB is the page size corresponding to the coarse page, by comparing the m high-order addresses of the virtual address to be queried with the current m addresses of the page table entry to be compared, it is determined whether the current page table entry to be compared is the page table entry queried by the virtual address to be queried.

[0021] In actual applications, for coarse pages, only the first m high-order addresses are valid (for example, for 32K pages, the addresses from the highest bit to the 15th bit are valid; and for 4K pages, the addresses from the 47th bit to the 12th bit are valid). Therefore, by taking the first m high-order addresses for comparison, it is possible to determine whether the page table entry corresponding to the coarse page is the page table entry queried by the virtual address to be queried.

[0022] Further, the coarse page is a 32K page; by comparing the m high-order addresses of the virtual address to be queried with the current m addresses of the page table entry to be compared, determining whether the current page table entry to be compared is the page table entry queried by the virtual address to be queried, including: comparing the highest to 15-bit addresses of the virtual address to be queried with the highest to 15-bit addresses recorded in the current page table entry to be compared; when the highest to 15-bit addresses of the virtual address to be queried are the same as the highest to 15-bit addresses recorded in the current page table entry to be compared, determining that the current page table entry to be compared is the page table entry queried by the virtual address to be queried; otherwise, determining that the current page table entry to be compared is not the page table entry queried by the virtual address to be queried.

[0023] Furthermore, the virtual address to be queried is a virtual address of a 4K page; the sub-table entry records the correspondence between the 14-bit to 12-bit address of the virtual address with a valid mapping page and the 14-bit to 12-bit address of the corresponding physical address; after determining that the page table entry currently to be compared is the page table entry queried by the virtual address to be queried, the method also includes: detecting whether there is a virtual address with a valid mapping that is the same as the 14-bit to 12-bit address of the virtual address to be queried in the sub-table entry of the page table entry currently to be compared; if not, determining that the TLB fails.

[0024] It should be understood that in the scheme of the embodiment of the present application, when querying in the TLB, there are two opportunities where TLB failure may occur. First, when no corresponding page table entry is found in the TLB according to the virtual address to be queried, a TLB failure occurs at this time. In addition, when the page table entry found is the page table entry corresponding to the coarse page, since further query is required in the sub-table entry according to the scheme of the embodiment of the present application, there may be a situation where there is no valid mapping in the sub-table entry for the virtual address to be queried. At this time, it means that the page table entry of the virtual address to be queried was not merged during the previous merge, so the valid mapping relationship of the virtual address to be queried is not recorded in the TLB, resulting in a TLB failure.

[0025] In the above implementation process, after determining that the page table entry of the coarse page is the page table entry queried by the virtual address to be queried, it is first determined whether there is a virtual address with a valid mapping that is the same as the 14-bit to 12-bit address of the virtual address to be queried in the sub-table entry, and then when there is a virtual address with a valid mapping that is the same as the 14-bit to 12-bit address of the virtual address to be queried (that is, when the TLB hits), the conversion from the virtual address to the physical address is performed, which can avoid the situation where the conversion from the virtual address to the physical address has already started when the TLB fails due to the sub-table entry, resulting in a waste of computing resources.

[0026] Furthermore, the method also includes: when there is a virtual address with a valid mapping that is the same as the 14-bit to 12-bit address of the virtual address to be queried in the sub-table entry of the page table entry to be compared, obtaining the 14-bit to 12-bit address of the physical address corresponding to the 14-bit to 12-bit address of the virtual address to be queried in the sub-table entry; determining the highest bit to 15-bit address of the physical address corresponding to the highest bit to 15-bit address of the virtual address to be queried according to the page table entry to be compared; and combining the highest bit to 15-bit address of the physical address with the 14-bit to 12-bit address to obtain the target physical address.

[0027] It should be understood that the content recorded in the page table entry can be understood as a mapping relationship from a page to a page frame (a page frame is part of the memory and is an actual storage area). The size of the page is consistent with the size of the page frame, so a coarse page of 32K size corresponds to a page frame of 32K size, so only the physical address of the 32K page frame can be determined based on the virtual address of the 32K page, that is, when the page table entry queried is a page table entry of a 32K page, only the highest bit to the 15-bit address of the physical address can be determined based on the highest bit to the 15-bit address of the virtual address to be queried. For a 4K page, it is also necessary to determine the 14-bit to 12-bit address. For this reason, in the embodiment of the present application, the 14-bit to 12-bit address of the physical address corresponding to the 14-bit to 12-bit address of the corresponding virtual address to be queried can be queried in the sub-table item, and then the 47th to 12-bit physical address corresponding to the complete 4K page is obtained in combination to ensure the reliability of the solution.

[0028] Furthermore, when the total data size of the page table entries corresponding to the pages to be merged with the target coarse page is greater than the data bus width, sending a data query request to the memory includes: sending multiple data query requests corresponding to the set data size; the set data size is less than or equal to the data bus width; the virtual address range of the page table entries requested to be queried by each of the data query requests is different.

[0029] It should be understood that in actual application, the data size of each query will be limited by the width of the data bus, so it may be that for a coarse page, it may not be possible to perform a complete query through a single data query request. For this reason, in an embodiment of the present application, the data size can be set so that the page table entries are queried multiple times to ensure that the determination of whether the target coarse page is merged or not can be completed. For example, if the data bus width is 32 bytes, if it is necessary to merge 4K pages into 32K pages on a 64-bit system, then due to the limitation of the data bus width, only 4 page table entries of 4K pages can be queried at a time, so the query can be performed twice.

[0030] Further, the sending of multiple data query requests corresponding to the set data size includes: after the previous data query request is sent, after obtaining the page table entries for the multiple pages queried by the previous data query request, sending the next data query request; or, after the previous data query request is sent, directly sending the next data query request.

[0031] An embodiment of the present application also provides an electronic device, comprising: a CPU, a memory management unit, a memory and a communication bus; the communication bus is used to realize connection and communication between the CPU, the memory management unit and the memory; a page table is stored in the memory; the CPU is used to send a virtual address to the memory management unit; the memory management unit includes a TLB, which is used to execute any of the above-mentioned page table entry merging methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0033] Figure 1 A schematic diagram of a flow chart of a page table entry merging method provided in an embodiment of the present application;

[0034] Figure 2 A schematic diagram of a mapping relationship of sub-item records provided in an embodiment of the present application;

[0035] Figure 3 A schematic diagram of an effective mapping relationship provided in an embodiment of the present application;

[0036] Figure 4 A schematic diagram of a TLB internal page table structure provided in an embodiment of the present application;

[0037] Figure 5 A schematic diagram of a query process provided in an embodiment of the present application;

[0038] Figure 6 A schematic diagram of a sub-table item structure provided in an embodiment of the present application;

[0039] Figure 7 A schematic diagram of another sub-item structure provided in an embodiment of the present application;

[0040] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0041] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0042] Embodiment 1:

[0043] In order to facilitate understanding of the technology of the embodiments of the present application, some related technologies are first introduced below.

[0044] In computer technology, there is a set of addresses that a program can generate, which is called the address range. The size of this range is determined by the number of bits of the CPU. For example, for a 32-bit CPU, its address range is 0 to 0xFFFFFFFF (4G), while for a 64-bit CPU, its address range is 0 to 0xFFFFFFFFFFFFFFFF (16E). This range is the address range that a program can generate. This address range is called the virtual address space, and an address in this space is called a virtual address. Corresponding to the virtual address space and virtual address are the physical address space and physical address. Most of the time, the physical address space of the system is only a subset of the virtual address space. For example, for a 32-bit x86 host with 256M memory, its virtual address space range is 0 to 0xFFFFFFFF (4G), and the physical address space range is 0x00000000 to 0x0FFFFFFF (256M).

[0045] In a computer system, the program gives the CPU a virtual address. The CPU needs to map the virtual address to the physical address in the physical address space before it can operate at the corresponding location in the memory.

[0046] In a computer, in order to realize the mapping from a virtual address to a physical address, an MMU (Memory Management Unit) is used in the computer to implement the corresponding mapping control.

[0047] Specifically, the virtual address space is divided into pages, and the corresponding physical address space is divided into page frames, which are the same size as the page. The mapping relationship between pages and page frames (i.e., page table) is established and saved in the page table area of ​​the memory. The MMU realizes the mapping from virtual address to physical address by accessing the page table.

[0048] In order to improve the efficiency of accessing the page table, TLB is introduced. Based on the principle of locality (that is, when a page table entry of a converted page is used, it may be used again in the near future), the page table entry that is most likely to be accessed is placed in the TLB, so that when mapping the physical address, the corresponding page table entry is first searched in the TLB. Only when the required page table entry is not found in the TLB, it is searched in the memory.

[0049] Based on the above introduction, the following further introduces the page table entry merging method provided by the embodiment of the present application. Figure 1 As shown, the page table entry merging method provided in the embodiment of the present application includes:

[0050] S101: Sending a data query request to the memory.

[0051] In the embodiment of the present application, a data query request may be sent to the memory only when a TLB miss occurs.

[0052] In actual application, after the CPU obtains the virtual address, it needs to convert the virtual address into a physical address. At this time, the CPU will pass the virtual address to be queried to the MMU, and the MMU will first search in the TLB. If the TLB hits, it will map the physical address of the virtual address to be queried. When a TLB miss occurs, it means that the page table entry corresponding to the virtual address to be queried does not exist in the TLB, so it is necessary to search in the memory and write the found page table entry into the TLB.

[0053] In this process, the MMU may send a data query request to the memory to request to query the page table entry of the page of the virtual address to be queried. That is, the page table entry requested to be queried by the data query request sent to the memory includes the page table entry corresponding to the virtual address of the TLBmiss.

[0054] It should be noted that the virtual address includes two parts: the page number and the page offset. The page number part is used to find the address of the page frame corresponding to the page (page frame number), and the page offset is used to determine the specific physical address in the page frame. Usually, the high ki bit of the virtual address represents the page number, and the low i bit represents the page offset (the value of i is affected by the page size. For example, for an 8K page, since 8K = 2 13 , so i is 13, for 32K pages, since 32K = 2 15 , i is 15; and the value of k is affected by the actual virtual address space used. For example, for 4G virtual space, k can be 32). The virtual address can be expressed as P (page number). d (offset within the page), and the physical address can be expressed as f (page frame number). d (offset within the page). f is the mapping of P in the physical address. The page table entry records the mapping from P to f, that is, the mapping from page to page frame. Therefore, to find the page table entry corresponding to the virtual address is to find the page table entry of the page where the virtual address is located. Therefore, the MMU sends a data query request to the memory, requesting to query the page table entry of the page of the virtual address to be queried.

[0055] In addition, it should be noted that within the range allowed by the data bus width, the MMU can request to query the page table entries of multiple pages at the same time.

[0056] The page table entries of the multiple pages to be queried may be the page table entries of the most recent multiple pages. For example, if the data bus width is 32 bytes and the page table entries of a 4K page are queried, then at most 4 page table entries of 4K pages may be queried, and the MMU may simultaneously generate a data query request for the page table entries of the most recent 4 4K pages and send it to the memory for page table entry query.

[0057] The page table entries of the multiple pages to be queried may be the page where the virtual address to be queried is located and the page table entries of the multiple pages adjacent to the page. For example, if the data bus width is 32 bytes and the page table entry of 4K page A is queried, then at most 4 4K page page entries can be queried, and the MMU can simultaneously generate data query requests for the page table entries of page A, page B adjacent to page A, page C, and page D, and send them to the memory for page table entry query. Among them, page A, page B, page C, and page D can be 4 4K pages in the virtual address range of the first half of a 32K page.

[0058] S102: Obtain page table entries of multiple pages queried for the data query request.

[0059] When searching for page table entries in memory, the MMU takes out the page number portion of the virtual address to be queried and searches it in the page table to find the corresponding page table entry (this process is called Translation Table Walk).

[0060] If there are multiple levels of page tables, the MMU will query each level of the page table according to the page number part corresponding to each level to find the corresponding page table entry.

[0061] It should be understood that the Translation Table Walk can be implemented by the hardware of the MMU, and there is no need to write relevant instructions to instruct the MMU.

[0062] In an embodiment of the present application, after querying the page table entry of the page of the virtual address to be queried currently received by the MMU, the physical address corresponding to the virtual address to be queried can be determined according to the page table entry and returned to the CPU so that the CPU can quickly access the corresponding physical address.

[0063] S103: Determine whether there are at least two page table entries in the page table entries that have valid mappings within the virtual address range of the target coarse page.

[0064] In the embodiment of the present application, for the multiple page table entries obtained, it can be determined whether they have a valid mapping within the virtual address range of the target coarse page.

[0065] It should be understood that in the actual process of dividing pages and page frames, the page frames corresponding to adjacent pages may not be adjacent, that is, the page frames corresponding to the pages constituting a coarse page may not necessarily constitute a coarse page frame.

[0066] It should be noted that a so-called coarse page refers to a large page composed of multiple small adjacent pages, such as 8 adjacent 4K pages forming a 32K page. Similarly, a coarse page frame refers to a large page frame composed of multiple adjacent page frames.

[0067] It should also be noted that at least two page table entries have valid mappings within the virtual address range of the target coarse page, which means that the virtual addresses of at least two page table entries are within the virtual address range of the target coarse page, and the physical addresses mapped by the at least two page table entries are within the physical address range of the coarse page frame mapped by the virtual address of the target coarse page. That is, there are at least two page table entries whose virtual addresses are within the virtual address range of the target coarse page, and the mapped physical addresses are within the physical address range of a coarse page frame.

[0068] The target coarse page can be determined according to the page of the virtual address of the TLB miss. For example, if the page of the virtual address of the TLB miss is an 8K page and the coarse page is a 32K page, the highest bit to the 15th bit of the page of the virtual address of the TLB miss can be taken as the virtual address range of the target coarse page.

[0069] It should be noted that, in the virtual address and physical address, the lowest bit is 0 and the highest bit is k-1. For example, for a 4G virtual space, the highest bit is 31.

[0070] In an embodiment of the present application, the process of step S103 may be to determine whether, among the queried page table entries, except for the page table entries corresponding to the virtual address of the TLB miss, there is at least one page table entry corresponding to the virtual address of the TLB miss that has a valid mapping within the virtual address range of the target coarse page.

[0071] Exemplarily, a target coarse page frame is determined according to the page table entry corresponding to the virtual address of the TLB miss, and then it is determined whether page frames corresponding to at least two page table entries among the queried page table entries are located within the target coarse page frame.

[0072] In the embodiment of the present application, the range of the physical address of the coarse page frame mapped by the virtual address of the target coarse page can be determined by the physical address of the page frame mapped by the virtual address of the TLB miss. For example, if the target coarse page is a 32K page and the page of the virtual address of the TLB miss is a 4K page, then the range of the physical address of the coarse page frame can be the range covered by the physical address from the highest bit to the 15th bit in the physical address of the page frame mapped by the page of the virtual address of the TLB miss.

[0073] For example, for the page of the virtual address of the TLB miss is 4K page A, assuming that the data query request requests to query the four 4K pages of the 16K coarse page determined based on 4K page A (assuming that they are 4K pages A, B, C, and D respectively), then if there are corresponding page frames in 4K pages B, C, and D located in the 16K coarse page frame corresponding to the 4K page A (the address of the 16K coarse page frame is the highest bit to 14 bits of the address of the page frame corresponding to the 4K page A), then it can be determined that there are at least two page table entries with valid mappings within the virtual address range of the target coarse page. For example, assuming that the corresponding page frame of 4K page B is located in the 16K coarse page frame corresponding to the 4K page A, the page table entries of 4K pages A and B can be merged, that is, the page table entries in the TLB can be saved according to step S104. It should be noted that the sub-table entry of the configured target page table entry at this time records the correspondence between the virtual addresses of 4K pages A and 4K pages B and the corresponding physical addresses.

[0074] S104: If there are at least two page table entries in the page table entries that have valid mappings within the virtual address range of the target coarse page, save the target page table entry of the target coarse page into the TLB, identify the page size corresponding to the target page table entry, and configure the sub-table entry of the target page table entry.

[0075] In the embodiment of the present application, the sub-table entry records the correspondence between the virtual address of the page with valid mapping and the corresponding physical address, while the correspondence between the virtual address of the page without valid mapping in the coarse page and the corresponding physical address is not recorded. Figure 2 As shown, Figure 2 The neutron table entry can also set a valid bit flag to indicate whether the corresponding page has a corresponding relationship (i.e. Figure 2 In V=0 and V=1, V=0 indicates that the corresponding pages have no corresponding relationship, and V=1 indicates that the corresponding pages have a corresponding relationship).

[0076] In this way, although in actual mapping relationship, the coarse page may not be completely mapped with the coarse page frame (because the physical address of some pages in the coarse page is not in the coarse page frame), the mapping relationship formed by the coarse page and the coarse page frame is valid and applicable for pages with valid mapping. By recording the correspondence between the virtual address of the page with valid mapping and the corresponding physical address through the sub-table entry, it is possible to effectively distinguish between pages with valid mapping and pages without valid mapping, thereby avoiding the occurrence of TLB query errors.

[0077] For example Figure 3 As shown, coarse page A is composed of eight small pages 1-8, among which page 2, page 4, page 5 and page 6 have valid mappings, and the remaining pages do not have valid mappings. Therefore, for page 2, page 4, page 5 and page 6, the mapping relationship from coarse page A to coarse page frame B is valid. Taking a coarse page of 32K size as an example, the highest bit to the 15th bit of the virtual address of coarse page A is mapped to the highest bit to the 15th bit of the physical address of coarse page frame B, which is consistent with the highest bit to the 15th bit of the physical address mapped to page 2, page 4, page 5 and page 6, and the physical addresses corresponding to the complete pages 2, page 4, page 5 and page 6 can be further determined according to the sub-table entries.

[0078] It should be understood that in an embodiment of the present application, the sub-table entry may only record the mapping relationship between the part of the page number portion of the small page constituting the coarse page, the part that the coarse page does not have the page number and the part that the coarse page frame does not have the page frame number, thereby saving valuable TLB storage resources.

[0079] Exemplarily, taking the case where the size of the coarse page and coarse page frame is 32K and the size of the page is 4K, the sub-table entry may record the mapping relationship between the 14-bit to 12-bit virtual address of the page and the 14-bit to 12-bit physical address of the page frame.

[0080] In addition, it is also necessary to understand that in actual application, the data length stored in the virtual address part of the page table entry in the TLB is usually specified. For example, in the case where the computer system mainly queries 4K pages, the virtual address of the highest bit to the 12th bit of the virtual address of the corresponding page needs to be recorded in the page table entry stored in the TLB (0 to 11 bits are the offset within the page). However, for coarse pages, only the first m bits need to be queried when querying (the value of m is determined according to the size of the coarse page, for example, for a 32K coarse page, the virtual addresses of the 8 4K pages that constitute the 32K page only need to query the virtual addresses from the highest bit to the 15th bit). However, in order to meet the virtual address storage specifications of the TLB, for coarse pages, it is still necessary to be consistent with the data length stored in the virtual address part of the remaining page table entries.

[0081] Therefore, in the embodiment of the present application, the virtual address of any page of the target coarse page can be taken and combined as the virtual address in the target page table entry of the target coarse page. In this way, the TLB can save the target page table entry while meeting the virtual address saving specification of the TLB.

[0082] For example, Figure 3 As shown, assuming that coarse page A is composed of eight small pages 1 to 8, the virtual address of any page from pages 1 to 8 can be taken as the virtual address in the target page table entry of the target coarse page.

[0083] Optionally, the virtual address of a page with a valid mapping among the pages merged to obtain the target coarse page may be taken as the virtual address in the target page table entry of the target coarse page.

[0084] At this time, when performing a query, you only need to determine the number of bits to be compared based on the page size corresponding to the page table entry. For example, when the page size corresponding to the page table entry is 32K, you can determine that the virtual address to be compared is the highest bit to the 15th bit of the virtual address, and when the page size corresponding to the page table entry is 4K, you can determine that the virtual address to be compared is the highest bit to the 12th bit of the virtual address.

[0085] It should be understood that if, among the page table entries of multiple pages queried for the data query request, the pages corresponding to each page table entry belong to different coarse pages, that is, there are not at least two page table entries that have valid mappings within the virtual address range of the target coarse page, at this time, if the target page table entry of the target coarse page is still saved in the TLB and the sub-table entry is configured, the effect of reducing the number of page table entries in the TLB cannot be achieved. On the contrary, since the sub-table entry needs to be queried during the query, the query speed is not as fast as directly saving the page table entry of the page.

[0086] It should also be noted that, as mentioned above, the number of page table entries of multiple pages to be queried is limited by the data bus width. Therefore, it is possible that sending a data query request once cannot query the page table entries of all pages corresponding to the entire coarse page.

[0087] For example, the data bus width is 32 bytes, the coarse page is a 32K page, and the queried page is a 4K page. Due to the limitation of the data bus width, a data query request can only query page table entries of up to 4 4K pages, so at least two data queries are required.

[0088] To this end, in an embodiment of the present application, when the total data size of the page table entries corresponding to the pages that need to be merged with the target coarse page is greater than the data bus width, the data size of the data query request can be pre-set, and the size is less than or equal to the data bus width, and then a data query request corresponding to the set data size is sent each time, and multiple data query requests are sent multiple times, and the virtual address range of the page table entries requested by each data query request is configured to be different, thereby realizing the query of each page that needs to be merged with the target coarse page.

[0089] Optionally, the data size may be set equal to the data bus width to maximize resource utilization and reduce the number of queries.

[0090] For example, if the data bus width is 32 bytes, the page table entry of a 4K page is queried, and the target coarse page is a 32K page, then at most four page table entries of 4K pages can be queried at one time. At this time, four data query requests for 4 4K pages in the first half of the virtual address range of the 32K target coarse page can be generated and sent to the memory, and then four data query requests for 4 4K pages in the second half of the virtual address range of the 32K target coarse page can be generated and sent to the memory.

[0091] Optionally, in an embodiment of the present application, when multiple data query requests need to be sent, the next data query request can be sent after the previous data query request is sent and after the page table entries for the multiple pages queried by the previous data query request are obtained.

[0092] At this time, the page corresponding to the virtual address of the TLB miss can be included in the previous data query request for query, or can also be included in the next data query request for query.

[0093] Optionally, in an embodiment of the present application, the next data query request may be sent directly after the previous data query request is sent, without waiting for the query result of the previous data query request, thereby saving query time.

[0094] After obtaining the page table entries of multiple pages queried by the previous data query request, if there are at least two page table entries with valid mappings within the virtual address range of the target coarse page, the target page table entry of the target coarse page can be directly saved in the TLB, and the sub-table entry of the target page table entry can be configured. After obtaining the page table entries of multiple pages queried by the next data query request, it is determined whether each page table entry has a valid mapping within the virtual address range of the target coarse page compared with the previously obtained page table entry. If so, the correspondence between the virtual address of the page with a valid mapping and the corresponding physical address is added to the sub-table entry.

[0095] After obtaining the page table entries of multiple pages queried by the previous data query request, if there are not at least two page table entries with valid mappings in the virtual address range of the target coarse page, then after obtaining the page table entries of multiple pages queried by the next data query request, it can be determined whether each page table entry queried by the next data query request has a valid mapping in the virtual address range of the target coarse page compared with the previously obtained page table entries. If yes, the target page table entry of the target coarse page is saved in the TLB, and the sub-table entry of the target page table entry is configured.

[0096] The TLB configured according to the embodiment of the present application may have page table entries corresponding to different page sizes, for example, see Figure 4 When performing a query, the query method may be determined according to the page size corresponding to the currently queried page table entry.

[0097] Exemplarily, when the TLB receives the virtual address to be queried from the CPU, it compares the virtual addresses one by one in the TLB until a TLB hit or a TLB miss occurs.

[0098] When performing a comparison, the number of virtual address bits required for comparison is first determined based on the page size corresponding to the page table entry currently to be compared.

[0099] When the page size corresponding to the current page table entry to be compared is the page size corresponding to the coarse page, the m high-order addresses of the virtual address to be queried are compared with the current m addresses of the page table entry to be compared to determine whether the current page table entry to be compared is the page table entry queried by the virtual address to be queried.

[0100] In an embodiment of the present application, when the coarse page is a 32K page, if the page size corresponding to the current page table entry to be compared is the page size corresponding to the coarse page, the highest to 15-bit address of the virtual address to be queried can be compared with the highest to 15-bit address recorded in the current page table entry to be compared, and then when the highest to 15-bit address of the virtual address to be queried is the same as the highest to 15-bit address recorded in the current page table entry to be compared, it is determined that the current page table entry to be compared is the page table entry queried by the virtual address to be queried; otherwise, it is determined that the current page table entry to be compared is not the page table entry queried by the virtual address to be queried.

[0101] After determining that the current page table entry to be compared is the page table entry queried by the virtual address to be queried, the sub-table entry of the current page table entry to be compared can be queried according to the part of the virtual address whose page size actually corresponds to the virtual address to be queried is different from the coarse page, the physical address of the corresponding part can be determined, and the physical address of the page frame mapped by the page actually corresponding to the virtual address to be queried can be mapped.

[0102] For example, see Figure 5 As shown, Figure 5 The following figure shows the page table structure in a 64-bit system that uses 4K pages as the base page to store page table entries (it should be noted that the CPU in a 64-bit system limits the number of bits available in the virtual address to 48 bits, so Figure 5 The virtual address is 0 to 47 bits, with the highest bit being 47. It should be noted that in Windows systems, the CPU will further limit the number of bits available in the virtual address to 44 bits. This example still uses the case where the number of bits available is 48 bits).

[0103] When searching for page table entries in the TLB, all page table entries can be obtained from the TLB for comparison, thereby achieving an efficient page table entry search effect.

[0104] for Figure 5 The page table entry shown in the figure, the page size corresponding to the first page table entry in the TLB is 4K. At this time, bits 47 to 12 of the virtual address to be queried are compared with the virtual address recorded in the first page table entry ( Figure 5 The virtual address recorded in the TLB page table entry is the 47th to 12th bit virtual address).

[0105] If the comparison is consistent, the TLB hits, and the 47-bit to 12-bit physical address of the corresponding page frame can be directly mapped according to the page table entry. Then, based on the 47-bit to 12-bit physical address, combined with the 11-bit to 0-bit address (industry offset) of the virtual address to be queried, the corresponding physical address is queried.

[0106] If the comparison is inconsistent, it indicates that the page table entry is not the page table entry actually required.

[0107] And in Figure 5 In the example, the page size corresponding to the second page table entry is 32K, so when comparing, the 47th to 15th bits of the virtual address to be queried are compared with the 47th to 15th bits of the virtual address recorded in the first page table entry.

[0108] If the comparison is inconsistent, it indicates that the page table entry is not the page table entry actually required.

[0109] If the comparison is consistent, then take the 14th to 12th bits of the virtual address to be queried and compare them with the sub-table entry corresponding to the second page table entry in the TLB. Figure 6As shown, the 14-bit to 12-bit virtual address to be queried is compared with each 14-bit to 12-bit virtual address in the sub-table entry to determine whether the same 14-bit to 12-bit virtual address exists in the sub-table entry. If so, the 47-bit to 15-bit address of the physical address mapped in the second page table entry in the TLB is obtained, and the 14-bit to 12-bit physical address mapped to the 14-bit to 12-bit virtual address in the sub-table entry that is the same as the 14-bit to 12-bit virtual address to be queried is obtained, and the 47-bit to 12-bit physical address is obtained by splicing, and then combined with the 11-bit to 0-bit address (industry offset) of the virtual address to be queried, that is, the physical address corresponding to the virtual address to be queried is obtained by querying.

[0110] It should be noted that if there is no 14-bit to 12-bit virtual address in the sub-table entry that is the same as the 14-bit to 12-bit virtual address to be queried, a TLB miss is determined. The corresponding page table entry can be queried in the memory and added to the TLB in the manner described above.

[0111] It should be understood that the structure of the sub-item can also be found in Figure 7 As shown, at this time, the sub-table entry will record the 14-bit to 12-bit virtual addresses of the 8 4K pages merged into a 32K page, but will record whether the 14-bit to 12-bit virtual address of each 4K page has a valid mapped physical address, and record the 14-bit to 12-bit of the valid mapped physical address, so that when the 14-bit to 12-bit of the virtual address to be queried is compared with each 14-bit to 12-bit virtual address in the sub-table entry in turn, it can be checked whether the 14-bit to 12-bit virtual address in the sub-table entry that is the same as the 14-bit to 12-bit of the virtual address to be queried is marked as having a valid mapping.

[0112] If it has it, the 47-bit to 15-bit address of the physical address mapped in the second page table entry in the TLB can be obtained, and the 14-bit to 12-bit physical address mapped by the 14-bit to 12-bit virtual address in the sub-table entry that is the same as the 14-bit to 12-bit of the virtual address to be queried can be obtained, and the 47-bit to 12-bit physical address can be concatenated, and then combined with the 11-bit to 0-bit address (industry offset) of the virtual address to be queried, the physical address corresponding to the virtual address to be queried can be obtained.

[0113] If not, a TLB miss is determined, and the corresponding page table entry can be queried in the memory and added to the TLB in the manner described above.

[0114] It should be noted that in actual applications, there is a multi-layer TLB technology. The so-called multi-layer TLB technology refers to setting up multiple TLBs, each TLB storing page table entries of the corresponding level, that is, saving page table entries in the form of multi-level page tables is realized through multiple TLBs.

[0115] For a multi-layer TLB, the page table entries of the coarse pages in the embodiment of the present application can be stored in each TLB in a hierarchical manner according to the hierarchical manner of the multi-layer TLB technology.

[0116] In addition, after the page table entries in the TLB are configured using the scheme introduced in the embodiment of the present application, when operations such as TLB replacement occur, if the page table entry to be replaced is a page table entry of a coarse page, the entire page table entry of the coarse page can be deleted, that is, the entire sub-table entry will also be deleted at once, and will not be restored to a normal page and retained in the TLB.

[0117] Similarly, when a TLB invalidation instruction for a page table entry of a coarse page is received, the corresponding page table entry of the entire coarse page will also be invalidated, and a corresponding small page in the sub-table entry will not be kept valid.

[0118] The present application also provides an electronic device, see Figure 8 As shown, it includes a CPU, MMU, memory and communication bus.

[0119] The communication bus is used to realize the connection and communication between the CPU, MMU and memory.

[0120] And in the memory, the page table is stored.

[0121] When the CPU receives a virtual address from a program, it sends the virtual address to the MMU.

[0122] The MMU includes a TLB, which can be used to execute the page table entry merging method described above in the embodiments of the present application.

[0123] It should be understood that since the TLB is a high-speed cache in the MMU, which caches the page table entries corresponding to the most recently searched virtual addresses, the virtual address will first reach the TLB, where the page table entry corresponding to the virtual address will be queried. When a TLB miss occurs, the MMU will query the memory.

[0124] After the MMU obtains the physical address corresponding to the virtual address, it can send the converted physical address to the external address pin of the CPU, making it easier for the CPU to access the physical address.

[0125] It should be understood that the above method of the present application can be implemented by the circuit of the existing MMU.

[0126] It should be noted that Figure 8 The structure shown is for illustration only. The electronic device may also include Figure 8 More or fewer components as shown, or with Figure 8 The different configurations shown may also include components such as a battery, a display screen, and a keyboard.

[0127] In addition, in the embodiments of the present application, the CPU and the MMU may be integrated into one processor chip.

[0128] The electronic device described in the embodiments of the present application can be any electronic device with a CPU addressing function, such as a mobile terminal such as a mobile phone, a tablet computer, a fixed terminal such as a desktop computer, or a non-terminal electronic device such as a server.

[0129] The page table entry merging method and electronic device provided in the embodiment of the present application, by sending a data query request to the memory, obtains the page table entries of multiple pages queried for the data query request, and determines whether there are at least two page table entries in the page table entries that have valid mappings within the virtual address range of the target coarse page. If so, the target page table entry of the target coarse page is saved in the TLB, and the page size corresponding to the target page table entry is identified, and the sub-table entry of the target page table entry is configured; the sub-table entry records the correspondence between the virtual address of the page with valid mapping and the corresponding physical address. In this way, when there are at least two page table entries in the page table entries of the returned multiple pages that have valid mappings within the virtual address range of the target coarse page, the target page table entry of the target coarse page can be saved in the TLB, and the correspondence between the virtual address of the page with valid mapping and the corresponding physical address is recorded. In this way, when the TLB is actually used for physical address search, the first stage of page table entry search can be realized through the target page table entry of the target coarse page, and then the physical address of the corresponding page is found through the sub-table entry of the target page table entry, thereby realizing the search of the physical address. The scheme of the embodiment of the present application no longer limits the page table entry merging to the time when the n consecutively accessed page table entries are mapped to the adjacent virtual pages of the adjacent physical pages. By recording the correspondence between the virtual address of the page with valid mapping and the corresponding physical address through the sub-table entry, when there are at least two page table entries with valid mapping within the virtual address range of the target coarse page, the page table entry merging can also realize the conversion of the virtual address of the page with valid mapping to the physical address, thereby reducing the requirements for page table entry merging, improving the applicability of page table entry merging technology in practical applications, improving the degree of page table entry merging in the TLB, and thus improving the TLB utilization rate.

[0130] Embodiment 2:

[0131] Based on the first embodiment, this embodiment takes the page table entry merging process of merging 4K pages into 32K pages on a 64-bit system with a data bus width of 32 bytes as an example to illustrate the solution of the present application.

[0132] When the TLB receives a virtual address to be queried from the CPU, it searches in the TLB. If a TLB miss occurs, the first and second halves of the virtual address range covered by the target 32K page are determined based on bits 47 to 12 of the virtual address to be queried.

[0133] The first 32B data request is generated according to the first half of the virtual address range covered by the 32K page to query the page table entries of the four 4K pages corresponding to the first half of the virtual address range of the target 32K page.

[0134] After sending the first 32B data request, a second 32B data request is generated according to the second half of the virtual address range covered by the 32K page to query the page table entries of the four 4K pages corresponding to the second half of the virtual address range of the target 32K page.

[0135] According to the page table entries of the four 4K pages returned by the first 32B data request, the page table entry corresponding to the 4K page of the virtual address to be queried is used to determine the physical address corresponding to the virtual address to be queried and return it to the CPU.

[0136] And according to the 47th to 12th bits of the physical address corresponding to the virtual address to be queried, it is determined that the 4K page of the virtual address to be queried corresponds to the 32K page frame.

[0137] Determine whether there are at least two 4K page page table entries corresponding to the mapped physical addresses, which are within the range of physical addresses covered by the 32K page frame. If so, add the page table entry corresponding to the 32K page in the TLB. In the page table entry, the virtual address part is the 47-bit to 12-bit virtual address of any 4K page constituting the 32K page, and the physical address part is the 47-bit to 12-bit physical address of any 4K page frame constituting the 32K page frame, and the corresponding size 32K is recorded in the page table entry.

[0138] At the same time, the sub-table entries of the page table entry are generated. The sub-table entries can be found in Figure 7 As shown, the correspondence between the 14-bit to 12-bit virtual address of the 4K page with valid mapping and the 14-bit to 12-bit physical address of the mapped 4K page frame is recorded and marked as valid (ie, the value of the mark column is 1).

[0139] When receiving the page table entries of the four 4K pages corresponding to the virtual address range of the second half of the target 32K page, it is determined whether the physical addresses of the four 4K page frames mapped by the four 4K pages are 4K page frames within the physical address range of the 32K page frame. If so, the correspondence between the 4-bit to 12-bit virtual address of the 4K page corresponding to the 4K page frame within the physical address range of the 32K page frame and the 14-bit to 12-bit physical address of the mapped 4K page frame is added to the sub-table entry, and the value of the original mark column is changed from 0 to 1.

[0140] The process of searching in the TLB is that the TLB determines the number of bits to be compared based on the size of the page table entry record. For example, if the size of the current page table entry to be compared is 32K, the TLB takes the 47th to 15th bits of the virtual address to be queried and compares it with the 47th to 15th bits of the virtual address of the current page table entry to be compared. If they are not the same, continue to compare the next page table entry. If they are the same, take the 14th to 12th bits of the virtual address to be queried and compare them with the sub-table entry of the current page table entry to be compared, and determine whether the value of the mark column corresponding to the virtual address that is the same as the 14th to 12th bits in the sub-table entry is 1. If not, determine that the TLB misses. If so, take the 47th to 15th bits of the physical address recorded in the page table entry according to the current page table entry to be compared, and at the same time take the 14th to 12th bits of the physical address corresponding to the virtual address that is the same as the 14th to 12th bits in the sub-table entry. The 47th to 15th bits and the 14th to 12th bits of the physical address are concatenated to obtain the 47th to 12th bits of the complete 4K page frame physical address.

[0141] Through the solution of the embodiment of the present application, the merging degree of TLB is effectively improved, the utilization rate of TLB is improved, and the overhead in the TLB query process is not increased.

[0142] In the embodiments provided in this application, it should be understood that the disclosed method can be implemented in other ways.

[0143] In addition, the units described as separate components may or may not be physically separated, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0144] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0145] As used herein, a plurality refers to two or more than two.

[0146] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A page table entry merging method, characterized in that: include: Send data query request to memory; Obtaining page table entries of multiple pages queried for the data query request; Determining whether there are at least two page table entries in the page table entries that have valid mappings within the virtual address range of the target coarse page; the at least two page table entries that have valid mappings within the virtual address range of the target coarse page means that the virtual addresses of the at least two page table entries are within the virtual address range of the target coarse page, and the physical addresses mapped by the at least two page table entries are within the range of the physical addresses of the coarse page frame mapped by the virtual address of the target coarse page; If so, the target page table entry of the target coarse page is saved in the TLB, the page size corresponding to the target page table entry is identified, and a sub-table entry of the target page table entry is configured; the sub-table entry records the correspondence between the virtual address of the page with a valid mapping and the corresponding physical address; the page size is used to determine the value of the number of high-order virtual address bits m required for comparison when performing a page table query on the target coarse page.

2. The page table entry merging method according to claim 1, characterized in that: The sending of a data query request to the memory includes: When a TLB failure occurs, a data query request is sent to the memory; the page table entry requested to be queried by the data query request includes the page table entry corresponding to the virtual address of the TLB failure.

3. The page table entry merging method according to claim 2, characterized in that: Determining whether at least two of the page table entries have valid mappings within a virtual address range of a target coarse page includes: It is determined whether, among the remaining page table entries except the page table entry corresponding to the virtual address of the TLB failure, at least one page table entry corresponding to the virtual address of the TLB failure has a valid mapping within the virtual address range of the target coarse page.

4. The page table entry merging method according to claim 3, characterized in that: Determining whether, among the remaining page table entries except the page table entry corresponding to the virtual address on which the TLB fails, at least one page table entry corresponding to the virtual address on which the TLB fails has a valid mapping within the virtual address range of the target coarse page comprises: Determine a target coarse page frame according to a page table entry corresponding to the virtual address of the TLB failure; It is determined whether there are at least two page frames corresponding to the page table entries in the page table entries that are located within the target coarse page frame.

5. The page table entry merging method according to claim 1, characterized in that: Saving the target page table entry of the target coarse page into the TLB includes: The virtual address of the page table entry of any page that can be merged to obtain the target coarse page is used as the virtual address in the target page table entry of the target coarse page, and the target page table entry is saved in the TLB.

6. The page table entry merging method according to claim 1, characterized in that: The method further comprises: When a virtual address to be queried is received and the page size corresponding to the current page table entry to be compared in the TLB is the page size corresponding to the coarse page, by comparing the m high-order addresses of the virtual address to be queried with the current m addresses of the page table entry to be compared, it is determined whether the current page table entry to be compared is the page table entry queried by the virtual address to be queried; the m is a value determined according to the page size corresponding to the coarse page.

7. The page table entry merging method according to claim 6, characterized in that: The coarse page is a 32K page; By comparing the m high-order addresses of the virtual address to be queried with the first m addresses of the page table entry to be compared, determining whether the page table entry to be compared is the page table entry queried by the virtual address to be queried includes: Compare the address of the most significant bit to the 15 bits of the virtual address to be queried with the address of the most significant bit to the 15 bits recorded in the page table entry currently to be compared; When the address of the most significant bit to the 15th bit of the virtual address to be queried is the same as the address of the most significant bit to the 15th bit recorded in the page table entry to be currently compared, determining that the page table entry to be currently compared is the page table entry queried by the virtual address to be queried; Otherwise, it is determined that the page table entry to be compared currently is not the page table entry queried by the virtual address to be queried.

8. The page table entry merging method according to claim 7, characterized in that: The virtual address to be queried is a virtual address of a 4K page; the sub-table entry records a correspondence between a 14-bit to 12-bit address of a virtual address with a valid mapping page and a 14-bit to 12-bit address of a corresponding physical address; After determining that the page table entry to be compared is the page table entry queried by the virtual address to be queried, the method further includes: Detect whether there is a virtual address with a valid mapping that is the same as the 14-bit to 12-bit address of the virtual address to be queried in the sub-table entry of the page table entry to be compared; When not present, a TLB failure is determined.

9. The page table entry merging method according to claim 8, characterized in that: The method further comprises: When there is a virtual address with a valid mapping that is the same as the 14-bit to 12-bit address of the virtual address to be queried in the sub-table entry of the page table entry to be compared, obtaining the 14-bit to 12-bit address of the physical address corresponding to the 14-bit to 12-bit address of the virtual address to be queried in the sub-table entry; Determine the highest bit to the 15th bit address of the physical address corresponding to the highest bit to the 15th bit address of the virtual address to be queried according to the page table entry to be compared currently; The target physical address is obtained by combining the most significant bit to the 15th bit of the physical address with the 14th bit to the 12th bit of the physical address.

10. The page table entry merging method according to any one of claims 1 to 9, characterized in that: When the total data size of the page table entries corresponding to the pages to be merged by the target coarse page is greater than the data bus width, sending the data query request to the memory includes: Sending multiple data query requests corresponding to a set data size; the set data size is less than or equal to the data bus width; the virtual address ranges of the page table entries requested to be queried by each of the data query requests are different.

11. The page table entry merging method according to claim 10, characterized in that: The sending of multiple data query requests corresponding to the set data size includes: After a previous data query request is sent, after receiving page table entries for a plurality of pages queried by the previous data query request, sending a next data query request; Or, after the previous data query request is sent, the next data query request is sent directly.

12. An electronic device, characterized in that: include: CPU, memory management unit, memory and communication bus; The communication bus is used to realize the connection and communication between the CPU, the memory management unit and the memory; A page table is stored in the memory; The CPU is used to send a virtual address to the memory management unit; The memory management unit includes a TLB, which is used to execute the page table entry merging method as described in any one of claims 1-11.