From 63836dce1610df58e5ce58120ead7c585440d2b3 Mon Sep 17 00:00:00 2001 From: Mel Gorman Date: Fri, 22 Feb 2013 16:35:59 -0800 Subject: [PATCH] --- yaml --- r: 356624 b: refs/heads/master c: 67d46b296a1ba1477c0df8ff3bc5e0167a0b0732 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/mm/fadvise.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 4d5f1126fd16..b68f6221f511 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: fa794199e36a13063913e75487001b3038316e51 +refs/heads/master: 67d46b296a1ba1477c0df8ff3bc5e0167a0b0732 diff --git a/trunk/mm/fadvise.c b/trunk/mm/fadvise.c index a47f0f50c89f..909ec558625c 100644 --- a/trunk/mm/fadvise.c +++ b/trunk/mm/fadvise.c @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -120,9 +121,22 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice) start_index = (offset+(PAGE_CACHE_SIZE-1)) >> PAGE_CACHE_SHIFT; end_index = (endbyte >> PAGE_CACHE_SHIFT); - if (end_index >= start_index) - invalidate_mapping_pages(mapping, start_index, + if (end_index >= start_index) { + unsigned long count = invalidate_mapping_pages(mapping, + start_index, end_index); + + /* + * If fewer pages were invalidated than expected then + * it is possible that some of the pages were on + * a per-cpu pagevec for a remote CPU. Drain all + * pagevecs and try again. + */ + if (count < (end_index - start_index + 1)) { + lru_add_drain_all(); + invalidate_mapping_pages(mapping, start_index, end_index); + } + } break; default: ret = -EINVAL;