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

From: Ingo Molnar
Date: Sun Apr 12 2009 - 04:49:14 EST



* Wu Fengguang <fengguang.wu@xxxxxxxxx> 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@xxxxxxx>

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/