Hi, I'm approaching this subject of virtual memory page size delicately, as it seems to create a lot of energy :-) In our design, we would get a non-trivial boost by increasing the VM page size to 16KB -- both in IPC and in energy. I heard a rumor that early Rocket looked at 16KB pages, but this was rejected. However, I haven't found much on the reason.
So, we have looked into the Linux kernel, and there appears to be one master location where the default page size is set:#define PAGE_SHIFT (12)Everything else appears to derive page size from there -- the page table walker, slab allocation, and so on. But we don't yet have kernel expertise on the team to verify.Also, looking further, for other examples, ARM and POWER both enable default page sizes larger than 4KB. POWER looks like it defaults to 64KB, and ARM can be set to default to 16KB or 64KB (in addition to the standard 4KB). As for the files system, in the recent kernels the only requirement seems to be alignment on 512 byte boundaries -- the file system page size appears insulated from the Virtual Memory page size..But.. this is at the heart of the kernel, with a tremendous amount of complexity throughout a vast system, with uncountable number of opportunities for things to go wrong.. so..Does anyone have concrete examples of what goes wrong when the default VM page size is increased, to, say 16KB? It makes me very nervous, messing with something this deep, but the gain is attractive..
Thanks for any pointers,Sean
--
You received this message because you are subscribed to the Google Groups "RISC-V HW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hw-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to hw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/hw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/hw-dev/CAJ4GwD%2BSdWfFvgNEx0fH9YmgkRuLbVa0jGeT0R7B9ZXGTfQZ9Q%40mail.gmail.com.
The problem is not the kernel, it is applications that expect mmap and mprotect to work with 4KB chunks. I don’t have concrete examples to hand, but there were quite a lot when we looked. Searching for mmap and mprotect in large open source code bases should give you a few. Note that even the ones that do try to support different paged sizes have often never been tested with non-4KB sizes so may fail in subtle and exciting ways.
On 25 Apr 2018, at 06:04, Sean Halle <sean...@gmail.com> wrote:However, it means we have to tweak the page table walker, and tweak mmap and mprotect implementations in the kernel. We'll also have to do a survey to figure out if any other user-land interfaces expose the VM page size, then look closely at device drivers, to see whether there are built-in assumptions about page-size that bypass the defines in the kernel header.. which, I expect there will be..So, for the MVP first product, we'll be sticking with 4KB pages, and put this on the list for version 2 :-) We're open to interested parties, would love to do some experiments with the 4KB permissions approach, to see what still breaks.
Some Apple folk that Andrew and I spoke to at ASPLOS hinted that they’d done this evaluation and come to the conclusion that enough stuff would break that it isn’t really worth it.
Modern operating systems are now very good at transparent superpage promotion. On FreeBSD, malloc asks for memory in 2-8MB chunks. These are initially backed by individual 4KB pages (allocated lazily), but once a region is packed with live objects, it almost always ends up being replaced by a smaller number of superpages. Anything being serviced by the buffer cache and backed by a file will often already be convenient for superpages, because it is more efficient to ask the disk to DMA a superpage-sized amount of data into a contiguous chunk of free memory (and evict the unused portions if not used) than to do a larger number of 4KB requests.
On RISC-V, increasing the base page size also increases the smallest superpage size. This increases the effort in transparent superpage promotion and means that, somewhat counterintuitively, you are likely to see increased TLB pressure with larger leaf page table entry sizes.
If you want a more scalable mechanism, you should consider asking Krste about Mondrian Memory Protection, which allows you to decouple the protection and translation granule sizes. Doing something more restrictive than a full Mondrian implementation, giving 4KB protection granules but 64KB translation granules may give some improvements and would be an interesting avenue for experimentation.
--
You received this message because you are subscribed to the Google Groups "RISC-V HW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hw-dev+un...@groups.riscv.org.
To post to this group, send email to hw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/hw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/hw-dev/8121410C-AB42-41E0-9EAB-49E684ADDD7F%40mac.com.