linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC V2] mm:add zero_page _mapcount when mapped into user space
@ 2014-12-02  9:27 Wang, Yalin
  2014-12-02 11:30 ` Kirill A. Shutemov
  0 siblings, 1 reply; 6+ messages in thread
From: Wang, Yalin @ 2014-12-02  9:27 UTC (permalink / raw)
  To: 'linux-kernel@vger.kernel.org',
	'linux-mm@kvack.org',
	'linux-arm-kernel@lists.infradead.org'

This patch add/dec zero_page's _mapcount to make sure
the mapcount is correct for zero_page,
so that when read from /proc/kpagecount, zero_page's
mapcount is also correct, userspace process like procrank can
calculate PSS correctly.

Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
---
 mm/memory.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/memory.c b/mm/memory.c
index 3e50383..7215423 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2198,6 +2198,7 @@ gotten:
 		new_page = alloc_zeroed_user_highpage_movable(vma, address);
 		if (!new_page)
 			goto oom;
+		atomic_dec(&pfn_to_page(pte_pfn(orig_pte))->_mapcount);
 	} else {
 		new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address);
 		if (!new_page)
@@ -2647,6 +2648,7 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
 		page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
 		if (!pte_none(*page_table))
 			goto unlock;
+		atomic_inc(&pfn_to_page(my_zero_pfn(address))->_mapcount);
 		goto setpte;
 	}
 
-- 
2.1.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-12-05  8:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-02  9:27 [RFC V2] mm:add zero_page _mapcount when mapped into user space Wang, Yalin
2014-12-02 11:30 ` Kirill A. Shutemov
2014-12-04  6:10   ` Wang, Yalin
2014-12-04 12:28     ` Kirill A. Shutemov
2014-12-05  6:39       ` Konstantin Khlebnikov
2014-12-05  8:08         ` Wang, Yalin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox