Skip to contentSkip to conversation

page fault patches: fix highpte in do_anon_page

PATCH New Hugh Dickins 1 participant 1 message Jul 30, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 page fault patches: fix highpte in do_anon_page

Fix "scheduling while atomic" messages below do_anonymous_page when CONFIG_HIGHPTE=y: must unmap and remap the page_table around page allocation. And let's shift the usual pte_unmap to the minor_fault exit.

---

Please don't interpret this fix as my approving the do_anonymous_page without page_table_lock patches! I'm still averse to this special route with different locking rules; but let's get it right for testing.

 mm/memory.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
mm/memory.c +3 -3
@@ -1796,12 +1796,12 @@ do_anonymous_page(struct mm_struct *mm, 
 		} else {
 			inc_page_state(cmpxchg_fail_anon_read);
 		}
-		pte_unmap(page_table);
 		goto minor_fault;
 	}
 
 	/* This leaves the write case */
 	page_table_atomic_stop(mm);
+	pte_unmap(page_table);
 	if (unlikely(anon_vma_prepare(vma)))
 		goto oom;
 
@@ -1812,10 +1812,10 @@ do_anonymous_page(struct mm_struct *mm, 
 	entry = maybe_mkwrite(pte_mkdirty(mk_pte(page,
 						vma->vm_page_prot)),
 				vma);
+	page_table = pte_offset_map(pmd, addr);
 	page_table_atomic_start(mm);
 
 	if (!ptep_cmpxchg(mm, addr, page_table, orig_entry, entry)) {
-		pte_unmap(page_table);
 		page_cache_release(page);
 		inc_page_state(cmpxchg_fail_anon_write);
 		goto minor_fault;
@@ -1829,12 +1829,12 @@ do_anonymous_page(struct mm_struct *mm, 
 	page_add_anon_rmap(page, vma, addr);
 	lru_cache_add_active(page);
 	inc_mm_counter(mm, rss);
-	pte_unmap(page_table);
 	update_mmu_cache(vma, addr, entry);
 	lazy_mmu_prot_update(entry);
 
 minor_fault:
 	page_table_atomic_stop(mm);
+	pte_unmap(page_table);
 	return VM_FAULT_MINOR;
 
 oom: