Re: [PATCH v4 3/3] mm/hugetlb: improve locking in dissolve_free_huge_pages()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon 26-09-16 19:28:11, Gerald Schaefer wrote:
> For every pfn aligned to minimum_order, dissolve_free_huge_pages() will
> call dissolve_free_huge_page() which takes the hugetlb spinlock, even if
> the page is not huge at all or a hugepage that is in-use.
> 
> Improve this by doing the PageHuge() and page_count() checks already in
> dissolve_free_huge_pages() before calling dissolve_free_huge_page(). In
> dissolve_free_huge_page(), when holding the spinlock, those checks need
> to be revalidated.
> 
> Signed-off-by: Gerald Schaefer <gerald.schaefer@xxxxxxxxxx>

Acked-by: Michal Hocko <mhocko@xxxxxxxx>

> ---
>  mm/hugetlb.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 91ae1f5..770d83e 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1476,14 +1476,20 @@ static int dissolve_free_huge_page(struct page *page)
>  int dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn)
>  {
>  	unsigned long pfn;
> +	struct page *page;
>  	int rc = 0;
>  
>  	if (!hugepages_supported())
>  		return rc;
>  
> -	for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << minimum_order)
> -		if (rc = dissolve_free_huge_page(pfn_to_page(pfn)))
> -			break;
> +	for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << minimum_order) {
> +		page = pfn_to_page(pfn);
> +		if (PageHuge(page) && !page_count(page)) {
> +			rc = dissolve_free_huge_page(page);
> +			if (rc)
> +				break;
> +		}
> +	}
>  
>  	return rc;
>  }
> -- 
> 2.8.4

-- 
Michal Hocko
SUSE Labs

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



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]