From: Andrew Morton - Make the mutex local to the function which uses it. - The declaration was in an odd place anyway? Cc: David Gibson Cc: William Lee Irwin III Signed-off-by: Andrew Morton --- mm/hugetlb.c | 22 ++++++++++------------ 1 files changed, 10 insertions(+), 12 deletions(-) diff -puN mm/hugetlb.c~hugepage-serialize-hugepage-allocation-and-instantiation-tidy mm/hugetlb.c --- devel/mm/hugetlb.c~hugepage-serialize-hugepage-allocation-and-instantiation-tidy 2006-02-27 22:26:11.000000000 -0800 +++ devel-akpm/mm/hugetlb.c 2006-02-27 22:26:46.000000000 -0800 @@ -27,6 +27,10 @@ unsigned long max_huge_pages; static struct list_head hugepage_freelists[MAX_NUMNODES]; static unsigned int nr_huge_pages_node[MAX_NUMNODES]; static unsigned int free_huge_pages_node[MAX_NUMNODES]; +/* + * Protects updates to hugepage_freelists, nr_huge_pages, and free_huge_pages + */ +static DEFINE_SPINLOCK(hugetlb_lock); static void clear_huge_page(struct page *page, unsigned long addr) { @@ -51,18 +55,6 @@ static void copy_huge_page(struct page * } } -/* - * Protects updates to hugepage_freelists, nr_huge_pages, and free_huge_pages - */ -static DEFINE_SPINLOCK(hugetlb_lock); - -/* - * Serializes hugepage allocation and instantiation, so that we don't - * get spurious allocation failures if two CPUs race to instantiate - * the same page in the page cache. - */ -static DEFINE_MUTEX(hugetlb_instantiation_mutex); - static void enqueue_huge_page(struct page *page) { int nid = page_to_nid(page); @@ -516,11 +508,17 @@ int hugetlb_fault(struct mm_struct *mm, pte_t *ptep; pte_t entry; int ret; + static DEFINE_MUTEX(hugetlb_instantiation_mutex); ptep = huge_pte_alloc(mm, address); if (!ptep) return VM_FAULT_OOM; + /* + * Serialize hugepage allocation and instantiation, so that we don't + * 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)) { _