On Sun, 2006-10-15 at 17:57 +0200, Nick Piggin wrote:
Hmm, but you may not be doing a copy*user within the kmap. And you may
want an atomic copy*user not within a kmap (maybe).
I think it really would be more logical to do it in a wrapper function
pagefault_disable() pagefault_enable()? ;)
I did that one first, but then noticed that most non trivial kmap_atomic
implementations already did the inc_preempt_count()/dec_preempt_count()
thing (except frv which did preempt_disable()/preempt_enable() ?)
Anyway, here goes:
Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Index: linux-2.6/mm/filemap.h
===================================================================
--- linux-2.6.orig/mm/filemap.h 2006-10-14 20:20:20.000000000 +0200
+++ linux-2.6/mm/filemap.h 2006-10-15 17:17:45.000000000 +0200
@@ -21,6 +21,22 @@ __filemap_copy_from_user_iovec_inatomic(
size_t bytes);
/*
+ * By increasing the preempt_count we make sure the arch preempt
+ * handler bails out early, before taking any locks, so that the copy
+ * operation gets terminated early.
+ */
+pagefault_static inline void disable(void)
+{
+ inc_preempt_count();
+}
+
+pagefault_static inline void enable(void)
+{
+ dec_preempt_count();
+ preempt_check_resched();
+}