diff options
author | Minchan Kim <minchan.kim@gmail.com> | 2011-10-31 20:06:47 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-01 15:27:16 -0400 |
commit | a15a3971cc49eefbde40b397a446c0fa9c5fed9c (patch) | |
tree | 31265bc7cd5b601457eb604777540cb788607849 | |
parent | f665a680f89357a6773fb97684690c76933888f6 (diff) |
mm: change isolate mode from #define to bitwise type
commit 4356f21d09283dc6d39a6f7287a65ddab61e2808 upstream.
Stable note: Not tracked in Bugzilla. This patch makes later patches
easier to apply but has no other impact.
Change ISOLATE_XXX macro with bitwise isolate_mode_t type. Normally,
macro isn't recommended as it's type-unsafe and making debugging harder as
symbol cannot be passed throught to the debugger.
Quote from Johannes
" Hmm, it would probably be cleaner to fully convert the isolation mode
into independent flags. INACTIVE, ACTIVE, BOTH is currently a
tri-state among flags, which is a bit ugly."
This patch moves isolate mode from swap.h to mmzone.h by memcontrol.h
Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | Documentation/trace/postprocess/trace-vmscan-postprocess.pl | 8 | ||||
-rw-r--r-- | include/linux/memcontrol.h | 3 | ||||
-rw-r--r-- | include/linux/mmzone.h | 8 | ||||
-rw-r--r-- | include/linux/swap.h | 7 | ||||
-rw-r--r-- | include/trace/events/vmscan.h | 8 | ||||
-rw-r--r-- | mm/compaction.c | 3 | ||||
-rw-r--r-- | mm/memcontrol.c | 3 | ||||
-rw-r--r-- | mm/vmscan.c | 37 |
8 files changed, 43 insertions, 34 deletions
diff --git a/Documentation/trace/postprocess/trace-vmscan-postprocess.pl b/Documentation/trace/postprocess/trace-vmscan-postprocess.pl index 12cecc83cd9..4a37c4759cd 100644 --- a/Documentation/trace/postprocess/trace-vmscan-postprocess.pl +++ b/Documentation/trace/postprocess/trace-vmscan-postprocess.pl | |||
@@ -379,10 +379,10 @@ EVENT_PROCESS: | |||
379 | 379 | ||
380 | # To closer match vmstat scanning statistics, only count isolate_both | 380 | # To closer match vmstat scanning statistics, only count isolate_both |
381 | # and isolate_inactive as scanning. isolate_active is rotation | 381 | # and isolate_inactive as scanning. isolate_active is rotation |
382 | # isolate_inactive == 0 | 382 | # isolate_inactive == 1 |
383 | # isolate_active == 1 | 383 | # isolate_active == 2 |
384 | # isolate_both == 2 | 384 | # isolate_both == 3 |
385 | if ($isolate_mode != 1) { | 385 | if ($isolate_mode != 2) { |
386 | $perprocesspid{$process_pid}->{HIGH_NR_SCANNED} += $nr_scanned; | 386 | $perprocesspid{$process_pid}->{HIGH_NR_SCANNED} += $nr_scanned; |
387 | } | 387 | } |
388 | $perprocesspid{$process_pid}->{HIGH_NR_CONTIG_DIRTY} += $nr_contig_dirty; | 388 | $perprocesspid{$process_pid}->{HIGH_NR_CONTIG_DIRTY} += $nr_contig_dirty; |
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 313a00eca40..4a8da84487b 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -35,7 +35,8 @@ enum mem_cgroup_page_stat_item { | |||
35 | extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, | 35 | extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, |
36 | struct list_head *dst, | 36 | struct list_head *dst, |
37 | unsigned long *scanned, int order, | 37 | unsigned long *scanned, int order, |
38 | int mode, struct zone *z, | 38 | isolate_mode_t mode, |
39 | struct zone *z, | ||
39 | struct mem_cgroup *mem_cont, | 40 | struct mem_cgroup *mem_cont, |
40 | int active, int file); | 41 | int active, int file); |
41 | 42 | ||
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index aa2d80b61d4..047ea6521cc 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
@@ -158,6 +158,14 @@ static inline int is_unevictable_lru(enum lru_list l) | |||
158 | return (l == LRU_UNEVICTABLE); | 158 | return (l == LRU_UNEVICTABLE); |
159 | } | 159 | } |
160 | 160 | ||
161 | /* Isolate inactive pages */ | ||
162 | #define ISOLATE_INACTIVE ((__force isolate_mode_t)0x1) | ||
163 | /* Isolate active pages */ | ||
164 | #define ISOLATE_ACTIVE ((__force isolate_mode_t)0x2) | ||
165 | |||
166 | /* LRU Isolation modes. */ | ||
167 | typedef unsigned __bitwise__ isolate_mode_t; | ||
168 | |||
161 | enum zone_watermarks { | 169 | enum zone_watermarks { |
162 | WMARK_MIN, | 170 | WMARK_MIN, |
163 | WMARK_LOW, | 171 | WMARK_LOW, |
diff --git a/include/linux/swap.h b/include/linux/swap.h index a273468f828..e73799d3b1c 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h | |||
@@ -243,11 +243,6 @@ static inline void lru_cache_add_file(struct page *page) | |||
243 | __lru_cache_add(page, LRU_INACTIVE_FILE); | 243 | __lru_cache_add(page, LRU_INACTIVE_FILE); |
244 | } | 244 | } |
245 | 245 | ||
246 | /* LRU Isolation modes. */ | ||
247 | #define ISOLATE_INACTIVE 0 /* Isolate inactive pages. */ | ||
248 | #define ISOLATE_ACTIVE 1 /* Isolate active pages. */ | ||
249 | #define ISOLATE_BOTH 2 /* Isolate both active and inactive pages. */ | ||
250 | |||
251 | /* linux/mm/vmscan.c */ | 246 | /* linux/mm/vmscan.c */ |
252 | extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, | 247 | extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, |
253 | gfp_t gfp_mask, nodemask_t *mask); | 248 | gfp_t gfp_mask, nodemask_t *mask); |
@@ -259,7 +254,7 @@ extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, | |||
259 | unsigned int swappiness, | 254 | unsigned int swappiness, |
260 | struct zone *zone, | 255 | struct zone *zone, |
261 | unsigned long *nr_scanned); | 256 | unsigned long *nr_scanned); |
262 | extern int __isolate_lru_page(struct page *page, int mode, int file); | 257 | extern int __isolate_lru_page(struct page *page, isolate_mode_t mode, int file); |
263 | extern unsigned long shrink_all_memory(unsigned long nr_pages); | 258 | extern unsigned long shrink_all_memory(unsigned long nr_pages); |
264 | extern int vm_swappiness; | 259 | extern int vm_swappiness; |
265 | extern int remove_mapping(struct address_space *mapping, struct page *page); | 260 | extern int remove_mapping(struct address_space *mapping, struct page *page); |
diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h index 36851f7f13d..edc4b3d25a2 100644 --- a/include/trace/events/vmscan.h +++ b/include/trace/events/vmscan.h | |||
@@ -266,7 +266,7 @@ DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template, | |||
266 | unsigned long nr_lumpy_taken, | 266 | unsigned long nr_lumpy_taken, |
267 | unsigned long nr_lumpy_dirty, | 267 | unsigned long nr_lumpy_dirty, |
268 | unsigned long nr_lumpy_failed, | 268 | unsigned long nr_lumpy_failed, |
269 | int isolate_mode), | 269 | isolate_mode_t isolate_mode), |
270 | 270 | ||
271 | TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode), | 271 | TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode), |
272 | 272 | ||
@@ -278,7 +278,7 @@ DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template, | |||
278 | __field(unsigned long, nr_lumpy_taken) | 278 | __field(unsigned long, nr_lumpy_taken) |
279 | __field(unsigned long, nr_lumpy_dirty) | 279 | __field(unsigned long, nr_lumpy_dirty) |
280 | __field(unsigned long, nr_lumpy_failed) | 280 | __field(unsigned long, nr_lumpy_failed) |
281 | __field(int, isolate_mode) | 281 | __field(isolate_mode_t, isolate_mode) |
282 | ), | 282 | ), |
283 | 283 | ||
284 | TP_fast_assign( | 284 | TP_fast_assign( |
@@ -312,7 +312,7 @@ DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate, | |||
312 | unsigned long nr_lumpy_taken, | 312 | unsigned long nr_lumpy_taken, |
313 | unsigned long nr_lumpy_dirty, | 313 | unsigned long nr_lumpy_dirty, |
314 | unsigned long nr_lumpy_failed, | 314 | unsigned long nr_lumpy_failed, |
315 | int isolate_mode), | 315 | isolate_mode_t isolate_mode), |
316 | 316 | ||
317 | TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode) | 317 | TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode) |
318 | 318 | ||
@@ -327,7 +327,7 @@ DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_memcg_isolate, | |||
327 | unsigned long nr_lumpy_taken, | 327 | unsigned long nr_lumpy_taken, |
328 | unsigned long nr_lumpy_dirty, | 328 | unsigned long nr_lumpy_dirty, |
329 | unsigned long nr_lumpy_failed, | 329 | unsigned long nr_lumpy_failed, |
330 | int isolate_mode), | 330 | isolate_mode_t isolate_mode), |
331 | 331 | ||
332 | TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode) | 332 | TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode) |
333 | 333 | ||
diff --git a/mm/compaction.c b/mm/compaction.c index d6ba0377e26..26521a12f22 100644 --- a/mm/compaction.c +++ b/mm/compaction.c | |||
@@ -371,7 +371,8 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone, | |||
371 | } | 371 | } |
372 | 372 | ||
373 | /* Try isolate the page */ | 373 | /* Try isolate the page */ |
374 | if (__isolate_lru_page(page, ISOLATE_BOTH, 0) != 0) | 374 | if (__isolate_lru_page(page, |
375 | ISOLATE_ACTIVE|ISOLATE_INACTIVE, 0) != 0) | ||
375 | continue; | 376 | continue; |
376 | 377 | ||
377 | VM_BUG_ON(PageTransCompound(page)); | 378 | VM_BUG_ON(PageTransCompound(page)); |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index ffb99b4e752..57cdf5ad692 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1251,7 +1251,8 @@ mem_cgroup_get_reclaim_stat_from_page(struct page *page) | |||
1251 | unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, | 1251 | unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, |
1252 | struct list_head *dst, | 1252 | struct list_head *dst, |
1253 | unsigned long *scanned, int order, | 1253 | unsigned long *scanned, int order, |
1254 | int mode, struct zone *z, | 1254 | isolate_mode_t mode, |
1255 | struct zone *z, | ||
1255 | struct mem_cgroup *mem_cont, | 1256 | struct mem_cgroup *mem_cont, |
1256 | int active, int file) | 1257 | int active, int file) |
1257 | { | 1258 | { |
diff --git a/mm/vmscan.c b/mm/vmscan.c index b146b427cda..9267ba1b664 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -1012,23 +1012,27 @@ keep_lumpy: | |||
1012 | * | 1012 | * |
1013 | * returns 0 on success, -ve errno on failure. | 1013 | * returns 0 on success, -ve errno on failure. |
1014 | */ | 1014 | */ |
1015 | int __isolate_lru_page(struct page *page, int mode, int file) | 1015 | int __isolate_lru_page(struct page *page, isolate_mode_t mode, int file) |
1016 | { | 1016 | { |
1017 | bool all_lru_mode; | ||
1017 | int ret = -EINVAL; | 1018 | int ret = -EINVAL; |
1018 | 1019 | ||
1019 | /* Only take pages on the LRU. */ | 1020 | /* Only take pages on the LRU. */ |
1020 | if (!PageLRU(page)) | 1021 | if (!PageLRU(page)) |
1021 | return ret; | 1022 | return ret; |
1022 | 1023 | ||
1024 | all_lru_mode = (mode & (ISOLATE_ACTIVE|ISOLATE_INACTIVE)) == | ||
1025 | (ISOLATE_ACTIVE|ISOLATE_INACTIVE); | ||
1026 | |||
1023 | /* | 1027 | /* |
1024 | * When checking the active state, we need to be sure we are | 1028 | * When checking the active state, we need to be sure we are |
1025 | * dealing with comparible boolean values. Take the logical not | 1029 | * dealing with comparible boolean values. Take the logical not |
1026 | * of each. | 1030 | * of each. |
1027 | */ | 1031 | */ |
1028 | if (mode != ISOLATE_BOTH && (!PageActive(page) != !mode)) | 1032 | if (!all_lru_mode && !PageActive(page) != !(mode & ISOLATE_ACTIVE)) |
1029 | return ret; | 1033 | return ret; |
1030 | 1034 | ||
1031 | if (mode != ISOLATE_BOTH && page_is_file_cache(page) != file) | 1035 | if (!all_lru_mode && !!page_is_file_cache(page) != file) |
1032 | return ret; | 1036 | return ret; |
1033 | 1037 | ||
1034 | /* | 1038 | /* |
@@ -1076,7 +1080,8 @@ int __isolate_lru_page(struct page *page, int mode, int file) | |||
1076 | */ | 1080 | */ |
1077 | static unsigned long isolate_lru_pages(unsigned long nr_to_scan, | 1081 | static unsigned long isolate_lru_pages(unsigned long nr_to_scan, |
1078 | struct list_head *src, struct list_head *dst, | 1082 | struct list_head *src, struct list_head *dst, |
1079 | unsigned long *scanned, int order, int mode, int file) | 1083 | unsigned long *scanned, int order, isolate_mode_t mode, |
1084 | int file) | ||
1080 | { | 1085 | { |
1081 | unsigned long nr_taken = 0; | 1086 | unsigned long nr_taken = 0; |
1082 | unsigned long nr_lumpy_taken = 0; | 1087 | unsigned long nr_lumpy_taken = 0; |
@@ -1201,8 +1206,8 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, | |||
1201 | static unsigned long isolate_pages_global(unsigned long nr, | 1206 | static unsigned long isolate_pages_global(unsigned long nr, |
1202 | struct list_head *dst, | 1207 | struct list_head *dst, |
1203 | unsigned long *scanned, int order, | 1208 | unsigned long *scanned, int order, |
1204 | int mode, struct zone *z, | 1209 | isolate_mode_t mode, |
1205 | int active, int file) | 1210 | struct zone *z, int active, int file) |
1206 | { | 1211 | { |
1207 | int lru = LRU_BASE; | 1212 | int lru = LRU_BASE; |
1208 | if (active) | 1213 | if (active) |
@@ -1448,6 +1453,7 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone, | |||
1448 | unsigned long nr_taken; | 1453 | unsigned long nr_taken; |
1449 | unsigned long nr_anon; | 1454 | unsigned long nr_anon; |
1450 | unsigned long nr_file; | 1455 | unsigned long nr_file; |
1456 | isolate_mode_t reclaim_mode = ISOLATE_INACTIVE; | ||
1451 | 1457 | ||
1452 | while (unlikely(too_many_isolated(zone, file, sc))) { | 1458 | while (unlikely(too_many_isolated(zone, file, sc))) { |
1453 | congestion_wait(BLK_RW_ASYNC, HZ/10); | 1459 | congestion_wait(BLK_RW_ASYNC, HZ/10); |
@@ -1458,15 +1464,15 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone, | |||
1458 | } | 1464 | } |
1459 | 1465 | ||
1460 | set_reclaim_mode(priority, sc, false); | 1466 | set_reclaim_mode(priority, sc, false); |
1467 | if (sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM) | ||
1468 | reclaim_mode |= ISOLATE_ACTIVE; | ||
1469 | |||
1461 | lru_add_drain(); | 1470 | lru_add_drain(); |
1462 | spin_lock_irq(&zone->lru_lock); | 1471 | spin_lock_irq(&zone->lru_lock); |
1463 | 1472 | ||
1464 | if (scanning_global_lru(sc)) { | 1473 | if (scanning_global_lru(sc)) { |
1465 | nr_taken = isolate_pages_global(nr_to_scan, | 1474 | nr_taken = isolate_pages_global(nr_to_scan, &page_list, |
1466 | &page_list, &nr_scanned, sc->order, | 1475 | &nr_scanned, sc->order, reclaim_mode, zone, 0, file); |
1467 | sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM ? | ||
1468 | ISOLATE_BOTH : ISOLATE_INACTIVE, | ||
1469 | zone, 0, file); | ||
1470 | zone->pages_scanned += nr_scanned; | 1476 | zone->pages_scanned += nr_scanned; |
1471 | if (current_is_kswapd()) | 1477 | if (current_is_kswapd()) |
1472 | __count_zone_vm_events(PGSCAN_KSWAPD, zone, | 1478 | __count_zone_vm_events(PGSCAN_KSWAPD, zone, |
@@ -1475,12 +1481,9 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone, | |||
1475 | __count_zone_vm_events(PGSCAN_DIRECT, zone, | 1481 | __count_zone_vm_events(PGSCAN_DIRECT, zone, |
1476 | nr_scanned); | 1482 | nr_scanned); |
1477 | } else { | 1483 | } else { |
1478 | nr_taken = mem_cgroup_isolate_pages(nr_to_scan, | 1484 | nr_taken = mem_cgroup_isolate_pages(nr_to_scan, &page_list, |
1479 | &page_list, &nr_scanned, sc->order, | 1485 | &nr_scanned, sc->order, reclaim_mode, zone, |
1480 | sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM ? | 1486 | sc->mem_cgroup, 0, file); |
1481 | ISOLATE_BOTH : ISOLATE_INACTIVE, | ||
1482 | zone, sc->mem_cgroup, | ||
1483 | 0, file); | ||
1484 | /* | 1487 | /* |
1485 | * mem_cgroup_isolate_pages() keeps track of | 1488 | * mem_cgroup_isolate_pages() keeps track of |
1486 | * scanned pages on its own. | 1489 | * scanned pages on its own. |