mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
radix-tree: delete radix_tree_range_tag_if_tagged()
This is an exceptionally complicated function with just one caller (tag_pages_for_writeback). We devote a large portion of the runtime of the test suite to testing this one function which has one caller. By introducing the new function radix_tree_iter_tag_set(), we can eliminate all of the complexity while keeping the performance. The caller can now use a fairly standard radix_tree_for_each() loop, and it doesn't need to worry about tricksy things like 'start' wrapping. The test suite continues to spend a large amount of time investigating this function, but now it's testing the underlying primitives such as radix_tree_iter_resume() and the radix_tree_for_each_tagged() iterator which are also used by other parts of the kernel. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox <[email protected]> Tested-by: Kirill A. Shutemov <[email protected]> Cc: Konstantin Khlebnikov <[email protected]> Cc: Ross Zwisler <[email protected]> Cc: Matthew Wilcox <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
478922e2b0
commit
268f42de71
9 changed files with 125 additions and 163 deletions
|
|
@ -2106,18 +2106,26 @@ void tag_pages_for_writeback(struct address_space *mapping,
|
|||
pgoff_t start, pgoff_t end)
|
||||
{
|
||||
#define WRITEBACK_TAG_BATCH 4096
|
||||
unsigned long tagged;
|
||||
unsigned long tagged = 0;
|
||||
struct radix_tree_iter iter;
|
||||
void **slot;
|
||||
|
||||
do {
|
||||
spin_lock_irq(&mapping->tree_lock);
|
||||
tagged = radix_tree_range_tag_if_tagged(&mapping->page_tree,
|
||||
&start, end, WRITEBACK_TAG_BATCH,
|
||||
PAGECACHE_TAG_DIRTY, PAGECACHE_TAG_TOWRITE);
|
||||
spin_lock_irq(&mapping->tree_lock);
|
||||
radix_tree_for_each_tagged(slot, &mapping->page_tree, &iter, start,
|
||||
PAGECACHE_TAG_DIRTY) {
|
||||
if (iter.index > end)
|
||||
break;
|
||||
radix_tree_iter_tag_set(&mapping->page_tree, &iter,
|
||||
PAGECACHE_TAG_TOWRITE);
|
||||
tagged++;
|
||||
if ((tagged % WRITEBACK_TAG_BATCH) != 0)
|
||||
continue;
|
||||
slot = radix_tree_iter_resume(slot, &iter);
|
||||
spin_unlock_irq(&mapping->tree_lock);
|
||||
WARN_ON_ONCE(tagged > WRITEBACK_TAG_BATCH);
|
||||
cond_resched();
|
||||
/* We check 'start' to handle wrapping when end == ~0UL */
|
||||
} while (tagged >= WRITEBACK_TAG_BATCH && start);
|
||||
spin_lock_irq(&mapping->tree_lock);
|
||||
}
|
||||
spin_unlock_irq(&mapping->tree_lock);
|
||||
}
|
||||
EXPORT_SYMBOL(tag_pages_for_writeback);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue