linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch] mm, thp: count thp_fault_fallback anytime thp fault fails
@ 2013-08-21  0:17 David Rientjes
  2013-08-21 14:28 ` Kirill A. Shutemov
  0 siblings, 1 reply; 5+ messages in thread
From: David Rientjes @ 2013-08-21  0:17 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Kirill A. Shutemov, Mel Gorman, Andrea Arcangeli, linux-kernel, linux-mm

Currently, thp_fault_fallback in vmstat only gets incremented if a
hugepage allocation fails.  If current's memcg hits its limit or the page
fault handler returns an error, it is incorrectly accounted as a
successful thp_fault_alloc.

Count thp_fault_fallback anytime the page fault handler falls back to
using regular pages and only count thp_fault_alloc when a hugepage has
actually been faulted.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 mm/huge_memory.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -801,7 +801,6 @@ int do_huge_pmd_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
 			zero_page = get_huge_zero_page();
 			if (unlikely(!zero_page)) {
 				pte_free(mm, pgtable);
-				count_vm_event(THP_FAULT_FALLBACK);
 				goto out;
 			}
 			spin_lock(&mm->page_table_lock);
@@ -816,11 +815,8 @@ int do_huge_pmd_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
 		}
 		page = alloc_hugepage_vma(transparent_hugepage_defrag(vma),
 					  vma, haddr, numa_node_id(), 0);
-		if (unlikely(!page)) {
-			count_vm_event(THP_FAULT_FALLBACK);
+		if (unlikely(!page))
 			goto out;
-		}
-		count_vm_event(THP_FAULT_ALLOC);
 		if (unlikely(mem_cgroup_newpage_charge(page, mm, GFP_KERNEL))) {
 			put_page(page);
 			goto out;
@@ -832,9 +828,11 @@ int do_huge_pmd_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
 			goto out;
 		}
 
+		count_vm_event(THP_FAULT_ALLOC);
 		return 0;
 	}
 out:
+	count_vm_event(THP_FAULT_FALLBACK);
 	/*
 	 * Use __pte_alloc instead of pte_alloc_map, because we can't
 	 * run pte_offset_map on the pmd, if an huge pmd could

--
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] 5+ messages in thread

* RE: [patch] mm, thp: count thp_fault_fallback anytime thp fault fails
  2013-08-21  0:17 [patch] mm, thp: count thp_fault_fallback anytime thp fault fails David Rientjes
@ 2013-08-21 14:28 ` Kirill A. Shutemov
  2013-08-21 22:16   ` David Rientjes
  2013-08-21 22:17   ` [patch v2] " David Rientjes
  0 siblings, 2 replies; 5+ messages in thread
From: Kirill A. Shutemov @ 2013-08-21 14:28 UTC (permalink / raw)
  To: David Rientjes
  Cc: Andrew Morton, Kirill A. Shutemov, Mel Gorman, Andrea Arcangeli,
	linux-kernel, linux-mm

David Rientjes wrote:
> Currently, thp_fault_fallback in vmstat only gets incremented if a
> hugepage allocation fails.  If current's memcg hits its limit or the page
> fault handler returns an error, it is incorrectly accounted as a
> successful thp_fault_alloc.
> 
> Count thp_fault_fallback anytime the page fault handler falls back to
> using regular pages and only count thp_fault_alloc when a hugepage has
> actually been faulted.
> 
> Signed-off-by: David Rientjes <rientjes@google.com>

It's probably a good idea, but please make the behaviour consistent in
do_huge_pmd_wp_page() and collapse path, otherwise it doesn't make sense.

And please make the patch against mm tree: do_huge_pmd_anonymous_page()
was modified recently.

> ---
>  mm/huge_memory.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -801,7 +801,6 @@ int do_huge_pmd_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
>  			zero_page = get_huge_zero_page();
>  			if (unlikely(!zero_page)) {
>  				pte_free(mm, pgtable);
> -				count_vm_event(THP_FAULT_FALLBACK);
>  				goto out;
>  			}
>  			spin_lock(&mm->page_table_lock);
> @@ -816,11 +815,8 @@ int do_huge_pmd_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
>  		}
>  		page = alloc_hugepage_vma(transparent_hugepage_defrag(vma),
>  					  vma, haddr, numa_node_id(), 0);
> -		if (unlikely(!page)) {
> -			count_vm_event(THP_FAULT_FALLBACK);
> +		if (unlikely(!page))
>  			goto out;
> -		}
> -		count_vm_event(THP_FAULT_ALLOC);
>  		if (unlikely(mem_cgroup_newpage_charge(page, mm, GFP_KERNEL))) {
>  			put_page(page);
>  			goto out;
> @@ -832,9 +828,11 @@ int do_huge_pmd_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
>  			goto out;
>  		}
>  
> +		count_vm_event(THP_FAULT_ALLOC);
>  		return 0;
>  	}
>  out:
> +	count_vm_event(THP_FAULT_FALLBACK);
>  	/*
>  	 * Use __pte_alloc instead of pte_alloc_map, because we can't
>  	 * run pte_offset_map on the pmd, if an huge pmd could

-- 
 Kirill A. Shutemov

--
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] 5+ messages in thread

* RE: [patch] mm, thp: count thp_fault_fallback anytime thp fault fails
  2013-08-21 14:28 ` Kirill A. Shutemov
@ 2013-08-21 22:16   ` David Rientjes
  2013-08-22 11:11     ` Kirill A. Shutemov
  2013-08-21 22:17   ` [patch v2] " David Rientjes
  1 sibling, 1 reply; 5+ messages in thread
From: David Rientjes @ 2013-08-21 22:16 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Andrew Morton, Mel Gorman, Andrea Arcangeli, linux-kernel, linux-mm

On Wed, 21 Aug 2013, Kirill A. Shutemov wrote:

> David Rientjes wrote:
> > Currently, thp_fault_fallback in vmstat only gets incremented if a
> > hugepage allocation fails.  If current's memcg hits its limit or the page
> > fault handler returns an error, it is incorrectly accounted as a
> > successful thp_fault_alloc.
> > 
> > Count thp_fault_fallback anytime the page fault handler falls back to
> > using regular pages and only count thp_fault_alloc when a hugepage has
> > actually been faulted.
> > 
> > Signed-off-by: David Rientjes <rientjes@google.com>
> 
> It's probably a good idea, but please make the behaviour consistent in
> do_huge_pmd_wp_page() and collapse path, otherwise it doesn't make sense.
> 

The collapse path has no fallback, the allocation either succeeds or it 
fails.

--
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] 5+ messages in thread

* [patch v2] mm, thp: count thp_fault_fallback anytime thp fault fails
  2013-08-21 14:28 ` Kirill A. Shutemov
  2013-08-21 22:16   ` David Rientjes
@ 2013-08-21 22:17   ` David Rientjes
  1 sibling, 0 replies; 5+ messages in thread
From: David Rientjes @ 2013-08-21 22:17 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Mel Gorman, Andrea Arcangeli, Kirill A. Shutemov, linux-kernel, linux-mm

Currently, thp_fault_fallback in vmstat only gets incremented if a
hugepage allocation fails.  If current's memcg hits its limit or the page
fault handler returns an error, it is incorrectly accounted as a
successful thp_fault_alloc.

Count thp_fault_fallback anytime the page fault handler falls back to
using regular pages and only count thp_fault_alloc when a hugepage has
actually been faulted.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 mm/huge_memory.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -825,17 +825,19 @@ int do_huge_pmd_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
 		count_vm_event(THP_FAULT_FALLBACK);
 		return VM_FAULT_FALLBACK;
 	}
-	count_vm_event(THP_FAULT_ALLOC);
 	if (unlikely(mem_cgroup_newpage_charge(page, mm, GFP_KERNEL))) {
 		put_page(page);
+		count_vm_event(THP_FAULT_FALLBACK);
 		return VM_FAULT_FALLBACK;
 	}
 	if (unlikely(__do_huge_pmd_anonymous_page(mm, vma, haddr, pmd, page))) {
 		mem_cgroup_uncharge_page(page);
 		put_page(page);
+		count_vm_event(THP_FAULT_FALLBACK);
 		return VM_FAULT_FALLBACK;
 	}
 
+	count_vm_event(THP_FAULT_ALLOC);
 	return 0;
 }
 
@@ -1148,7 +1150,6 @@ alloc:
 		new_page = NULL;
 
 	if (unlikely(!new_page)) {
-		count_vm_event(THP_FAULT_FALLBACK);
 		if (is_huge_zero_pmd(orig_pmd)) {
 			ret = do_huge_pmd_wp_zero_page_fallback(mm, vma,
 					address, pmd, orig_pmd, haddr);
@@ -1159,9 +1160,9 @@ alloc:
 				split_huge_page(page);
 			put_page(page);
 		}
+		count_vm_event(THP_FAULT_FALLBACK);
 		goto out;
 	}
-	count_vm_event(THP_FAULT_ALLOC);
 
 	if (unlikely(mem_cgroup_newpage_charge(new_page, mm, GFP_KERNEL))) {
 		put_page(new_page);
@@ -1169,10 +1170,13 @@ alloc:
 			split_huge_page(page);
 			put_page(page);
 		}
+		count_vm_event(THP_FAULT_FALLBACK);
 		ret |= VM_FAULT_OOM;
 		goto out;
 	}
 
+	count_vm_event(THP_FAULT_ALLOC);
+
 	if (is_huge_zero_pmd(orig_pmd))
 		clear_huge_page(new_page, haddr, HPAGE_PMD_NR);
 	else

--
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] 5+ messages in thread

* RE: [patch] mm, thp: count thp_fault_fallback anytime thp fault fails
  2013-08-21 22:16   ` David Rientjes
@ 2013-08-22 11:11     ` Kirill A. Shutemov
  0 siblings, 0 replies; 5+ messages in thread
From: Kirill A. Shutemov @ 2013-08-22 11:11 UTC (permalink / raw)
  To: David Rientjes
  Cc: Kirill A. Shutemov, Andrew Morton, Mel Gorman, Andrea Arcangeli,
	linux-kernel, linux-mm

David Rientjes wrote:
> On Wed, 21 Aug 2013, Kirill A. Shutemov wrote:
> 
> > David Rientjes wrote:
> > > Currently, thp_fault_fallback in vmstat only gets incremented if a
> > > hugepage allocation fails.  If current's memcg hits its limit or the page
> > > fault handler returns an error, it is incorrectly accounted as a
> > > successful thp_fault_alloc.
> > > 
> > > Count thp_fault_fallback anytime the page fault handler falls back to
> > > using regular pages and only count thp_fault_alloc when a hugepage has
> > > actually been faulted.
> > > 
> > > Signed-off-by: David Rientjes <rientjes@google.com>
> > 
> > It's probably a good idea, but please make the behaviour consistent in
> > do_huge_pmd_wp_page() and collapse path, otherwise it doesn't make sense.
> > 
> 
> The collapse path has no fallback, the allocation either succeeds or it 
> fails.

THP_COLLAPSE_ALLOC should be counted after successful memcg charge or even
only after successful collapse.

-- 
 Kirill A. Shutemov

--
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] 5+ messages in thread

end of thread, other threads:[~2013-08-22 11:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-21  0:17 [patch] mm, thp: count thp_fault_fallback anytime thp fault fails David Rientjes
2013-08-21 14:28 ` Kirill A. Shutemov
2013-08-21 22:16   ` David Rientjes
2013-08-22 11:11     ` Kirill A. Shutemov
2013-08-21 22:17   ` [patch v2] " David Rientjes

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