Re: [PATCH 2/2] mm: Implement writeback livelock avoidance using page tagging

Andrew Morton
2010-06-18T22:22:00Z

On Wed, 16 Jun 2010 18:33:51 +0200
Jan Kara <jack@suse.cz> wrote:

> We try to avoid livelocks of writeback when some steadily creates
> dirty pages in a mapping we are writing out. For memory-cleaning
> writeback, using nr_to_write works reasonably well but we cannot
> really use it for data integrity writeback. This patch tries to
> solve the problem.
>
> The idea is simple: Tag all pages that should be written back
> with a special tag (TOWRITE) in the radix tree. This can be done
> rather quickly and thus livelocks should not happen in practice.
> Then we start doing the hard work of locking pages and sending
> them to disk only for those pages that have TOWRITE tag set.
>
> Note: Adding new radix tree tag grows radix tree node from 288 to
> 296 bytes for 32-bit archs and from 552 to 560 bytes for 64-bit archs.
> However, the number of slab/slub items per page remains the same
> (13 and 7 respectively).
>
>
> ...
>
> +void tag_pages_for_writeback(struct address_space *mapping,
> + pgoff_t start, pgoff_t end)
> +{
> + unsigned long tagged;
> +
> + 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_unlock_irq(&mapping->tree_lock);
> + cond_resched();
> + } while (tagged >= WRITEBACK_TAG_BATCH);
> +}

grumble. (tagged > WRITEBACK_TAG_BATCH) would be a bug, wouldn't it?
So the ">=" is hiding a bug.