diff options
Diffstat (limited to 'mm/page-writeback.c')
| -rw-r--r-- | mm/page-writeback.c | 27 | 
1 files changed, 17 insertions, 10 deletions
| diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 838a5e31394c..d55cfcae2ef1 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
| @@ -297,20 +297,12 @@ get_dirty_limits(long *pbackground, long *pdirty, long *pbdi_dirty, | |||
| 297 | { | 297 | { | 
| 298 | int background_ratio; /* Percentages */ | 298 | int background_ratio; /* Percentages */ | 
| 299 | int dirty_ratio; | 299 | int dirty_ratio; | 
| 300 | int unmapped_ratio; | ||
| 301 | long background; | 300 | long background; | 
| 302 | long dirty; | 301 | long dirty; | 
| 303 | unsigned long available_memory = determine_dirtyable_memory(); | 302 | unsigned long available_memory = determine_dirtyable_memory(); | 
| 304 | struct task_struct *tsk; | 303 | struct task_struct *tsk; | 
| 305 | 304 | ||
| 306 | unmapped_ratio = 100 - ((global_page_state(NR_FILE_MAPPED) + | ||
| 307 | global_page_state(NR_ANON_PAGES)) * 100) / | ||
| 308 | available_memory; | ||
| 309 | |||
| 310 | dirty_ratio = vm_dirty_ratio; | 305 | dirty_ratio = vm_dirty_ratio; | 
| 311 | if (dirty_ratio > unmapped_ratio / 2) | ||
| 312 | dirty_ratio = unmapped_ratio / 2; | ||
| 313 | |||
| 314 | if (dirty_ratio < 5) | 306 | if (dirty_ratio < 5) | 
| 315 | dirty_ratio = 5; | 307 | dirty_ratio = 5; | 
| 316 | 308 | ||
| @@ -355,8 +347,8 @@ get_dirty_limits(long *pbackground, long *pdirty, long *pbdi_dirty, | |||
| 355 | */ | 347 | */ | 
| 356 | static void balance_dirty_pages(struct address_space *mapping) | 348 | static void balance_dirty_pages(struct address_space *mapping) | 
| 357 | { | 349 | { | 
| 358 | long bdi_nr_reclaimable; | 350 | long nr_reclaimable, bdi_nr_reclaimable; | 
| 359 | long bdi_nr_writeback; | 351 | long nr_writeback, bdi_nr_writeback; | 
| 360 | long background_thresh; | 352 | long background_thresh; | 
| 361 | long dirty_thresh; | 353 | long dirty_thresh; | 
| 362 | long bdi_thresh; | 354 | long bdi_thresh; | 
| @@ -376,11 +368,26 @@ static void balance_dirty_pages(struct address_space *mapping) | |||
| 376 | 368 | ||
| 377 | get_dirty_limits(&background_thresh, &dirty_thresh, | 369 | get_dirty_limits(&background_thresh, &dirty_thresh, | 
| 378 | &bdi_thresh, bdi); | 370 | &bdi_thresh, bdi); | 
| 371 | |||
| 372 | nr_reclaimable = global_page_state(NR_FILE_DIRTY) + | ||
| 373 | global_page_state(NR_UNSTABLE_NFS); | ||
| 374 | nr_writeback = global_page_state(NR_WRITEBACK); | ||
| 375 | |||
| 379 | bdi_nr_reclaimable = bdi_stat(bdi, BDI_RECLAIMABLE); | 376 | bdi_nr_reclaimable = bdi_stat(bdi, BDI_RECLAIMABLE); | 
| 380 | bdi_nr_writeback = bdi_stat(bdi, BDI_WRITEBACK); | 377 | bdi_nr_writeback = bdi_stat(bdi, BDI_WRITEBACK); | 
| 378 | |||
| 381 | if (bdi_nr_reclaimable + bdi_nr_writeback <= bdi_thresh) | 379 | if (bdi_nr_reclaimable + bdi_nr_writeback <= bdi_thresh) | 
| 382 | break; | 380 | break; | 
| 383 | 381 | ||
| 382 | /* | ||
| 383 | * Throttle it only when the background writeback cannot | ||
| 384 | * catch-up. This avoids (excessively) small writeouts | ||
| 385 | * when the bdi limits are ramping up. | ||
| 386 | */ | ||
| 387 | if (nr_reclaimable + nr_writeback < | ||
| 388 | (background_thresh + dirty_thresh) / 2) | ||
| 389 | break; | ||
| 390 | |||
| 384 | if (!bdi->dirty_exceeded) | 391 | if (!bdi->dirty_exceeded) | 
| 385 | bdi->dirty_exceeded = 1; | 392 | bdi->dirty_exceeded = 1; | 
| 386 | 393 | ||
