Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: mm/vmscan.c

Issue 4128001: CHROMIUM: vmscan: add min_filelist_kbytes sysctl for protecting the working set (Closed) Base URL: http://git.chromium.org/git/kernel.git
Patch Set: Handle cgroup case. Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « kernel/sysctl.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * linux/mm/vmscan.c 2 * linux/mm/vmscan.c
3 * 3 *
4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
5 * 5 *
6 * Swap reorganised 29.12.95, Stephen Tweedie. 6 * Swap reorganised 29.12.95, Stephen Tweedie.
7 * kswapd added: 7.1.96 sct 7 * kswapd added: 7.1.96 sct
8 * Removed kswapd_ctl limits, and swap out as many pages as needed 8 * Removed kswapd_ctl limits, and swap out as many pages as needed
9 * to bring the system back to freepages.high: 2.4.97, Rik van Riel. 9 * to bring the system back to freepages.high: 2.4.97, Rik van Riel.
10 * Zone aware kswapd started 02/00, Kanoj Sarcar (kanoj@sgi.com). 10 * Zone aware kswapd started 02/00, Kanoj Sarcar (kanoj@sgi.com).
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 #else 123 #else
124 #define prefetchw_prev_lru_page(_page, _base, _field) do { } while (0) 124 #define prefetchw_prev_lru_page(_page, _base, _field) do { } while (0)
125 #endif 125 #endif
126 126
127 /* 127 /*
128 * From 0 .. 100. Higher means more swappy. 128 * From 0 .. 100. Higher means more swappy.
129 */ 129 */
130 int vm_swappiness = 60; 130 int vm_swappiness = 60;
131 long vm_total_pages; /* The total number of pages which the VM controls */ 131 long vm_total_pages; /* The total number of pages which the VM controls */
132 132
133 /*
134 * Low watermark used to prevent fscache thrashing during low memory.
135 */
136 int min_filelist_kbytes = 0;
137
133 static LIST_HEAD(shrinker_list); 138 static LIST_HEAD(shrinker_list);
134 static DECLARE_RWSEM(shrinker_rwsem); 139 static DECLARE_RWSEM(shrinker_rwsem);
135 140
136 #ifdef CONFIG_CGROUP_MEM_RES_CTLR 141 #ifdef CONFIG_CGROUP_MEM_RES_CTLR
137 #define scanning_global_lru(sc) (!(sc)->mem_cgroup) 142 #define scanning_global_lru(sc) (!(sc)->mem_cgroup)
138 #else 143 #else
139 #define scanning_global_lru(sc) (1) 144 #define scanning_global_lru(sc) (1)
140 #endif 145 #endif
141 146
142 static struct zone_reclaim_stat *get_reclaim_stat(struct zone *zone, 147 static struct zone_reclaim_stat *get_reclaim_stat(struct zone *zone,
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 1508
1504 static int inactive_list_is_low(struct zone *zone, struct scan_control *sc, 1509 static int inactive_list_is_low(struct zone *zone, struct scan_control *sc,
1505 int file) 1510 int file)
1506 { 1511 {
1507 if (file) 1512 if (file)
1508 return inactive_file_is_low(zone, sc); 1513 return inactive_file_is_low(zone, sc);
1509 else 1514 else
1510 return inactive_anon_is_low(zone, sc); 1515 return inactive_anon_is_low(zone, sc);
1511 } 1516 }
1512 1517
1518 /*
1519 * Check low watermark used to prevent fscache thrashing during low memory.
1520 */
1521 static int file_is_low(struct zone *zone, struct scan_control *sc)
1522 {
1523 unsigned long pages_min, active, inactive;
1524
1525 if (!scanning_global_lru(sc))
1526 return false;
1527
1528 pages_min = min_filelist_kbytes >> (PAGE_SHIFT - 10);
1529 active = zone_page_state(zone, NR_ACTIVE_FILE);
1530 inactive = zone_page_state(zone, NR_INACTIVE_FILE);
1531
1532 return ((active + inactive) < pages_min);
1533 }
1534
1513 static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan, 1535 static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,
1514 struct zone *zone, struct scan_control *sc, int priority) 1536 struct zone *zone, struct scan_control *sc, int priority)
1515 { 1537 {
1516 int file = is_file_lru(lru); 1538 int file = is_file_lru(lru);
1517 1539
1540 if (file && file_is_low(zone, sc))
1541 return 0;
1542
1518 if (is_active_lru(lru)) { 1543 if (is_active_lru(lru)) {
1519 if (inactive_list_is_low(zone, sc, file)) 1544 if (inactive_list_is_low(zone, sc, file))
1520 shrink_active_list(nr_to_scan, zone, sc, priority, file); 1545 shrink_active_list(nr_to_scan, zone, sc, priority, file);
1521 return 0; 1546 return 0;
1522 } 1547 }
1523 1548
1524 return shrink_inactive_list(nr_to_scan, zone, sc, priority, file); 1549 return shrink_inactive_list(nr_to_scan, zone, sc, priority, file);
1525 } 1550 }
1526 1551
1527 /* 1552 /*
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2949 int scan_unevictable_register_node(struct node *node) 2974 int scan_unevictable_register_node(struct node *node)
2950 { 2975 {
2951 return sysdev_create_file(&node->sysdev, &attr_scan_unevictable_pages); 2976 return sysdev_create_file(&node->sysdev, &attr_scan_unevictable_pages);
2952 } 2977 }
2953 2978
2954 void scan_unevictable_unregister_node(struct node *node) 2979 void scan_unevictable_unregister_node(struct node *node)
2955 { 2980 {
2956 sysdev_remove_file(&node->sysdev, &attr_scan_unevictable_pages); 2981 sysdev_remove_file(&node->sysdev, &attr_scan_unevictable_pages);
2957 } 2982 }
2958 2983
OLDNEW
« no previous file with comments | « kernel/sysctl.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698