What does Linux / proc / meminfo "Mapped" theme mean?

What does Linux / proc / meminfo "Mapped" theme mean? I have seen a few one-liners that tell me that it is "Total memory size in kilobytes displayed by devices or libraries using mmap". But I spent almost twenty hours searching for the 2.6.30.5 kernel source trying to confirm this claim, and I was unable to do so - indeed, I see some things that seem to conflict with it.

The "Mapped" account is held at global_page_state[NR_FILE_MAPPED]

. The comment next to the announcement NR_FILE_MAPPED

reads: "Pagecache pages displayed in pagetables, only modified from the process context."

  • Are not all pages referenced by meminfo "Cached" theme with file? Doesn't that mean that all of these pages should be "displayed"? I've looked at dozens of meminfo entries from several different architectures and always the "Mapped" value is much less than the "Cached" value.

  • At any given time, most of the memory is filled with executable images and shared libraries. Looking at / proc / pid / smaps I can see that they are all showing up in the VMA. Are they all memory-mapped using mmap ()? If so, why is "Mapped" so small? If they are not displayed in memory using mmap (), how are they displayed? The caller handle_mm_fault

    , which is invoked by get_user_pages

    various architecture dependent page error handlers, increments the "Mapped" counter, and they seem to do so for any VMA-bound page.

  • I looked at the mmap () functions from a bunch of drivers. Many of them are called vm_insert_page

    or remap_vmalloc_range

    to set their mappings, and these functions increase the Mapping count. But many other drivers seem to be calling remap_pfn_range

    , which as far as I can tell does not increment the "Match" counter.

+2


source to share


2 answers


  • It's the other way around. Everything in Mapped is also in Cached - Mapped is the pagecache data that has been mapped into the process's virtual memory space. Most of the pages in the cache are not rendered by processes.

  • The same page can be mapped to many different pagetables - it will only be counted in Mapped. So if you have 100 processes running, each with 2 MB mapped to /lib/i686/cmov/libc-2.7.so

    , that will only add 2 MB to Mapped anyway.



+2


source


I think the intent is that it counts the number of pages that are rendered from files. In my copy of the source (2.6.31), it increases in page_add_file_rmap

and decreases in page_remove_rmap

if the page to be deleted is not displayed anonymously. page_add_file_rmap

, for example, is called in __do_fault

, again, if the mapping is not anonymous.



So this seems to all agree with me ...

0


source







All Articles