linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Paul Cassella <cassella@cray.com>,
	Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
	linux-mm@kvack.org
Subject: Re: hugetlb: reservation race leading to under provisioning
Date: Mon, 9 Jan 2017 11:25:20 +0100	[thread overview]
Message-ID: <20170109102520.GG7495@dhcp22.suse.cz> (raw)
In-Reply-To: <f6f7338c-2afe-885b-4c72-44b7daba07d8@oracle.com>

On Sun 08-01-17 11:08:30, Mike Kravetz wrote:
[...]
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 3edb759..221abdc 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1783,12 +1783,9 @@ static void return_unused_surplus_pages(struct hstate *h,
>  {
>  	unsigned long nr_pages;
>  
> -	/* Uncommit the reservation */
> -	h->resv_huge_pages -= unused_resv_pages;
> -
>  	/* Cannot return gigantic pages currently */
>  	if (hstate_is_gigantic(h))
> -		return;
> +		goto out;
>  
>  	nr_pages = min(unused_resv_pages, h->surplus_huge_pages);
>  
> @@ -1801,10 +1798,16 @@ static void return_unused_surplus_pages(struct hstate *h,
>  	 * on-line nodes with memory and will handle the hstate accounting.
>  	 */
>  	while (nr_pages--) {
> +		h->resv_huge_pages--;
> +		unused_resv_pages--;
>  		if (!free_pool_huge_page(h, &node_states[N_MEMORY], 1))
> -			break;
> +			goto out;
>  		cond_resched_lock(&hugetlb_lock);
>  	}
> +
> +out:
> +	/* Fully uncommit the reservation */
> +	h->resv_huge_pages -= unused_resv_pages;
>  }

OK, this would handle the case I was wondering about. It really deserves
a big fat comment explaining when this can happen.

Other than that this looks OK and safe enough for the stable after
second look into the code.

Thanks!
-- 
Michal Hocko
SUSE Labs

--
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>

  reply	other threads:[~2017-01-09 10:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-05 15:15 Michal Hocko
2017-01-06  0:48 ` Mike Kravetz
2017-01-06  8:58   ` Michal Hocko
2017-01-06 15:01     ` Michal Hocko
2017-01-06 21:57     ` Paul Cassella
2017-01-08 19:08       ` Mike Kravetz
2017-01-09 10:25         ` Michal Hocko [this message]
2017-01-09  8:58       ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170109102520.GG7495@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=cassella@cray.com \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=n-horiguchi@ah.jp.nec.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox