Virtual machine migration time dirty page recording method based on customized TLB replacement

文档序号:809172 发布日期:2021-03-26 浏览:7次 中文

阅读说明:本技术 基于定制tlb代换的虚拟机迁移时脏页记录方法 (Virtual machine migration time dirty page recording method based on customized TLB replacement ) 是由 刘松 王星焱 林海南 黄高阳 郑岩 邹通 于 2019-09-25 设计创作,主要内容包括:本发明公开一种基于定制TLB代换的虚拟机迁移时脏页记录方法,包括以下步骤:将虚拟机的迁移标志设置为开启,在虚拟机管理层申请“脏页缓冲区”;判断造成缺页的读写标志,如果是读标志,则需要设置TLB的只读标志位;如果是写标志,计算虚拟地址对应的宿主机页面号,并记录脏页;在数据流异常处理流程中,重填TLB,判断此时TLB是否真正具有只读标志,如果没有则需要记录脏页;否则,进入正常的数据流异常处理流程中。本发明通过虚拟地址到宿主机页面的映射关系,在特权指令模式下实现脏页记录过程,无需维护额外的影子页表,节约大量的内存资源;无需频繁虚拟机退出操作,节约大量的CPU资源,并且大幅度提高了TLB的命中率,进而提高CPU执行效率。(The invention discloses a method for recording dirty pages during virtual machine migration based on customized TLB replacement, which comprises the following steps: setting a migration mark of a virtual machine to be started, and applying for a 'dirty page buffer' on a virtual machine management layer; judging the reading and writing mark causing the page fault, if the reading mark is the page fault, setting a read-only mark bit of the TLB; if the address is the writing mark, calculating a host page number corresponding to the virtual address, and recording dirty pages; in the data flow exception handling flow, the TLB is refilled, whether the TLB really has a read-only mark at the moment is judged, and if not, dirty pages need to be recorded; otherwise, entering a normal data flow exception processing flow. According to the method, the dirty page recording process is realized in the privilege instruction mode through the mapping relation from the virtual address to the host page, an additional shadow page table does not need to be maintained, and a large amount of memory resources are saved; frequent virtual machine quitting operation is not needed, a large amount of CPU resources are saved, the hit rate of the TLB is greatly improved, and the execution efficiency of the CPU is improved.)

1. A dirty page recording method during virtual machine migration based on customized TLB replacement is characterized in that: the method comprises the following steps:

s1: before the migration process of the virtual machine starts, setting a migration flag in a control state register to be on;

s2: applying for a dirty page buffer at a virtual machine management layer;

s3: in the TLB Miss process of the virtual machine, judging a read-write mark causing page faults, and if the read-write mark is a read mark, setting the TLB corresponding to the virtual address at the moment as read-only; if the address is the writing mark, calculating a host page number corresponding to the virtual address, and recording dirty pages;

s4: in the abnormal processing process of the data flow of the virtual machine, the TLB corresponding to the virtual address is refilled, whether the TLB really has a read-only mark at the moment is judged, and if not, a dirty bit is recorded into a dirty page buffer area; otherwise, entering a normal data flow exception handling flow;

s5: and exiting to the host, and migrating the page corresponding to the dirty page bit to the target virtual machine according to the dirty page bit recorded by the virtual machine management layer.

2. The method for dirty page logging during virtual machine migration based on custom TLB replacement of a virtual machine according to claim 1, wherein: dirty page logging is implemented in privileged instruction mode.

Technical Field

The invention relates to a method for recording dirty pages during virtual machine migration based on customized TLB replacement, belongs to the technical field of computers, and particularly relates to the technical field of operating systems of domestic Shenwei multi-core servers.

Background

With the rapid development of cloud computing and data centers, dynamic migration of virtual machines becomes an important aspect of virtualization technology application. The dynamic migration of the virtual machine needs to copy the dirty pages to be migrated through multiple rounds of iteration under the condition that the virtual machine does not stop, and finally all the pages of the virtual machine are migrated to a target host machine. Therefore, fast and stable recording of dirty pages becomes a key technology for dynamic migration of virtual machines.

Currently, a technology that supports a live migration of a virtual machine from a software level for dirty page logging is a shadow page table. Shadow page tables (Shadow page tables) support translation from guest virtual addresses to host physical addresses. To achieve this, there is a set of shadow page tables corresponding to each process of the client, which takes up a significant amount of memory resources. Second, the shadow page table must be kept in sync with the guest page table, and each modification to the guest page table must also pass through the shadow page table, requiring frequent virtual machine retirement during the TLB Miss, which places very high demands on CPU performance.

Disclosure of Invention

The invention aims to provide a dirty page recording method during virtual machine migration based on customized TLB (translation lookaside buffer) replacement, which is used for directly setting dirty page bits of a virtual machine in the processing process of TLB Miss and data flow exception through the mapping relation between a virtual address and a host machine page without performing virtual machine exit action; therefore, a large amount of memory for maintaining the shadow page table is saved, meanwhile, the CPU resource consumption caused by exiting of the virtual machine is saved, and the performance of the virtual machine is further improved.

In order to achieve the purpose, the invention adopts the technical scheme that: a method for recording dirty pages during virtual machine migration based on customized TLB replacement comprises the following steps:

s1: before the migration process of the virtual machine starts, setting a migration flag in a control state register to be on;

s2: applying for a dirty page buffer at a virtual machine management layer;

s3: in the TLB Miss process of the virtual machine, judging a read-write mark causing page faults, and if the read-write mark is a read mark, setting the TLB corresponding to the virtual address at the moment as read-only; if the address is the writing mark, calculating a host page number corresponding to the virtual address, and recording dirty pages;

s4: in the abnormal processing process of the data flow of the virtual machine, the TLB corresponding to the virtual address is refilled, whether the TLB really has a read-only mark at the moment is judged, and if not, dirty pages need to be recorded; otherwise, entering a normal data flow exception handling flow;

s5: and exiting to the host machine, and migrating the corresponding dirty page to the target virtual machine according to the dirty page position recorded by the virtual machine management layer.

The further improved scheme in the technical scheme is as follows:

1. in the above scheme, the dirty page record is implemented in the privileged instruction mode.

Due to the application of the technical scheme, compared with the prior art, the invention has the following advantages:

1) according to the method for recording the dirty pages during virtual machine migration based on the customized TLB replacement, an additional shadow page table does not need to be maintained, and precious memory resources are saved;

2) the invention relates to a dirty page recording method during virtual machine migration based on customized TLB replacement, which realizes a dirty page recording process in an Hmcode (privileged instruction) mode. Compared with the traditional dirty page recording method, the virtual machine does not need to be frequently quitted, a large amount of CPU resources are saved, and the requirement on the performance of the CPU is greatly reduced.

3) According to the dirty page recording method during virtual machine migration based on customized TLB replacement, the dirty page recording process is directly completed in the virtual machine mode, and the virtual machine does not need to be exited, so that TLB clearing and refilling caused by virtual machine exiting and entering are reduced, the TLB hit rate is greatly improved, and the CPU execution efficiency is further improved.

Drawings

FIG. 1 is a schematic flow diagram of the present invention;

FIG. 2 is another flow chart of the present invention.

Detailed Description

As shown in fig. 1 and 2, a method for recording dirty pages during virtual machine migration based on customized TLB replacement includes the following steps:

s1: before the migration process of the virtual machine starts, setting a migration flag in a control state register to be on;

s2: applying for a dirty page buffer at a virtual machine management layer;

s3: in the TLB Miss process of the virtual machine, judging a read-write mark causing page faults, and if the read-write mark is a read mark, setting the TLB corresponding to the virtual address at the moment as read-only; if the address is the writing mark, calculating a host page number corresponding to the virtual address, and recording dirty pages;

s4: in the abnormal processing process of the data flow of the virtual machine, the TLB corresponding to the virtual address is refilled, whether the TLB really has a read-only mark at the moment is judged, and if not, dirty pages need to be recorded; otherwise, entering a normal data flow exception handling flow;

s5: and exiting to the host machine, and migrating the corresponding dirty page to the target virtual machine according to the dirty page position recorded by the virtual machine management layer.

The dirty page record is implemented in a privileged instruction mode. In fig. 1 and 2, Y represents yes, N represents no, and VA represents a virtual address.

The examples are further explained below:

example 1: in the dynamic migration process of the virtual machine, it is assumed that a page a in the client 1 causes a TLB Miss due to a certain write instruction, and a virtual address of the access instruction at this time is va (virtual address), and a corresponding PA (physical address, PA) of the host is directly obtained by customizing TLB substitution. In the privileged instruction mode, the pfn-th bit of the dirty PAGE buffer is set to be a dirty bit by calculating that the corresponding PAGE is pfn = pa > > PAGE _ SHIFT (where PAGE _ SHIFT is the number of PAGE bits). In the dynamic migration iteration process, the Hypervisor collects the dirty pages and migrates the dirty pages to the target machine to realize dynamic migration.

Example 2: in the dynamic migration process of the virtual machine, suppose that a page B in the client 1 causes a TLB Miss due to a certain read instruction, at this time, the Hmcode loads a virtual address va of the read instruction into the TLB, and sets a read-only attribute, and directly obtains pa of the corresponding host through customizing TLB substitution. After that, the client 1 performs a write operation on the page B, and since the read-only attribute is set in the page at this time, a data flow exception handling process is performed. In the data flow exception processing flow, the Hmcode refills the TLB corresponding to the VA and determines that there is no read-only attribute, so it is determined that the data flow exception is caused by the read-only attribute added by the TLB Miss. In the privileged instruction mode, the pfn-th bit of the dirty PAGE buffer is set as a dirty bit by calculating that the corresponding PAGE is pfn = pa > > PAGE _ SHIFT. In the dynamic migration iteration process, the Hypervisor collects the dirty pages and migrates the dirty pages to the target machine to realize dynamic migration.

1) Setting a dirty page bit: assuming that the dirty page needs to be set as the y-th page and the dirty page buffer first address is dirty _ addr, the y-th bit of the buffer needs to be set to 1, i.e., (y%8) bit of the dirty _ addr + (y/8) address is set to 1.

2) Collecting dirty pages: hypervisor determines the dirty pages to be migrated by scanning the dirty page buffer and locates 0 corresponding to these pages.

To facilitate a better understanding of the invention, the terms used herein will be briefly explained as follows: dynamic migration of the virtual machine: refers to a technique of moving a running virtual machine ahead of a different physical machine in a state where the virtual machine is not stopped.

TLB (translation detection buffer): the cache memory is a memory management unit and is used for improving the speed of converting a virtual address into a physical address, and the time consumed for searching the physical address can be effectively reduced.

TLB Miss (TLB Miss): and the table entry corresponding to the virtual address is not searched through the TLB fast mapping table.

TLB replacement: the virtual address of the memory access is used for calculating the page number of the physical page corresponding to the memory access actually through a certain rule, the virtual page number is used as an index, and the physical page number and the access authority are used as contents to be stored in a fast mapping table, so that the actual physical page can be obtained quickly through the following memory access instruction.

Data flow write exception: the exception caused by the operation of writing a page marked with read-only property by the operating system is generally caused by the copy-on-write mechanism of the process.

Hypervisor: the virtual machine management layer, also called a virtual machine monitor (vm monitor), is used to establish and execute software, firmware or hardware of the vm.

Privileged instruction: the method is mainly used for allocating and managing system resources, and comprises the steps of changing the working mode of the system, detecting the access authority of a user, modifying a segment table and a page table managed by a virtual memory, completing the creation and switching of tasks and the like. Common privileged instructions are the following: (1) instructions used for the I/O device, such as an instruction for starting the I/O device, an instruction for testing the working state of the I/O device and an instruction for controlling the action of the I/O device; (2) instructions related to accessing program status such as instructions to a Program Status Word (PSW), etc.; (3) and accessing special register instructions, such as accessing an interrupt register, a clock register and the like.

The above embodiments are merely illustrative of the technical ideas and features of the present invention, and the purpose thereof is to enable those skilled in the art to understand the contents of the present invention and implement the present invention, and not to limit the protection scope of the present invention. All equivalent changes and modifications made according to the spirit of the present invention should be covered within the protection scope of the present invention.

6页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:系统库访问方法、装置以及电子设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类