aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Khlebnikov <khlebnikov@openvz.org>2012-05-29 18:06:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-29 19:22:25 -0400
commitf3fd4a61928a5edf5b033a417e761b488b43e203 (patch)
treef56c5b6f4a4c732c9167e4cacb3e9c25ced0d000
parent014483bcccc5edbf861d89dc1a6f7cdc02f9f4c0 (diff)
mm: remove lru type checks from __isolate_lru_page()
After patch "mm: forbid lumpy-reclaim in shrink_active_list()" we can completely remove anon/file and active/inactive lru type filters from __isolate_lru_page(), because isolation for 0-order reclaim always isolates pages from right lru list. And pages-isolation for lumpy shrink_inactive_list() or memory-compaction anyway allowed to isolate pages from all evictable lru lists. Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Hugh Dickins <hughd@google.com> Acked-by: Michal Hocko <mhocko@suse.cz> Cc: Glauber Costa <glommer@parallels.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Minchan Kim <minchan@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/mmzone.h10
-rw-r--r--include/linux/swap.h2
-rw-r--r--mm/compaction.c4
-rw-r--r--mm/vmscan.c23
4 files changed, 10 insertions, 29 deletions
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 1b89861eedc0..5c4880bc027a 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -209,16 +209,12 @@ struct lruvec {
209#define LRU_ALL_EVICTABLE (LRU_ALL_FILE | LRU_ALL_ANON) 209#define LRU_ALL_EVICTABLE (LRU_ALL_FILE | LRU_ALL_ANON)
210#define LRU_ALL ((1 << NR_LRU_LISTS) - 1) 210#define LRU_ALL ((1 << NR_LRU_LISTS) - 1)
211 211
212/* Isolate inactive pages */
213#define ISOLATE_INACTIVE ((__force isolate_mode_t)0x1)
214/* Isolate active pages */
215#define ISOLATE_ACTIVE ((__force isolate_mode_t)0x2)
216/* Isolate clean file */ 212/* Isolate clean file */
217#define ISOLATE_CLEAN ((__force isolate_mode_t)0x4) 213#define ISOLATE_CLEAN ((__force isolate_mode_t)0x1)
218/* Isolate unmapped file */ 214/* Isolate unmapped file */
219#define ISOLATE_UNMAPPED ((__force isolate_mode_t)0x8) 215#define ISOLATE_UNMAPPED ((__force isolate_mode_t)0x2)
220/* Isolate for asynchronous migration */ 216/* Isolate for asynchronous migration */
221#define ISOLATE_ASYNC_MIGRATE ((__force isolate_mode_t)0x10) 217#define ISOLATE_ASYNC_MIGRATE ((__force isolate_mode_t)0x4)
222 218
223/* LRU Isolation modes. */ 219/* LRU Isolation modes. */
224typedef unsigned __bitwise__ isolate_mode_t; 220typedef unsigned __bitwise__ isolate_mode_t;
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 49c0fa9ef5cf..ff38eb7c0ec4 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -251,7 +251,7 @@ static inline void lru_cache_add_file(struct page *page)
251/* linux/mm/vmscan.c */ 251/* linux/mm/vmscan.c */
252extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, 252extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
253 gfp_t gfp_mask, nodemask_t *mask); 253 gfp_t gfp_mask, nodemask_t *mask);
254extern int __isolate_lru_page(struct page *page, isolate_mode_t mode, int file); 254extern int __isolate_lru_page(struct page *page, isolate_mode_t mode);
255extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem, 255extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem,
256 gfp_t gfp_mask, bool noswap); 256 gfp_t gfp_mask, bool noswap);
257extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, 257extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
diff --git a/mm/compaction.c b/mm/compaction.c
index 840ee288e296..74e1b3803839 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -226,7 +226,7 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
226 unsigned long last_pageblock_nr = 0, pageblock_nr; 226 unsigned long last_pageblock_nr = 0, pageblock_nr;
227 unsigned long nr_scanned = 0, nr_isolated = 0; 227 unsigned long nr_scanned = 0, nr_isolated = 0;
228 struct list_head *migratelist = &cc->migratepages; 228 struct list_head *migratelist = &cc->migratepages;
229 isolate_mode_t mode = ISOLATE_ACTIVE|ISOLATE_INACTIVE; 229 isolate_mode_t mode = 0;
230 230
231 /* 231 /*
232 * Ensure that there are not too many pages isolated from the LRU 232 * Ensure that there are not too many pages isolated from the LRU
@@ -329,7 +329,7 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
329 mode |= ISOLATE_ASYNC_MIGRATE; 329 mode |= ISOLATE_ASYNC_MIGRATE;
330 330
331 /* Try isolate the page */ 331 /* Try isolate the page */
332 if (__isolate_lru_page(page, mode, 0) != 0) 332 if (__isolate_lru_page(page, mode) != 0)
333 continue; 333 continue;
334 334
335 VM_BUG_ON(PageTransCompound(page)); 335 VM_BUG_ON(PageTransCompound(page));
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 987be819fad6..27ef5769b9e4 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -949,29 +949,14 @@ keep:
949 * 949 *
950 * returns 0 on success, -ve errno on failure. 950 * returns 0 on success, -ve errno on failure.
951 */ 951 */
952int __isolate_lru_page(struct page *page, isolate_mode_t mode, int file) 952int __isolate_lru_page(struct page *page, isolate_mode_t mode)
953{ 953{
954 bool all_lru_mode;
955 int ret = -EINVAL; 954 int ret = -EINVAL;
956 955
957 /* Only take pages on the LRU. */ 956 /* Only take pages on the LRU. */
958 if (!PageLRU(page)) 957 if (!PageLRU(page))
959 return ret; 958 return ret;
960 959
961 all_lru_mode = (mode & (ISOLATE_ACTIVE|ISOLATE_INACTIVE)) ==
962 (ISOLATE_ACTIVE|ISOLATE_INACTIVE);
963
964 /*
965 * When checking the active state, we need to be sure we are
966 * dealing with comparible boolean values. Take the logical not
967 * of each.
968 */
969 if (!all_lru_mode && !PageActive(page) != !(mode & ISOLATE_ACTIVE))
970 return ret;
971
972 if (!all_lru_mode && !!page_is_file_cache(page) != file)
973 return ret;
974
975 /* Do not give back unevictable pages for compaction */ 960 /* Do not give back unevictable pages for compaction */
976 if (PageUnevictable(page)) 961 if (PageUnevictable(page))
977 return ret; 962 return ret;
@@ -1070,7 +1055,7 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
1070 1055
1071 VM_BUG_ON(!PageLRU(page)); 1056 VM_BUG_ON(!PageLRU(page));
1072 1057
1073 switch (__isolate_lru_page(page, mode, file)) { 1058 switch (__isolate_lru_page(page, mode)) {
1074 case 0: 1059 case 0:
1075 mem_cgroup_lru_del(page); 1060 mem_cgroup_lru_del(page);
1076 list_move(&page->lru, dst); 1061 list_move(&page->lru, dst);
@@ -1282,7 +1267,7 @@ shrink_inactive_list(unsigned long nr_to_scan, struct mem_cgroup_zone *mz,
1282 unsigned long nr_file; 1267 unsigned long nr_file;
1283 unsigned long nr_dirty = 0; 1268 unsigned long nr_dirty = 0;
1284 unsigned long nr_writeback = 0; 1269 unsigned long nr_writeback = 0;
1285 isolate_mode_t isolate_mode = ISOLATE_INACTIVE; 1270 isolate_mode_t isolate_mode = 0;
1286 int file = is_file_lru(lru); 1271 int file = is_file_lru(lru);
1287 struct zone *zone = mz->zone; 1272 struct zone *zone = mz->zone;
1288 struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(mz); 1273 struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(mz);
@@ -1452,7 +1437,7 @@ static void shrink_active_list(unsigned long nr_to_scan,
1452 struct page *page; 1437 struct page *page;
1453 struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(mz); 1438 struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(mz);
1454 unsigned long nr_rotated = 0; 1439 unsigned long nr_rotated = 0;
1455 isolate_mode_t isolate_mode = ISOLATE_ACTIVE; 1440 isolate_mode_t isolate_mode = 0;
1456 int file = is_file_lru(lru); 1441 int file = is_file_lru(lru);
1457 struct zone *zone = mz->zone; 1442 struct zone *zone = mz->zone;
1458 1443