Commit 73960360 authored by Andrew Morton's avatar Andrew Morton Committed by Christoph Hellwig

[PATCH] add /proc/meminfo:Mapped

The patch adds a "Mapped" field to /proc/meminfo - tha amount of memory
which is mapped into pagetables.

This is a useful statistic to monitor when testing and observing the
vitual memory system.
parent 05d9bac3
...@@ -178,6 +178,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off, ...@@ -178,6 +178,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
"SwapFree: %8lu kB\n" "SwapFree: %8lu kB\n"
"Dirty: %8lu kB\n" "Dirty: %8lu kB\n"
"Writeback: %8lu kB\n" "Writeback: %8lu kB\n"
"Mapped: %8lu kB\n"
"Committed_AS: %8u kB\n" "Committed_AS: %8u kB\n"
"PageTables: %8lu kB\n" "PageTables: %8lu kB\n"
"ReverseMaps: %8lu\n" "ReverseMaps: %8lu\n"
...@@ -199,6 +200,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off, ...@@ -199,6 +200,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
K(i.freeswap), K(i.freeswap),
K(ps.nr_dirty), K(ps.nr_dirty),
K(ps.nr_writeback), K(ps.nr_writeback),
K(ps.nr_mapped),
K(committed), K(committed),
K(ps.nr_page_table_pages), K(ps.nr_page_table_pages),
ps.nr_reverse_maps, ps.nr_reverse_maps,
......
...@@ -78,6 +78,7 @@ extern struct page_state { ...@@ -78,6 +78,7 @@ extern struct page_state {
unsigned long nr_pagecache; unsigned long nr_pagecache;
unsigned long nr_page_table_pages; unsigned long nr_page_table_pages;
unsigned long nr_reverse_maps; unsigned long nr_reverse_maps;
unsigned long nr_mapped;
} ____cacheline_aligned_in_smp page_states[NR_CPUS]; } ____cacheline_aligned_in_smp page_states[NR_CPUS];
extern void get_page_state(struct page_state *ret); extern void get_page_state(struct page_state *ret);
......
...@@ -562,6 +562,7 @@ void get_page_state(struct page_state *ret) ...@@ -562,6 +562,7 @@ void get_page_state(struct page_state *ret)
ret->nr_pagecache += ps->nr_pagecache; ret->nr_pagecache += ps->nr_pagecache;
ret->nr_page_table_pages += ps->nr_page_table_pages; ret->nr_page_table_pages += ps->nr_page_table_pages;
ret->nr_reverse_maps += ps->nr_reverse_maps; ret->nr_reverse_maps += ps->nr_reverse_maps;
ret->nr_mapped += ps->nr_mapped;
} }
} }
......
...@@ -214,6 +214,7 @@ void page_add_rmap(struct page * page, pte_t * ptep) ...@@ -214,6 +214,7 @@ void page_add_rmap(struct page * page, pte_t * ptep)
if (page->pte.direct == 0) { if (page->pte.direct == 0) {
page->pte.direct = pte_paddr; page->pte.direct = pte_paddr;
SetPageDirect(page); SetPageDirect(page);
inc_page_state(nr_mapped);
goto out; goto out;
} }
...@@ -336,6 +337,8 @@ void page_remove_rmap(struct page * page, pte_t * ptep) ...@@ -336,6 +337,8 @@ void page_remove_rmap(struct page * page, pte_t * ptep)
out: out:
pte_chain_unlock(page); pte_chain_unlock(page);
if (!page_mapped(page))
dec_page_state(nr_mapped);
return; return;
} }
...@@ -501,6 +504,8 @@ int try_to_unmap(struct page * page) ...@@ -501,6 +504,8 @@ int try_to_unmap(struct page * page)
} }
} }
out: out:
if (!page_mapped(page))
dec_page_state(nr_mapped);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment