在ARMv7的上下文中,当mmu必须执行页表转换时,Linux内核一对一映射内存的优势是什么? [英] In context of ARMv7 what is the advantage of Linux kernel one to one mapped memory when mmu has to do a page table translation

查看:351
本文介绍了在ARMv7的上下文中,当mmu必须执行页表转换时,Linux内核一对一映射内存的优势是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Linux内核虚拟地址是一对一映射的.因此,通过在虚拟地址中减去PAGE_OFFSET,我们将获得物理地址.这就是 virt_to_phys phys_to_virt http://lxr.free-electrons.com/source/arch/arm/include/asm/memory.h#L256"rel =" nofollow> memory.h .

Linux kernel virtual address are one-to-one mapped. So by subtracting a PAGE_OFFSET to virtual address we will get the physical address. That is how virt_to_phys and phys_to_virt are implemented in memory.h.

我的问题是,当存在TLB未命中时,mmu必须执行页表转换时,armv7 mmu上这些一对一映射的优点是什么?

My question is what is the advantage of these one to one mapping on the armv7 mmu, when the mmu has to do the page table translation when there is a TLB miss?

一对一映射的唯一优势是S/W只需减去PAGE_OFFSET就可以直接获取相应虚拟地址的物理地址,还是ARMV7 MMU页面转换还有其他优势?

Is the only advantage of one to one mapping so that S/W can directly gets the physical address of respective virtual address by just subtracting PAGE_OFFSET or there is some other advantage on ARMV7 MMU page translation too?

如果1:1映射的内存比mmu页表转换没有优势,那么为什么我们需要1:1映射的内存的页表.我的意思是mmu可以用与virt_to_phys类似的方式进行操作,而不用遍历所有页表.

If there is no advantage of 1:1 mapped memory over mmu page table translation then why we need page tables for 1:1 mapped memory. I mean mmu can do the operation in similar way of virt_to_phys instead walking all the page tables.

推荐答案

我的问题是,这些一对一映射的优点是什么 armv7 mmu,当mmu必须执行页表转换时 有TLB小姐吗?

My question is what is the advantage of these one to one mapping on the armv7 mmu, when the mmu has to do the page table translation when there is a TLB miss?

您的答案部分在问题中. 1:1映射由1MB的部分实现,因此TLB条目较小.即,一个4k页需要1级和2级TLB条目,并且它仅包含4k的内存. ARM内核必须始终保持映射状态,因为它具有中断,页面错误和可能随时调用的其他关键代码.

Your answer is partially in the question. The 1:1 mappings are implemented with 1MB sections so the TLB entry is smaller. Ie, a 4k page needs a level 1 and level 2 TLB entry and it only encompasses 4k of memory. The ARM kernel must always remain mapped as it has interrupt, page fault and other critical code which maybe called at any time.

对于用户空间代码,每个4k代码块都由 inode 支持,并且可能在内存压力期间从内存中逐出.用户空间代码通常只是几个热进程/例程,因此它们的TLB条目并不那么关键. TLB通常仅次于L1/L2缓存.

For user space code, each 4k chunk of code is backed by an inode and maybe evicted from memory during times of memory pressure. The user space code is usually only a few hot processes/routines, so the TLB entries for them are not as critical. The TLB is often secondary to L1/L2 caches.

同样,设备驱动程序通常需要知道物理地址,因为它们在CPU之外,并且不知道虚拟地址.减去PAGE_OFFSET的简单性使代码更有效.

As well, device drivers typically need to know physical addresses as they are outside of the CPU and do not know virtual addresses. The simplicity of subtracting PAGE_OFFSET makes for efficient code.

一对一映射的唯一优势是S/W只需减去PAGE_OFFSET就可以直接获取相应虚拟地址的物理地址,或者ARMV7 MMU页面转换还有其他优势吗?

Is the only advantage of one to one mapping so that S/W can directly gets the physical address of respective virtual address by just subtracting PAGE_OFFSET or there is some other advantage on ARMV7 MMU page translation too?

1:1映射允许一次映射更大的范围.典型的SDRAM/核心内存以1MB为增量.这也是非常有效的.还有其他可能性,但是这些可能是此选择的胜利.

The 1:1 mapping allows for larger ranges to be mapped a one time. Typical SDRAM/core memory comes in 1MB increments. It is also very efficient. There are other possibilities, but these are probably wins for this choice.

是一对一映射的唯一优势,因此S/W可以直接 仅通过获取虚拟地址的物理地址 减去PAGE_OFFSET或在ARMV7 MMU上还有其他优势 页面翻译了吗?

Is the only advantage of one to one mapping so that S/W can directly gets the physical address of respective virtual address by just subtracting PAGE_OFFSET or there is some other advantage on ARMV7 MMU page translation too?

必须打开MMU才能使用数据缓存并在用户空间进程之间进行内存保护;彼此之间以及用户/内核分离.仅检查内核对1:1映射的使用并不完整.内核的其他部分需要MMU.如果没有MMU,则1:1映射将是身份. IE. PAGE_OFFSET==0.具有固定偏移量的唯一原因是允许将任何物理地址处的内存映射到公共虚拟地址.并非所有平台都具有相同的PAGE_OFFSET值.

The MMU must be on to use the data cache and for memory protection between user space process; each other as well as user/kernel separation. Examining the kernels use of 1:1 mappings by itself is not the full story. Other parts of the kernel need the MMU. Without the MMU, the 1:1 mapping would be the identity. Ie. PAGE_OFFSET==0. The only reason to have a fixed offset is to allow memory at any physical address to be mapped to a common virtual address. Not all platforms have the same PAGE_OFFSET value.

virt_to_phys关系的另一个好处;内核被编写为在固定的虚拟地址上执行.这意味着内核代码不需要相对于PC,而是可以在具有不同核心内存物理地址的平台上运行.由于引导加载程序要在MMU关闭的情况下进行手动控制,因此请注意 arm/boot 汇编程序代码是否与PC相关.此 arm/boot 代码设置了初始映射.

Another benefit of the virt_to_phys relation; the kernel is written to execute at a fixed virtual address. This means the kernel code doesn't need to be PC-relative and yet can run on platforms with different physical addresses of the core memory. Care is taken in the arm/boot assembler code to be PC-relative as the boot loader is to hand control with the MMU off. This arm/boot code sets up up an initial mapping.

另请参阅:找到物理地址向量表,是virt_to_phys映射的例外.
                内核如何管理小于1gb的内容?
                Linux内核中的页表-早期启动和MMU.

See also: Find the physical address of the vector table, an exception to the virt_to_phys mapping.
                Kernel data swappable?
                How does the kernel manage less than 1gb?
                Some details on ARM Linux boot?
                Page table in linux kernel - early boot and MMU.

这篇关于在ARMv7的上下文中,当mmu必须执行页表转换时,Linux内核一对一映射内存的优势是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆