From: Wu Fengguang <fengguang.wu@intel.com>
To: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Cc: Jan Kara <jack@suse.cz>, Dave Chinner <david@fromorbit.com>,
Christoph Hellwig <hch@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Wu Fengguang <fengguang.wu@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 7/7] writeback: timestamp based bdi dirty_exceeded state
Date: Sun, 19 Jun 2011 23:01:15 +0800 [thread overview]
Message-ID: <20110619150510.717948499@intel.com> (raw)
In-Reply-To: 20110619150108.691351746@intel.com
[-- Attachment #1: writeback-dirty-exceed-time.patch --]
[-- Type: text/plain, Size: 3705 bytes --]
When there are only one (or several) dirtiers, dirty_exceeded is always
(or mostly) off. Converting to timestamp avoids this problem. It helps
to use smaller write_chunk for smoother throttling.
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
Before patch, the wait time in balance_dirty_pages() are ~200ms:
[ 1093.397700] write_bandwidth: comm=swapper pages=1536 time=204ms
[ 1093.594319] write_bandwidth: comm=swapper pages=1536 time=196ms
[ 1093.796642] write_bandwidth: comm=swapper pages=1536 time=200ms
After patch, ~25ms:
[ 90.261339] write_bandwidth: comm=swapper pages=192 time=20ms
[ 90.293168] write_bandwidth: comm=swapper pages=192 time=24ms
[ 90.323853] write_bandwidth: comm=swapper pages=192 time=24ms
[ 90.354510] write_bandwidth: comm=swapper pages=192 time=28ms
[ 90.389890] write_bandwidth: comm=swapper pages=192 time=28ms
[ 90.421787] write_bandwidth: comm=swapper pages=192 time=24ms
include/linux/backing-dev.h | 2 +-
mm/backing-dev.c | 2 --
mm/page-writeback.c | 24 ++++++++++++------------
3 files changed, 13 insertions(+), 15 deletions(-)
--- linux-next.orig/mm/page-writeback.c 2011-06-19 22:59:49.000000000 +0800
+++ linux-next/mm/page-writeback.c 2011-06-19 22:59:53.000000000 +0800
@@ -483,6 +483,15 @@ unsigned long bdi_dirty_limit(struct bac
return bdi_dirty;
}
+/*
+ * last time exceeded (limit - limit/DIRTY_BRAKE)
+ */
+static bool dirty_exceeded_recently(struct backing_dev_info *bdi,
+ unsigned long time_window)
+{
+ return jiffies - bdi->dirty_exceed_time <= time_window;
+}
+
static void bdi_update_write_bandwidth(struct backing_dev_info *bdi,
unsigned long elapsed,
unsigned long written)
@@ -621,7 +630,6 @@ static void balance_dirty_pages(struct a
unsigned long bdi_thresh;
unsigned long pages_written = 0;
unsigned long pause = 1;
- bool dirty_exceeded = false;
struct backing_dev_info *bdi = mapping->backing_dev_info;
unsigned long start_time = jiffies;
@@ -669,14 +677,9 @@ static void balance_dirty_pages(struct a
* bdi or process from holding back light ones; The latter is
* the last resort safeguard.
*/
- dirty_exceeded = (bdi_dirty > bdi_thresh) ||
- (nr_dirty > dirty_thresh);
-
- if (!dirty_exceeded)
+ if (bdi_dirty <= bdi_thresh && nr_dirty <= dirty_thresh)
break;
-
- if (!bdi->dirty_exceeded)
- bdi->dirty_exceeded = 1;
+ bdi->dirty_exceed_time = jiffies;
bdi_update_bandwidth(bdi, dirty_thresh, nr_dirty, bdi_dirty,
start_time);
@@ -719,9 +722,6 @@ static void balance_dirty_pages(struct a
pause = HZ / 10;
}
- if (!dirty_exceeded && bdi->dirty_exceeded)
- bdi->dirty_exceeded = 0;
-
if (writeback_in_progress(bdi))
return;
@@ -775,7 +775,7 @@ void balance_dirty_pages_ratelimited_nr(
return;
ratelimit = ratelimit_pages;
- if (mapping->backing_dev_info->dirty_exceeded)
+ if (dirty_exceeded_recently(bdi, MAX_PAUSE))
ratelimit = 8;
/*
--- linux-next.orig/include/linux/backing-dev.h 2011-06-19 22:54:58.000000000 +0800
+++ linux-next/include/linux/backing-dev.h 2011-06-19 22:59:53.000000000 +0800
@@ -79,7 +79,7 @@ struct backing_dev_info {
unsigned long avg_write_bandwidth;
struct prop_local_percpu completions;
- int dirty_exceeded;
+ unsigned long dirty_exceed_time;
unsigned int min_ratio;
unsigned int max_ratio, max_prop_frac;
--- linux-next.orig/mm/backing-dev.c 2011-06-19 22:59:49.000000000 +0800
+++ linux-next/mm/backing-dev.c 2011-06-19 22:59:53.000000000 +0800
@@ -670,8 +670,6 @@ int bdi_init(struct backing_dev_info *bd
goto err;
}
- bdi->dirty_exceeded = 0;
-
bdi->bw_time_stamp = jiffies;
bdi->written_stamp = 0;
next prev parent reply other threads:[~2011-06-19 15:28 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-19 15:01 [PATCH 0/7] more writeback patches for 3.1 Wu Fengguang
2011-06-19 15:01 ` [PATCH 1/7] writeback: consolidate variable names in balance_dirty_pages() Wu Fengguang
2011-06-20 7:45 ` Christoph Hellwig
2011-06-19 15:01 ` [PATCH 2/7] writeback: add parameters to __bdi_update_bandwidth() Wu Fengguang
2011-06-19 15:31 ` Christoph Hellwig
2011-06-19 15:35 ` Wu Fengguang
2011-06-19 15:01 ` [PATCH 3/7] writeback: introduce smoothed global dirty limit Wu Fengguang
2011-06-19 15:36 ` Christoph Hellwig
2011-06-19 15:55 ` Wu Fengguang
2011-06-21 23:59 ` Andrew Morton
2011-06-22 14:11 ` Wu Fengguang
2011-06-20 21:18 ` Jan Kara
2011-06-21 14:24 ` Wu Fengguang
2011-06-22 0:04 ` Andrew Morton
2011-06-22 14:24 ` Wu Fengguang
2011-06-19 15:01 ` [PATCH 4/7] writeback: introduce max-pause and pass-good dirty limits Wu Fengguang
2011-06-22 0:20 ` Andrew Morton
2011-06-23 13:18 ` Wu Fengguang
2011-06-19 15:01 ` [PATCH 5/7] writeback: make writeback_control.nr_to_write straight Wu Fengguang
2011-06-19 15:35 ` Christoph Hellwig
2011-06-19 16:14 ` Wu Fengguang
2011-06-19 15:01 ` [PATCH 6/7] writeback: scale IO chunk size up to half device bandwidth Wu Fengguang
2011-06-19 15:01 ` Wu Fengguang [this message]
2011-06-20 20:09 ` [PATCH 7/7] writeback: timestamp based bdi dirty_exceeded state Christoph Hellwig
2011-06-21 10:00 ` Steven Whitehouse
2011-06-20 21:38 ` Jan Kara
2011-06-21 15:07 ` Wu Fengguang
2011-06-21 21:14 ` Jan Kara
2011-06-22 14:37 ` Wu Fengguang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110619150510.717948499@intel.com \
--to=fengguang.wu@intel.com \
--cc=akpm@linux-foundation.org \
--cc=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.