Re: [patch v2 -mm] mm, hugetlb: schedule when potentially allocating many hugepages

2017-07-05 Thread Anshuman Khandual
On 06/10/2017 04:06 AM, David Rientjes wrote:
> A few hugetlb allocators loop while calling the page allocator and can
> potentially prevent rescheduling if the page allocator slowpath is not
> utilized.
> 
> Conditionally schedule when large numbers of hugepages can be allocated.
> 
> Signed-off-by: David Rientjes 

Fixes a task which was getting hung while writing like 1
hugepages (16MB on POWER8) into /proc/sys/vm/nr_hugepages.

Tested-by: Anshuman Khandual 



Re: [patch v2 -mm] mm, hugetlb: schedule when potentially allocating many hugepages

2017-06-09 Thread Mike Kravetz
On 06/09/2017 03:36 PM, David Rientjes wrote:
> A few hugetlb allocators loop while calling the page allocator and can
> potentially prevent rescheduling if the page allocator slowpath is not
> utilized.
> 
> Conditionally schedule when large numbers of hugepages can be allocated.
> 
> Signed-off-by: David Rientjes 

Thanks for doing this.

Reviewed-by: Mike Kravetz 

-- 
Mike Kravetz

> ---
>  Based on -mm only to prevent merge conflicts with
>  "mm/hugetlb.c: warn the user when issues arise on boot due to hugepages"
> 
>  v2: removed redundant cond_resched() per Mike
> 
>  mm/hugetlb.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1754,6 +1754,7 @@ static int gather_surplus_pages(struct hstate *h, int 
> delta)
>   break;
>   }
>   list_add(&page->lru, &surplus_list);
> + cond_resched();
>   }
>   allocated += i;
>  
> @@ -,6 +2223,7 @@ static void __init hugetlb_hstate_alloc_pages(struct 
> hstate *h)
>   } else if (!alloc_fresh_huge_page(h,
>&node_states[N_MEMORY]))
>   break;
> + cond_resched();
>   }
>   if (i < h->max_huge_pages) {
>   char buf[32];
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majord...@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: mailto:"d...@kvack.org";> em...@kvack.org 
> 


[patch v2 -mm] mm, hugetlb: schedule when potentially allocating many hugepages

2017-06-09 Thread David Rientjes
A few hugetlb allocators loop while calling the page allocator and can
potentially prevent rescheduling if the page allocator slowpath is not
utilized.

Conditionally schedule when large numbers of hugepages can be allocated.

Signed-off-by: David Rientjes 
---
 Based on -mm only to prevent merge conflicts with
 "mm/hugetlb.c: warn the user when issues arise on boot due to hugepages"

 v2: removed redundant cond_resched() per Mike

 mm/hugetlb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1754,6 +1754,7 @@ static int gather_surplus_pages(struct hstate *h, int 
delta)
break;
}
list_add(&page->lru, &surplus_list);
+   cond_resched();
}
allocated += i;
 
@@ -,6 +2223,7 @@ static void __init hugetlb_hstate_alloc_pages(struct 
hstate *h)
} else if (!alloc_fresh_huge_page(h,
 &node_states[N_MEMORY]))
break;
+   cond_resched();
}
if (i < h->max_huge_pages) {
char buf[32];