mm: use lockless radix-tree probe
authorNick Piggin <npiggin@suse.de>
Tue, 16 Oct 2007 08:24:40 +0000 (01:24 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 16 Oct 2007 16:42:53 +0000 (09:42 -0700)
Probing pages and radix_tree_tagged are lockless operations with the lockless
radix-tree.  Convert these users to RCU locking rather than using tree_lock.

Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/page-writeback.c
mm/readahead.c

index 44720363374cb24ca3e90cb48db64d99e5bbdb5b..2adb89959885e77e228097a6405ffd929b2b4f68 100644 (file)
@@ -1022,17 +1022,15 @@ int test_set_page_writeback(struct page *page)
 EXPORT_SYMBOL(test_set_page_writeback);
 
 /*
- * Return true if any of the pages in the mapping are marged with the
+ * Return true if any of the pages in the mapping are marked with the
  * passed tag.
  */
 int mapping_tagged(struct address_space *mapping, int tag)
 {
-       unsigned long flags;
        int ret;
-
-       read_lock_irqsave(&mapping->tree_lock, flags);
+       rcu_read_lock();
        ret = radix_tree_tagged(&mapping->page_tree, tag);
-       read_unlock_irqrestore(&mapping->tree_lock, flags);
+       rcu_read_unlock();
        return ret;
 }
 EXPORT_SYMBOL(mapping_tagged);
index fc52f9f1b80cb08695c2379ed8faf5d761021293..c5c8981469e7078e9d107b95d574edbdff5b1c82 100644 (file)
@@ -149,20 +149,19 @@ __do_page_cache_readahead(struct address_space *mapping, struct file *filp,
        /*
         * Preallocate as many pages as we will need.
         */
-       read_lock_irq(&mapping->tree_lock);
        for (page_idx = 0; page_idx < nr_to_read; page_idx++) {
                pgoff_t page_offset = offset + page_idx;
 
                if (page_offset > end_index)
                        break;
 
+               rcu_read_lock();
                page = radix_tree_lookup(&mapping->page_tree, page_offset);
+               rcu_read_unlock();
                if (page)
                        continue;
 
-               read_unlock_irq(&mapping->tree_lock);
                page = page_cache_alloc_cold(mapping);
-               read_lock_irq(&mapping->tree_lock);
                if (!page)
                        break;
                page->index = page_offset;
@@ -171,7 +170,6 @@ __do_page_cache_readahead(struct address_space *mapping, struct file *filp,
                        SetPageReadahead(page);
                ret++;
        }
-       read_unlock_irq(&mapping->tree_lock);
 
        /*
         * Now start the IO.  We ignore I/O errors - if the page is not