aboutsummaryrefslogtreecommitdiffstats
path: root/mm/truncate.c
diff options
context:
space:
mode:
authorMinchan Kim <minchan.kim@gmail.com>2011-03-22 19:32:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-22 20:44:03 -0400
commit315601809d124d046abd6c3ffa346d0dbd7aa29d (patch)
treebe48e1a0053e3ada3a5c25561923f1b87f8e1719 /mm/truncate.c
parent481b4bb5e370aa69c1dc276bd08871ec01b41d2a (diff)
mm: deactivate invalidated pages
Recently, there are reported problem about thrashing. (http://marc.info/?l=rsync&m=128885034930933&w=2) It happens by backup workloads(ex, nightly rsync). That's because the workload makes just use-once pages and touches pages twice. It promotes the page into active list so that it results in working set page eviction. Some app developer want to support POSIX_FADV_NOREUSE. But other OSes don't support it, either. (http://marc.info/?l=linux-mm&m=128928979512086&w=2) By other approach, app developers use POSIX_FADV_DONTNEED. But it has a problem. If kernel meets page is writing during invalidate_mapping_pages, it can't work. It makes for application programmer to use it since they always have to sync data before calling fadivse(..POSIX_FADV_DONTNEED) to make sure the pages could be discardable. At last, they can't use deferred write of kernel so that they could see performance loss. (http://insights.oetiker.ch/linux/fadvise.html) In fact, invalidation is very big hint to reclaimer. It means we don't use the page any more. So let's move the writing page into inactive list's head if we can't truncate it right now. Why I move page to head of lru on this patch, Dirty/Writeback page would be flushed sooner or later. It can prevent writeout of pageout which is less effective than flusher's writeout. Originally, I reused lru_demote of Peter with some change so added his Signed-off-by. Signed-off-by: Minchan Kim <minchan.kim@gmail.com> Reported-by: Ben Gamari <bgamari.foss@gmail.com> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Acked-by: Rik van Riel <riel@redhat.com> Acked-by: Mel Gorman <mel@csn.ul.ie> Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Wu Fengguang <fengguang.wu@intel.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Nick Piggin <npiggin@kernel.dk> Cc: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/truncate.c')
-rw-r--r--mm/truncate.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/mm/truncate.c b/mm/truncate.c
index 3d2ae1f423dc..a95667529135 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -321,11 +321,12 @@ EXPORT_SYMBOL(truncate_inode_pages);
321 * pagetables. 321 * pagetables.
322 */ 322 */
323unsigned long invalidate_mapping_pages(struct address_space *mapping, 323unsigned long invalidate_mapping_pages(struct address_space *mapping,
324 pgoff_t start, pgoff_t end) 324 pgoff_t start, pgoff_t end)
325{ 325{
326 struct pagevec pvec; 326 struct pagevec pvec;
327 pgoff_t next = start; 327 pgoff_t next = start;
328 unsigned long ret = 0; 328 unsigned long ret;
329 unsigned long count = 0;
329 int i; 330 int i;
330 331
331 pagevec_init(&pvec, 0); 332 pagevec_init(&pvec, 0);
@@ -352,9 +353,15 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
352 if (lock_failed) 353 if (lock_failed)
353 continue; 354 continue;
354 355
355 ret += invalidate_inode_page(page); 356 ret = invalidate_inode_page(page);
356
357 unlock_page(page); 357 unlock_page(page);
358 /*
359 * Invalidation is a hint that the page is no longer
360 * of interest and try to speed up its reclaim.
361 */
362 if (!ret)
363 deactivate_page(page);
364 count += ret;
358 if (next > end) 365 if (next > end)
359 break; 366 break;
360 } 367 }
@@ -362,7 +369,7 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
362 mem_cgroup_uncharge_end(); 369 mem_cgroup_uncharge_end();
363 cond_resched(); 370 cond_resched();
364 } 371 }
365 return ret; 372 return count;
366} 373}
367EXPORT_SYMBOL(invalidate_mapping_pages); 374EXPORT_SYMBOL(invalidate_mapping_pages);
368 375