On Thu, May 14, 2015 at 04:12:29PM +0200, Vlastimil Babka wrote:
On 04/23/2015 11:03 PM, Kirill A. Shutemov wrote:
With new refcounting all subpages of the compound page are not nessessary
have the same mapcount. We need to take into account mapcount of every
sub-page.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
Tested-by: Sasha Levin <sasha.levin@xxxxxxxxxx>
Acked-by: Vlastimil Babka <vbabka@xxxxxxx>
(some nitpicks below)
---
fs/proc/task_mmu.c | 43 ++++++++++++++++++++++---------------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 956b75d61809..95bc384ee3f7 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -449,9 +449,10 @@ struct mem_size_stats {
};
static void smaps_account(struct mem_size_stats *mss, struct page *page,
- unsigned long size, bool young, bool dirty)
+ bool compound, bool young, bool dirty)
{
- int mapcount;
+ int i, nr = compound ? hpage_nr_pages(page) : 1;
Why not just HPAGE_PMD_NR instead of hpage_nr_pages(page)?
Okay, makes sense. Compiler is smart enough to optimize away HPAGE_PMD_NR
for THP=n. (HPAGE_PMD_NR is BUILD_BUG() for THP=n)