aboutsummaryrefslogtreecommitdiffstats
path: root/mm/page-writeback.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/page-writeback.c')
-rw-r--r--mm/page-writeback.c62
1 files changed, 29 insertions, 33 deletions
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 63807583d8e8..7106cb1aca8e 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -191,6 +191,26 @@ static unsigned long writeout_period_time = 0;
191 * global dirtyable memory first. 191 * global dirtyable memory first.
192 */ 192 */
193 193
194/**
195 * zone_dirtyable_memory - number of dirtyable pages in a zone
196 * @zone: the zone
197 *
198 * Returns the zone's number of pages potentially available for dirty
199 * page cache. This is the base value for the per-zone dirty limits.
200 */
201static unsigned long zone_dirtyable_memory(struct zone *zone)
202{
203 unsigned long nr_pages;
204
205 nr_pages = zone_page_state(zone, NR_FREE_PAGES);
206 nr_pages -= min(nr_pages, zone->dirty_balance_reserve);
207
208 nr_pages += zone_page_state(zone, NR_INACTIVE_FILE);
209 nr_pages += zone_page_state(zone, NR_ACTIVE_FILE);
210
211 return nr_pages;
212}
213
194static unsigned long highmem_dirtyable_memory(unsigned long total) 214static unsigned long highmem_dirtyable_memory(unsigned long total)
195{ 215{
196#ifdef CONFIG_HIGHMEM 216#ifdef CONFIG_HIGHMEM
@@ -198,11 +218,9 @@ static unsigned long highmem_dirtyable_memory(unsigned long total)
198 unsigned long x = 0; 218 unsigned long x = 0;
199 219
200 for_each_node_state(node, N_HIGH_MEMORY) { 220 for_each_node_state(node, N_HIGH_MEMORY) {
201 struct zone *z = 221 struct zone *z = &NODE_DATA(node)->node_zones[ZONE_HIGHMEM];
202 &NODE_DATA(node)->node_zones[ZONE_HIGHMEM];
203 222
204 x += zone_page_state(z, NR_FREE_PAGES) + 223 x += zone_dirtyable_memory(z);
205 zone_reclaimable_pages(z) - z->dirty_balance_reserve;
206 } 224 }
207 /* 225 /*
208 * Unreclaimable memory (kernel memory or anonymous memory 226 * Unreclaimable memory (kernel memory or anonymous memory
@@ -238,9 +256,12 @@ static unsigned long global_dirtyable_memory(void)
238{ 256{
239 unsigned long x; 257 unsigned long x;
240 258
241 x = global_page_state(NR_FREE_PAGES) + global_reclaimable_pages(); 259 x = global_page_state(NR_FREE_PAGES);
242 x -= min(x, dirty_balance_reserve); 260 x -= min(x, dirty_balance_reserve);
243 261
262 x += global_page_state(NR_INACTIVE_FILE);
263 x += global_page_state(NR_ACTIVE_FILE);
264
244 if (!vm_highmem_is_dirtyable) 265 if (!vm_highmem_is_dirtyable)
245 x -= highmem_dirtyable_memory(x); 266 x -= highmem_dirtyable_memory(x);
246 267
@@ -289,32 +310,6 @@ void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty)
289} 310}
290 311
291/** 312/**
292 * zone_dirtyable_memory - number of dirtyable pages in a zone
293 * @zone: the zone
294 *
295 * Returns the zone's number of pages potentially available for dirty
296 * page cache. This is the base value for the per-zone dirty limits.
297 */
298static unsigned long zone_dirtyable_memory(struct zone *zone)
299{
300 /*
301 * The effective global number of dirtyable pages may exclude
302 * highmem as a big-picture measure to keep the ratio between
303 * dirty memory and lowmem reasonable.
304 *
305 * But this function is purely about the individual zone and a
306 * highmem zone can hold its share of dirty pages, so we don't
307 * care about vm_highmem_is_dirtyable here.
308 */
309 unsigned long nr_pages = zone_page_state(zone, NR_FREE_PAGES) +
310 zone_reclaimable_pages(zone);
311
312 /* don't allow this to underflow */
313 nr_pages -= min(nr_pages, zone->dirty_balance_reserve);
314 return nr_pages;
315}
316
317/**
318 * zone_dirty_limit - maximum number of dirty pages allowed in a zone 313 * zone_dirty_limit - maximum number of dirty pages allowed in a zone
319 * @zone: the zone 314 * @zone: the zone
320 * 315 *
@@ -2178,11 +2173,12 @@ int __set_page_dirty_nobuffers(struct page *page)
2178 if (!TestSetPageDirty(page)) { 2173 if (!TestSetPageDirty(page)) {
2179 struct address_space *mapping = page_mapping(page); 2174 struct address_space *mapping = page_mapping(page);
2180 struct address_space *mapping2; 2175 struct address_space *mapping2;
2176 unsigned long flags;
2181 2177
2182 if (!mapping) 2178 if (!mapping)
2183 return 1; 2179 return 1;
2184 2180
2185 spin_lock_irq(&mapping->tree_lock); 2181 spin_lock_irqsave(&mapping->tree_lock, flags);
2186 mapping2 = page_mapping(page); 2182 mapping2 = page_mapping(page);
2187 if (mapping2) { /* Race with truncate? */ 2183 if (mapping2) { /* Race with truncate? */
2188 BUG_ON(mapping2 != mapping); 2184 BUG_ON(mapping2 != mapping);
@@ -2191,7 +2187,7 @@ int __set_page_dirty_nobuffers(struct page *page)
2191 radix_tree_tag_set(&mapping->page_tree, 2187 radix_tree_tag_set(&mapping->page_tree,
2192 page_index(page), PAGECACHE_TAG_DIRTY); 2188 page_index(page), PAGECACHE_TAG_DIRTY);
2193 } 2189 }
2194 spin_unlock_irq(&mapping->tree_lock); 2190 spin_unlock_irqrestore(&mapping->tree_lock, flags);
2195 if (mapping->host) { 2191 if (mapping->host) {
2196 /* !PageAnon && !swapper_space */ 2192 /* !PageAnon && !swapper_space */
2197 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); 2193 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);