Re: [PATCH 3/3] readahead: introduce context readahead algorithm

Ingo Molnar
2009-04-12T08:49:13Z

* Wu Fengguang <fengguang.wu@intel.com> wrote:

> Introduce page cache context based readahead algorithm.
> This is to better support concurrent read streams in general.

> /*
> + * Count contiguously cached pages from @offset-1 to @offset-@max,
> + * this count is a conservative estimation of
> + * - length of the sequential read sequence, or
> + * - thrashing threshold in memory tight systems
> + */
> +static pgoff_t count_history_pages(struct address_space *mapping,
> + struct file_ra_state *ra,
> + pgoff_t offset, unsigned long max)
> +{
> + pgoff_t head;
> +
> + rcu_read_lock();
> + head = radix_tree_prev_hole(&mapping->page_tree, offset - 1, max);
> + rcu_read_unlock();
> +
> + return offset - 1 - head;
> +}

Very elegant method! I suspect this will work far better
than adding various increasingly more complex heuristics.

Emphatically-Acked-by: Ingo Molnar <mingo@elte.hu>

Ingo