From: Joe Korty <joe.korty@ccur.com>

We need to check whether preemption is needed after reenabling preemption
in kunmap_atomic().


 25-akpm/arch/i386/mm/highmem.c    |    3 +++
 25-akpm/arch/mips/mm/highmem.c    |    3 +++
 25-akpm/arch/sparc/mm/highmem.c   |    3 +++
 25-akpm/include/asm-ppc/highmem.h |    3 +++
 4 files changed, 12 insertions(+)

diff -puN arch/i386/mm/highmem.c~kunmap_atomic-check-resched arch/i386/mm/highmem.c
--- 25/arch/i386/mm/highmem.c~kunmap_atomic-check-resched	Mon Dec 22 14:49:30 2003
+++ 25-akpm/arch/i386/mm/highmem.c	Mon Dec 22 14:49:30 2003
@@ -30,6 +30,7 @@ void *kmap_atomic(struct page *page, enu
 	enum fixed_addresses idx;
 	unsigned long vaddr;
 
+	/* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
 	inc_preempt_count();
 	if (page < highmem_start_page)
 		return page_address(page);
@@ -54,6 +55,7 @@ void kunmap_atomic(void *kvaddr, enum km
 
 	if (vaddr < FIXADDR_START) { // FIXME
 		dec_preempt_count();
+		preempt_check_resched();
 		return;
 	}
 
@@ -69,6 +71,7 @@ void kunmap_atomic(void *kvaddr, enum km
 #endif
 
 	dec_preempt_count();
+	preempt_check_resched();
 }
 
 struct page *kmap_atomic_to_page(void *ptr)
diff -puN arch/mips/mm/highmem.c~kunmap_atomic-check-resched arch/mips/mm/highmem.c
--- 25/arch/mips/mm/highmem.c~kunmap_atomic-check-resched	Mon Dec 22 14:49:30 2003
+++ 25-akpm/arch/mips/mm/highmem.c	Mon Dec 22 14:49:30 2003
@@ -40,6 +40,7 @@ void *kmap_atomic(struct page *page, enu
 	enum fixed_addresses idx;
 	unsigned long vaddr;
 
+	/* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
 	inc_preempt_count();
 	if (page < highmem_start_page)
 		return page_address(page);
@@ -64,6 +65,7 @@ void kunmap_atomic(void *kvaddr, enum km
 
 	if (vaddr < FIXADDR_START) { // FIXME
 		dec_preempt_count();
+		preempt_check_resched();
 		return;
 	}
 
@@ -79,6 +81,7 @@ void kunmap_atomic(void *kvaddr, enum km
 #endif
 
 	dec_preempt_count();
+	preempt_check_resched();
 }
 
 struct page *kmap_atomic_to_page(void *ptr)
diff -puN arch/sparc/mm/highmem.c~kunmap_atomic-check-resched arch/sparc/mm/highmem.c
--- 25/arch/sparc/mm/highmem.c~kunmap_atomic-check-resched	Mon Dec 22 14:49:30 2003
+++ 25-akpm/arch/sparc/mm/highmem.c	Mon Dec 22 14:49:30 2003
@@ -33,6 +33,7 @@ void *kmap_atomic(struct page *page, enu
 	unsigned long idx;
 	unsigned long vaddr;
 
+	/* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
 	inc_preempt_count();
 	if (page < highmem_start_page)
 		return page_address(page);
@@ -69,6 +70,7 @@ void kunmap_atomic(void *kvaddr, enum km
 
 	if (vaddr < fix_kmap_begin) { // FIXME
 		dec_preempt_count();
+		preempt_check_resched();
 		return;
 	}
 
@@ -96,4 +98,5 @@ void kunmap_atomic(void *kvaddr, enum km
 #endif
 #endif
 	dec_preempt_count();
+	preempt_check_resched();
 }
diff -puN include/asm-ppc/highmem.h~kunmap_atomic-check-resched include/asm-ppc/highmem.h
--- 25/include/asm-ppc/highmem.h~kunmap_atomic-check-resched	Mon Dec 22 14:49:30 2003
+++ 25-akpm/include/asm-ppc/highmem.h	Mon Dec 22 14:49:30 2003
@@ -81,6 +81,7 @@ static inline void *kmap_atomic(struct p
 	unsigned int idx;
 	unsigned long vaddr;
 
+	/* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
 	inc_preempt_count();
 	if (page < highmem_start_page)
 		return page_address(page);
@@ -105,6 +106,7 @@ static inline void kunmap_atomic(void *k
 
 	if (vaddr < KMAP_FIX_BEGIN) { // FIXME
 		dec_preempt_count();
+		preempt_check_resched();
 		return;
 	}
 
@@ -119,6 +121,7 @@ static inline void kunmap_atomic(void *k
 	flush_tlb_page(0, vaddr);
 #endif
 	dec_preempt_count();
+	preempt_check_resched();
 }
 
 static inline struct page *kmap_atomic_to_page(void *ptr)

_