WO2015043445A1 - Method and device for correlating virtual large page and physical large page - Google Patents
Method and device for correlating virtual large page and physical large page Download PDFInfo
- Publication number
- WO2015043445A1 WO2015043445A1 PCT/CN2014/087162 CN2014087162W WO2015043445A1 WO 2015043445 A1 WO2015043445 A1 WO 2015043445A1 CN 2014087162 W CN2014087162 W CN 2014087162W WO 2015043445 A1 WO2015043445 A1 WO 2015043445A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- physical
- page
- virtual
- large page
- pages
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/10—Address translation
Definitions
- the present invention relates to the field of computer applications, and in particular, to a method and an apparatus for corresponding virtual large pages and physical large pages.
- Large page (Hugepage or Hugetlb) technology can map multiple consecutive virtual memory space pages to consecutive multiple physical memory space pages, so that these physical memory space pages form a large page, and each large page is next to the transfer address. Only one TLB entry is required in the Translation Lookaside Buffer (TLB), which greatly increases the address range that the TLB can cover without increasing the number of TLB entries, effectively reducing the number of TLB misses and improving The performance of the application and system.
- TLB Translation Lookaside Buffer
- a large page composed of a plurality of virtual pages with consecutive virtual addresses is referred to as a virtual large page, and the virtual pages are mapped to a plurality of physical pages consecutive to the corresponding physical addresses by TLB entries.
- the large pages of these contiguous physical pages are called physical large pages.
- the physical page has a fixed correspondence with the cache set cache set in the cache cache. And each cache set controls a color.
- the physical large pages corresponding to these virtual large pages share the cache, so that a cache conflict occurs.
- the physical large page will occupy a continuous 512 page color, which is just a color cycle, which means that each 2MB physical large page will occupy all available page colors, so that Each 2MB physical large page will share the cache, so when you access the physical large page, there is a cache conflict.
- Embodiments of the present invention provide a method and an apparatus for mapping a virtual large page and a physical large page, which can map a virtual large page to a plurality of discrete physical large pages, thereby controlling a cache set that can be occupied by the virtual large page, and reducing the cache set.
- the first aspect provides a corresponding method for a virtual large page and a physical large page, including:
- the color configuration information includes a corresponding physical page corresponding to the virtual large page in each of the physical large pages and the virtual large page in each of the physical large pages The number of corresponding physical pages;
- one virtual page in the virtual large page corresponds to one physical page in the physical large page
- the acquiring the color configuration information of the virtual large page includes:
- the color configuration information is determined from the bypass conversion buffer TLB by a virtual large page number in the virtual address.
- the method further includes:
- the color block is used to represent multiple colors in the cache corresponding to the plurality of physical pages corresponding to the virtual large page in each of the physical large pages;
- the plurality of physical pages corresponding to the color block are in one physical large page, and physical addresses of the plurality of physical pages are consecutive.
- the virtual large page number is recorded in the TLB Corresponding to the physical large page number, the method further includes:
- the second aspect provides a corresponding device for a virtual large page and a physical large page.
- a virtual large page corresponds to multiple physical large pages, and physical addresses of the plurality of physical large pages are discontinuous.
- the device includes:
- An obtaining unit configured to obtain color configuration information of a virtual large page, where the color configuration information includes a corresponding starting physical page and a virtual large page in each of the physical large pages. The number of corresponding physical pages in the physical large page;
- one virtual page in the virtual large page corresponds to one physical page in the physical large page
- the obtaining unit is further configured to acquire, according to the acquired color configuration information of the virtual large page, a correspondence between the virtual large page and multiple physical large pages;
- a storage unit configured to store color configuration information of the virtual large page acquired by the acquiring unit.
- the acquiring unit includes:
- the method further includes:
- a dividing unit configured to divide the virtual large page internal offset in the virtual address determined by the determining subunit into two parts: a discrete shift Scattered Shift and an internal offset CR Offset of the color block, the Scattered Shift a physical large page number corresponding to the virtual large page;
- the color block is used to represent multiple colors in the cache corresponding to the plurality of physical pages corresponding to the virtual large page in each of the physical large pages;
- the plurality of physical pages corresponding to the color block are in one physical large page, and physical addresses of the plurality of physical pages are consecutive.
- the virtual large page number is recorded in the TLB
- the device further includes:
- a determining unit configured to determine, by using a virtual large page number in the virtual address, a page number of the first physical large page corresponding to the virtual large page from the TLB;
- a calculating unit configured to add, by the determining unit, a page number of the first physical large page and a number of the physical large page corresponding to the virtual large page, to obtain a corresponding to the virtual large page The page number of each physical large page;
- the determining unit is further configured to determine a page number of the corresponding starting physical page of the virtual large page in each of the physical large pages;
- a splicing unit configured to splicing a page number of a corresponding starting physical page in each of the physical large pages determined by the determining unit with the CR Offset, to obtain the physical address corresponding to the virtual address.
- a virtual large page corresponds to multiple physical large pages, and physical addresses of multiple physical large pages are discontinuous.
- the color configuration can be configured according to the color
- the information acquires the correspondence between the virtual large page and the plurality of physical large pages.
- a virtual large page can only correspond to a physical large page whose physical address is continuous, so that when there are multiple virtual large pages, a physical large page corresponding to the virtual large page is shared, thereby causing a cache. conflict.
- the technical solution provided by the embodiment of the present invention can map a virtual large page to a plurality of discrete physical large pages, thereby controlling a cache set that can be occupied by the virtual large page, and reducing a cache conflict between the virtual large pages.
- FIG. 1 is a flowchart of a method for mapping a virtual large page and a physical large page according to an embodiment of the present invention
- FIG. 2 is a flowchart of a method for mapping a virtual large page and a physical large page according to another embodiment of the present invention
- FIG. 3 is a schematic structural diagram of a virtual address of a virtual large page according to another embodiment of the present invention.
- FIG. 4 is a schematic structural diagram of a TLB according to another embodiment of the present disclosure.
- 5-1 is a schematic diagram of a correspondence between a virtual large page and a physical large page according to another embodiment of the present invention.
- 5-2 is a schematic diagram of correspondence between another virtual large page and a physical large page according to another embodiment of the present invention.
- FIG. 6 is a schematic diagram of a composition of a corresponding device of a virtual large page and a physical large page according to another embodiment of the present invention.
- FIG. 7 is a schematic structural diagram of another device corresponding to a virtual large page and a physical large page according to another embodiment of the present invention.
- FIG. 8 is a schematic structural diagram of a corresponding device of a virtual large page and a physical large page according to another embodiment of the present invention.
- An embodiment of the present invention provides a method for mapping a virtual large page and a physical large page.
- a virtual large page corresponds to multiple physical large pages, and physical addresses of the multiple physical large pages are discontinuous.
- the method includes:
- the color configuration information includes a corresponding physical start page of the virtual large page in each physical large page.
- one virtual page in the virtual large page corresponds to one physical page in the physical large page, and the corresponding relationship is variable.
- a method for correspondingly displaying a virtual large page and a physical large page obtains a starting physical page and a virtual large page corresponding to each virtual large page in each physical large page. After the color configuration information of the number of physical pages is corresponding, the correspondence between the virtual large page and the plurality of physical large pages can be acquired according to the color configuration information.
- a virtual large page can only correspond to a physical large page whose physical address is continuous, so that when there are multiple virtual large pages, a physical large page corresponding to the virtual large page is shared, thereby causing a cache. conflict.
- the technical solution provided by the embodiment of the present invention can map a virtual large page to a plurality of discrete physical large pages, thereby controlling a cache set occupied by the virtual large page, and reducing a cache conflict between the virtual large pages.
- Another embodiment of the present invention provides a method for mapping a virtual large page to a physical large page. As shown in FIG. 2, the method includes:
- each virtual large page is composed of a plurality of virtual pages consecutively by virtual addresses, and each virtual page has a virtual address of the virtual page corresponding thereto, so after determining the virtual large page to be operated, the The virtual address of the virtual large page is determined.
- the virtual address of the virtual large page is composed of a high virtual large page number and a low virtual outer page internal offset.
- the internal offset of the virtual large page in the virtual address is divided into two parts: a discrete shift Scattered Shift and an internal offset CR Offset of the color block.
- the Scattered Shift is used to index the physical large page number corresponding to the virtual large page, and the Scattered Shift is divided into the high position of the internal offset of the virtual large page.
- the Scattered Shift can represent the number of physical large pages corresponding to the virtual large page.
- the Scattered Shift is represented by two bits, corresponding to each When the physical page is large, it can be 00, 01, 10, and 11, respectively.
- the first two digits are left, and the remaining digits are CR Offset.
- the virtual address from the high to the low is the virtual large page number, the virtual Huge Page Number, the discrete shift Scattered Shift, and the internal offset CR of the color block. Offset, and Scattered Shift and CR Offset form a virtual large page internal offset Huge Page Offset.
- the following 202 is performed.
- page table files are stored in the TLB. These page table files are conversion tables of virtual addresses to physical addresses, and records the correspondence between virtual large page numbers and physical large page numbers. Specifically, the physical large page number corresponding to the virtual large page number is found in the TLB according to the virtual large page number in the virtual address, and the color configuration information is determined together from the TLB.
- the TLB structure includes: Tag, Attr., Base Huge PPN (Physical Page Number), CR_Entry (Color Region_Entry), and CR_Num.
- the Tag indicates the tag of the page address matching; the Attr. indicates the page attribute; the Base Huge PPN indicates the physical large page start page number, which in this embodiment also refers to the first physical large page corresponding to the virtual large page.
- the page number; CR_Entry indicates the starting color block used by the physical large page, that is, the corresponding starting physical page of the virtual large page in each physical large page; the number of CR_Num color blocks, that is, the virtual large page is in each physical large page. The number of corresponding physical pages. Among them, CR_Entry and CR_Num are stored in the TLB as color configuration information of the virtual large page.
- CR represents a color block
- the color block can represent a color and can also represent a continuous color.
- a configurable color region composed of a plurality of colors, that is, a plurality of colors in the cache corresponding to the plurality of physical pages corresponding to the virtual large page in each physical large page, and corresponding to the color block
- Multiple physical pages are in one physical large page, and the physical addresses of these physical pages are continuous. Since a physical large page contains a large number of physical pages, the number of colors corresponding to the physical large page corresponds to a large number, so that it is not necessary to perform fine-grained control on the color corresponding to each physical page.
- a color block can be thought of as the basic unit of color configuration in a large physical page.
- the TLB involved in the embodiment of the present invention adds color configuration information compared to the conventional TLB, and the color configuration information may be directly added to the TLB, and the color configuration information may be controlled by software, and then written. Go to the TLB.
- the interface for obtaining the color configuration information needs to be set on the TLB, and the interface can be configured in the TLB.
- the implementation form of the interface is not limited in the embodiment of the present invention.
- the plurality of physical large pages whose physical addresses are not consecutive may be referred to as discrete large pages.
- a configuration interface for deciding whether to start a discrete large page. Further, when the configuration is 1 to indicate that the discrete large page is enabled, and 0 is to use the conventional large page, wherein the regular large page, that is, one virtual large page corresponds to one physical large page.
- each color block contains the same number of colors, and the starting color block is the same in each physical large page corresponding to the virtual large page, and the color occupied in each physical large page.
- the number of blocks is also the same.
- the physical address corresponding to the virtual address may be obtained according to the virtual address of the virtual large page and the color configuration information of the obtained virtual large page, and the following 204 may be continued. .
- the virtual address of the virtual large page and the color configuration information of the virtual large page are obtained.
- splicing is a simple physical shift, that is, the digit representing the latter parameter is directly added to the lower digit of the previously determined digit.
- val(Scattered_Shift) represents the return value of Scattered_Shift, such as when Scattered_Shift is 00, the value of val(Scattered_Shift) is 0; when Scattered_Shift is 01. Then determine the value of val(Scattered_Shift) to 1.
- obtaining the physical address includes:
- the physical address of the first physical large page corresponding to the virtual large page needs to be determined, that is, the first physical large page corresponding to the virtual large page is determined. Page number. Therefore, it is necessary to perform the following a.
- each virtual large page is composed of a plurality of virtual pages consecutive to virtual addresses.
- a virtual page of consecutive virtual addresses is used as a virtual page.
- the overall analysis that is, dividing a plurality of virtual pages in a virtual large page into a plurality of virtual page groups of consecutive virtual addresses, each set of virtual pages corresponding to a set of physical pages consecutive to physical addresses, that is, corresponding to one color block, and The one or more sets of physical pages with consecutive physical addresses exist in one physical large page.
- the page number of the physical large page corresponding to each virtual page needs to be determined, that is, the Base Huge PPN+val (Scattered_Shift) is determined, and b is performed as follows.
- one virtual large page is corresponding to multiple physical large pages, and the physical addresses between the multiple physical large pages are discontinuous.
- the number of physical large pages corresponding to the virtual large page can be further determined by CR_Entry and CR_Num.
- the number of colors available in the cahce is the number of all colors available for the physical large page, and only the number of all available color blocks.
- the page number of the first physical large page corresponding to the virtual large page obtained in the above a may be sequentially acquired to correspond to the virtual large page.
- the page number of each physical large page may be sequentially acquired to correspond to the virtual large page.
- the obtained color configuration information of the virtual large page includes the corresponding starting physical page of the virtual large page in each physical large page, after determining the starting physical page, the starting can be determined.
- the physical address of the physical page, and the page number of the starting physical page is included in the physical address of the starting physical page, so that the page number of the page in the corresponding starting area in each physical large page can be determined.
- the color configuration information of the virtual large page includes CR_Entry, and the CR_Entry represents the starting color block used by the physical large page, that is, the virtual large page corresponds to each physical large page.
- the page number corresponding to the physical page can be determined when the physical page is determined.
- the splicing mentioned here is based on determining the number of digits before the physical address, adding CR Offset to the lower bit, thereby forming a complete physical address, and the physical address is corresponding to the virtual address of the virtual large page. .
- the color block is a basic unit of color configuration in a physical large page, that is, a plurality of virtual pages in the virtual large page are divided into a plurality of virtual page groups, wherein each virtual page group is divided by a virtual address. Consecutive multiple virtual pages.
- each physical large page is also divided into the same number of physical page groups, thereby determining that the number of color blocks is the same as the number of physical page groups.
- each physical large page has 8 available color blocks, and in turn, each color block is labeled 0, 1, 2...7.
- a method for correspondingly displaying a virtual large page and a physical large page obtains a starting physical page and a virtual large page corresponding to each virtual large page in each physical large page. After the color configuration information of the number of physical pages is corresponding, the correspondence between the virtual large page and the plurality of physical large pages can be acquired according to the color configuration information.
- a virtual large page can only correspond to a physical large page whose physical address is continuous, so that when there are multiple virtual large pages, a physical large page corresponding to the virtual large page is shared, thereby causing a cache. conflict.
- the technical solution provided by the embodiment of the present invention can map a virtual large page to a plurality of discrete physical large pages, thereby controlling a cache set that can be occupied by the virtual large page, and reducing a cache conflict between the virtual large pages.
- a virtual large page corresponds to multiple physical large pages, and physical addresses of the multiple physical large pages are discontinuous.
- the apparatus includes an acquisition unit 61 and a storage unit 62.
- the obtaining unit 61 is configured to obtain color configuration information of the virtual large page.
- the color configuration information includes the number of corresponding physical pages of the virtual large page in each physical large page and the corresponding physical pages of the virtual large page in each physical large page.
- a virtual page in a virtual large page corresponds to one physical page in a physical large page.
- the obtaining unit 61 is further configured to obtain a correspondence between the virtual large page and the plurality of physical large pages according to the acquired color configuration information of the virtual large page.
- the storage unit 62 is configured to store color configuration information of the virtual large page acquired by the obtaining unit 61.
- the apparatus further includes: a dividing unit 63, a determining unit 64, a calculating unit 65, a splicing unit 66, an obtaining unit 61, and a determining subunit 611.
- the determining subunit 611 is configured to determine a virtual address of the virtual large page; and determine color configuration information from the bypass conversion buffer TLB by the virtual large page number in the virtual address.
- the dividing unit 63 is configured to divide the virtual large page internal offset in the virtual address determined by the determining subunit 611 in the obtaining unit 61 into two parts: a discrete shift Scattered Shift and an internal offset CR Offset of the color block.
- the Scattered Shift is used to index the physical large page number corresponding to the virtual large page; the color block is used to represent multiple colors in the cache corresponding to the plurality of physical pages corresponding to the virtual large page in each physical large page, and the color The plurality of physical pages corresponding to the block are in one physical large page, and the physical addresses of the plurality of physical pages are consecutive.
- the determining unit 64 is further configured to determine, by the virtual large page number in the virtual address determined by the determining subunit 611 in the obtaining unit 61, the page number of the first physical large page corresponding to the virtual large page from the TLB.
- the calculating unit 65 is configured to add the page number of the first physical large page determined by the determining unit 64 to the number of physical large pages corresponding to the virtual large page, to obtain a page of each physical large page corresponding to the virtual large page. number.
- the determining unit 64 is further configured to determine a page number of the corresponding starting physical page of the virtual large page in each physical large page.
- the splicing unit 66 is configured to splicing the page number of the corresponding starting physical page in each physical large page determined by the determining unit 64 with the CR Offset obtained by the dividing unit 63 to obtain a virtual address corresponding to the splicing unit 63. Physical address.
- the corresponding device of the virtual large page and the physical large page provided by the embodiment of the present invention acquires the starting physical page and the virtual large page corresponding to each virtual large page in each physical large page in the obtaining unit. After the color configuration information of the number of corresponding physical pages in the page, the corresponding relationship between the virtual large page and the plurality of physical large pages can be acquired according to the color configuration information.
- a virtual large page can only correspond to a physical large page whose physical address is continuous, so that when there are multiple virtual large pages, a physical large page corresponding to the virtual large page is shared, thereby causing a cache. conflict.
- the technical solution provided by the embodiment of the present invention can map a virtual large page to a plurality of discrete physical large pages, thereby controlling a cache set that can be occupied by the virtual large page, and reducing a cache conflict between the virtual large pages.
- FIG. 8 is a schematic diagram of a hardware structure of a corresponding device of a virtual large page and a physical large page.
- the device may include a processor 01, a memory 02, and a bus 03.
- the processor 01 and the memory 02 are connected by a bus 03.
- the processor 01 can be a general-purpose central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), or one or more integrated circuits for executing related programs.
- CPU central processing unit
- ASIC application specific integrated circuit
- the memory 02 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM).
- the memory 1102 can store an operating system and other applications.
- the program code for implementing the technical solution provided by the embodiment of the present invention is stored in the memory 02 and executed by the processor 01 when the technical solution provided by the embodiment of the present invention is implemented by software or firmware.
- Bus 03 may include a path for communicating information between various components of the device (e.g., memory 02 and processor 01).
- FIG. 8 only shows the processor 01, the memory 02, and the bus 03, in the specific implementation process, those skilled in the art should understand that the terminal also includes other necessary for normal operation. Device. At the same time, according to specific needs, those skilled in the art should understand that Hardware devices that implement other functions can also be included.
- the processor 01 is configured to determine a virtual address of the virtual large page, and determine color configuration information from the bypass conversion buffer TLB by using a virtual large page number in the virtual address.
- the color configuration information includes the number of corresponding physical pages of the virtual large page in each physical large page and the corresponding physical pages of the virtual large page in each physical large page. And one virtual page in the virtual large page corresponds to one physical page in the physical large page.
- the processor 01 is further configured to obtain a correspondence between the virtual large page and the plurality of physical large pages according to the color configuration information of the virtual large page.
- the memory 02 is configured to store a virtual address of the virtual large page determined by the processor 01 and color configuration information determined from the TLB.
- the processor 01 is further configured to divide the virtual large page internal offset in the virtual address into two parts: a discrete shift Scattered Shift and an internal offset CR Offset of the color block.
- the Scattered Shift is used to index the physical large page number corresponding to the virtual large page; the color block is used to represent multiple colors in the cache corresponding to the plurality of physical pages corresponding to the virtual large page in each physical large page.
- the plurality of physical pages corresponding to the color block are in one physical large page, and physical addresses of the plurality of physical pages are consecutive.
- the mapping between the virtual large page number and the physical large page number is recorded in the TLB.
- the processor 01 is further configured to determine, by the virtual large page number in the virtual address, the large virtual number from the TLB.
- the page number of the first physical large page corresponding to the page; adding the page number of the first physical large page to the number of physical large pages corresponding to the virtual large page, and obtaining each physical large page corresponding to the virtual large page The page number of the corresponding physical page of the virtual large page in each physical large page; and the page number of the corresponding starting physical page in each physical large page is spliced with CR Offset to obtain the same
- the corresponding device of the virtual large page and the physical large page acquires the starting physical page and the virtual large page corresponding to each virtual large page in each physical large page in the processor. After storing the color configuration information of the number of corresponding physical pages in the page, the memory stores the Obtaining the color configuration information, and further obtaining the correspondence between the virtual large page and the plurality of physical large pages according to the color configuration information.
- a virtual large page can only correspond to a physical large page whose physical address is continuous, so that when there are multiple virtual large pages, a physical large page corresponding to the virtual large page is shared, thereby causing a cache. conflict.
- the technical solution provided by the embodiment of the present invention can map a virtual large page to a plurality of discrete physical large pages, thereby controlling a cache set that can be occupied by the virtual large page, and reducing a cache conflict between the virtual large pages.
- the present invention can be implemented by means of software plus necessary general hardware, and of course, by hardware, but in many cases, the former is a better implementation. .
- the technical solution of the present invention which is essential or contributes to the prior art, can be embodied in the form of a software product stored in a readable storage medium, such as a floppy disk of a computer.
- a hard disk or optical disk, etc. includes instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform the methods described in various embodiments of the present invention.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Memory System Of A Hierarchy Structure (AREA)
Abstract
A method and device for correlating a virtual large page and a physical large page, which relate to the field of computer applications. A virtual large page is correlated to a plurality of discrete physical large pages, so that the virtual large page can occupy a designated cache set, thereby reducing cache conflicts among virtual large pages. A specific embodiment comprises: acquiring colour configuration information about a virtual large page, and according to the colour configuration information about the virtual large page, acquiring a correlation between the virtual large page and a plurality of physical large pages, wherein the configuration information comprises the number of start physical pages corresponding to the virtual large page in each physical large page and physical pages corresponding to the virtual large page in each physical large page. The method and device are mainly applied to a correlating flow of a virtual large page and a physical large page.
Description
本发明涉及计算机应用领域,尤其涉及一种虚拟大页面与物理大页面的对应方法及装置。The present invention relates to the field of computer applications, and in particular, to a method and an apparatus for corresponding virtual large pages and physical large pages.
大页面(Hugepage或Hugetlb)技术可实现将连续的多个虚拟内存空间页面映射到连续的多个物理内存空间页面,从而使这些物理内存空间页面组成一个大页面,每个大页面在转址旁路缓存(Translation Lookaside Buffer,TLB)中只需占用1个TLB项,进而在不增加TLB项数的情况下,极大提高TLB可覆盖的地址范围,有效降低TLB缺失(Miss)个数,提高了应用程序及系统的性能。在实际应用中,将虚拟地址连续的多个虚拟页面组成的大页面称为虚拟大页面,而这些虚拟页面通过TLB表项,映射到与之对应个数的物理地址连续的多个物理页面上,这些连续的物理页面组成的大页面称为物理大页面。在操作系统中,物理页面与缓存器cache中的缓存组cache set存在固定的对应关系。并且每一个cache set控制一种颜色,当存在多个虚拟大页面时,这些虚拟大页面对应的物理大页面会共享cache,这样就会出现cache冲突。比如,对于2MB的物理大页面,该物理大页面将占用连续的512个页面颜色,刚好是一个颜色周期,这就意味着,每个2MB的物理大页面都将占用全部可用的页面颜色,这样每个2MB的物理大页面就会共享cache,从而在访问物理大页面时,就是出现cache冲突问题。Large page (Hugepage or Hugetlb) technology can map multiple consecutive virtual memory space pages to consecutive multiple physical memory space pages, so that these physical memory space pages form a large page, and each large page is next to the transfer address. Only one TLB entry is required in the Translation Lookaside Buffer (TLB), which greatly increases the address range that the TLB can cover without increasing the number of TLB entries, effectively reducing the number of TLB misses and improving The performance of the application and system. In a practical application, a large page composed of a plurality of virtual pages with consecutive virtual addresses is referred to as a virtual large page, and the virtual pages are mapped to a plurality of physical pages consecutive to the corresponding physical addresses by TLB entries. The large pages of these contiguous physical pages are called physical large pages. In the operating system, the physical page has a fixed correspondence with the cache set cache set in the cache cache. And each cache set controls a color. When there are multiple virtual large pages, the physical large pages corresponding to these virtual large pages share the cache, so that a cache conflict occurs. For example, for a 2MB physical large page, the physical large page will occupy a continuous 512 page color, which is just a color cycle, which means that each 2MB physical large page will occupy all available page colors, so that Each 2MB physical large page will share the cache, so when you access the physical large page, there is a cache conflict.
发明内容Summary of the invention
本发明的实施例提供一种虚拟大页面与物理大页面的对应方法及装置,能够将虚拟大页面对应到多个离散的物理大页面上,从而控制虚拟大页面能够占用的cache set,降低了虚拟大页面之间的cache冲突。Embodiments of the present invention provide a method and an apparatus for mapping a virtual large page and a physical large page, which can map a virtual large page to a plurality of discrete physical large pages, thereby controlling a cache set that can be occupied by the virtual large page, and reducing the cache set. A cache conflict between virtual large pages.
为达到上述目的,本发明的实施例采用如下技术方案:In order to achieve the above object, embodiments of the present invention adopt the following technical solutions:
第一方面,提供了一种虚拟大页面与物理大页面的对应方法,包括:
The first aspect provides a corresponding method for a virtual large page and a physical large page, including:
获取虚拟大页面的颜色配置信息,所述颜色配置信息包括所述虚拟大页面在每个所述物理大页面中对应的起始物理页面和所述虚拟大页面在每个所述物理大页面中对应的物理页面的个数;Obtaining color configuration information of the virtual large page, where the color configuration information includes a corresponding physical page corresponding to the virtual large page in each of the physical large pages and the virtual large page in each of the physical large pages The number of corresponding physical pages;
其中,所述虚拟大页面中的一个虚拟页面对应所述物理大页面中的一个物理页面;Wherein one virtual page in the virtual large page corresponds to one physical page in the physical large page;
根据所述虚拟大页面的颜色配置信息,获取所述虚拟大页面与多个物理大页面的对应关系。Obtaining a correspondence between the virtual large page and the plurality of physical large pages according to the color configuration information of the virtual large page.
在第一方面的第一种可能实现方式中,所述获取虚拟大页面的颜色配置信息,包括:In a first possible implementation manner of the first aspect, the acquiring the color configuration information of the virtual large page includes:
确定所述虚拟大页面的虚拟地址;Determining a virtual address of the virtual large page;
通过所述虚拟地址中的虚拟大页面号,从旁路转换缓冲TLB中确定所述颜色配置信息。The color configuration information is determined from the bypass conversion buffer TLB by a virtual large page number in the virtual address.
结合第一方面、第一方面的第一种可能实现方式,在第一方面的第二种可能实现方式中,还包括:With reference to the first aspect, the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the method further includes:
将所述虚拟地址中的虚拟大页面内部偏移划分为:离散移位Scattered Shift和颜色块的内部偏移CR Offset两个部分,所述Scattered Shift用于索引所述虚拟大页面对应的物理大页面号;Dividing the internal offset of the virtual large page in the virtual address into two parts: a discrete shift Scattered Shift and an internal offset CR Offset of the color block, where the Scattered Shift is used to index the physical large corresponding to the virtual large page Page number
所述颜色块用于表征所述虚拟大页面在每个所述物理大页面中对应的多个物理页面所对应的缓存中的多种颜色;The color block is used to represent multiple colors in the cache corresponding to the plurality of physical pages corresponding to the virtual large page in each of the physical large pages;
其中,与所述颜色块对应的所述多个物理页面在一个物理大页面中,且所述多个物理页面的物理地址连续。The plurality of physical pages corresponding to the color block are in one physical large page, and physical addresses of the plurality of physical pages are consecutive.
结合第一方面、第一方面的第一种可能实现方式、第一方面的第二种可能实现方式,在第一方面的第三种可能实现方式中,所述TLB中记录有虚拟大页面号和物理大页面号的对应关系,所述方法还包括:With reference to the first aspect, the first possible implementation manner of the first aspect, and the second possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect, the virtual large page number is recorded in the TLB Corresponding to the physical large page number, the method further includes:
通过所述虚拟地址中的虚拟大页面号,从所述TLB中确定与所述虚拟大页面对应的第一个物理大页面的页面号;Determining, by the virtual large page number in the virtual address, a page number of the first physical large page corresponding to the virtual large page from the TLB;
将所述第一个物理大页面的页面号与所述虚拟大页面对应的所述物理大页
面的个数相加,得到与所述虚拟大页面对应的每个物理大页面的页面号;The page number of the first physical large page and the physical large page corresponding to the virtual large page
Adding the number of faces to obtain a page number of each physical large page corresponding to the virtual large page;
确定所述虚拟大页面在每个所述物理大页面中对应的起始物理页面的页面号;并将每个所述物理大页面中对应的起始物理页面的页面号与所述CR Offset拼接,得到与所述虚拟地址对应的所述物理地址。Determining a page number of the corresponding starting physical page of the virtual large page in each of the physical large pages; and splicing the page number of the corresponding starting physical page in each of the physical large pages with the CR Offset And obtaining the physical address corresponding to the virtual address.
第二方面,提供了一种虚拟大页面与物理大页面的对应装置,在所述装置中,一个虚拟大页面与多个物理大页面对应,所述多个物理大页面的物理地址不连续,所述装置包括:The second aspect provides a corresponding device for a virtual large page and a physical large page. In the device, a virtual large page corresponds to multiple physical large pages, and physical addresses of the plurality of physical large pages are discontinuous. The device includes:
获取单元,用于获取虚拟大页面的颜色配置信息,所述颜色配置信息包括所述虚拟大页面在每个所述物理大页面中对应的起始物理页面和所述虚拟大页面在每个所述物理大页面中对应的物理页面的个数;An obtaining unit, configured to obtain color configuration information of a virtual large page, where the color configuration information includes a corresponding starting physical page and a virtual large page in each of the physical large pages. The number of corresponding physical pages in the physical large page;
其中,所述虚拟大页面中的一个虚拟页面对应所述物理大页面中的一个物理页面;Wherein one virtual page in the virtual large page corresponds to one physical page in the physical large page;
所述获取单元,还用于根据获取的所述虚拟大页面的颜色配置信息,获取所述虚拟大页面与多个物理大页面的对应关系;The obtaining unit is further configured to acquire, according to the acquired color configuration information of the virtual large page, a correspondence between the virtual large page and multiple physical large pages;
存储单元,用于存储所述获取单元获取的所述虚拟大页面的颜色配置信息。a storage unit, configured to store color configuration information of the virtual large page acquired by the acquiring unit.
在第二方面的第一种可能实现方式中,所述获取单元包括:In a first possible implementation manner of the second aspect, the acquiring unit includes:
确定子单元,用于确定所述虚拟大页面的虚拟地址;并通过所述虚拟地址中的虚拟大页面号,从旁路转换缓冲TLB中确定所述颜色配置信息。Determining a sub-unit for determining a virtual address of the virtual large page; and determining the color configuration information from the bypass conversion buffer TLB by a virtual large page number in the virtual address.
结合第二方面、第二方面的第一种可能实现方式,在第二方面的第二种可能实现方式中,还包括:With reference to the second aspect, the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the method further includes:
划分单元,用于将所述确定子单元确定的所述虚拟地址中的虚拟大页面内部偏移划分为:离散移位Scattered Shift和颜色块的内部偏移CR Offset两个部分,所述Scattered Shift用于索引所述虚拟大页面对应的物理大页面号;a dividing unit, configured to divide the virtual large page internal offset in the virtual address determined by the determining subunit into two parts: a discrete shift Scattered Shift and an internal offset CR Offset of the color block, the Scattered Shift a physical large page number corresponding to the virtual large page;
所述颜色块用于表征所述虚拟大页面在每个所述物理大页面中对应的多个物理页面所对应的缓存中的多种颜色;The color block is used to represent multiple colors in the cache corresponding to the plurality of physical pages corresponding to the virtual large page in each of the physical large pages;
其中,与所述颜色块对应的所述多个物理页面在一个物理大页面中,且所述多个物理页面的物理地址连续。
The plurality of physical pages corresponding to the color block are in one physical large page, and physical addresses of the plurality of physical pages are consecutive.
结合第二方面、第二方面的第一种可能实现方式、第二方面的第二种可能实现方式,在第二方面的第三种可能实现方式中,所述TLB中记录有虚拟大页面号和物理大页面号的对应关系,所述装置还包括:With reference to the second aspect, the first possible implementation manner of the second aspect, and the second possible implementation manner of the second aspect, in a third possible implementation manner of the second aspect, the virtual large page number is recorded in the TLB Corresponding to the physical large page number, the device further includes:
确定单元,还用于通过所述虚拟地址中的虚拟大页面号,从所述TLB中确定与所述虚拟大页面对应的第一个物理大页面的页面号;a determining unit, configured to determine, by using a virtual large page number in the virtual address, a page number of the first physical large page corresponding to the virtual large page from the TLB;
计算单元,用于将所述确定单元确定的所述第一个物理大页面的页面号与所述虚拟大页面对应的所述物理大页面的个数相加,得到与所述虚拟大页面对应的每个物理大页面的页面号;a calculating unit, configured to add, by the determining unit, a page number of the first physical large page and a number of the physical large page corresponding to the virtual large page, to obtain a corresponding to the virtual large page The page number of each physical large page;
所述确定单元,还用于确定所述虚拟大页面在每个所述物理大页面中对应的起始物理页面的页面号;The determining unit is further configured to determine a page number of the corresponding starting physical page of the virtual large page in each of the physical large pages;
拼接单元,用于将所述确定单元确定的每个所述物理大页面中对应的起始物理页面的页面号与所述CR Offset拼接,得到与所述虚拟地址对应的所述物理地址。a splicing unit, configured to splicing a page number of a corresponding starting physical page in each of the physical large pages determined by the determining unit with the CR Offset, to obtain the physical address corresponding to the virtual address.
本发明实施例提供的虚拟大页面与物理大页面的对应方法及装置,在本发明实施例中,一个虚拟大页面与多个物理大页面对应,且多个物理大页面的物理地址不连续。在获取到包括虚拟大页面在每个物理大页面中对应的起始物理页面和虚拟大页面在每个物理大页面中对应的物理页面的个数的颜色配置信息后,进而能够根据该颜色配置信息获取虚拟大页面与多个物理大页面的对应关系。在现有技术中,虚拟大页面只能与物理地址连续的物理大页面对应,这样在存在多个虚拟大页面时,就会造成这一虚拟大页面对应的物理大页面共享cache,从而引起cache冲突。本发明实施例提供的技术方案,能够将虚拟大页面对应到多个离散的物理大页面上,从而控制虚拟大页面能够占用的cache set,降低了虚拟大页面之间的cache冲突。In the embodiment of the present invention, a virtual large page corresponds to multiple physical large pages, and physical addresses of multiple physical large pages are discontinuous. After obtaining the color configuration information including the starting physical page corresponding to the virtual large page in each physical large page and the physical page corresponding to the virtual large page in each physical large page, the color configuration can be configured according to the color The information acquires the correspondence between the virtual large page and the plurality of physical large pages. In the prior art, a virtual large page can only correspond to a physical large page whose physical address is continuous, so that when there are multiple virtual large pages, a physical large page corresponding to the virtual large page is shared, thereby causing a cache. conflict. The technical solution provided by the embodiment of the present invention can map a virtual large page to a plurality of discrete physical large pages, thereby controlling a cache set that can be occupied by the virtual large page, and reducing a cache conflict between the virtual large pages.
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付
出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below. Obviously, the drawings in the following description are only Some embodiments of the present invention, for those of ordinary skill in the art, do not pay
Other drawings can also be obtained from these drawings on the premise of creative labor.
图1为本发明一实施例提供的一种虚拟大页面与物理大页面的对应方法的流程图;FIG. 1 is a flowchart of a method for mapping a virtual large page and a physical large page according to an embodiment of the present invention;
图2为本发明另一实施例提供的一种虚拟大页面与物理大页面的对应方法的流程图;2 is a flowchart of a method for mapping a virtual large page and a physical large page according to another embodiment of the present invention;
图3为本发明另一实施例提供的一种虚拟大页面的虚拟地址的组成示意图;3 is a schematic structural diagram of a virtual address of a virtual large page according to another embodiment of the present invention;
图4为本发明另一实施例提供的一种TLB的结构示意图;FIG. 4 is a schematic structural diagram of a TLB according to another embodiment of the present disclosure;
图5-1为本发明另一实施例提供的一种虚拟大页面与物理大页面的对应关系示意图;5-1 is a schematic diagram of a correspondence between a virtual large page and a physical large page according to another embodiment of the present invention;
图5-2为本发明另一实施例提供的另一种虚拟大页面与物理大页面的对应关系示意图;5-2 is a schematic diagram of correspondence between another virtual large page and a physical large page according to another embodiment of the present invention;
图6为本发明另一实施例提供的一种虚拟大页面与物理大页面的对应装置的组成示意图;FIG. 6 is a schematic diagram of a composition of a corresponding device of a virtual large page and a physical large page according to another embodiment of the present invention;
图7为本发明另一实施例提供的另一种虚拟大页面与物理大页面的对应装置的组成示意图;FIG. 7 is a schematic structural diagram of another device corresponding to a virtual large page and a physical large page according to another embodiment of the present invention;
图8为本发明另一实施例提供的一种虚拟大页面与物理大页面的对应装置的组成示意图。FIG. 8 is a schematic structural diagram of a corresponding device of a virtual large page and a physical large page according to another embodiment of the present invention.
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, but not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
本发明一实施例提供了一种虚拟大页面与物理大页面的对应方法,在该方法中,一个虚拟大页面与多个物理大页面对应,且该多个物理大页面的物理地址不连续,如图1所示,该方法包括:An embodiment of the present invention provides a method for mapping a virtual large page and a physical large page. In the method, a virtual large page corresponds to multiple physical large pages, and physical addresses of the multiple physical large pages are discontinuous. As shown in Figure 1, the method includes:
101、获取虚拟大页面的颜色配置信息。101. Obtain color configuration information of a virtual large page.
其中,颜色配置信息包括虚拟大页面在每个物理大页面中对应的起始物理
页面和虚拟大页面在每个物理大页面中对应的物理页面的个数。Wherein, the color configuration information includes a corresponding physical start page of the virtual large page in each physical large page.
The number of physical pages corresponding to the page and virtual large page in each physical large page.
值得说明的是,虚拟大页面中的一个虚拟页面对应物理大页面中的一个物理页面,且该对应关系是可变的。It is worth noting that one virtual page in the virtual large page corresponds to one physical page in the physical large page, and the corresponding relationship is variable.
102、根据虚拟大页面的颜色配置信息,获取虚拟大页面与多个物理大页面的对应关系。102. Acquire a correspondence between the virtual large page and the plurality of physical large pages according to the color configuration information of the virtual large page.
本发明实施例提供的一种虚拟大页面与物理大页面的对应方法,在获取到包括虚拟大页面在每个物理大页面中对应的起始物理页面和虚拟大页面在每个物理大页面中对应的物理页面的个数的颜色配置信息后,进而能够根据该颜色配置信息获取虚拟大页面与多个物理大页面的对应关系。在现有技术中,虚拟大页面只能与物理地址连续的物理大页面对应,这样在存在多个虚拟大页面时,就会造成这一虚拟大页面对应的物理大页面共享cache,从而引起cache冲突。本发明实施例提供的技术方案,能够将虚拟大页面对应到多个离散的物理大页面上,从而控制虚拟大页面占用的cache set,降低了虚拟大页面之间的cache冲突。A method for correspondingly displaying a virtual large page and a physical large page according to an embodiment of the present invention obtains a starting physical page and a virtual large page corresponding to each virtual large page in each physical large page. After the color configuration information of the number of physical pages is corresponding, the correspondence between the virtual large page and the plurality of physical large pages can be acquired according to the color configuration information. In the prior art, a virtual large page can only correspond to a physical large page whose physical address is continuous, so that when there are multiple virtual large pages, a physical large page corresponding to the virtual large page is shared, thereby causing a cache. conflict. The technical solution provided by the embodiment of the present invention can map a virtual large page to a plurality of discrete physical large pages, thereby controlling a cache set occupied by the virtual large page, and reducing a cache conflict between the virtual large pages.
本发明另一实施例提供了一种虚拟大页面与物理大页面的对应方法,如图2所示,该方法包括:Another embodiment of the present invention provides a method for mapping a virtual large page to a physical large page. As shown in FIG. 2, the method includes:
201、确定虚拟大页面的虚拟地址。201. Determine a virtual address of the virtual large page.
值得说明的是,每个虚拟大页面是由虚拟地址连续多个虚拟页面组成,每个虚拟页面都有与之对应的虚拟页面的虚拟地址,所以在确定待操作的虚拟大页面之后,则该虚拟大页面的虚拟地址是确定的。It should be noted that each virtual large page is composed of a plurality of virtual pages consecutively by virtual addresses, and each virtual page has a virtual address of the virtual page corresponding thereto, so after determining the virtual large page to be operated, the The virtual address of the virtual large page is determined.
其中,虚拟大页面的虚拟地址由高位的虚拟大页面号和低位的虚拟大页面内部偏移组成。The virtual address of the virtual large page is composed of a high virtual large page number and a low virtual outer page internal offset.
进一步的,将虚拟地址中的虚拟大页面内部偏移划分为:离散移位Scattered Shift和颜色块的内部偏移CR Offset两个部分。Further, the internal offset of the virtual large page in the virtual address is divided into two parts: a discrete shift Scattered Shift and an internal offset CR Offset of the color block.
其中,Scattered Shift用于索引虚拟大页面对应的物理大页面号,且该Scattered Shift划分在虚拟大页面内部偏移的高位。结合对虚拟地址的描述,其中,表示虚拟大页面的内部偏移的总位数是确定的,在该总位数中,去除掉
Scattered Shift占用的位数,其余的低位即为CR Offset。值得说明的是,该Scattered Shift可以表示虚拟大页面对应的物理大页面的个数,比如,当虚拟大页面对应4个离散的物理大页面时,该Scattered Shift由两位表示,在对应每个物理大页面时可以分别为00、01、10、11,相应的,在虚拟大页面的内部偏移中,出去前两位,其余的数位即为CR Offset。The Scattered Shift is used to index the physical large page number corresponding to the virtual large page, and the Scattered Shift is divided into the high position of the internal offset of the virtual large page. In conjunction with the description of the virtual address, wherein the total number of bits representing the internal offset of the virtual large page is determined, and in the total number of bits, removed
The number of bits occupied by the Scattered Shift, and the remaining low bits are CR Offset. It should be noted that the Scattered Shift can represent the number of physical large pages corresponding to the virtual large page. For example, when the virtual large page corresponds to four discrete physical large pages, the Scattered Shift is represented by two bits, corresponding to each When the physical page is large, it can be 00, 01, 10, and 11, respectively. Correspondingly, in the internal offset of the virtual large page, the first two digits are left, and the remaining digits are CR Offset.
结合上述对虚拟地址的描述,如图3所示,在本实施例中,虚拟地址从高位到低位依次为虚拟大页面号Virtual Huge Page Number、离散移位Scattered Shift和颜色块的内部偏移CR Offset,且Scattered Shift与CR Offset组成虚拟大页面内部偏移Huge Page Offset。In combination with the above description of the virtual address, as shown in FIG. 3, in the embodiment, the virtual address from the high to the low is the virtual large page number, the virtual Huge Page Number, the discrete shift Scattered Shift, and the internal offset CR of the color block. Offset, and Scattered Shift and CR Offset form a virtual large page internal offset Huge Page Offset.
进一步的,为了获取到虚拟大页面的颜色配置信息,需执行下述202。Further, in order to obtain the color configuration information of the virtual large page, the following 202 is performed.
202、通过虚拟地址中的虚拟大页面号,从旁路转换缓冲TLB中确定颜色配置信息。202. Determine color configuration information from the bypass conversion buffer TLB by using a virtual large page number in the virtual address.
值得说明的是,TLB里面存放的是一些页表文件,这些页表文件为虚拟地址到物理地址的转换表,记录有虚拟大页面号和物理大页面号的对应关系。具体的,可以根据虚拟地址中的虚拟大页面号,在TLB中查找到与该虚拟大页面号对应的物理大页面号,同时从该TLB中一并确定颜色配置信息。It is worth noting that some of the page table files are stored in the TLB. These page table files are conversion tables of virtual addresses to physical addresses, and records the correspondence between virtual large page numbers and physical large page numbers. Specifically, the physical large page number corresponding to the virtual large page number is found in the TLB according to the virtual large page number in the virtual address, and the color configuration information is determined together from the TLB.
为了更清楚的描述TLB的结构,结合下述附图3来进行说明:In order to more clearly describe the structure of the TLB, it will be described in conjunction with FIG. 3 below:
如图4所示,该TLB结构包括:Tag、Attr.、Base Huge PPN(Physical Page Number)、CR_Entry(Color Region_Entry)、CR_Num。As shown in FIG. 4, the TLB structure includes: Tag, Attr., Base Huge PPN (Physical Page Number), CR_Entry (Color Region_Entry), and CR_Num.
其中,Tag表示页面地址匹配的标记;Attr.表示页面属性;Base Huge PPN表示物理大页面起始页面号,在本实施例中也就是指,与虚拟大页面对应的第一个物理大页面的页面号;CR_Entry表示物理大页面使用的起始颜色块,即虚拟大页面在每个物理大页面中对应的起始物理页面;CR_Num颜色块个数,即虚拟大页面在每个物理大页面中对应的物理页面的个数。其中,CR_Entry和CR_Num作为虚拟大页面的颜色配置信息存储在TLB中。The Tag indicates the tag of the page address matching; the Attr. indicates the page attribute; the Base Huge PPN indicates the physical large page start page number, which in this embodiment also refers to the first physical large page corresponding to the virtual large page. The page number; CR_Entry indicates the starting color block used by the physical large page, that is, the corresponding starting physical page of the virtual large page in each physical large page; the number of CR_Num color blocks, that is, the virtual large page is in each physical large page. The number of corresponding physical pages. Among them, CR_Entry and CR_Num are stored in the TLB as color configuration information of the virtual large page.
可选的,CR表示颜色块,该颜色块可以表示一种颜色,还可以表示连续的
多个颜色组成的一个可配置颜色区域,也就是说,用于表征虚拟大页面在每个物理大页面中对应的多个物理页面所对应的缓存中的多种颜色,且与颜色块对应的多个物理页面在一个物理大页面中,这些物理页面的物理地址连续。由于一个物理大页面包含的物理页面的个数较多,则与该物理大页面对应的颜色个数相应就较多,所以可以不必对每个物理页面对应的颜色都进行细粒度的控制,则颜色块可认为是物理大页面中颜色配置的基本单位。Optionally, CR represents a color block, and the color block can represent a color and can also represent a continuous color.
a configurable color region composed of a plurality of colors, that is, a plurality of colors in the cache corresponding to the plurality of physical pages corresponding to the virtual large page in each physical large page, and corresponding to the color block Multiple physical pages are in one physical large page, and the physical addresses of these physical pages are continuous. Since a physical large page contains a large number of physical pages, the number of colors corresponding to the physical large page corresponds to a large number, so that it is not necessary to perform fine-grained control on the color corresponding to each physical page. A color block can be thought of as the basic unit of color configuration in a large physical page.
值得说明的是,本发明实施例中涉及的TLB较之常规的TLB,添加了颜色配置信息,该颜色配置信息可以直接添加在TLB中,该颜色配置信息可以是由软件控制的,进而写入到该TLB中。相应的,在TLB上需要设置获取该颜色配置信息的接口,该接口能够在TLB中实现这两个参数的配置即可,本发明实施例对该接口的实现形式不进行限定。It should be noted that the TLB involved in the embodiment of the present invention adds color configuration information compared to the conventional TLB, and the color configuration information may be directly added to the TLB, and the color configuration information may be controlled by software, and then written. Go to the TLB. Correspondingly, the interface for obtaining the color configuration information needs to be set on the TLB, and the interface can be configured in the TLB. The implementation form of the interface is not limited in the embodiment of the present invention.
可选的,该多个物理地址不连续的物理大页面,可以称之为离散式大页面。为了提高系统的灵活性,还可以对增加一个配置接口,用于决定是否启动离散式大页面。进一步可选的,当配置为1表示启用离散式大页面,为0表示使用常规大页面,其中,常规大页面即一个虚拟大页面对应一个物理大页面。Optionally, the plurality of physical large pages whose physical addresses are not consecutive may be referred to as discrete large pages. In order to increase the flexibility of the system, it is also possible to add a configuration interface for deciding whether to start a discrete large page. Further, when the configuration is 1 to indicate that the discrete large page is enabled, and 0 is to use the conventional large page, wherein the regular large page, that is, one virtual large page corresponds to one physical large page.
进一步的,在本实施例中,每个颜色块所包含的颜色个数相同,且在虚拟大页面对应的每个物理大页面中起始颜色块相同,在每个物理大页面中占用的颜色块的个数也是相同的。Further, in this embodiment, each color block contains the same number of colors, and the starting color block is the same in each physical large page corresponding to the virtual large page, and the color occupied in each physical large page. The number of blocks is also the same.
203、根据虚拟大页面的颜色配置信息,获取虚拟大页面与多个物理大页面的对应关系。203. Acquire a correspondence between the virtual large page and the plurality of physical large pages according to the color configuration information of the virtual large page.
进一步的,在本发明实施例提供的技术方案中,还可以根据虚拟大页面的虚拟地址以及获取的虚拟大页面的颜色配置信息获取到与该虚拟地址对应的物理地址,可继续执行下述204。Further, in the technical solution provided by the embodiment of the present invention, the physical address corresponding to the virtual address may be obtained according to the virtual address of the virtual large page and the color configuration information of the obtained virtual large page, and the following 204 may be continued. .
204、根据虚拟大页面的虚拟地址以及虚拟大页面的颜色配置信息获取与该虚拟地址对应的物理地址。204. Obtain a physical address corresponding to the virtual address according to the virtual address of the virtual large page and the color configuration information of the virtual large page.
可选的,通过虚拟大页面的虚拟地址以及虚拟大页面的颜色配置信息获取
与该虚拟大页面的虚拟地址对应的物理地址,可以通过下述公式计算得到。Physical Address=(Base Huge PPN+val(Scattered_Shift))^CR_Entry^CR_OffsetOptionally, the virtual address of the virtual large page and the color configuration information of the virtual large page are obtained.
The physical address corresponding to the virtual address of the virtual large page can be calculated by the following formula. Physical Address=(Base Huge PPN+val(Scattered_Shift))^CR_Entry^CR_Offset
其中,符号^,表示拼接,拼接就是简单的物理移位,也就是将表示后一个参数的数位直接添加到之前已经确定的数位的低位。Wherein, the symbol ^ indicates splicing, and splicing is a simple physical shift, that is, the digit representing the latter parameter is directly added to the lower digit of the previously determined digit.
其中,val(Scattered_Shift)表示,Scattered_Shift的返回值,比如当Scattered_Shift为00时,val(Scattered_Shift)的值为0;当Scattered_Shift为01时。则确定val(Scattered_Shift)的值为1。Where val(Scattered_Shift) represents the return value of Scattered_Shift, such as when Scattered_Shift is 00, the value of val(Scattered_Shift) is 0; when Scattered_Shift is 01. Then determine the value of val(Scattered_Shift) to 1.
具体的,获取该物理地址的包括:Specifically, obtaining the physical address includes:
首先,在确定待操作的虚拟大页面的虚拟地址之后,需要确定出该虚拟大页面对应的第一个物理大页面的物理地址,也就是确定出该虚拟大页面对应的第一个物理大页面的页面号。从而需要执行下述a。First, after determining the virtual address of the virtual large page to be operated, the physical address of the first physical large page corresponding to the virtual large page needs to be determined, that is, the first physical large page corresponding to the virtual large page is determined. Page number. Therefore, it is necessary to perform the following a.
a、通过虚拟地址中的虚拟大页面号,从TLB中确定与虚拟大页面对应的第一个物理大页面的页面号。a. Determine the page number of the first physical large page corresponding to the virtual large page from the TLB by using the virtual large page number in the virtual address.
值得说明的是,该a的执行即确定了Base Huge PPN。It is worth noting that the execution of this a determines the Base Huge PPN.
进一步的,结合上述的描述,每个虚拟大页面是由多个虚拟地址连续的虚拟页面组成的,当CR对应的颜色块表示多种连续的颜色时,即将多个虚拟地址连续的虚拟页面作为整体分析,也就是将虚拟大页面中的多个虚拟页面均分为多组虚拟地址连续的虚拟页面组,每组虚拟页面对应一组物理地址连续的物理页面,也就是对应一个颜色块,并且该一组或多组物理地址连续的物理页面存在于一个物理大页面中。Further, in combination with the above description, each virtual large page is composed of a plurality of virtual pages consecutive to virtual addresses. When the color block corresponding to the CR represents a plurality of consecutive colors, a virtual page of consecutive virtual addresses is used as a virtual page. The overall analysis, that is, dividing a plurality of virtual pages in a virtual large page into a plurality of virtual page groups of consecutive virtual addresses, each set of virtual pages corresponding to a set of physical pages consecutive to physical addresses, that is, corresponding to one color block, and The one or more sets of physical pages with consecutive physical addresses exist in one physical large page.
进一步的,需要确定该每个虚拟页面对应的物理大页面的页面号,即确定出Base Huge PPN+val(Scattered_Shift),需要执行下述b。Further, the page number of the physical large page corresponding to each virtual page needs to be determined, that is, the Base Huge PPN+val (Scattered_Shift) is determined, and b is performed as follows.
b、将第一个物理大页面的页面号与虚拟大页面对应的物理大页面的个数相加,得到与虚拟大页面对应的每个物理大页面的页面号。b. Add the page number of the first physical large page to the number of physical large pages corresponding to the virtual large page, and obtain the page number of each physical large page corresponding to the virtual large page.
值得说明的是,在本实施例中,一个虚拟大页面是与多个物理大页面对应的,且该多个物理大页面之间的物理地址是不连续的。
It should be noted that, in this embodiment, one virtual large page is corresponding to multiple physical large pages, and the physical addresses between the multiple physical large pages are discontinuous.
结合上述的202的描述,由CR_Entry和CR_Num可以进一步的确定虚拟大页面对应的物理大页面的个数。Combined with the description of 202 above, the number of physical large pages corresponding to the virtual large page can be further determined by CR_Entry and CR_Num.
具体的,一个物理大页面中包含确定的物理页面,则相应的能够确定该物理大页面可用的所有颜色块的个数,则物理大页面的个数=每个物理大页面可用的所有颜色块的个数/CR_Num。Specifically, if a physical large page includes a determined physical page, and correspondingly, the number of all color blocks available for the physical large page can be determined, the number of physical large pages = all color blocks available for each physical large page. The number /CR_Num.
此外,当物理页面的个数多于cache中可用的颜色个数时,该cahce中可用的颜色个数为该物理大页面可用的所有颜色的个数,仅为可用的所有颜色块的个数。In addition, when the number of physical pages is greater than the number of colors available in the cache, the number of colors available in the cahce is the number of all colors available for the physical large page, and only the number of all available color blocks. .
进一步的,在确定了虚拟大页面对应的物理大页面的个数之后,结合上述a中获取的虚拟大页面对应的第一个物理大页面的页面号,可以依次获取到该虚拟大页面对应的每个物理大页面的页面号。Further, after determining the number of physical large pages corresponding to the virtual large page, the page number of the first physical large page corresponding to the virtual large page obtained in the above a, may be sequentially acquired to correspond to the virtual large page. The page number of each physical large page.
c、确定虚拟大页面在每个物理大页面中对应的起始物理页面的页面号。c. Determine the page number of the corresponding starting physical page of the virtual large page in each physical large page.
值得说明的是,由于获取的虚拟大页面的颜色配置信息中包括虚拟大页面在每个物理大页面中对应的起始物理页面,则在确定出起始物理页面之后,就能够确定该起始物理页面的物理地址,并且在该起始物理页面的物理地址中包含有该起始物理页面的页面号,进而能够确定每个物理大页面中对应的起始区里页面的页面号。It is to be noted that, since the obtained color configuration information of the virtual large page includes the corresponding starting physical page of the virtual large page in each physical large page, after determining the starting physical page, the starting can be determined. The physical address of the physical page, and the page number of the starting physical page is included in the physical address of the starting physical page, so that the page number of the page in the corresponding starting area in each physical large page can be determined.
此外,当以颜色块为基本单位时,虚拟大页面的颜色配置信息中包含,CR_Entry,该CR_Entry表示物理大页面使用的起始颜色块,即虚拟大页面在每个物理大页面中对应的起始物理页面组,则在确定物理页面的情况下就能够确定出物理页面对应的页面号。In addition, when the color block is used as the basic unit, the color configuration information of the virtual large page includes CR_Entry, and the CR_Entry represents the starting color block used by the physical large page, that is, the virtual large page corresponds to each physical large page. When the physical page group is started, the page number corresponding to the physical page can be determined when the physical page is determined.
d、将每个物理大页面中对应的起始物理页面的页面号与CR Offset拼接,得到与虚拟地址对应的物理地址。d. splicing the page number of the corresponding starting physical page in each physical large page with CR Offset to obtain a physical address corresponding to the virtual address.
值得说明的是,此处提到的拼接就是在确定物理地址之前数位的基础上,将CR Offset添加到低位,从而构成完整的物理地址,且该物理地址是与虚拟大页面的虚拟地址对应的。It is worth noting that the splicing mentioned here is based on determining the number of digits before the physical address, adding CR Offset to the lower bit, thereby forming a complete physical address, and the physical address is corresponding to the virtual address of the virtual large page. .
此外,以具体实例说明,根据颜色配置信息确定的虚拟大页面和多个物理大页面的对应关系。
In addition, the specific relationship between the virtual large page and the plurality of physical large pages determined according to the color configuration information is illustrated by a specific example.
具体的,颜色块作为是物理大页面中颜色配置的基本单位,也就是说,将虚拟大页面中的多个虚拟页面均分为多个虚拟页面组,其中,每一个虚拟页面组由虚拟地址连续的多个虚拟页面组成。对应的,每个物理大页面同样划分为相同数量的物理页面组,进而确定颜色块的个数与该物理页面组的数量相同。Specifically, the color block is a basic unit of color configuration in a physical large page, that is, a plurality of virtual pages in the virtual large page are divided into a plurality of virtual page groups, wherein each virtual page group is divided by a virtual address. Consecutive multiple virtual pages. Correspondingly, each physical large page is also divided into the same number of physical page groups, thereby determining that the number of color blocks is the same as the number of physical page groups.
比如,确定所有可用的颜色块的个数为8,这8个颜色块分别表示不同的颜色,因为物理大页面划分为的物理页面组的数量与cache中的颜色块的个数相同,且物理大页面与cache的对应关系是固定的,则可以认为每个物理大页面有8个可用的颜色块,且依次为每个颜色块标号为0、1、2…7。For example, it is determined that the number of all available color blocks is 8, and the eight color blocks respectively represent different colors, because the physical large page is divided into the same number of physical page groups as the number of color blocks in the cache, and the physical The correspondence between the large page and the cache is fixed, and it can be considered that each physical large page has 8 available color blocks, and in turn, each color block is labeled 0, 1, 2...7.
具体的,如图5-1所示,当CR_Entry=0,CR_Num=4,物理大页面的个数为2时,也就是一个虚拟大页面对应到两个离散的物理大页面上,在每个物理大页面中只使用其中从0开始的4个颜色块,{0、1、2、3}。当然,也可以选取任意颜色块为起始颜色块。比如,如图5-2所示,当CR_Entry=4,CR_Num=4,物理大页面的个数为2时,也就是说,一个虚拟大页面对应两个物理地址不连续的物理大页面,且在每个物理大页面中只使用其中,从标号4开始的4个颜色块{4、5、6、7}。Specifically, as shown in Figure 5-1, when CR_Entry=0, CR_Num=4, the number of physical large pages is 2, that is, a virtual large page corresponds to two discrete physical large pages, in each Only the 4 color blocks from 0 are used in the physical large page, {0, 1, 2, 3}. Of course, you can also select any color block as the starting color block. For example, as shown in Figure 5-2, when CR_Entry=4, CR_Num=4, and the number of physical large pages is 2, that is, one virtual large page corresponds to two physical large pages whose physical addresses are not continuous, and Only four color blocks {4, 5, 6, 7} starting from the number 4 are used in each physical large page.
本发明实施例提供的一种虚拟大页面与物理大页面的对应方法,在获取到包括虚拟大页面在每个物理大页面中对应的起始物理页面和虚拟大页面在每个物理大页面中对应的物理页面的个数的颜色配置信息后,进而能够根据该颜色配置信息获取虚拟大页面与多个物理大页面的对应关系。在现有技术中,虚拟大页面只能与物理地址连续的物理大页面对应,这样在存在多个虚拟大页面时,就会造成这一虚拟大页面对应的物理大页面共享cache,从而引起cache冲突。本发明实施例提供的技术方案,能够将虚拟大页面对应到多个离散的物理大页面上,从而控制虚拟大页面能够占用的cache set,降低了虚拟大页面之间的cache冲突。A method for correspondingly displaying a virtual large page and a physical large page according to an embodiment of the present invention obtains a starting physical page and a virtual large page corresponding to each virtual large page in each physical large page. After the color configuration information of the number of physical pages is corresponding, the correspondence between the virtual large page and the plurality of physical large pages can be acquired according to the color configuration information. In the prior art, a virtual large page can only correspond to a physical large page whose physical address is continuous, so that when there are multiple virtual large pages, a physical large page corresponding to the virtual large page is shared, thereby causing a cache. conflict. The technical solution provided by the embodiment of the present invention can map a virtual large page to a plurality of discrete physical large pages, thereby controlling a cache set that can be occupied by the virtual large page, and reducing a cache conflict between the virtual large pages.
本发明另一实施例提供了一种虚拟大页面与物理大页面的对应装置,在该装置中,一个虚拟大页面与多个物理大页面对应,该多个物理大页面的物理地址不连续,如图6所示,该装置包括:获取单元61、存储单元62。Another embodiment of the present invention provides a corresponding device for a virtual large page and a physical large page. In the device, a virtual large page corresponds to multiple physical large pages, and physical addresses of the multiple physical large pages are discontinuous. As shown in FIG. 6, the apparatus includes an acquisition unit 61 and a storage unit 62.
获取单元61,用于获取虚拟大页面的颜色配置信息。
The obtaining unit 61 is configured to obtain color configuration information of the virtual large page.
其中,该颜色配置信息包括虚拟大页面在每个物理大页面中对应的起始物理页面和虚拟大页面在每个物理大页面中对应的物理页面的个数。虚拟大页面中的一个虚拟页面对应物理大页面中的一个物理页面。The color configuration information includes the number of corresponding physical pages of the virtual large page in each physical large page and the corresponding physical pages of the virtual large page in each physical large page. A virtual page in a virtual large page corresponds to one physical page in a physical large page.
进一步的,获取单元61,还用于根据获取的虚拟大页面的颜色配置信息,获取虚拟大页面与多个物理大页面的对应关系。Further, the obtaining unit 61 is further configured to obtain a correspondence between the virtual large page and the plurality of physical large pages according to the acquired color configuration information of the virtual large page.
存储单元62,用于存储获取单元61获取的虚拟大页面的颜色配置信息。The storage unit 62 is configured to store color configuration information of the virtual large page acquired by the obtaining unit 61.
可选的,如图7所示,该装置还包括:划分单元63、确定单元64、计算单元65、拼接单元66;获取单元61,还包括确定子单元611。Optionally, as shown in FIG. 7, the apparatus further includes: a dividing unit 63, a determining unit 64, a calculating unit 65, a splicing unit 66, an obtaining unit 61, and a determining subunit 611.
确定子单元611,用于确定虚拟大页面的虚拟地址;并通过该虚拟地址中的虚拟大页面号,从旁路转换缓冲TLB中确定颜色配置信息。The determining subunit 611 is configured to determine a virtual address of the virtual large page; and determine color configuration information from the bypass conversion buffer TLB by the virtual large page number in the virtual address.
划分单元63,用于将获取单元61中的确定子单元611确定的虚拟地址中的虚拟大页面内部偏移划分为:离散移位Scattered Shift和颜色块的内部偏移CR Offset两个部分。The dividing unit 63 is configured to divide the virtual large page internal offset in the virtual address determined by the determining subunit 611 in the obtaining unit 61 into two parts: a discrete shift Scattered Shift and an internal offset CR Offset of the color block.
其中,Scattered Shift用于索引虚拟大页面对应的物理大页面号;颜色块用于表征虚拟大页面在每个物理大页面中对应的多个物理页面所对应的缓存中的多种颜色,且颜色块对应的多个物理页面在一个物理大页面中,且多个物理页面的物理地址连续。The Scattered Shift is used to index the physical large page number corresponding to the virtual large page; the color block is used to represent multiple colors in the cache corresponding to the plurality of physical pages corresponding to the virtual large page in each physical large page, and the color The plurality of physical pages corresponding to the block are in one physical large page, and the physical addresses of the plurality of physical pages are consecutive.
确定单元64,还用于通过获取单元61中的确定子单元611确定的虚拟地址中的虚拟大页面号,从TLB中确定与该虚拟大页面对应的第一个物理大页面的页面号。The determining unit 64 is further configured to determine, by the virtual large page number in the virtual address determined by the determining subunit 611 in the obtaining unit 61, the page number of the first physical large page corresponding to the virtual large page from the TLB.
计算单元65,用于将确定单元64确定的第一个物理大页面的页面号与虚拟大页面对应的物理大页面的个数相加,得到与虚拟大页面对应的每个物理大页面的页面号。The calculating unit 65 is configured to add the page number of the first physical large page determined by the determining unit 64 to the number of physical large pages corresponding to the virtual large page, to obtain a page of each physical large page corresponding to the virtual large page. number.
确定单元64,还用于确定虚拟大页面在每个物理大页面中对应的起始物理页面的页面号。The determining unit 64 is further configured to determine a page number of the corresponding starting physical page of the virtual large page in each physical large page.
拼接单元66,用于将确定单元64确定的每个物理大页面中对应的起始物理页面的页面号与划分单元63划分得到的CR Offset拼接,得到与虚拟地址对应
的物理地址。The splicing unit 66 is configured to splicing the page number of the corresponding starting physical page in each physical large page determined by the determining unit 64 with the CR Offset obtained by the dividing unit 63 to obtain a virtual address corresponding to the splicing unit 63.
Physical address.
本发明实施例提供的一种虚拟大页面与物理大页面的对应装置,在获取单元获取到包括虚拟大页面在每个物理大页面中对应的起始物理页面和虚拟大页面在每个物理大页面中对应的物理页面的个数的颜色配置信息后,进而能够根据该颜色配置信息获取虚拟大页面与多个物理大页面的对应关系。在现有技术中,虚拟大页面只能与物理地址连续的物理大页面对应,这样在存在多个虚拟大页面时,就会造成这一虚拟大页面对应的物理大页面共享cache,从而引起cache冲突。本发明实施例提供的技术方案,能够将虚拟大页面对应到多个离散的物理大页面上,从而控制虚拟大页面能够占用的cache set,降低了虚拟大页面之间的cache冲突。The corresponding device of the virtual large page and the physical large page provided by the embodiment of the present invention acquires the starting physical page and the virtual large page corresponding to each virtual large page in each physical large page in the obtaining unit. After the color configuration information of the number of corresponding physical pages in the page, the corresponding relationship between the virtual large page and the plurality of physical large pages can be acquired according to the color configuration information. In the prior art, a virtual large page can only correspond to a physical large page whose physical address is continuous, so that when there are multiple virtual large pages, a physical large page corresponding to the virtual large page is shared, thereby causing a cache. conflict. The technical solution provided by the embodiment of the present invention can map a virtual large page to a plurality of discrete physical large pages, thereby controlling a cache set that can be occupied by the virtual large page, and reducing a cache conflict between the virtual large pages.
本发明另一实施例提供了一种虚拟大页面与物理大页面的对应装置,该装置包括:处理器01、存储器02。如图8所示,图8为一种虚拟大页面与物理大页面的对应装置的硬件结构示意图。其中,该装置可包括处理器01、存储器02、和总线03。其中,处理器01、存储器02通过总线03连接。Another embodiment of the present invention provides a corresponding device for a virtual large page and a physical large page. The device includes: a processor 01 and a memory 02. As shown in FIG. 8, FIG. 8 is a schematic diagram of a hardware structure of a corresponding device of a virtual large page and a physical large page. The device may include a processor 01, a memory 02, and a bus 03. The processor 01 and the memory 02 are connected by a bus 03.
处理器01可以采用通用的中央处理器(Central Processing Unit,CPU),微处理器,应用专用集成电路(Application Specific Integrated Circuit,ASIC),或者一个或多个集成电路,用于执行相关程序,以实现本发明实施例所提供的技术方案。The processor 01 can be a general-purpose central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), or one or more integrated circuits for executing related programs. The technical solution provided by the embodiment of the present invention is implemented.
存储器02可以是只读存储器(Read Only Memory,ROM),静态存储设备,动态存储设备或者随机存取存储器(Random Access Memory,RAM)。存储器1102可以存储操作系统和其他应用程序。在通过软件或者固件来实现本发明实施例提供的技术方案时,用于实现本发明实施例提供的技术方案的程序代码保存在存储器02中,并由处理器01来执行。The memory 02 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1102 can store an operating system and other applications. The program code for implementing the technical solution provided by the embodiment of the present invention is stored in the memory 02 and executed by the processor 01 when the technical solution provided by the embodiment of the present invention is implemented by software or firmware.
总线03可包括一通路,在装置各个部件(例如,存储器02和处理器01)之间传送信息。Bus 03 may include a path for communicating information between various components of the device (e.g., memory 02 and processor 01).
应注意,尽管图8所示的硬件仅仅示出了处理器01、存储器02和总线03,但是在具体实现过程中,本领域的技术人员应当明白,该终端还包含实现正常运行所必须的其他器件。同时,根据具体需要,本领域的技术人员应当明白,
还可包含实现其他功能的硬件器件。It should be noted that although the hardware shown in FIG. 8 only shows the processor 01, the memory 02, and the bus 03, in the specific implementation process, those skilled in the art should understand that the terminal also includes other necessary for normal operation. Device. At the same time, according to specific needs, those skilled in the art should understand that
Hardware devices that implement other functions can also be included.
具体的,处理器01,用于确定虚拟大页面的虚拟地址,并通过虚拟地址中的虚拟大页面号,从旁路转换缓冲TLB中确定颜色配置信息。Specifically, the processor 01 is configured to determine a virtual address of the virtual large page, and determine color configuration information from the bypass conversion buffer TLB by using a virtual large page number in the virtual address.
可选的,颜色配置信息包括虚拟大页面在每个物理大页面中对应的起始物理页面和虚拟大页面在每个物理大页面中对应的物理页面的个数。且虚拟大页面中的一个虚拟页面对应物理大页面中的一个物理页面。Optionally, the color configuration information includes the number of corresponding physical pages of the virtual large page in each physical large page and the corresponding physical pages of the virtual large page in each physical large page. And one virtual page in the virtual large page corresponds to one physical page in the physical large page.
进一步的,处理器01,还用于根据虚拟大页面的颜色配置信息,获取虚拟大页面与多个物理大页面的对应关系。Further, the processor 01 is further configured to obtain a correspondence between the virtual large page and the plurality of physical large pages according to the color configuration information of the virtual large page.
存储器02,用于存储处理器01确定的虚拟大页面的虚拟地址以及从TLB中确定的颜色配置信息。The memory 02 is configured to store a virtual address of the virtual large page determined by the processor 01 and color configuration information determined from the TLB.
可选的,处理器01,还用于将虚拟地址中的虚拟大页面内部偏移划分为:离散移位Scattered Shift和颜色块的内部偏移CR Offset两个部分。Optionally, the processor 01 is further configured to divide the virtual large page internal offset in the virtual address into two parts: a discrete shift Scattered Shift and an internal offset CR Offset of the color block.
其中,Scattered Shift用于索引虚拟大页面对应的物理大页面号;颜色块用于表征虚拟大页面在每个物理大页面中对应的多个物理页面所对应的缓存中的多种颜色。与该颜色块对应的多个物理页面在一个物理大页面中,这多个物理页面的物理地址连续。The Scattered Shift is used to index the physical large page number corresponding to the virtual large page; the color block is used to represent multiple colors in the cache corresponding to the plurality of physical pages corresponding to the virtual large page in each physical large page. The plurality of physical pages corresponding to the color block are in one physical large page, and physical addresses of the plurality of physical pages are consecutive.
可选的,在TLB中记录有虚拟大页面号和物理大页面号的对应关系,进一步的,处理器01,还用于通过虚拟地址中的虚拟大页面号,从TLB中确定与该虚拟大页面对应的第一个物理大页面的页面号;将第一个物理大页面的页面号与虚拟大页面对应的物理大页面的个数相加,得到与虚拟大页面对应的每个物理大页面的页面号;确定虚拟大页面在每个物理大页面中对应的起始物理页面的页面号;并将每个物理大页面中对应的起始物理页面的页面号与CR Offset拼接,得到与所述虚拟地址对应的所述物理地址。Optionally, the mapping between the virtual large page number and the physical large page number is recorded in the TLB. Further, the processor 01 is further configured to determine, by the virtual large page number in the virtual address, the large virtual number from the TLB. The page number of the first physical large page corresponding to the page; adding the page number of the first physical large page to the number of physical large pages corresponding to the virtual large page, and obtaining each physical large page corresponding to the virtual large page The page number of the corresponding physical page of the virtual large page in each physical large page; and the page number of the corresponding starting physical page in each physical large page is spliced with CR Offset to obtain the same The physical address corresponding to the virtual address.
本发明实施例提供的一种虚拟大页面与物理大页面的对应装置,在处理器获取到包括虚拟大页面在每个物理大页面中对应的起始物理页面和虚拟大页面在每个物理大页面中对应的物理页面的个数的颜色配置信息后,存储器存储该
获取到的颜色配置信息,进而能够根据该颜色配置信息获取虚拟大页面与多个物理大页面的对应关系。在现有技术中,虚拟大页面只能与物理地址连续的物理大页面对应,这样在存在多个虚拟大页面时,就会造成这一虚拟大页面对应的物理大页面共享cache,从而引起cache冲突。本发明实施例提供的技术方案,能够将虚拟大页面对应到多个离散的物理大页面上,从而控制虚拟大页面能够占用的cache set,降低了虚拟大页面之间的cache冲突。The corresponding device of the virtual large page and the physical large page provided by the embodiment of the present invention acquires the starting physical page and the virtual large page corresponding to each virtual large page in each physical large page in the processor. After storing the color configuration information of the number of corresponding physical pages in the page, the memory stores the
Obtaining the color configuration information, and further obtaining the correspondence between the virtual large page and the plurality of physical large pages according to the color configuration information. In the prior art, a virtual large page can only correspond to a physical large page whose physical address is continuous, so that when there are multiple virtual large pages, a physical large page corresponding to the virtual large page is shared, thereby causing a cache. conflict. The technical solution provided by the embodiment of the present invention can map a virtual large page to a plurality of discrete physical large pages, thereby controlling a cache set that can be occupied by the virtual large page, and reducing a cache conflict between the virtual large pages.
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到本发明可借助软件加必需的通用硬件的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在可读取的存储介质中,如计算机的软盘,硬盘或光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the present invention can be implemented by means of software plus necessary general hardware, and of course, by hardware, but in many cases, the former is a better implementation. . Based on the understanding, the technical solution of the present invention, which is essential or contributes to the prior art, can be embodied in the form of a software product stored in a readable storage medium, such as a floppy disk of a computer. A hard disk or optical disk, etc., includes instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform the methods described in various embodiments of the present invention.
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。
The above is only a specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily think of changes or substitutions within the technical scope of the present invention. It should be covered by the scope of the present invention. Therefore, the scope of the invention should be determined by the scope of the appended claims.
Claims (8)
- 一种虚拟大页面与物理大页面的对应方法,其特征在于,一个虚拟大页面与多个物理大页面对应,所述多个物理大页面的物理地址不连续,所述方法包括:A method for mapping a virtual large page and a physical large page, wherein a virtual large page corresponds to a plurality of physical large pages, and physical addresses of the plurality of physical large pages are discontinuous, and the method includes:获取虚拟大页面的颜色配置信息,所述颜色配置信息包括所述虚拟大页面在每个所述物理大页面中对应的起始物理页面和所述虚拟大页面在每个所述物理大页面中对应的物理页面的个数;Obtaining color configuration information of the virtual large page, where the color configuration information includes a corresponding physical page corresponding to the virtual large page in each of the physical large pages and the virtual large page in each of the physical large pages The number of corresponding physical pages;其中,所述虚拟大页面中的一个虚拟页面对应所述物理大页面中的一个物理页面;Wherein one virtual page in the virtual large page corresponds to one physical page in the physical large page;根据所述虚拟大页面的颜色配置信息,获取所述虚拟大页面与多个物理大页面的对应关系。Obtaining a correspondence between the virtual large page and the plurality of physical large pages according to the color configuration information of the virtual large page.
- 根据权利要求1所述的方法,其特征在于,所述获取虚拟大页面的颜色配置信息,包括:The method according to claim 1, wherein the obtaining color configuration information of the virtual large page comprises:确定所述虚拟大页面的虚拟地址;Determining a virtual address of the virtual large page;通过所述虚拟地址中的虚拟大页面号,从旁路转换缓冲TLB中确定所述颜色配置信息。The color configuration information is determined from the bypass conversion buffer TLB by a virtual large page number in the virtual address.
- 根据权利要求2所述的方法,其特征在于,所述方法还包括:The method of claim 2, wherein the method further comprises:将所述虚拟地址中的虚拟大页面内部偏移划分为:离散移位Scattered Shift和颜色块的内部偏移CR Offset两个部分,所述Scattered Shift用于索引所述虚拟大页面对应的物理大页面号;Dividing the internal offset of the virtual large page in the virtual address into two parts: a discrete shift Scattered Shift and an internal offset CR Offset of the color block, where the Scattered Shift is used to index the physical large corresponding to the virtual large page Page number所述颜色块用于表征所述虚拟大页面在每个所述物理大页面中对应的多个物理页面所对应的缓存中的多种颜色;The color block is used to represent multiple colors in the cache corresponding to the plurality of physical pages corresponding to the virtual large page in each of the physical large pages;其中,与所述颜色块对应的所述多个物理页面在一个物理大页面中,且所述多个物理页面的物理地址连续。The plurality of physical pages corresponding to the color block are in one physical large page, and physical addresses of the plurality of physical pages are consecutive.
- 根据权利要求3所述的方法,其特征在于,所述TLB中记录有虚拟大页面号和物理大页面号的对应关系,所述方法还包括: The method according to claim 3, wherein the mapping between the virtual large page number and the physical large page number is recorded in the TLB, the method further comprising:通过所述虚拟地址中的虚拟大页面号,从所述TLB中确定与所述虚拟大页面对应的第一个物理大页面的页面号;Determining, by the virtual large page number in the virtual address, a page number of the first physical large page corresponding to the virtual large page from the TLB;将所述第一个物理大页面的页面号与所述虚拟大页面对应的所述物理大页面的个数相加,得到与所述虚拟大页面对应的每个物理大页面的页面号;Adding a page number of the first physical large page to the number of the physical large pages corresponding to the virtual large page, to obtain a page number of each physical large page corresponding to the virtual large page;确定所述虚拟大页面在每个所述物理大页面中对应的起始物理页面的页面号;并将每个所述物理大页面中对应的起始物理页面的页面号与所述CR Offset拼接,得到与所述虚拟地址对应的所述物理地址。Determining a page number of the corresponding starting physical page of the virtual large page in each of the physical large pages; and splicing the page number of the corresponding starting physical page in each of the physical large pages with the CR Offset And obtaining the physical address corresponding to the virtual address.
- 一种虚拟大页面与物理大页面的对应装置,其特征在于,在所述装置中,一个虚拟大页面与多个物理大页面对应,所述多个物理大页面的物理地址不连续,所述装置包括:Corresponding device for a virtual large page and a physical large page, wherein in the device, one virtual large page corresponds to multiple physical large pages, and physical addresses of the plurality of physical large pages are discontinuous, The device includes:获取单元,用于获取虚拟大页面的颜色配置信息,所述颜色配置信息包括所述虚拟大页面在每个所述物理大页面中对应的起始物理页面和所述虚拟大页面在每个所述物理大页面中对应的物理页面的个数;An obtaining unit, configured to obtain color configuration information of a virtual large page, where the color configuration information includes a corresponding starting physical page and a virtual large page in each of the physical large pages. The number of corresponding physical pages in the physical large page;其中,所述虚拟大页面中的一个虚拟页面对应所述物理大页面中的一个物理页面;Wherein one virtual page in the virtual large page corresponds to one physical page in the physical large page;所述获取单元,还用于根据获取的所述虚拟大页面的颜色配置信息,获取所述虚拟大页面与多个物理大页面的对应关系;The obtaining unit is further configured to acquire, according to the acquired color configuration information of the virtual large page, a correspondence between the virtual large page and multiple physical large pages;存储单元,用于存储所述获取单元获取的所述虚拟大页面的颜色配置信息。a storage unit, configured to store color configuration information of the virtual large page acquired by the acquiring unit.
- 根据权利要求5所述的装置,其特征在于,所述获取单元包括:The device according to claim 5, wherein the obtaining unit comprises:确定子单元,用于确定所述虚拟大页面的虚拟地址;并通过所述虚拟地址中的虚拟大页面号,从旁路转换缓冲TLB中确定所述颜色配置信息。Determining a sub-unit for determining a virtual address of the virtual large page; and determining the color configuration information from the bypass conversion buffer TLB by a virtual large page number in the virtual address.
- 根据权利要求6所述的装置,其特征在于,所述装置还包括:The device according to claim 6, wherein the device further comprises:划分单元,用于将所述确定子单元确定的所述虚拟地址中的虚拟大页面内部偏移划分为:离散移位Scattered Shift和颜色块的内部偏移CR Offset两个部分,所述Scattered Shift用于索引所述虚拟大页面对应的物理大页面号;a dividing unit, configured to divide the virtual large page internal offset in the virtual address determined by the determining subunit into two parts: a discrete shift Scattered Shift and an internal offset CR Offset of the color block, the Scattered Shift a physical large page number corresponding to the virtual large page;所述颜色块用于表征所述虚拟大页面在每个所述物理大页面中对应的多个物理页面所对应的缓存中的多种颜色; The color block is used to represent multiple colors in the cache corresponding to the plurality of physical pages corresponding to the virtual large page in each of the physical large pages;其中,与所述颜色块对应的所述多个物理页面在一个物理大页面中,且所述多个物理页面的物理地址连续。The plurality of physical pages corresponding to the color block are in one physical large page, and physical addresses of the plurality of physical pages are consecutive.
- 根据权利要求7所述的装置,其特征在于,所述TLB中记录有虚拟大页面号和物理大页面号的对应关系,所述装置还包括:The device according to claim 7, wherein the correspondence between the virtual large page number and the physical large page number is recorded in the TLB, and the device further includes:确定单元,还用于通过所述虚拟地址中的虚拟大页面号,从所述TLB中确定与所述虚拟大页面对应的第一个物理大页面的页面号;a determining unit, configured to determine, by using a virtual large page number in the virtual address, a page number of the first physical large page corresponding to the virtual large page from the TLB;计算单元,用于将所述确定单元确定的所述第一个物理大页面的页面号与所述虚拟大页面对应的所述物理大页面的个数相加,得到与所述虚拟大页面对应的每个物理大页面的页面号;a calculating unit, configured to add, by the determining unit, a page number of the first physical large page and a number of the physical large page corresponding to the virtual large page, to obtain a corresponding to the virtual large page The page number of each physical large page;所述确定单元,还用于确定所述虚拟大页面在每个所述物理大页面中对应的起始物理页面的页面号;The determining unit is further configured to determine a page number of the corresponding starting physical page of the virtual large page in each of the physical large pages;拼接单元,用于将所述确定单元确定的每个所述物理大页面中对应的起始物理页面的页面号与所述CR Offset拼接,得到与所述虚拟地址对应的所述物理地址。 a splicing unit, configured to splicing a page number of a corresponding starting physical page in each of the physical large pages determined by the determining unit with the CR Offset, to obtain the physical address corresponding to the virtual address.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310462565.7 | 2013-09-30 | ||
CN201310462565.7A CN104516826B (en) | 2013-09-30 | 2013-09-30 | The corresponding method and device of a kind of virtual big page and the big page of physics |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2015043445A1 true WO2015043445A1 (en) | 2015-04-02 |
Family
ID=52742053
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2014/087162 WO2015043445A1 (en) | 2013-09-30 | 2014-09-23 | Method and device for correlating virtual large page and physical large page |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN104516826B (en) |
WO (1) | WO2015043445A1 (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107688745B (en) * | 2016-08-04 | 2020-10-30 | 阿里巴巴集团控股有限公司 | Method for processing and generating kernel mirror image, kernel initialization method, device and equipment |
EP3454218B1 (en) * | 2016-08-11 | 2023-02-01 | Huawei Technologies Co., Ltd. | Method for accessing table entry in translation lookaside buffer (tlb) and processing chip |
CN111344667B (en) * | 2017-12-01 | 2021-10-15 | 华为技术有限公司 | System and method for compiling and executing code within virtual memory sub-pages of one or more virtual memory pages |
CN110209603B (en) * | 2019-05-31 | 2021-08-31 | 龙芯中科技术股份有限公司 | Address translation method, device, equipment and computer readable storage medium |
CN113094173B (en) * | 2021-04-02 | 2022-05-17 | 烽火通信科技股份有限公司 | DPDK-based large-page memory dynamic migration method and device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070245041A1 (en) * | 2006-03-21 | 2007-10-18 | Binh Hua | Method to improve system DMA mapping while substantially reducing memory fragmentation |
CN102184142A (en) * | 2011-04-19 | 2011-09-14 | 中兴通讯股份有限公司 | Method and device for reducing central processing unit (CPU) resource consumption by using giant page mapping |
CN102339302A (en) * | 2011-07-07 | 2012-02-01 | 曙光信息产业股份有限公司 | Method for realizing godson blade file system based on hugetlbfs technique |
CN102446136A (en) * | 2010-10-14 | 2012-05-09 | 无锡江南计算技术研究所 | Self-adaptive large-page allocation method and device |
CN103257929A (en) * | 2013-04-18 | 2013-08-21 | 中国科学院计算技术研究所 | Virtual machine memory mapping method and system |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2009110446A1 (en) * | 2008-03-04 | 2009-09-11 | 日本電気株式会社 | Memory mapping method, memory system |
CN101661437A (en) * | 2008-08-28 | 2010-03-03 | 国际商业机器公司 | By-pass conversion buffer as well as method and device for matching addresses in same |
-
2013
- 2013-09-30 CN CN201310462565.7A patent/CN104516826B/en active Active
-
2014
- 2014-09-23 WO PCT/CN2014/087162 patent/WO2015043445A1/en active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070245041A1 (en) * | 2006-03-21 | 2007-10-18 | Binh Hua | Method to improve system DMA mapping while substantially reducing memory fragmentation |
CN102446136A (en) * | 2010-10-14 | 2012-05-09 | 无锡江南计算技术研究所 | Self-adaptive large-page allocation method and device |
CN102184142A (en) * | 2011-04-19 | 2011-09-14 | 中兴通讯股份有限公司 | Method and device for reducing central processing unit (CPU) resource consumption by using giant page mapping |
CN102339302A (en) * | 2011-07-07 | 2012-02-01 | 曙光信息产业股份有限公司 | Method for realizing godson blade file system based on hugetlbfs technique |
CN103257929A (en) * | 2013-04-18 | 2013-08-21 | 中国科学院计算技术研究所 | Virtual machine memory mapping method and system |
Also Published As
Publication number | Publication date |
---|---|
CN104516826A (en) | 2015-04-15 |
CN104516826B (en) | 2017-11-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105283855B (en) | A kind of addressing method and device | |
US9858192B2 (en) | Cross-page prefetching method, apparatus, and system | |
WO2015043445A1 (en) | Method and device for correlating virtual large page and physical large page | |
KR102161448B1 (en) | System comprising multi channel memory and operating method for the same | |
KR101994021B1 (en) | File manipulation method and apparatus | |
WO2016082191A1 (en) | File access method and apparatus | |
US9817689B2 (en) | Dirty page tracking of guest-uncached memory | |
JP2019109906A (en) | Multiple sets of attribute fields in single page table entry | |
WO2016026433A1 (en) | Data processing method and data processing apparatus | |
KR20170088933A (en) | File access method and apparatus and storage device | |
CN103970870A (en) | Database query method and server | |
CN113641596B (en) | Cache management method, cache management device and processor | |
US9984003B2 (en) | Mapping processing method for a cache address in a processor to provide a color bit in a huge page technology | |
WO2015043379A1 (en) | Memory accessing method and device | |
US9798674B2 (en) | N-ary tree for mapping a virtual memory space | |
GB2581938A (en) | Configuration state registers grouped based on functional affinity | |
CN103077120A (en) | Address conversion method and device of application shared memory | |
JP2020523682A (en) | Sharing virtual and real transformations in virtual cache | |
TWI696949B (en) | Direct memory access method, device, dedicated computing chip and heterogeneous computing system | |
WO2021062982A1 (en) | Method and apparatus for managing hmb memory, and computer device and storage medium | |
US20220012183A1 (en) | Methods and systems for translating virtual addresses in a virtual memory based system | |
CN107766259B (en) | Page table cache access method, page table cache, processor chip and storage unit | |
WO2019011311A1 (en) | Data access method and apparatus | |
CN107209761B (en) | A kind of data access method, apparatus and system | |
CN105659216B (en) | The CACHE DIRECTORY processing method and contents controller of multi-core processor system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 14846918 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 14846918 Country of ref document: EP Kind code of ref document: A1 |