7

On a modern 64-bit x86 Linux, how is the mapping between virtual and physical pages set up, kernel side? On the user side, you can mmap in pages from the page cache, and this will map 4K pages in directly into user space - but I am interesting in how the pages are mapped in the kernel side.

Does it make use of the "whole ram identity mapping" or something else? Is that whole ram identity mapping generally using 1GB pages?

2
  • Which cache are you talking about? Commented Dec 31, 2016 at 21:41
  • @Gilles - the page cache, i.e., the cache that holds pages read from disk (including unwritten dirty blocks). Commented Dec 31, 2016 at 21:50

1 Answer 1

1

On a modern 64-bit x86 Linux?

Yes. It calls kmap() or kmap_atomic(), but on x86-64 these will always use the identity mapping. x86-32 has a specific definition of it, but I think x86-64 uses a generic definition in include/linux/highmem.h.

And yes, the identity mapping uses 1GB hugepages.

LWN article which mentions kmap_atomic.

I found kmap_atomic() by looking at the PIO code.[*]

Finally, when read() / write() copy data from/to the page cache:

generic_file_buffered_read -> copy_page_to_iter -> kmap_atomic() again.


[*] I looked at PIO, because I realized that when performing DMA to/from the page cache, the kernel could avoid using any mapping. The kernel could just resolve the physical address and pass it to the hardware :-). (Subject to IOMMU). Although, the kernel will need a mapping if it wants to checksum or encrypt the data first.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.