Index: linux-2.6/mm/hugetlb.c =================================================================== --- linux-2.6.orig/mm/hugetlb.c 2006-12-04 10:17:35.000000000 -0800 +++ linux-2.6/mm/hugetlb.c 2006-12-04 10:21:58.000000000 -0800 @@ -466,6 +466,9 @@ struct page *page; struct address_space *mapping; pte_t new_pte; + static DEFINE_MUTEX(hugetlb_instantiation_mutex); + + mutex_lock(&hugetlb_instantiation_mutex); mapping = vma->vm_file->f_mapping; idx = ((address - vma->vm_start) >> HPAGE_SHIFT) @@ -528,6 +531,7 @@ spin_unlock(&mm->page_table_lock); unlock_page(page); out: + mutex_unlock(&hugetlb_instantiation_mutex); return ret; backout: @@ -544,7 +548,6 @@ pte_t *ptep; pte_t entry; int ret; - static DEFINE_MUTEX(hugetlb_instantiation_mutex); ptep = huge_pte_alloc(mm, address); if (!ptep) @@ -555,11 +558,9 @@ * get spurious allocation failures if two CPUs race to instantiate * the same page in the page cache. */ - mutex_lock(&hugetlb_instantiation_mutex); entry = *ptep; if (pte_none(entry)) { ret = hugetlb_no_page(mm, vma, address, ptep, write_access); - mutex_unlock(&hugetlb_instantiation_mutex); return ret; } @@ -571,7 +572,6 @@ if (write_access && !pte_write(entry)) ret = hugetlb_cow(mm, vma, address, ptep, entry); spin_unlock(&mm->page_table_lock); - mutex_unlock(&hugetlb_instantiation_mutex); return ret; }