Re: [PATCH 2/4] mm: pagevec: Defer deciding what LRU to add a pageto until pagevec drain time

From: Andrew Morton
Date: Wed May 15 2013 - 18:53:37 EST


On Mon, 13 May 2013 11:21:20 +0100 Mel Gorman <mgorman@xxxxxxx> wrote:

> mark_page_accessed cannot activate an inactive page that is located on
> an inactive LRU pagevec. Hints from filesystems may be ignored as a
> result. In preparation for fixing that problem, this patch removes the
> per-LRU pagevecs and leaves just one pagevec. The final LRU the page is
> added to is deferred until the pagevec is drained.
>
> This means that fewer pagevecs are available and potentially there is
> greater contention on the LRU lock. However, this only applies in the case
> where there is an almost perfect mix of file, anon, active and inactive
> pages being added to the LRU. In practice I expect that we are adding
> stream of pages of a particular time and that the changes in contention
> will barely be measurable.
>
> ...
>
> index c612a6a..0911579 100644
> --- a/mm/swap.c
> +++ b/mm/swap.c
> @@ -39,7 +39,7 @@
> /* How many pages do we try to swap or page in/out together? */
> int page_cluster;
>
> -static DEFINE_PER_CPU(struct pagevec[NR_LRU_LISTS], lru_add_pvecs);
> +static DEFINE_PER_CPU(struct pagevec, lru_add_pvec);
> static DEFINE_PER_CPU(struct pagevec, lru_rotate_pvecs);
> static DEFINE_PER_CPU(struct pagevec, lru_deactivate_pvecs);
>
> @@ -460,13 +460,18 @@ EXPORT_SYMBOL(mark_page_accessed);
> */

The comment preceding __lru_cache_add() needs an update.

> void __lru_cache_add(struct page *page, enum lru_list lru)
> {
> - struct pagevec *pvec = &get_cpu_var(lru_add_pvecs)[lru];
> + struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
> +
> + if (is_active_lru(lru))
> + SetPageActive(page);
> + else
> + ClearPageActive(page);

The whole use of `enum lru_list' here has always made my cry, but I'll weep
about that in [4/4].

> page_cache_get(page);
> if (!pagevec_space(pvec))
> __pagevec_lru_add(pvec, lru);
> pagevec_add(pvec, page);
> - put_cpu_var(lru_add_pvecs);
> + put_cpu_var(lru_add_pvec);
> }
>
> ...
>
--
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/