aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/writeback.h21
-rw-r--r--mm/page-writeback.c33
2 files changed, 54 insertions, 0 deletions
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index e9d371b6053b..b625073b80c8 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -7,6 +7,27 @@
7#include <linux/sched.h> 7#include <linux/sched.h>
8#include <linux/fs.h> 8#include <linux/fs.h>
9 9
10/*
11 * The 1/16 region above the global dirty limit will be put to maximum pauses:
12 *
13 * (limit, limit + limit/DIRTY_MAXPAUSE_AREA)
14 *
15 * The 1/16 region above the max-pause region, dirty exceeded bdi's will be put
16 * to loops:
17 *
18 * (limit + limit/DIRTY_MAXPAUSE_AREA, limit + limit/DIRTY_PASSGOOD_AREA)
19 *
20 * Further beyond, all dirtier tasks will enter a loop waiting (possibly long
21 * time) for the dirty pages to drop, unless written enough pages.
22 *
23 * The global dirty threshold is normally equal to the global dirty limit,
24 * except when the system suddenly allocates a lot of anonymous memory and
25 * knocks down the global dirty threshold quickly, in which case the global
26 * dirty limit will follow down slowly to prevent livelocking all dirtier tasks.
27 */
28#define DIRTY_MAXPAUSE_AREA 16
29#define DIRTY_PASSGOOD_AREA 8
30
10struct backing_dev_info; 31struct backing_dev_info;
11 32
12/* 33/*
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index da959952b9f5..798842a22474 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -37,6 +37,11 @@
37#include <trace/events/writeback.h> 37#include <trace/events/writeback.h>
38 38
39/* 39/*
40 * Sleep at most 200ms at a time in balance_dirty_pages().
41 */
42#define MAX_PAUSE max(HZ/5, 1)
43
44/*
40 * Estimate write bandwidth at 200ms intervals. 45 * Estimate write bandwidth at 200ms intervals.
41 */ 46 */
42#define BANDWIDTH_INTERVAL max(HZ/5, 1) 47#define BANDWIDTH_INTERVAL max(HZ/5, 1)
@@ -399,6 +404,11 @@ unsigned long determine_dirtyable_memory(void)
399 return x + 1; /* Ensure that we never return 0 */ 404 return x + 1; /* Ensure that we never return 0 */
400} 405}
401 406
407static unsigned long hard_dirty_limit(unsigned long thresh)
408{
409 return max(thresh, global_dirty_limit);
410}
411
402/* 412/*
403 * global_dirty_limits - background-writeback and dirty-throttling thresholds 413 * global_dirty_limits - background-writeback and dirty-throttling thresholds
404 * 414 *
@@ -723,6 +733,29 @@ static void balance_dirty_pages(struct address_space *mapping,
723 io_schedule_timeout(pause); 733 io_schedule_timeout(pause);
724 trace_balance_dirty_wait(bdi); 734 trace_balance_dirty_wait(bdi);
725 735
736 dirty_thresh = hard_dirty_limit(dirty_thresh);
737 /*
738 * max-pause area. If dirty exceeded but still within this
739 * area, no need to sleep for more than 200ms: (a) 8 pages per
740 * 200ms is typically more than enough to curb heavy dirtiers;
741 * (b) the pause time limit makes the dirtiers more responsive.
742 */
743 if (nr_dirty < dirty_thresh +
744 dirty_thresh / DIRTY_MAXPAUSE_AREA &&
745 time_after(jiffies, start_time + MAX_PAUSE))
746 break;
747 /*
748 * pass-good area. When some bdi gets blocked (eg. NFS server
749 * not responding), or write bandwidth dropped dramatically due
750 * to concurrent reads, or dirty threshold suddenly dropped and
751 * the dirty pages cannot be brought down anytime soon (eg. on
752 * slow USB stick), at least let go of the good bdi's.
753 */
754 if (nr_dirty < dirty_thresh +
755 dirty_thresh / DIRTY_PASSGOOD_AREA &&
756 bdi_dirty < bdi_thresh)
757 break;
758
726 /* 759 /*
727 * Increase the delay for each loop, up to our previous 760 * Increase the delay for each loop, up to our previous
728 * default of taking a 100ms nap. 761 * default of taking a 100ms nap.