summaryrefslogtreecommitdiff
path: root/include/linux/rmap-locking.h
diff options
context:
space:
mode:
authorAndrew Morton <akpm@zip.com.au>2002-09-03 05:33:46 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2002-09-03 05:33:46 -0700
commit11bf19bc0eb48735772e664d07573f916f6e3f29 (patch)
tree441037455364b8a1241238f7d9a12035da4ffdc1 /include/linux/rmap-locking.h
parentef5bf0b55cb5563d80acdc7a8cbb54b8b86d07c3 (diff)
[PATCH] place rmap locking in rmap-locking.h
The rmap locking inlines are causing some header file dependency/ordering problems - move them out of page-flags.h and into their own header file.
Diffstat (limited to 'include/linux/rmap-locking.h')
-rw-r--r--include/linux/rmap-locking.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/linux/rmap-locking.h b/include/linux/rmap-locking.h
new file mode 100644
index 000000000000..302a58f54ca3
--- /dev/null
+++ b/include/linux/rmap-locking.h
@@ -0,0 +1,33 @@
+/*
+ * include/linux/rmap-locking.h
+ *
+ * Locking primitives for exclusive access to a page's reverse-mapping
+ * pte chain.
+ */
+
+static inline void pte_chain_lock(struct page *page)
+{
+ /*
+ * Assuming the lock is uncontended, this never enters
+ * the body of the outer loop. If it is contended, then
+ * within the inner loop a non-atomic test is used to
+ * busywait with less bus contention for a good time to
+ * attempt to acquire the lock bit.
+ */
+ preempt_disable();
+#ifdef CONFIG_SMP
+ while (test_and_set_bit(PG_chainlock, &page->flags)) {
+ while (test_bit(PG_chainlock, &page->flags))
+ cpu_relax();
+ }
+#endif
+}
+
+static inline void pte_chain_unlock(struct page *page)
+{
+#ifdef CONFIG_SMP
+ smp_mb__before_clear_bit();
+ clear_bit(PG_chainlock, &page->flags);
+#endif
+ preempt_enable();
+}