]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blobdiff - include/linux/pagemap.h
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatchin...
[mirror_ubuntu-eoan-kernel.git] / include / linux / pagemap.h
index e2d7039af6a38b65f13a5a4fd2dfd8bd1b86f489..b477a70cc2e4587fd828ee921ce0b9ec2138775d 100644 (file)
@@ -164,7 +164,7 @@ void release_pages(struct page **pages, int nr);
  * will find the page or it will not. Likewise, the old find_get_page could run
  * either before the insertion or afterwards, depending on timing.
  */
-static inline int page_cache_get_speculative(struct page *page)
+static inline int __page_cache_add_speculative(struct page *page, int count)
 {
 #ifdef CONFIG_TINY_RCU
 # ifdef CONFIG_PREEMPT_COUNT
@@ -180,10 +180,10 @@ static inline int page_cache_get_speculative(struct page *page)
         * SMP requires.
         */
        VM_BUG_ON_PAGE(page_count(page) == 0, page);
-       page_ref_inc(page);
+       page_ref_add(page, count);
 
 #else
-       if (unlikely(!get_page_unless_zero(page))) {
+       if (unlikely(!page_ref_add_unless(page, count, 0))) {
                /*
                 * Either the page has been freed, or will be freed.
                 * In either case, retry here and the caller should
@@ -197,27 +197,14 @@ 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)
+static inline int page_cache_get_speculative(struct page *page)
 {
-       VM_BUG_ON(in_interrupt());
-
-#if !defined(CONFIG_SMP) && defined(CONFIG_TREE_RCU)
-# ifdef CONFIG_PREEMPT_COUNT
-       VM_BUG_ON(!in_atomic() && !irqs_disabled());
-# endif
-       VM_BUG_ON_PAGE(page_count(page) == 0, page);
-       page_ref_add(page, count);
-
-#else
-       if (unlikely(!page_ref_add_unless(page, count, 0)))
-               return 0;
-#endif
-       VM_BUG_ON_PAGE(PageCompound(page) && page != compound_head(page), page);
+       return __page_cache_add_speculative(page, 1);
+}
 
-       return 1;
+static inline int page_cache_add_speculative(struct page *page, int count)
+{
+       return __page_cache_add_speculative(page, count);
 }
 
 #ifdef CONFIG_NUMA