From: Andrew Morton <akpm@linux-foundation.org>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
Davidlohr Bueso <dave@stgolabs.net>,
David Rientjes <rientjes@google.com>,
Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [PATCH 2/2] mm/hugetlb: handle races in alloc_huge_page and hugetlb_reserve_pages
Date: Thu, 21 May 2015 16:35:53 -0700 [thread overview]
Message-ID: <20150521163553.987ac88a9541036a4cc9bc0e@linux-foundation.org> (raw)
In-Reply-To: <1431971349-6668-3-git-send-email-mike.kravetz@oracle.com>
On Mon, 18 May 2015 10:49:09 -0700 Mike Kravetz <mike.kravetz@oracle.com> wrote:
> alloc_huge_page and hugetlb_reserve_pages use region_chg to
> calculate the number of pages which will be added to the reserve
> map. Subpool and global reserve counts are adjusted based on
> the output of region_chg. Before the pages are actually added
> to the reserve map, these routines could race and add fewer
> pages than expected. If this happens, the subpool and global
> reserve counts are not correct.
>
> Compare the number of pages actually added (region_add) to those
> expected to added (region_chg). If fewer pages are actually added,
> this indicates a race and adjust counters accordingly.
>
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1374,13 +1374,16 @@ static long vma_commit_reservation(struct hstate *h,
> return 0;
> }
>
> +/* Forward declaration */
> +static int hugetlb_acct_memory(struct hstate *h, long delta);
> +
Its best to put forward declarations at top-of-file. Otherwise we can
end up with multiple forward declarations if someone later needs the
symbol at an earlier site in the file.
Had you done that you might have noticed that hugetlb_acct_memory() was
already declared ;)
--- a/mm/hugetlb.c~mm-hugetlb-handle-races-in-alloc_huge_page-and-hugetlb_reserve_pages-fix
+++ a/mm/hugetlb.c
@@ -1475,9 +1475,6 @@ static long vma_commit_reservation(struc
return 0;
}
-/* Forward declaration */
-static int hugetlb_acct_memory(struct hstate *h, long delta);
-
static struct page *alloc_huge_page(struct vm_area_struct *vma,
unsigned long addr, int avoid_reserve)
{
_
--
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>
prev parent reply other threads:[~2015-05-21 23:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 17:49 [PATCH 0/2] alloc_huge_page/hugetlb_reserve_pages race Mike Kravetz
2015-05-18 17:49 ` [PATCH 1/2] mm/hugetlb: compute/return the number of regions added by region_add() Mike Kravetz
2015-05-21 23:30 ` Andrew Morton
2015-05-21 23:43 ` Mike Kravetz
2015-05-18 17:49 ` [PATCH 2/2] mm/hugetlb: handle races in alloc_huge_page and hugetlb_reserve_pages Mike Kravetz
2015-05-21 23:35 ` Andrew Morton [this message]
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=20150521163553.987ac88a9541036a4cc9bc0e@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=dave@stgolabs.net \
--cc=lcapitulino@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=rientjes@google.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