Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1640771 > unrolled thread

Re: [PATCH V2] mm/madvise: Enable (soft|hard) offline of HugeTLB pages at PGD level

Started byAndrew Morton <akpm@linux-foundation.org>
First post2017-05-12 23:40 +0200
Last post2017-05-14 06:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH V2] mm/madvise: Enable (soft|hard) offline of HugeTLB  pages at PGD level Andrew Morton <akpm@linux-foundation.org> - 2017-05-12 23:40 +0200
    Re: [PATCH V2] mm/madvise: Enable (soft|hard) offline of HugeTLB  pages at PGD level Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-05-14 06:20 +0200

#1640771 — Re: [PATCH V2] mm/madvise: Enable (soft|hard) offline of HugeTLB pages at PGD level

FromAndrew Morton <akpm@linux-foundation.org>
Date2017-05-12 23:40 +0200
SubjectRe: [PATCH V2] mm/madvise: Enable (soft|hard) offline of HugeTLB pages at PGD level
Message-ID<tGqs2-2k3-23@gated-at.bofh.it>
On Wed, 26 Apr 2017 09:27:31 +0530 Anshuman Khandual <khandual@linux.vnet.ibm.com> wrote:

> Though migrating gigantic HugeTLB pages does not sound much like real
> world use case, they can be affected by memory errors. Hence migration
> at the PGD level HugeTLB pages should be supported just to enable soft
> and hard offline use cases.
> 
> While allocating the new gigantic HugeTLB page, it should not matter
> whether new page comes from the same node or not. There would be very
> few gigantic pages on the system afterall, we should not be bothered
> about node locality when trying to save a big page from crashing.
> 
> This introduces a new HugeTLB allocator called alloc_huge_page_nonid()
> which will scan over all online nodes on the system and allocate a
> single HugeTLB page.
> 
> ...
>
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1669,6 +1669,23 @@ struct page *__alloc_buddy_huge_page_with_mpol(struct hstate *h,
>  	return __alloc_buddy_huge_page(h, vma, addr, NUMA_NO_NODE);
>  }
>  
> +struct page *alloc_huge_page_nonid(struct hstate *h)
> +{
> +	struct page *page = NULL;
> +	int nid = 0;
> +
> +	spin_lock(&hugetlb_lock);
> +	if (h->free_huge_pages - h->resv_huge_pages > 0) {
> +		for_each_online_node(nid) {
> +			page = dequeue_huge_page_node(h, nid);
> +			if (page)
> +				break;
> +		}
> +	}
> +	spin_unlock(&hugetlb_lock);
> +	return page;
> +}
> +
>  /*
>   * This allocation function is useful in the context where vma is irrelevant.
>   * E.g. soft-offlining uses this function because it only cares physical
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index fe64d7729a8e..d4f5710cf3f7 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -1481,11 +1481,15 @@ EXPORT_SYMBOL(unpoison_memory);
>  static struct page *new_page(struct page *p, unsigned long private, int **x)
>  {
>  	int nid = page_to_nid(p);
> -	if (PageHuge(p))
> +	if (PageHuge(p)) {
> +		if (hstate_is_gigantic(page_hstate(compound_head(p))))
> +			return alloc_huge_page_nonid(page_hstate(compound_head(p)));
> +
>  		return alloc_huge_page_node(page_hstate(compound_head(p)),
>  						   nid);
> -	else
> +	} else {
>  		return __alloc_pages_node(nid, GFP_HIGHUSER_MOVABLE, 0);
> +	}
>  }

Rather than adding alloc_huge_page_nonid(), would it be neater to teach
alloc_huge_page_node() (actually dequeue_huge_page_node()) to understand
nid==NUMA_NO_NODE?

[toc] | [next] | [standalone]


#1641054

FromAnshuman Khandual <khandual@linux.vnet.ibm.com>
Date2017-05-14 06:20 +0200
Message-ID<tGTaG-56j-3@gated-at.bofh.it>
In reply to#1640771
On 05/13/2017 03:05 AM, Andrew Morton wrote:
> On Wed, 26 Apr 2017 09:27:31 +0530 Anshuman Khandual <khandual@linux.vnet.ibm.com> wrote:
> 
>> Though migrating gigantic HugeTLB pages does not sound much like real
>> world use case, they can be affected by memory errors. Hence migration
>> at the PGD level HugeTLB pages should be supported just to enable soft
>> and hard offline use cases.
>>
>> While allocating the new gigantic HugeTLB page, it should not matter
>> whether new page comes from the same node or not. There would be very
>> few gigantic pages on the system afterall, we should not be bothered
>> about node locality when trying to save a big page from crashing.
>>
>> This introduces a new HugeTLB allocator called alloc_huge_page_nonid()
>> which will scan over all online nodes on the system and allocate a
>> single HugeTLB page.
>>
>> ...
>>
>> --- a/mm/hugetlb.c
>> +++ b/mm/hugetlb.c
>> @@ -1669,6 +1669,23 @@ struct page *__alloc_buddy_huge_page_with_mpol(struct hstate *h,
>>  	return __alloc_buddy_huge_page(h, vma, addr, NUMA_NO_NODE);
>>  }
>>  
>> +struct page *alloc_huge_page_nonid(struct hstate *h)
>> +{
>> +	struct page *page = NULL;
>> +	int nid = 0;
>> +
>> +	spin_lock(&hugetlb_lock);
>> +	if (h->free_huge_pages - h->resv_huge_pages > 0) {
>> +		for_each_online_node(nid) {
>> +			page = dequeue_huge_page_node(h, nid);
>> +			if (page)
>> +				break;
>> +		}
>> +	}
>> +	spin_unlock(&hugetlb_lock);
>> +	return page;
>> +}
>> +
>>  /*
>>   * This allocation function is useful in the context where vma is irrelevant.
>>   * E.g. soft-offlining uses this function because it only cares physical
>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>> index fe64d7729a8e..d4f5710cf3f7 100644
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>> @@ -1481,11 +1481,15 @@ EXPORT_SYMBOL(unpoison_memory);
>>  static struct page *new_page(struct page *p, unsigned long private, int **x)
>>  {
>>  	int nid = page_to_nid(p);
>> -	if (PageHuge(p))
>> +	if (PageHuge(p)) {
>> +		if (hstate_is_gigantic(page_hstate(compound_head(p))))
>> +			return alloc_huge_page_nonid(page_hstate(compound_head(p)));
>> +
>>  		return alloc_huge_page_node(page_hstate(compound_head(p)),
>>  						   nid);
>> -	else
>> +	} else {
>>  		return __alloc_pages_node(nid, GFP_HIGHUSER_MOVABLE, 0);
>> +	}
>>  }
> 
> Rather than adding alloc_huge_page_nonid(), would it be neater to teach
> alloc_huge_page_node() (actually dequeue_huge_page_node()) to understand
> nid==NUMA_NO_NODE?

Sure, will change dequeue_huge_page_node() to accommodate NUMA_NO_NODE and
let soft offline call with NUMA_NO_NODE in case of gigantic huge pages.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web