diff options
Diffstat (limited to 'mm/vmstat.c')
-rw-r--r-- | mm/vmstat.c | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/mm/vmstat.c b/mm/vmstat.c index 355a9e669aaa..4d7faebb9b70 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c | |||
@@ -81,6 +81,30 @@ EXPORT_SYMBOL(vm_stat); | |||
81 | 81 | ||
82 | #ifdef CONFIG_SMP | 82 | #ifdef CONFIG_SMP |
83 | 83 | ||
84 | static int calculate_pressure_threshold(struct zone *zone) | ||
85 | { | ||
86 | int threshold; | ||
87 | int watermark_distance; | ||
88 | |||
89 | /* | ||
90 | * As vmstats are not up to date, there is drift between the estimated | ||
91 | * and real values. For high thresholds and a high number of CPUs, it | ||
92 | * is possible for the min watermark to be breached while the estimated | ||
93 | * value looks fine. The pressure threshold is a reduced value such | ||
94 | * that even the maximum amount of drift will not accidentally breach | ||
95 | * the min watermark | ||
96 | */ | ||
97 | watermark_distance = low_wmark_pages(zone) - min_wmark_pages(zone); | ||
98 | threshold = max(1, (int)(watermark_distance / num_online_cpus())); | ||
99 | |||
100 | /* | ||
101 | * Maximum threshold is 125 | ||
102 | */ | ||
103 | threshold = min(125, threshold); | ||
104 | |||
105 | return threshold; | ||
106 | } | ||
107 | |||
84 | static int calculate_threshold(struct zone *zone) | 108 | static int calculate_threshold(struct zone *zone) |
85 | { | 109 | { |
86 | int threshold; | 110 | int threshold; |
@@ -159,6 +183,48 @@ static void refresh_zone_stat_thresholds(void) | |||
159 | } | 183 | } |
160 | } | 184 | } |
161 | 185 | ||
186 | void reduce_pgdat_percpu_threshold(pg_data_t *pgdat) | ||
187 | { | ||
188 | struct zone *zone; | ||
189 | int cpu; | ||
190 | int threshold; | ||
191 | int i; | ||
192 | |||
193 | get_online_cpus(); | ||
194 | for (i = 0; i < pgdat->nr_zones; i++) { | ||
195 | zone = &pgdat->node_zones[i]; | ||
196 | if (!zone->percpu_drift_mark) | ||
197 | continue; | ||
198 | |||
199 | threshold = calculate_pressure_threshold(zone); | ||
200 | for_each_online_cpu(cpu) | ||
201 | per_cpu_ptr(zone->pageset, cpu)->stat_threshold | ||
202 | = threshold; | ||
203 | } | ||
204 | put_online_cpus(); | ||
205 | } | ||
206 | |||
207 | void restore_pgdat_percpu_threshold(pg_data_t *pgdat) | ||
208 | { | ||
209 | struct zone *zone; | ||
210 | int cpu; | ||
211 | int threshold; | ||
212 | int i; | ||
213 | |||
214 | get_online_cpus(); | ||
215 | for (i = 0; i < pgdat->nr_zones; i++) { | ||
216 | zone = &pgdat->node_zones[i]; | ||
217 | if (!zone->percpu_drift_mark) | ||
218 | continue; | ||
219 | |||
220 | threshold = calculate_threshold(zone); | ||
221 | for_each_online_cpu(cpu) | ||
222 | per_cpu_ptr(zone->pageset, cpu)->stat_threshold | ||
223 | = threshold; | ||
224 | } | ||
225 | put_online_cpus(); | ||
226 | } | ||
227 | |||
162 | /* | 228 | /* |
163 | * For use when we know that interrupts are disabled. | 229 | * For use when we know that interrupts are disabled. |
164 | */ | 230 | */ |
@@ -826,7 +892,7 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat, | |||
826 | "\n scanned %lu" | 892 | "\n scanned %lu" |
827 | "\n spanned %lu" | 893 | "\n spanned %lu" |
828 | "\n present %lu", | 894 | "\n present %lu", |
829 | zone_nr_free_pages(zone), | 895 | zone_page_state(zone, NR_FREE_PAGES), |
830 | min_wmark_pages(zone), | 896 | min_wmark_pages(zone), |
831 | low_wmark_pages(zone), | 897 | low_wmark_pages(zone), |
832 | high_wmark_pages(zone), | 898 | high_wmark_pages(zone), |