]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/pagemap.h
powerpc/mm: Lockless get_user_pages_fast() for 64-bit (v3)
[linux-2.6-omap-h63xx.git] / include / linux / pagemap.h
index a39b38ccdc976e920b077fcd484cabb8cc402ba8..69ed3cb1197ac942b8d982e395fb48d5ecdbb29b 100644 (file)
@@ -143,6 +143,29 @@ static inline int page_cache_get_speculative(struct page *page)
        return 1;
 }
 
+/*
+ * Same as above, but add instead of inc (could just be merged)
+ */
+static inline int page_cache_add_speculative(struct page *page, int count)
+{
+       VM_BUG_ON(in_interrupt());
+
+#if !defined(CONFIG_SMP) && defined(CONFIG_CLASSIC_RCU)
+# ifdef CONFIG_PREEMPT
+       VM_BUG_ON(!in_atomic());
+# endif
+       VM_BUG_ON(page_count(page) == 0);
+       atomic_add(count, &page->_count);
+
+#else
+       if (unlikely(!atomic_add_unless(&page->_count, count, 0)))
+               return 0;
+#endif
+       VM_BUG_ON(PageCompound(page) && page != compound_head(page));
+
+       return 1;
+}
+
 static inline int page_freeze_refs(struct page *page, int count)
 {
        return likely(atomic_cmpxchg(&page->_count, count, 0) == count);