From a2e93d1c3a04ff2d1c5620f3a29d2c1232b0ad07 Mon Sep 17 00:00:00 2001 From: Robin Dong Date: Mon, 8 Oct 2012 16:29:05 -0700 Subject: [PATCH] --- yaml --- r: 332345 b: refs/heads/master c: d741c9cdeee6a569dae0dbbaf028065402955b59 h: refs/heads/master i: 332343: de7410c708ce38b6259d373ba6b990336848d8e4 v: v3 --- [refs] | 2 +- trunk/mm/swap.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 80a7c6e60fac..97100cefb8cb 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 314e51b9851b4f4e8ab302243ff5a6fc6147f379 +refs/heads/master: d741c9cdeee6a569dae0dbbaf028065402955b59 diff --git a/trunk/mm/swap.c b/trunk/mm/swap.c index 77825883298f..f76c76c7501b 100644 --- a/trunk/mm/swap.c +++ b/trunk/mm/swap.c @@ -446,13 +446,22 @@ void mark_page_accessed(struct page *page) } EXPORT_SYMBOL(mark_page_accessed); +/* + * Order of operations is important: flush the pagevec when it's already + * full, not when adding the last page, to make sure that last page is + * not added to the LRU directly when passed to this function. Because + * mark_page_accessed() (called after this when writing) only activates + * pages that are on the LRU, linear writes in subpage chunks would see + * every PAGEVEC_SIZE page activated, which is unexpected. + */ void __lru_cache_add(struct page *page, enum lru_list lru) { struct pagevec *pvec = &get_cpu_var(lru_add_pvecs)[lru]; page_cache_get(page); - if (!pagevec_add(pvec, page)) + if (!pagevec_space(pvec)) __pagevec_lru_add(pvec, lru); + pagevec_add(pvec, page); put_cpu_var(lru_add_pvecs); } EXPORT_SYMBOL(__lru_cache_add);