From 8cf6b1558e1cc4fe2f4c584dd12c2a1ddaa38388 Mon Sep 17 00:00:00 2001 From: Dean Nelson Date: Tue, 26 Oct 2010 14:22:08 -0700 Subject: mm/hugetlb.c: add missing spin_lock() to hugetlb_cow() commit 44e2aa937e698ea95dd86b2a4fabd734ef2c76db upstream. Add missing spin_lock() of the page_table_lock before an error return in hugetlb_cow(). Callers of hugtelb_cow() expect it to be held upon return. Signed-off-by: Dean Nelson Cc: Mel Gorman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/hugetlb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mm/hugetlb.c') diff --git a/mm/hugetlb.c b/mm/hugetlb.c index c03273807182..8ee804bdbbab 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2380,8 +2380,11 @@ retry_avoidcopy: * When the original hugepage is shared one, it does not have * anon_vma prepared. */ - if (unlikely(anon_vma_prepare(vma))) + if (unlikely(anon_vma_prepare(vma))) { + /* Caller expects lock to be held */ + spin_lock(&mm->page_table_lock); return VM_FAULT_OOM; + } copy_huge_page(new_page, old_page, address, vma); __SetPageUptodate(new_page); -- cgit v1.2.3 From befb3a2d6721ecdc380d2047cffe24419c11fa24 Mon Sep 17 00:00:00 2001 From: Dean Nelson Date: Thu, 2 Dec 2010 14:31:12 -0800 Subject: mm/hugetlb.c: avoid double unlock_page() in hugetlb_fault() commit 1f64d69c7ad2e48e697493e45590679f7a69b7b2 upstream. Have hugetlb_fault() call unlock_page(page) only if it had previously called lock_page(page). Setting CONFIG_DEBUG_VM=y and then running the libhugetlbfs test suite, resulted in the tripping of VM_BUG_ON(!PageLocked(page)) in unlock_page() having been called by hugetlb_fault() when page == pagecache_page. This patch remedied the problem. Signed-off-by: Dean Nelson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/hugetlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mm/hugetlb.c') diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 8ee804bdbbab..2697806746d0 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2668,7 +2668,8 @@ out_page_table_lock: unlock_page(pagecache_page); put_page(pagecache_page); } - unlock_page(page); + if (page != pagecache_page) + unlock_page(page); out_mutex: mutex_unlock(&hugetlb_instantiation_mutex); -- cgit v1.2.3