Storage management device, storage management method, processor and computer system
By using multi-level translation backup buffers and preset algorithms in the processor, searching virtual addresses in a hierarchical manner, the delay and power consumption problems caused by excessive cached table entries in traditional TLBs are solved, and the efficiency and performance of the processor are improved.
Patent Information
- Application Number
- CN201910907572.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-24
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2039-09-24
AI Technical Summary
In high-performance processors, the traditional address translation process causes delay and power consumption to increase due to the storage of a large number of cached table entries in the TLB, which affects the processor frequency and efficiency.
A multi-level translation backup buffer (TLB) is used, including level 1 and level 2 cache table entries, to reduce matching comparisons during address translation through hierarchical lookup, and to use preset algorithms to select and replace cache table entries to improve hit rate.
Reduces time and power consumption during address translation, improves processor efficiency and performance, and further optimizes the processor frequency by increasing TLB hit rate.
Smart Images

Figure CN112631962B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of processors, and more specifically, to a storage management device, a storage management method, a processor and a computer system. Background Art
[0002] In a computer system that supports a virtual storage mechanism, a virtual address (also called an effective address, logical address, Virtual Address, or VA for short) can be used to specify data, and multiple virtual addresses can be used to manage the virtual storage space of the computer system. In the process of accessing memory, the virtual address needs to be translated into a physical address (also called an actual address, real address, Physical Address, or PA for short). In order to implement address translation, the computer system needs to store a large number of table entries, each of which is used to translate a specified range of virtual addresses into corresponding physical addresses.
[0003] In order to speed up the address translation process, a translation look-aside buffer (TLB) can be used to cache some of the table entries stored in the computer system to avoid the need to search all the table entries stored in the computer system during each address translation process. If the virtual address to be translated matches one of the table entries cached by the TLB (called a hit), the computer system can directly use the TLB to implement the address translation without performing a table entry search outside the TLB.
[0004] For high-performance processors, the range of virtual addresses dynamically accessed by programs may be very wide. In order to maximize the efficiency of address translation, the total number of cache entries stored in the TLB is continuously increased, so that the address range of the TLB mapping is expanded and the hit rate of the TLB is improved. On the other hand, high-performance processors also have high frequency requirements, and address translation is an operation process that occurs very frequently.
[0005] In traditional solutions, the address translation process usually requires searching one by one in multiple cache entries for cache entries that match the virtual address to be translated. When a large number of cache entries are stored in the TLB, the large delay caused by the address translation process will hinder the further improvement of the processor frequency and affect the efficiency and performance of the processor; the process of searching for cache entries that match the translation request in a large number of cache entries will also generate large power consumption. Summary of the invention
[0006] In view of this, embodiments of the present invention provide a storage management device, a storage management method, a processor and a computer system to solve the above problems.
[0007] To achieve this objective, in a first aspect, the present invention provides a storage management device, comprising: at least one translation lookaside buffer, for storing a plurality of cache entries, the plurality of cache entries comprising a plurality of level 1 cache entries and a plurality of level 2 cache entries; and an address conversion unit, coupled to the at least one translation lookaside buffer, adapted to translate a virtual address specified by a translation request into a corresponding translation address according to one of the plurality of level 1 cache entries, or to translate a virtual address specified by the translation request into a corresponding translation address according to one of the plurality of level 2 cache entries when none of the plurality of level 1 cache entries hits the translation request.
[0008] In some embodiments, each of the cache table entries is stored by multiple registers, and the multiple registers include: a first register for storing a virtual address tag to indicate the virtual page mapped by the cache table entry; and a second register for storing a translation address tag to indicate the translation page mapped by the virtual page, and the page size of the virtual page and the translation page mapped by each of the cache table entries is consistent.
[0009] In some embodiments, the storage management device also includes a control unit, which is coupled to the address translation unit and is suitable for: when the virtual address tags of the multiple cache table entries do not hit the virtual address specified by the translation request, obtaining a to-be-backfilled table entry that matches the virtual address specified by the translation request from the root page table, and writing the to-be-backfilled table entry into the at least one transfer backup buffer.
[0010] In some embodiments, the address conversion unit is suitable for: judging whether the multiple first-level cache entries hit the virtual address specified by the translation request; if one of the multiple first-level cache entries hits, translating the virtual address specified by the translation request into a corresponding translation address according to the hit first-level cache entry; if none of the multiple first-level cache entries hits, judging whether the multiple second-level cache entries hit the virtual address specified by the transfer request; if one of the multiple second-level cache entries hits, translating the virtual address specified by the translation request into a corresponding translation address according to the hit second-level cache entry; if none of the multiple second-level cache entries hits, providing mismatch information to the control unit so that the control unit obtains the entry to be backfilled.
[0011] In some embodiments, the control unit is further adapted to: when the multiple first-level cache entries miss and one of the multiple second-level cache entries hits, select one of the multiple first-level cache entries according to a preset algorithm, and replace the selected one of the multiple first-level cache entries with the hit second-level cache entry.
[0012] In some embodiments, the plurality of registers further include: a third register for storing a reference flag bit to indicate whether the cache entry is the cache entry that has been hit least recently.
[0013] In some embodiments, when selecting the multiple level 1 cache entries to be replaced according to the preset algorithm, the control unit is suitable for selecting the level 1 cache entry that has been hit least recently according to the reference mark bit of each level 1 cache entry.
[0014] In some embodiments, when selecting the multiple first-level cache entries that need to be replaced according to the preset algorithm, the control unit is suitable for selecting the first-level cache entry that is written first according to the order in which the multiple first-level cache entries are written into the at least one transfer backup buffer.
[0015] In some embodiments, when the multiple level 1 cache entries miss and one of the multiple level 2 cache entries hits, the control unit is further adapted to write the replaced level 1 cache entry into the at least one transfer lookaside buffer as one of the level 2 cache entries.
[0016] In some embodiments, the plurality of registers further include: a fourth register, configured to store a size flag bit to indicate a page size of the virtual page / the translation page.
[0017] In some embodiments, when the multiple first-level cache entries miss and one of the multiple second-level cache entries hits, the control unit is further adapted to select the first-level cache entry to be replaced according to the size tag bit, so that the page size mapped by the hit second-level cache entry is equal to that of the replaced first-level cache entry.
[0018] In some embodiments, in the at least one translation lookaside buffer, the number of the level 1 cache entries is less than / equal to the number of the level 2 cache entries.
[0019] In a second aspect, the present invention provides a processor, comprising the storage management device as described in any of the above embodiments.
[0020] In some embodiments, the processor further includes an instruction prefetch unit, which provides the translation request to the address translation unit, wherein the translation request specifies a virtual address of a prefetch instruction, and the address translation unit communicates with a first translation lookaside buffer in the at least one translation lookaside buffer, and provides the translation address of the prefetch instruction to the instruction prefetch unit based on the cache entry provided by the first translation lookaside buffer.
[0021] In some embodiments, the processor further includes a load storage unit, which provides the translation request to the address translation unit, wherein the translation request specifies the virtual address of the memory access instruction, and the address translation unit communicates with a second translation lookaside buffer in the at least one translation lookaside buffer, and provides the translation address of the memory access instruction to the load storage unit according to the cache table entry provided by the second translation lookaside buffer.
[0022] In a third aspect, the present invention provides a computer system, comprising: a processor as described in any of the above embodiments; and a memory coupled to the processor.
[0023] In a fourth aspect, the present invention provides a storage management method, comprising: providing multiple cache entries, the multiple cache entries including multiple first-level cache entries and multiple second-level cache entries; receiving a translation request, the translation request specifying a virtual address to be translated; and translating the virtual address specified by the translation request into a corresponding translation address according to one of the multiple first-level cache entries, or translating the virtual address specified by the translation request into a corresponding translation address according to one of the multiple second-level cache entries when none of the multiple first-level cache entries hits the translation request.
[0024] In some embodiments, each of the cache table entries is stored by multiple registers, and the multiple registers include: a first register for storing a virtual address tag to indicate the virtual page mapped by the cache table entry; and a second register for storing a translation address tag to indicate the translation page mapped by the virtual page, and the page size of the virtual page and the translation page mapped by each of the cache table entries is consistent.
[0025] In some embodiments, the storage management method also includes: when the virtual address tags of the multiple cache table entries do not hit the virtual address specified by the translation request, obtaining a to-be-backfilled table entry that matches the virtual address specified by the translation request from the root page table, and writing the to-be-backfilled table entry as a first-level cache table entry or a second-level cache entry into at least one transfer backup buffer for storing the multiple cache table entries.
[0026] In some embodiments, the step of translating the virtual address specified by the transfer request into a corresponding translation address according to one of the multiple cache entries includes: determining whether the multiple first-level cache entries hit the virtual address specified by the translation request; if one of the multiple first-level cache entries hits, translating the virtual address specified by the translation request into a corresponding translation address according to the hit first-level cache entry; if none of the multiple first-level cache entries hits, determining whether the multiple second-level cache entries hit the virtual address specified by the transfer request; if one of the multiple second-level cache entries hits, translating the virtual address specified by the translation request into a corresponding translation address according to the hit second-level cache entry; if none of the multiple second-level cache entries hits, providing mismatch information to the control unit so that the control unit obtains the entry to be backfilled.
[0027] In some embodiments, the storage management method also includes: when the multiple first-level cache entries miss and one of the multiple second-level cache entries hits, selecting one of the multiple first-level cache entries according to a preset algorithm, and replacing the selected one of the multiple first-level cache entries with the hit second-level cache entry.
[0028] In some embodiments, the plurality of registers further include: a third register for storing a reference flag bit to indicate whether the cache entry is the cache entry that has been hit least recently.
[0029] In some embodiments, when selecting the multiple level 1 cache entries to be replaced according to the preset algorithm, the preset algorithm selects the level 1 cache entry that has been hit least recently according to the reference mark bit of each level 1 cache entry.
[0030] In some embodiments, when selecting the multiple first-level cache entries that need to be replaced according to the preset algorithm, the preset algorithm selects the first-level cache entry that is written first according to the order in which the multiple first-level cache entries are written into the at least one transfer backup buffer.
[0031] In some embodiments, the storage management method further includes: when the multiple first-level cache entries miss and one of the multiple second-level cache entries hits, writing the replaced first-level cache entry into the at least one transfer backup buffer as a second-level cache entry.
[0032] In some embodiments, the plurality of registers further include: a fourth register, configured to store a size flag bit to indicate a page size of the virtual page / the translation page.
[0033] In some embodiments, when the multiple first-level cache entries miss and one of the multiple second-level cache entries hits, the preset algorithm selects the first-level cache entry to be replaced according to the size flag bit, so that the page size mapped by the hit second-level cache entry is equal to that of the replaced first-level cache entry.
[0034] In some embodiments, the number of the first-level cache entries is less than / equal to the number of the second-level cache entries.
[0035] Compared with traditional solutions, the storage management method and storage management device provided in the embodiments of the present invention perform hierarchical searches on multiple cache entries according to the virtual address specified by the translation request. Since the number of first-level cache entries is less than the total number of cache entries provided by the storage management device, if a first-level cache entry can be hit, the number of cache entries that need to be matched and compared with the virtual address specified by the translation request can be significantly reduced, thereby reducing the time required to search the cache entries during the address translation process, so that the efficiency, frequency and performance of the processor can be improved and the power consumption generated by the address translation process can be reduced.
[0036] In some preferred embodiments, if all first-level cache entries are not hit and a second-level cache entry is hit, the hit rate of multiple first-level cache entries can be further improved by replacing the hit second-level cache entry with a less frequently used first-level cache entry, thereby further reducing the time required to search for cache entries during the address translation process. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The above and other objects, features and advantages of the present invention will become more apparent through the description of the embodiments of the present invention with reference to the following drawings, in which:
[0038] Figure 1 A schematic block diagram showing a system according to an embodiment of the present invention;
[0039] Figure 2 is a schematic block diagram of a processor 1100 according to an embodiment of the present invention;
[0040] Figure 3 A schematic block diagram of a storage management unit according to an embodiment of the present invention is shown;
[0041] Figure 4 The schematic diagram of the principle of implementing address translation using TLB is shown;
[0042] Figure 5 A schematic diagram showing the flow of implementing address translation through TLB. DETAILED DESCRIPTION
[0043] The present invention is described below based on embodiments, but the present invention is not limited to these embodiments. In the detailed description of the present invention below, some specific details are described in detail. It is possible for a person skilled in the art to fully understand the present invention without the description of these details. In order to avoid confusing the essence of the present invention, known methods, processes, and procedures are not described in detail. In addition, the drawings are not necessarily drawn to scale.
[0044] The following terms are used in this article.
[0045] Computer systems: general-purpose embedded systems, desktops, servers, or other systems with information processing capabilities.
[0046] Memory: A physical structure located within a computer system and used to store information. Depending on the purpose, memory can be divided into main memory (also called internal memory, or simply internal memory / main memory) and auxiliary memory (also called external memory, or simply auxiliary memory / external memory). Main memory is used to store instruction information and / or data information represented by data signals, such as data provided by the processor, and can also be used to implement information exchange between the processor and external memory. The information provided by the external memory needs to be transferred to the main memory before it can be accessed by the processor. Therefore, the memory mentioned in this article generally refers to the main memory, and the storage device mentioned in this article generally refers to the external memory.
[0047] Physical Address (PA): An address on the address bus. The processor or other hardware can provide a physical address to the address bus to access main memory. A physical address may also be called an actual address, real address, or absolute address.
[0048] Virtual address: An abstract address used by software or programs. The virtual address space can be larger than the physical address space, and the virtual address can be mapped to the corresponding physical address.
[0049] Paging management mechanism: divide the virtual address space into multiple parts, each part is a virtual page, and divide the physical address space into multiple parts, each part is a physical page. Physical pages are also called physical address blocks or physical address page frames.
[0050] Root page table: used to specify the correspondence between virtual pages and physical pages, usually stored in main memory. The root page table includes multiple entries, each of which is used to specify the mapping relationship between virtual pages and physical pages and some management flags, so that the virtual address in the virtual page can be translated into the physical address in the corresponding physical page.
[0051] Cache entries: Some entries in the root page table that may be frequently used can be cached in the translation lookaside buffer so that they can be called during the address translation process, thereby speeding up the address translation process. In order to distinguish them from the entries in the root page table, the entries stored in the TLB will be referred to as cache entries in the following text.
[0052] The embodiments of the present application can be applied to systems such as the Internet and the Internet of Things (IoT), such as 5G mobile Internet systems, autonomous driving systems, etc. However, it should be understood that the embodiments of the present invention are not limited thereto, and can also be applied to any scenario where address translation needs to be implemented.
[0053] System Overview
[0054] Figure 1 A schematic block diagram of a computer system illustrating an embodiment of the present invention. Figure 1 The computer system 1000 shown in the figure is intended to illustrate at least some components of one or more electronic devices, and in other embodiments of the present invention, the components may be omitted. Figure 1 Some of the components shown may be connected to each other in a different architecture, and may also include Figure 1 Some hardware and / or software modules not shown in FIG. Figure 1 Two or more components shown in the figure may also be combined into one component in a software system and / or a hardware system.
[0055] In some embodiments, the computer system 1000 can be applied to a mobile device, a handheld device, or an embedded device, such as a smartphone using 5G technology or a processing platform of an autonomous vehicle. The computer system 1000 can also be applied to an Internet of Things device, a wearable device (such as a smart watch, smart glasses, etc.), or a television, a set-top box, and other devices.
[0056] like Figure 1 As shown, the computer system 1000 may include one or more processors 1100. For example, the computer system 1000 may be a terminal system including at least one processor, a workstation system including multiple processors, or a server system including a large number of processors or processor cores. The one or more processors 1100 in the computer system 1000 may be chips that are individually packaged, or may be integrated circuits integrated in a system on chip (SoC). The processor 1100 may be a central processing unit, a graphics processing unit, a physical processor, etc.
[0057] like Figure 1As shown, the computer system 1000 also includes a bus 1200, and the processor 1100 can be coupled to one or more buses 1200. The bus 1200 is used to transmit signals between the processor 1100 and other components in the computer system 1000, such as transmitting addresses, data or control signals. The bus 1200 can be a processor bus, such as a Direct Media Interface (DMI) bus, but the interface bus 1200 of the embodiment of the present invention is not limited to using the DMI bus as the interface bus, and can also include one or more interconnection buses, such as: a bus based on the Peripheral Component Interconnect (PCI) standard, a memory bus or other types of buses.
[0058] In some embodiments, Figure 1 As shown, the computer system 1000 also includes a memory 1300. The memory 1300, as the main memory of the computer system, can be a dynamic random access memory (DRAM), a static random access memory (SRAM) or other modules with storage capabilities. In some embodiments, the memory 1300 can be used to store data information and instruction information for use by one or more processors 1100 when executing applications or processes. In addition, the computer system 1000 can also include one or more storage devices 1800 to provide additional storage space as auxiliary memory.
[0059] The computer system 1000 may also be coupled to a display device 1400 , such as a cathode ray tube (CRT), a liquid crystal display (LCD), or an organic light emitting diode (OLED) array, via the bus 1200 to display information that the user needs to know.
[0060] In some embodiments, the computer system 1000 may include an input device 1500, such as a keyboard, a mouse, a touch panel, etc., for transmitting information corresponding to user operations to the corresponding processor 1100 via the bus 1200. The computer system 1000 may also include a collection device 1600, which can be coupled to the bus 1200 to transmit instructions and data related to information that can be collected, such as images / sounds. The collection device 1600 is, for example, a microphone and / or a video camera or camera for collecting images. The data provided by the input device 1500 and the collection device 1600 can be stored in the corresponding storage area of the storage device 1300, and the instructions provided by the input device 1500 and the collection device 1600 can be executed by the corresponding processor 1100.
[0061] The computer system 1000 may further include a network interface 1700 so that the system can access a network, such as a local area network (LAN), a wide area network (WAN), a metropolitan area network (MAN), a personal area network (PAN), Bluetooth, a cloud network, a mobile network (such as a Long Term Evolution, LTE) network, a 3G network, a 4G network, or a 5G network, etc.), an intranet, the Internet, etc. The network interface 1700 may include a wireless network interface having at least one antenna and / or a wired network interface that communicates via a network cable, and the network cable may be an Ethernet cable, a coaxial cable, a fiber optic cable, a serial cable, or a parallel cable.
[0062] The network interface 1700 may provide access to a LAN according to the IEEE 802.11b and / or 802.11g standards, or may provide access to a personal area network according to the Bluetooth standard, or may support other wireless network interfaces and / or protocols, including existing communication standards and future communication standards. The network interface 1700 may also utilize a time division multiple access (TDMI) protocol, a global system for mobile communications (GSM) protocol, a code division multiple access (CDMA) protocol, and / or other types of wireless communication protocols.
[0063] It should be noted that the above and Figure 1 It is only used to exemplarily describe the computer system 1000, and is not used to limit the specific implementation of the computer system 1000. The computer system 1000 may also include other components, such as a data processing unit, etc.; the various components of the computer system 1000 described above may also be appropriately omitted in actual applications.
[0064] processor
[0065] Figure 2 is a schematic block diagram of the processor 1100 in an embodiment of the present invention.
[0066] In some embodiments, each processor 1100 may include one or more processor cores 101 for processing instructions, and the processing and execution of instructions may be controlled by a user (e.g., through an application) and / or a system platform. In some embodiments, each processor core may be used to process a specific instruction set. In some embodiments, the instruction set may support complex instruction set computing (CISC), reduced instruction set computing (RISC), or very long instruction word (VLIW)-based computing. Different processor cores 101 may each process different instruction sets. In some embodiments, the processor core 101 may also include other processing modules, such as a digital signal processor (DSP), etc. As an example, Figure 2 , processor cores 1 to m are shown, where m is a non-zero natural number.
[0067] In some embodiments, Figure 2 As shown, the processor 1100 may include a cache, and according to different architectures, the cache in the processor 1100 may be a single or multi-level internal cache located inside and / or outside each processor core 101 (e.g., Figure 2 3-level cache L1 to L3) shown in the figure may also include an instruction-oriented instruction cache and a data-oriented data cache. In some embodiments, various components in the processor 1100 may share at least a portion of the cache, such as Figure 2 As shown, the processor cores 1 to m, for example, share a third-level cache L3. The processor 1100 may also include an external cache (not shown), and other cache structures may also serve as the external cache of the processor 1100.
[0068] In some embodiments, Figure 2 As shown, the processor 1100 may include a register file 104 (Register File), and the register file 104 may include multiple registers for storing different types of data and / or instructions, and these registers may be of different types. For example, the register file 104 may include: integer registers, floating point registers, status registers, instruction registers, and pointer registers. The registers in the register file 104 may be implemented by selecting general registers, or may adopt a specific design according to the actual needs of the processor 1100.
[0069] The processor 1100 may include a memory management unit (MMU) 105. The memory management unit 105 stores multiple cache entries for translating virtual addresses into physical addresses. One or more memory management units 105 may be provided in each processor core 101, and the memory management units 105 in different processor cores 101 may also be synchronized with the memory management units 105 in other processors or processor cores, so that each processor or processor core can share a unified virtual storage system.
[0070] In some embodiments, the internal interconnect structure is used to connect the storage management unit 105 to other processor cores via the internal bus of the system on chip, or directly connect to other modules in the system on chip to achieve signal exchange.
[0071] The storage management unit 105 may communicate with an instruction prefetch unit 106 for prefetching instructions and / or a load / store unit (LSU) 107 for loading / storing data in the processor 1100 .
[0072] The instruction prefetch unit 106 uses the virtual address of the prefetch instruction to access the storage management unit 105 to translate the physical address of the prefetch instruction, and the instruction prefetch unit 106 performs addressing in the physical address space to obtain the corresponding instruction according to the physical address generated by the translation of the storage management unit 105. The execution unit in the processor core 101 can receive the instruction obtained by the instruction prefetch unit 106 and process the instruction (e.g., decode) so that the instruction can be executed.
[0073] The load-store unit 107 is an instruction execution unit for memory access instructions (load instructions or store instructions). The load-store unit 107 can be used to obtain data information in the cache and / or memory 1300 according to the load instruction, and load the data information into the corresponding register in the processor 1100; the load-store unit 107 can also store the data information in the corresponding register into the cache and / or memory 1300 according to the store instruction. The registers include, for example, address registers, step registers, and address mask registers in the register file 104. The load-store unit 107 accesses the storage management unit 105 according to the virtual address of the memory access instruction, and the storage management unit 105 provides the physical address of the memory access instruction obtained after translation to the load-store unit 107, so that the load-store unit 107 can access the corresponding data in the physical address space according to the physical address.
[0074] It should be noted that the above and Figure 2It is only used to exemplify one of the processors in the system, and is not used to limit the specific implementation of the processor 1100. The processor 1100 may also include other components, such as a data processing unit, etc.; the various components of the processor 1100 described above may also be appropriately omitted in practical applications.
[0075] Storage Management Unit
[0076] The storage management unit 105 may also be referred to as a memory management unit in some cases, and may be a storage management device implemented by hardware and / or software.
[0077] In order to better manage the address space exclusively occupied by each process, the computer system 1000 can allocate independent virtual address space to some processes, and provide a mapping relationship from virtual address to physical address, so as to map or demap the virtual address space to the physical address space. As described above, since data is usually transmitted in the computer system 1000 in units of pages, the computer system and / or the operating system running on the computer system usually manages the physical address space and the virtual address space in units of pages, and the virtual address space can be larger than the physical address space, that is, a virtual page in the virtual address space can be mapped to a physical page in the physical address space, or can be mapped to a swap file, or there may be no mapping content.
[0078] Based on the above paging management mechanism, the mapping relationship between each virtual page in the virtual address space and each physical page in the physical address space can be stored in the root page table in the main memory. The root page table generally includes many entries, each of which is used to provide a mapping relationship between a virtual page and a corresponding physical page, so that the virtual address in the virtual page matching the entry can be translated into the corresponding physical address according to the entry.
[0079] For a certain process, the virtual address range corresponding to each virtual page (which may be referred to as the page size of the virtual page) should be consistent with the page size of the corresponding physical page, such as but not limited to 4kB (kilobytes), 8kB, 16kB, 64kB, etc. It should be added that for different processes, the page size of the corresponding virtual page may be consistent or inconsistent; similarly, for different processes, the page size of the corresponding physical page may be consistent or inconsistent, and different embodiments have different choices.
[0080] If TLB is not set, the storage management unit needs to access the memory (such as the RAM in the storage device 1300) at least twice after receiving the translation request: query the root page table stored in the memory to obtain the table entry that matches the translation request (the first memory access), and then translate the virtual address specified by the translation request into the corresponding physical address according to the table entry; read instructions and / or data from the memory according to the physical address (the second memory access). Multiple memory accesses result in a decrease in processor performance.
[0081] In order to reduce the number of memory accesses by the storage management unit and speed up the address translation process, such as Figure 2 As shown, at least one translation backup buffer TLB (also called fast table, bypass translation buffer, page table buffer, etc.) is provided in the storage management unit 105 of the disclosed embodiment, which is used to copy the table items that may be accessed from the memory to the TLB, and store them as cache table items, so as to cache the mapping relationship between the commonly used virtual pages and physical pages. Only when the cache table items that match the virtual address specified by the translation request cannot be queried in the TLB, the storage management unit 105 will access the root page table in the memory to obtain the corresponding table items; when there are cache table items that match the virtual address specified by the translation request in the TLB, the storage management unit 105 can complete the address translation without accessing the root page table. Therefore, the TLB can reduce the number of times the storage management unit accesses the memory, save the time required for address translation, and improve the processor performance.
[0082] Figure 3 A schematic block diagram of a storage management unit according to an embodiment of the present invention is shown.
[0083] According to different processing objects, the storage management unit 105 can independently set an instruction storage management unit for managing instruction storage and / or a data storage management unit for managing data storage. The storage management unit 105 can also manage the storage of instructions and data in a unified manner.
[0084] In some embodiments, Figure 3 As shown, an instruction TLB and a data TLB may be set in the storage management unit 105. The instruction TLB is used to cache instruction cache entries corresponding to instruction read and write addresses, and the data TLB is used to cache data cache entries corresponding to data read and write addresses. The instruction TLB is used, for example, to receive a translation request sent by the instruction prefetch unit 106, and return a corresponding physical address to the instruction prefetch unit 106. The data TLB is used, for example, to receive a translation request sent by the load storage unit 107, and return a corresponding physical address to the load storage unit 107.
[0085] In the embodiment of the present disclosure, the storage management unit 105 includes a multi-level TLB. As described above, the multi-level TLB can be a multi-level instruction TLB set in the instruction storage management unit for instruction address translation, or a multi-level data TLB set in the data storage management unit for data address translation, or a multi-level TLB in the storage management unit for unified management of the storage of instructions and data. In some embodiments, the storage management unit 105 may also include other TLBs set independently of the above-mentioned multi-level TLB.
[0086] As an example, Figure 3 As shown, the storage management unit 105 includes a first-level translation lookaside buffer TLB1 and a second-level translation lookaside buffer TLB2. The first-level translation lookaside buffer TLB1 stores m1 first-level cache entries, and the second-level translation lookaside buffer TLB2 stores m2 second-level cache entries, so that the total number of cache entries that the storage management unit 105 can provide is equal to m_all=m1+m2. Wherein, m1 and m2 are both natural numbers greater than or equal to 1, and m_all is a natural number greater than or equal to 2. In some preferred embodiments, m1 is less than or equal to m2, and each first-level cache entry is different from each second-level cache entry.
[0087] The following mainly describes the embodiment of the present invention by taking a 2-level TLB as an example, however, the embodiment of the present invention is not limited thereto, and at least a 3-level TLB may be set in the storage management unit 105 according to the example of the 2-level TLB proposed in the embodiment of the present disclosure.
[0088] like Figure 3 As shown, the storage management unit 105 may also include an address conversion unit 51 and a control unit 52. The address conversion unit 51 is used to search for a corresponding cache entry in the multi-level TLB according to a translation request, and translate the virtual address specified by the translation request into a physical address according to the cache entry; when the address conversion unit 51 does not find a cache entry matching the virtual address to be translated in the multi-level TLB, it may transmit mismatch information to the control unit 52, and the control unit 52 obtains a matching backfill entry from the root page table according to the mismatch information, and writes the backfill entry into the multi-level TLB so that one of the multi-level TLBs can hit; subsequently, the address conversion unit 51 may convert the virtual address to be translated into a physical address according to the matching cache entry.
[0089] In the embodiment of the present disclosure, the control unit 52 is also used to: when multiple first-level cache entries are missed and one of multiple second-level cache entries is hit, select one of the multiple first-level cache entries according to a preset algorithm, and replace the second-level cache entry that hits this time with one of the multiple first-level cache entries selected by the preset algorithm.
[0090] It should be noted that the above and Figure 3 It is only used to exemplify one of the storage management units in the computer system, and is not used to limit the specific implementation of the storage management unit 105. The storage management unit 105 may also include other components, and the various components of the storage management unit 105 described above may also be appropriately omitted in actual applications.
[0091] Translation Lookaside Buffer
[0092] In an embodiment of the present invention, each level of translation lookaside buffer TLB may include hardware devices and / or software programs, for example, implemented by multiple registers. Each cache entry may be stored independently in a corresponding register, and each level of TLB may also include a register for storing instructions such as read instructions and write instructions. Since the total number m_all of cache entries stored in the storage management unit 105 is limited by hardware resources, the total number m_all of cache entries in the storage management unit 105 characterizes the potential number of requests for the address translation process that the processor can realize without performance loss through TLB, that is, the larger the total number m_all of cache entries is, the stronger the address translation capability of the storage management unit 105 is, and therefore, as described above, it is desirable to increase the total number m_all of cache entries cached in the storage management unit 105 as much as possible.
[0093] This embodiment will take the full associative method as an example to describe the mapping method between the virtual address and the cache entry, that is, the TLB entry can map any entry in the root page table without being restricted by the specified bits in the virtual address or physical address. However, the embodiment of the present invention is not limited to this. In some other embodiments, the mapping method between the virtual address and the TLB entry can also be: direct mapping method, set associative method or other mapping methods.
[0094] Figure 4 A schematic diagram showing the principle of implementing address translation using TLB is shown.
[0095] Take a 32-bit address (which can refer to a virtual address or a physical address) and each address in a page (which can refer to a virtual page or a physical page) corresponds to 1B (Byte) as an example: if the size of the page is 4kB, then the page offset PO_4k of each address A[31:0] in the page is =A[11:0], and the page number PN_4k is =A[31:12]; if the size of the page is 8kB, then the page offset PO_8k of each address A[31:0] in the page is =A[12:0], and the page number PN_8k is =A[31:13]. Since the mapping between the virtual address and the physical address can be a mapping between pages, and the page size of the virtual page and the physical page to which it is mapped is consistent, the virtual address and the physical address to which it is mapped have the same page offset. The following will take this as an example to describe the process of using TLB to implement address translation in an embodiment of the present invention. However, it should be noted that the embodiment of the present invention is not limited to this. The virtual page or physical page can have other page sizes (for example, 64kB, 32kB, etc.), and the virtual address or physical address can be in other formats (for example, 64 bits, 128 bits, etc.), and in some other embodiments, the high and low positions of the page number and the offset within the page contained in the virtual address (or physical address) may be set and divided differently.
[0096] like Figure 4 As shown, the virtual address specified by the translation request can be translated into a corresponding physical address through a matching cache entry. The data structure of each cache entry (including the first-level cache entry and the second-level cache entry) may include: a virtual address tag Vtag, a physical address tag Ptag, and auxiliary information.
[0097] The virtual address tag Vtag is used to determine whether the cache entry matches the virtual address to be translated. Based on the above analysis, it can be known that the virtual page number can be used to identify the virtual page, so the virtual address tag Vtag of the cache entry and the virtual page number VPN of the virtual page mapped by the cache entry can be set to a consistent binary code, and the physical address tag of the cache entry and the physical page number PFN of the physical page mapped by the cache entry can be set to a consistent binary code. When the virtual page number VPN of the virtual address to be translated is consistent with the virtual address tag Vtag of the cache entry, it means that the cache entry is hit; in this case, since the virtual address and the physical address to which it is mapped have the same in-page offset PO, the physical address tag Ptag (used to replace the virtual page number of the virtual address) provided by the hit cache entry and the in-page offset PO of the virtual address to be translated can be synthesized into the physical address mapped by the virtual address to be translated to complete the translation.
[0098] For each cache table entry, the page size of the virtual page it maps is equal to the page size of the physical page it maps. Therefore, this article collectively refers to the page size of the virtual page mapped by the cache table entry and the page size of the physical page as the page size or page size mapped by the cache table entry.
[0099] In order to indicate the size of the page size mapped by each cache entry, the auxiliary information of the cache entry may include a size mark bit, which may be a one-bit or multi-bit binary code. In some embodiments, each cache entry may map a 4kB or 8kB page, and the size mark bit of the cache entry mapped to the 4kB page size may be set to 0, and the size mark bit of the cache entry mapped to the 8kB page size may be set to 1; when the page size mapped by a cache entry is extended from a 4kB page to an 8kB page, the size mark bit may be updated from 0 to 1. It should be noted that the embodiments of the present invention are not limited to this, and the cache entry may also be mapped to other page sizes, that is, each cache entry in the TLB may be mapped to one of a plurality of page sizes, and the number of bits of the size mark bit S may also be set accordingly according to the type of page size.
[0100] After receiving the translation request, the virtual page number VPN of the virtual address to be translated can be compared with the virtual address tag Vtag of each cache table entry to find a matching cache table entry. The size mark bit can be used to indicate the number of valid bits of the virtual address tag (that is, the number of bits used to compare with the virtual address during the search process). For example, the cache table entry E1 maps a 4kB virtual page VP1_4k. Assuming that the size identification bit S1 of the cache table entry E1 is 0, it means that the number of bits of the virtual address tag Vtag1 it contains is 20. These 20 bits can be compared with the 20-bit virtual page number of the virtual address to be translated to determine whether there is a match; Figure 5 The cache entry E2 shown maps an 8kB virtual page VP2_8k. Assuming that the size identification bit S2 of the cache entry E2 is 1, it means that the number of bits of the virtual address tag Vtag2 it contains is 19. These 19 bits can be compared with the 19-bit virtual page number of the virtual address to be translated to determine whether there is a match.
[0101] The auxiliary information of each cache entry may include a valid bit, which is used to indicate the status of each cache entry. In some scenarios, such as after executing a process switch or a root page table update operation, the translation relationship provided by the cache entry may no longer be applicable to the current situation. At this time, the valid bit of the corresponding cache entry can indicate a failure state (for example, an invalid level or 0), indicating that the cache entry cannot be used in the current address translation process and can be replaced or overwritten. When the valid bit of a cache entry indicates a valid state (for example, a valid level or 1), it indicates that the cache entry can be used to indicate whether the cache entry can be used in the current translation process. In some embodiments, when there is still free storage space that can be used to store cache entries in a multi-level TLB, the free storage space can also be equivalent to a cache entry in a failed state, and its valid bit indicates a failed state, which is used to indicate that the free storage space can be used to write a new cache entry.
[0102] It should be noted that in the following description, all cache entries that are hit are cache entries in a valid state.
[0103] In some embodiments, when each cache entry in the storage management unit 105 misses the translation request and the number of cache entries stored in the storage management unit 105 has reached the upper limit m_all, one of the cache entries needs to be replaced. At this time, a cache entry that can be replaced can be selected according to the frequency of use of each cache entry, for example, using an LRU (Least Recently Used) algorithm to replace the cache entry that has not been used the longest. In order to indicate the frequency of use, the auxiliary information of the cache entry may include a reference mark bit, which may be a binary code of one or more bits. When a cache entry is used for translation, the reference mark bit of the cache entry may be updated to indicate a higher frequency of use (or the reference mark bit of other cache entries is updated to indicate a lower frequency of use), so that when executing the LRU algorithm, a replaceable cache entry can be selected according to the reference mark bit of each cache entry.
[0104] In some embodiments, the auxiliary information of the cache entry may further include a dirty bit, which is used to indicate whether a certain address space in the memory has been modified. The dirty bit may also be one or more bits of binary code.
[0105] In some embodiments, the auxiliary information of the cache entry may further include other indication bits, for example, bits for indicating a process identification number associated with the page, the read and write permissions of the page, and page address attributes.
[0106] It should be noted that although in the above and Figure 4In the description, the virtual address tag, physical address tag and auxiliary information of each cache entry are arranged in order from high to low, but the embodiment of the present invention is not limited thereto. The virtual address tag, physical address tag and auxiliary information such as the size mark and valid bit of each cache entry can be arranged in different orders, for example, the size mark bit can be located at the highest bit of the cache entry to facilitate identification of the page size corresponding to the cache entry.
[0107] Address translation process
[0108] Figure 5 A schematic diagram showing a flow chart of a storage management method according to an embodiment of the present invention is shown. Figures 3 to 5 The illustrated embodiment exemplarily describes the process of translating a virtual address into a physical address.
[0109] like Figure 3 As shown, the storage management unit 105 includes a first-level translation lookaside buffer TLB1 and a second-level translation lookaside buffer TLB2. The first-level translation lookaside buffer TLB1 stores m1 first-level cache entries, and the second-level translation lookaside buffer TLB2 stores m2 second-level cache entries, so that the total number of cache entries that the storage management unit 105 can provide is equal to m_all=m1+m2. As described above and below, the embodiments of the present invention are not limited thereto.
[0110] like Figure 5 In step 510, a translation request is received, wherein the translation request specifies a virtual address to be translated, such as a virtual address of a prefetch instruction or a virtual address of a load instruction.
[0111] like Figure 5 Step 520 is shown, searching each level 1 cache entry for a virtual address tag that matches the virtual page number of the virtual address to be translated, to determine whether the level 1 translation lookaside buffer TLB1 hits.
[0112] This process can be achieved by comparing each data bit of the virtual page number of the virtual address to be translated with each data bit in the virtual address tag of each first-level cache entry. If the virtual address tag of a first-level cache entry is consistent with the virtual page number of the virtual address to be translated, and the first-level cache entry is in a valid state (that is, the first-level cache entry can be used for translation, for example, the valid bit of the first-level cache entry is at a valid level), it means that the first-level translation lookaside buffer TLB1 hits, and then step 560 is executed; if the virtual address tags of all first-level cache entries are inconsistent with the virtual page number of the virtual address to be translated, then the first-level translation lookaside buffer TLB1 does not hit, and then step 530 is executed.
[0113] As described above, the page sizes mapped by each level 1 cache entry may be different, and the size identification bit of each level 1 cache entry may indicate the number of valid bits of the corresponding virtual address tag.
[0114] As an example, when the number of valid bits of the virtual address tag of the first-level cache table entry being compared is 8, the size tag is set to 0, and the virtual address tag of the first-level cache table entry is compared with the upper 8 bits of the virtual address to be translated. If the two are consistent, it is determined that the first-level cache table entry matches the virtual address to be translated, otherwise it does not match; when the number of valid bits of the virtual address tag of the first-level cache table entry being compared is 7, the size tag is set to 1, and the virtual address tag of the first-level cache table entry is compared with the upper 7 bits of the virtual address to be translated. If the two are consistent, it is determined that the first-level cache table entry matches the virtual address to be translated, otherwise it does not match.
[0115] It should be noted that the above-mentioned terms such as "high 8 bits" and "high 7 bits" are merely examples, and are only used to limit the number of bits in the virtual address to be translated that are used for comparison with each virtual address label to be consistent with the effective number of bits of the virtual address label, and can be distributed in other positions of the virtual address in other examples to indicate at least a part of the virtual page number of the virtual address.
[0116] In some embodiments, when executing step 520, if a certain level 1 cache entry is hit, the search process can be stopped without continuing to compare the virtual address tags of the remaining level 1 cache entries with the virtual address to be translated, so as to save resources.
[0117] If the first level translation lookaside buffer TLB1 hits, Figure 5 In step 560, a physical address may be generated according to the hit first-level cache entry, thereby implementing the translation of the virtual address to the physical address through the first-level translation lookaside buffer TLB1. As described above, in the process of generating the physical address, the physical address tag of the hit cache entry and the page offset of the virtual address to be translated may be combined into a corresponding physical address.
[0118] Since the first-level translation lookaside buffer TLB1 hits, at most only m1 virtual address tags need to be compared with the virtual page number of the virtual address to be translated. Compared with the traditional solution of directly searching for matching cache entries in the m_all cache entries provided in the storage management unit according to the virtual address to be translated, the embodiment of the present disclosure can reduce the time required to search for cache entries to a certain extent, thereby improving the efficiency of the processor.
[0119] If the first level translation lookaside buffer TLB1 misses, Figure 5In the shown step 530, the second-level translation lookaside buffer TLB2 can continue to be searched for whether there is a second-level cache entry that matches the virtual address to be translated, that is, whether there is a virtual address tag that matches the virtual page number of the virtual address to be translated in each second-level cache entry, so as to determine whether the second-level translation lookaside buffer TLB2 hits.
[0120] Similar to step 520, in step 530, each data bit of the virtual page number of the virtual address to be translated can be compared with each data bit in the virtual address tag of each second-level cache table entry. If the virtual address tag of a second-level cache table entry is consistent with the virtual page number of the virtual address to be translated, and the second-level cache table entry is in a valid state (that is, the second-level cache table entry can be used for translation, for example, the valid bit of the second-level cache table entry is at a valid level), then it means that the second-level translation backup buffer TLB2 hits, and then step 570 is executed; if the virtual address tags of all second-level cache table entries are inconsistent with the virtual page number of the virtual address to be translated, then the second-level translation backup buffer TLB2 does not hit, and then step 550 is executed.
[0121] As described above, the page sizes mapped by each level 2 cache entry may be different, and the size identification bit of each level 2 cache entry may indicate the number of valid bits of the corresponding virtual address tag.
[0122] In some embodiments, when executing step 530, if a certain level 2 cache entry is hit, the search process can be stopped without continuing to compare the virtual address tags of the remaining level 2 cache entries with the virtual address to be translated, so as to save resources.
[0123] If the second level translation lookaside buffer TLB2 hits, Figure 5 In step 570, a physical address may be generated according to the hit second-level cache entry, thereby implementing the translation of the virtual address to the physical address through the second-level translation lookaside buffer TLB2. As described above, in the process of generating the physical address, the physical address tag of the hit cache entry and the page offset of the virtual address to be translated may be combined into a corresponding physical address.
[0124] Different from step 560, in step 570, if the second-level translation lookaside buffer TLB2 hits, the control unit 52 can exchange the hit second-level cache entry with a first-level cache entry in the first-level translation lookaside buffer TLB1, so that the hit second-level cache entry is written into the first-level translation lookaside buffer TLB1 as a new first-level cache entry, thereby further improving the hit rate of the first-level translation lookaside buffer TLB1, reducing the time required to determine whether each cache entry in the storage management unit is hit, and improving processor efficiency in an environment with good access locality.
[0125] In step 570, the control unit 52 may select the first-level cache entry that needs to be exchanged with the second-level cache entry that hits this time according to a preset algorithm. The control unit 52 may, for example, use a register to temporarily store the selected first-level cache entry and the second-level cache entry that hits this time, so that the temporarily stored first-level cache entry can be written into the corresponding position of the second-level translation lookaside buffer TLB2, and the second-level cache entry that hits this time can be written into the first-level translation lookaside buffer TLB1 as a new first-level cache entry.
[0126] The preset algorithm, for example, the LRU algorithm described above, can select the first-level cache entry that has not been used for the longest time (also known as the least recently hit) according to the reference mark bit of each first-level cache entry, and write the first-level cache entry into the second-level translation lookaside buffer TLB2 to achieve exchange with the second-level cache entry that is hit this time.
[0127] In some other more simplified embodiments, the preset algorithm may also be a first-in-first-out (FIFO) algorithm, and the first-level cache entry to be replaced may be selected according to the storage order of each first-level cache entry in the first-level translation lookaside buffer. For example, a corresponding register may be set for the first-in-first-out algorithm, in which a sequence flag code is stored, and the sequence flag code has an initial value (for example, 16'h0001). When the control unit 52 detects that the sequence flag code is the initial value, the first first-level cache entry written in the first-level translation lookaside buffer may be used as the first-level cache entry to be replaced; subsequently, the sequence flag code in the register increases by a gradient (for example, shifted left by one position to become 16'h0002), so that in the next first-in-first-out algorithm, the second first-level cache entry written in the first-level translation lookaside buffer may be used as the first-level cache entry to be replaced, and so on.
[0128] Compared with the FIFO algorithm, the LRU algorithm can more accurately select the first-level cache table items with low usage frequency, thereby having a lower impact on the hit rate of the first-level translation lookaside buffer; and compared with the LRU algorithm, the operation process of the FIFO algorithm is simpler, does not require too many software and hardware resources and time resources to implement, and has a faster response speed. Therefore, the FIFO algorithm or the LRU algorithm can be selected to implement step 570 according to actual needs.
[0129] However, the embodiments of the present disclosure are not limited to this. The preset algorithm can also select the first-level cache table entry to be replaced based on the size mark bit of the second-level cache table entry hit this time, so as to ensure that the size mark bit of the replaced first-level cache table entry is consistent with the size mark bit of the second-level cache table entry hit this time, or ensure that the page size indicated by the size mark bit of the replaced first-level cache table entry is less than / equal to the page size mapped by the size mark bit of the second-level cache table entry hit this time, so as to avoid reducing the address range mapped by the first-level translation backup buffer.
[0130] If the second level translation lookaside buffer TLB2 misses, Figure 5 In step 540 shown, a to-be-backfilled entry that matches the virtual address to be translated can be searched in the root page table (stored in a storage device such as a memory or a hard disk), and the to-be-backfilled entry can be written into the first-level translation lookaside buffer TLB1 or the second-level translation lookaside buffer TLB2, thereby implementing an update of the multi-level TLB, so that the updated multi-level TLB contains a cache entry that matches the virtual address to be translated.
[0131] In some embodiments, the cache entry to be replaced by the entry to be backfilled can be selected based on the reference mark bits of each cache entry in the multi-level TLB, and the replaced cache entry can be a level 1 cache entry or a level 2 cache entry. In other embodiments, the level 2 cache entry to be replaced can be preferentially selected in the level 2 translation lookaside buffer. The disclosed embodiments are not limited to this, for example: step 540 can also select a cache entry mapped to a smaller page size as the cache entry to be replaced by the entry to be backfilled based on the size mark bit.
[0132] In some embodiments, when it is determined that the second-level translation lookaside buffer TLB2 misses, the address translation unit 51 may first generate mismatch information based on the virtual address to be translated (including at least the virtual page number of the virtual address to be translated, and may also include all the bits of the virtual address to be translated), and then access the root page table based on the mismatch information, thereby searching for a table entry that matches the virtual address to be translated based on the mismatch information, and using the table entry as the entry to be backfilled.
[0133] In some embodiments, after step 550 is executed, a translation request (corresponding to the same virtual address as the translation request described in step 510) can be re-initiated, and steps 520, 560 or steps 520, 530 and 570 are executed accordingly, so as to use the updated first-level translation lookaside buffer TLB1 or the second-level translation lookaside buffer TLB2 to perform translation to obtain the corresponding physical address.
[0134] In other embodiments, after step 550 is executed, the virtual address to be translated can be directly translated using the updated cache entries in the first-level translation lookaside buffer TLB1 or the second-level translation lookaside buffer TLB2 to obtain the corresponding physical address, thereby omitting the process of searching each cache entry again.
[0135] The above mainly describes the embodiment of the present invention by taking the 2-level TLB as an example, however, the embodiment of the present invention is not limited thereto, and at least 3-level TLBs may be set in the storage management unit 105 according to the example of the 2-level TLB proposed in the embodiment of the present disclosure.
[0136] For example, the storage management unit 105 includes a first-level translation lookaside buffer TLB1, a second-level translation lookaside buffer TLB2, and a third-level translation lookaside buffer TLB3. The address translation unit 51 can search for a cache entry that matches the translation request in the priority order of the first to third-level translation lookaside buffers, that is, first search in the first-level translation lookaside buffer TLB1 whether there is a first-level cache entry that matches the translation request. If so, the address translation is directly implemented according to the hit first-level cache entry. If not, continue. A search is performed in the second-level translation lookaside buffer TLB2 to determine whether there is a second-level cache entry that matches the translation request. If the second-level translation lookaside buffer TLB2 still does not hit, a search is continued in the third-level translation lookaside buffer TLB3 to determine whether there is a third-level cache entry that matches the translation request. If the second-level translation lookaside buffer TLB2 or the third-level translation lookaside buffer TLB3 hits, the hit cache entry can be interchanged with the selected first-level cache entry to improve the hit rate of the first-level translation lookaside buffer TLB1.
[0137] In some embodiments, the number of cache entries provided by the first-level translation lookaside buffer (which is prioritized for hit determination) in the multi-level TLB is smaller than the number of cache entries provided by the translation lookaside buffers at other levels, so as to streamline the number of first-level cache entries provided by the first-level translation lookaside buffer, thereby reducing the time required to search for the first-level cache entries. In a further optimized embodiment, the number of cache entries provided by the first-level to last-level translation lookaside buffers in the multi-level TLB may be increased sequentially.
[0138] The above-mentioned embodiments uniformly divide the multiple cache entries provided by the storage management unit 105 into multiple first-level cache entries and multiple second-level cache entries, but the embodiments of the present invention are not limited thereto. For example, the storage management unit 105 may include multiple translation lookaside buffers TLBs (e.g., instruction TLBs and data TLBs), one or some of which may include several first-level cache entries and several second-level cache entries, and another or other translation lookaside buffers may not be divided into a multi-level structure, but only include several cache entries with the same search priority, and these cache entries with the same search priority may be cache entries with a higher access frequency.
[0139] So far, the method of implementing address translation by using a multi-level TLB has been described by way of example. The storage management method provided by the embodiment of the present invention is also described in the above embodiments.
[0140] When the processor executes a program, based on the program's access locality principle, whether it is accessing data or instructions, the continuous virtual addresses accessed by the processor are usually mapped to continuous physical addresses. Therefore, based on the above-mentioned paging management mechanism, it can be seen that the continuity of page allocation is very strong. The phenomena caused by the access locality principle can include: temporal locality, that is, a piece of information being accessed is likely to be accessed again in the near future. This phenomenon may be caused by the design of program loops or stacks; spatial locality, that is, the information being used and the information to be used are likely to be continuous or adjacent in address; and sequential locality, that is, most instructions are executed in sequence, and arrays may also be accessed in a continuous storage order.
[0141] In the traditional scheme, each address translation process needs to search for cache entries that match the virtual address to be translated one by one in the multiple cache entries provided by the storage management unit. The number of cache entries limits the address range that the storage management unit can directly translate. For high-performance processors, the virtual address range dynamically accessed by the program may be very wide. In order to improve the address translation efficiency as much as possible, the total number of cache entries stored in the storage management unit is constantly increased; on the other hand, high-performance processors also have high frequency requirements, and address translation is an operation process that occurs very frequently. Therefore, the large delay generated by the address translation process will hinder the further improvement of the processor frequency, and the process of searching for cache entries that match the translation request in more cache entries will also generate large power consumption. In particular, in the fully associative method mentioned above, each cache entry in the storage management unit may need to be compared with the virtual page number of the virtual address to be translated one by one, and then a cache entry is selected from the multiple cache entries that hit for the address translation process. The address translation efficiency is low, a large amount of power consumption is generated, the efficiency and performance of the processor are affected, and the improvement of the processor frequency is hindered.
[0142] Compared with traditional solutions, the storage management method and storage management device provided in the embodiments of the present invention perform hierarchical searches on multiple cache entries according to the virtual address specified by the translation request. Since the number of first-level cache entries is less than the total number of cache entries provided by the storage management device, if a first-level cache entry can be hit, the number of cache entries that need to be matched and compared with the virtual address specified by the translation request can be significantly reduced, thereby reducing the time required to search the cache entries during the address translation process, so that the efficiency, frequency and performance of the processor can be improved and the power consumption generated by the address translation process can be reduced.
[0143] In some preferred embodiments, if all first-level cache entries are not hit and a second-level cache entry is hit, the hit rate of multiple first-level cache entries can be further improved by replacing the hit second-level cache entry with a less frequently used first-level cache entry, thereby further reducing the time required to search for cache entries during the address translation process.
[0144] The present application also discloses a computer-readable storage medium including computer-executable instructions stored thereon, and when the computer-executable instructions are executed by a processor, the processor is caused to perform the methods of the embodiments described herein.
[0145] In addition, the present application also discloses a computer system, which includes a device for implementing the methods of the embodiments described herein.
[0146] It should be understood that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, there are many variations of the embodiments of this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
[0147] For example, although the specification only describes a method of translating a virtual address into a physical address using a multi-level TLB, each level of TLB is not limited to storing the relationship between the virtual address and the physical address. Before obtaining the physical address, some cache entries in the TLB can also convert the virtual address into a translation address, which can be converted into a physical address after further translation. The translation address space can also be divided into multiple parts under the paging management mechanism, each part is called a translation page. In addition, although in some embodiments, the cache entries of the TLB are used to translate virtual pages in the virtual address space, in other embodiments, the cache entries in the TLB can also be used to translate other types of addresses.
[0148] For another example, in some embodiments, the storage management unit may include an enable register, and the storage management unit may be turned on and off by configuring at least one value in the enable register.
[0149] It should be understood that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the method embodiment, since it is basically similar to the method described in the device and system embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of other embodiments.
[0150] It should be understood that the above is a description of a specific embodiment of the present specification. Other embodiments are within the scope of the claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0151] It should be understood that an element described in singular form herein or shown in the drawings as only one does not limit the number of the element to one. In addition, modules or elements described or shown as separate herein may be combined into a single module or element, and modules or elements described or shown as single herein may be split into multiple modules or elements.
[0152] It should also be understood that the terms and expressions used herein are for description only, and one or more embodiments of this specification should not be limited to these terms and expressions. The use of these terms and expressions does not mean to exclude any equivalent features of the illustrations and descriptions (or parts thereof), and it should be recognized that various modifications that may exist should also be included in the scope of the claims. Other modifications, changes and substitutions may also exist. Accordingly, the claims should be deemed to cover all such equivalents.
Claims
1. A storage management device, characterized in that: include: At least one translation lookaside buffer, used to store a plurality of cache entries, one or some of the at least one translation lookaside buffer having a multi-level structure and used to cache a plurality of first-level cache entries and a plurality of second-level cache entries, another or some of the at least one translation lookaside buffer not having a multi-level structure and used to cache other entries having the same search priority; an address translation unit, coupled to the at least one translation lookaside buffer, adapted to translate the virtual address specified by the translation request into a corresponding translation address according to one of the plurality of first-level cache entries, or to translate the virtual address specified by the translation request into a corresponding translation address according to one of the plurality of second-level cache entries when none of the plurality of first-level cache entries hits the translation request; as well as a control unit, when the plurality of first-level cache entries miss and one of the plurality of second-level cache entries hits, selecting one of the plurality of first-level cache entries according to a preset algorithm, and replacing the selected one of the plurality of first-level cache entries with the hit second-level cache entry, The preset algorithm includes: selecting one of the plurality of first-level cache entries according to the usage frequency, invalidation status or order of being written into the at least one translation lookaside buffer of each first-level cache entry for replacement by the hit second-level cache entry.
2. The storage management device according to claim 1, characterized in that: Each of the cache entries is stored by a plurality of registers, and the plurality of registers include: A first register, used to store a virtual address tag to indicate a virtual page mapped by the cache entry; and The second register is used to store a translation address tag to indicate the translation page mapped by the virtual page, and the page size of the virtual page and the translation page mapped by each cache entry is consistent.
3. The storage management device according to claim 2, characterized in that: The control unit is coupled to the address translation unit and is adapted to: When the virtual address tags of the plurality of cache entries do not hit the virtual address specified by the translation request, obtaining a to-be-backfilled entry matching the virtual address specified by the translation request from the root page table, The to-be-backfilled table entry is written into the at least one transfer lookaside buffer.
4. The storage management device according to claim 3, characterized in that: The address translation unit is adapted to: Determine whether the plurality of first-level cache entries hit the virtual address specified by the translation request, and if one of the plurality of first-level cache entries hits, translate the virtual address specified by the translation request into a corresponding translation address according to the hit first-level cache entry, If none of the plurality of first-level cache entries hits, determining whether the plurality of second-level cache entries hits the virtual address specified by the translation request, If one of the plurality of level 2 cache entries hits, the virtual address specified by the translation request is translated into a corresponding translation address according to the hit level 2 cache entry, If none of the plurality of level 2 cache entries hits, mismatch information is provided to the control unit so that the control unit acquires the entry to be backfilled.
5. The storage management device according to claim 2, characterized in that: The plurality of registers further comprises: The third register is used to store a reference mark bit to indicate whether the cache entry is the cache entry that has been hit least recently.
6. The storage management device according to claim 5, characterized in that: When selecting the plurality of first-level cache entries to be replaced according to the preset algorithm, the control unit is adapted to select the first-level cache entry that has been hit least recently according to the reference mark bit of each of the first-level cache entries.
7. The storage management device according to claim 1, characterized in that: When selecting the multiple first-level cache entries to be replaced according to the preset algorithm, the control unit is suitable for selecting the first-level cache entry written according to the order in which the multiple first-level cache entries are written into the at least one transfer backup buffer.
8. The storage management device according to claim 1, characterized in that: When the plurality of level 1 cache entries miss and one of the plurality of level 2 cache entries hits, the control unit is further adapted to write the replaced level 1 cache entry into the at least one transfer lookaside buffer as the level 2 cache entry.
9. The storage management device according to claim 2, characterized in that: The plurality of registers further comprises: The fourth register is used to store a size mark bit to indicate the page size of the virtual page / the translation page.
10. The storage management device according to claim 9, characterized in that: When the multiple first-level cache entries miss and one of the multiple second-level cache entries hits, the control unit is also suitable for selecting the first-level cache entry to be replaced according to the size mark bit, so that the page size mapped by the hit second-level cache entry is equal to that of the replaced first-level cache entry.
11. The storage management device according to claim 1, characterized in that: In the at least one translation lookaside buffer, the number of the level 1 cache entries is less than / equal to the number of the level 2 cache entries.
12. A processor, characterized in that: It comprises a storage management device as described in any one of claims 1 to 11.
13. The processor according to claim 12, characterized in that It also includes an instruction prefetch unit, which provides the translation request to the address conversion unit, wherein the translation request specifies the virtual address of the prefetch instruction. The address conversion unit communicates with a first translation lookaside buffer of the at least one translation lookaside buffer, and provides a translation address of the prefetch instruction to the instruction prefetch unit according to the cache entry provided by the first translation lookaside buffer.
14. The processor according to claim 12, characterized in that The invention also includes a load storage unit, wherein the load storage unit provides the translation request to the address conversion unit, wherein the translation request specifies the virtual address of the memory access instruction. The address conversion unit communicates with a second translation lookaside buffer of the at least one translation lookaside buffer, and provides the load-store unit with a translation address of the memory access instruction according to the cache entry provided by the second translation lookaside buffer.
15. A computer system, characterized in that: include: A processor as claimed in any one of claims 12 to 14; as well as A memory is coupled to the processor.
16. A storage management method, characterized in that: include: Providing a plurality of cache entries, the plurality of cache entries comprising a plurality of first-level cache entries and a plurality of second-level cache entries, the plurality of cache entries further comprising other entries that are not hierarchical and have the same search priority; receiving a translation request, the translation request specifying a virtual address to be translated; translating the virtual address specified by the translation request into a corresponding translation address according to one of the plurality of first-level cache entries, or translating the virtual address specified by the translation request into a corresponding translation address according to one of the plurality of second-level cache entries when none of the plurality of first-level cache entries hits the translation request; and When the plurality of first-level cache entries miss and one of the plurality of second-level cache entries hits, one of the plurality of first-level cache entries is selected according to a preset algorithm, and the selected one of the plurality of first-level cache entries is replaced with the hit second-level cache entry, The preset algorithm includes: selecting one of the plurality of first-level cache entries according to the usage frequency, invalidation status or order of being written into at least one translation lookaside buffer of each first-level cache entry for replacement by the hit second-level cache entry.
17. The storage management method according to claim 16, characterized in that: Each of the cache entries is stored by a plurality of registers, and the plurality of registers include: A first register, used to store a virtual address tag to indicate a virtual page mapped by the cache entry; and The second register is used to store a translation address tag to indicate the translation page mapped by the virtual page, and the page size of the virtual page and the translation page mapped by each cache entry is consistent.
18. The storage management method according to claim 17, characterized in that: Also includes: When the virtual address tags of the plurality of cache entries do not hit the virtual address specified by the translation request, obtaining a to-be-backfilled entry matching the virtual address specified by the translation request from the root page table, The to-be-backfilled entry is written as the first-level cache entry or the second-level cache representation into at least one transfer lookaside buffer for storing the plurality of cache entries.
19. The storage management method according to claim 18, characterized in that: The step of translating the virtual address specified by the translation request into a corresponding translation address according to one of the plurality of cache entries comprises: Determine whether the plurality of first-level cache entries hit the virtual address specified by the translation request, and if one of the plurality of first-level cache entries hits, translate the virtual address specified by the translation request into a corresponding translation address according to the hit first-level cache entry, If none of the plurality of first-level cache entries hits, determining whether the plurality of second-level cache entries hits the virtual address specified by the translation request, If one of the plurality of level 2 cache entries hits, the virtual address specified by the translation request is translated into a corresponding translation address according to the hit level 2 cache entry, If none of the plurality of level 2 cache entries hits, mismatch information is provided to a control unit so that the control unit acquires the entry to be backfilled.
20. The storage management method according to claim 17, characterized in that: The plurality of registers further comprises: The third register is used to store a reference mark bit to indicate whether the cache entry is the cache entry that has been hit least recently.
21. The storage management method according to claim 20, characterized in that: When selecting the plurality of first-level cache entries to be replaced according to the preset algorithm, the preset algorithm selects the first-level cache entry that has been hit least recently according to the reference mark bit of each of the first-level cache entries.
22. The storage management method according to claim 16, characterized in that: When selecting the multiple first-level cache entries to be replaced according to the preset algorithm, the preset algorithm selects the first-level cache entry written according to the order in which the multiple first-level cache entries are written into the at least one transfer backup buffer.
23. The storage management method according to claim 16, characterized in that: Also includes: When the plurality of first-level cache entries miss and one of the plurality of second-level cache entries hits, the replaced first-level cache entry is written into the at least one transfer lookaside buffer as one of the second-level cache entries.
24. The storage management method according to claim 17, characterized in that: The plurality of registers further comprises: The fourth register is used to store a size mark bit to indicate the page size of the virtual page / the translation page.
25. The storage management method according to claim 24, characterized in that: When the multiple first-level cache entries miss and one of the multiple second-level cache entries hits, the preset algorithm selects the first-level cache entry to be replaced according to the size mark bit, so that the page size mapped by the hit second-level cache entry is equal to the page size mapped by the replaced first-level cache entry.
26. The storage management method according to claim 16, characterized in that: The number of the first-level cache entries is less than / equal to the number of the second-level cache entries.
