Re: [patch] hugetlb strict commit accounting - v3

Adam Litke
2006-03-20T15:35:34Z

On Thu, 2006-03-09 at 19:14 -0800, Chen, Kenneth W wrote:
> @@ -98,6 +98,12 @@ struct page *alloc_huge_page(struct vm_a
> int i;
>
> spin_lock(&hugetlb_lock);
> + if (vma->vm_flags & VM_MAYSHARE)
> + resv_huge_pages--;
> + else if (free_huge_pages <= resv_huge_pages) {
> + spin_unlock(&hugetlb_lock);
> + return NULL;
> + }
> page = dequeue_huge_page(vma, addr);
> if (!page) {
> spin_unlock(&hugetlb_lock);

Unfortunately this will break down when two or more threads race to
allocate the same page. You end up with a double-decrement of
resv_huge_pages even though only one thread will win the race.

--
Adam Litke - (agl at us.ibm.com)
IBM Linux Technology Center