[PATCH] mm: pagefault_{disable,enable}()
[deliverable/linux.git] / include / linux / uaccess.h
index a48d7f11c7be06772327604dc40c3f91b0b57145..67918c22339c5334836ed102e3be0e3ffd5695ed 100644 (file)
@@ -1,8 +1,43 @@
 #ifndef __LINUX_UACCESS_H__
 #define __LINUX_UACCESS_H__
 
+#include <linux/preempt.h>
 #include <asm/uaccess.h>
 
+/*
+ * These routines enable/disable the pagefault handler in that
+ * it will not take any locks and go straight to the fixup table.
+ *
+ * They have great resemblance to the preempt_disable/enable calls
+ * and in fact they are identical; this is because currently there is
+ * no other way to make the pagefault handlers do this. So we do
+ * disable preemption but we don't necessarily care about that.
+ */
+static inline void pagefault_disable(void)
+{
+       inc_preempt_count();
+       /*
+        * make sure to have issued the store before a pagefault
+        * can hit.
+        */
+       barrier();
+}
+
+static inline void pagefault_enable(void)
+{
+       /*
+        * make sure to issue those last loads/stores before enabling
+        * the pagefault handler again.
+        */
+       barrier();
+       dec_preempt_count();
+       /*
+        * make sure we do..
+        */
+       barrier();
+       preempt_check_resched();
+}
+
 #ifndef ARCH_HAS_NOCACHE_UACCESS
 
 static inline unsigned long __copy_from_user_inatomic_nocache(void *to,
@@ -35,9 +70,9 @@ static inline unsigned long __copy_from_user_nocache(void *to,
        ({                                              \
                long ret;                               \
                                                        \
-               inc_preempt_count();                    \
+               pagefault_disable();                    \
                ret = __get_user(retval, addr);         \
-               dec_preempt_count();                    \
+               pagefault_enable();                     \
                ret;                                    \
        })
 
This page took 0.027171 seconds and 5 git commands to generate.