From: Wu Fengguang <fengguang.wu@intel.com>
To: Jan Kara <jack@suse.cz>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
Christoph Hellwig <hch@infradead.org>,
Dave Chinner <david@fromorbit.com>
Subject: Re: [PATCH 1/2] writeback: Improve busyloop prevention
Date: Wed, 19 Oct 2011 21:35:06 +0800 [thread overview]
Message-ID: <20111019133506.GC13259@localhost> (raw)
In-Reply-To: <20111019115630.GA22266@quack.suse.cz>
> From 595677f8efcaa0d9f675bf74a7048739323afd06 Mon Sep 17 00:00:00 2001
> From: Jan Kara <jack@suse.cz>
> Date: Wed, 19 Oct 2011 13:44:46 +0200
> Subject: [PATCH] writeback: Retry kupdate work early if we need to retry some inode writeback
>
> In case we could not do any writeback for some inodes, trigger next kupdate
> work early so that writeback on these inodes is not delayed for the whole
> dirty_writeback_interval.
Looks good, too.
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> fs/fs-writeback.c | 25 ++++++++++++++++++-------
> 1 files changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 8314241..e48da04 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -701,6 +701,7 @@ static long wb_writeback(struct bdi_writeback *wb,
> unsigned long oldest_jif;
> struct inode *inode;
> long progress;
> + long total_progress = 0;
>
> oldest_jif = jiffies;
> work->older_than_this = &oldest_jif;
> @@ -750,6 +751,7 @@ static long wb_writeback(struct bdi_writeback *wb,
> else
> progress = __writeback_inodes_wb(wb, work);
> trace_writeback_written(wb->bdi, work);
> + total_progress += progress;
>
> wb_update_bandwidth(wb, wb_start);
>
> @@ -783,7 +785,7 @@ static long wb_writeback(struct bdi_writeback *wb,
> }
> spin_unlock(&wb->list_lock);
>
> - return nr_pages - work->nr_pages;
> + return total_progress;
> }
>
> /*
> @@ -845,7 +847,7 @@ static long wb_check_old_data_flush(struct bdi_writeback *wb)
>
> expired = wb->last_old_flush +
> msecs_to_jiffies(dirty_writeback_interval * 10);
> - if (time_before(jiffies, expired))
> + if (time_before(jiffies, expired) && list_empty(&wb->b_more_io_wait))
> return 0;
>
> wb->last_old_flush = jiffies;
> @@ -915,7 +917,11 @@ int bdi_writeback_thread(void *data)
> {
> struct bdi_writeback *wb = data;
> struct backing_dev_info *bdi = wb->bdi;
> - long pages_written;
> + long progress;
I'd like to separate out the pages_written=>progress changes,
which will make two more clear patches.
Thanks,
Fengguang
> + unsigned int pause = 1;
> + unsigned int max_pause = dirty_writeback_interval ?
> + msecs_to_jiffies(dirty_writeback_interval * 10) :
> + HZ;
>
> current->flags |= PF_SWAPWRITE;
> set_freezable();
> @@ -935,12 +941,14 @@ int bdi_writeback_thread(void *data)
> */
> del_timer(&wb->wakeup_timer);
>
> - pages_written = wb_do_writeback(wb, 0);
> + progress = wb_do_writeback(wb, 0);
>
> trace_writeback_pages_written(pages_written);
>
> - if (pages_written)
> + if (progress) {
> wb->last_active = jiffies;
> + pause = 1;
> + }
>
> set_current_state(TASK_INTERRUPTIBLE);
> if (!list_empty(&bdi->work_list) || kthread_should_stop()) {
> @@ -948,8 +956,11 @@ int bdi_writeback_thread(void *data)
> continue;
> }
>
> - if (wb_has_dirty_io(wb) && dirty_writeback_interval)
> - schedule_timeout(msecs_to_jiffies(dirty_writeback_interval * 10));
> + if (!list_empty(&wb->b_more_io_wait) && pause < max_pause) {
> + schedule_timeout(pause);
> + pause <<= 1;
> + } else if (wb_has_dirty_io(wb) && dirty_writeback_interval)
> + schedule_timeout(max_pause);
> else {
> /*
> * We have nothing to do, so can go sleep without any
> --
> 1.7.1
>
next prev parent reply other threads:[~2011-10-19 13:35 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-12 20:57 [PATCH 0/2 v4] writeback: Improve busyloop prevention and inode requeueing Jan Kara
2011-10-12 20:57 ` [PATCH 1/2] writeback: Improve busyloop prevention Jan Kara
2011-10-13 14:26 ` Wu Fengguang
2011-10-13 20:13 ` Jan Kara
2011-10-14 7:18 ` Christoph Hellwig
2011-10-14 19:31 ` Chris Mason
[not found] ` <20111013143939.GA9691@localhost>
2011-10-13 20:18 ` Jan Kara
2011-10-14 16:00 ` Wu Fengguang
2011-10-14 16:28 ` Wu Fengguang
2011-10-18 0:51 ` Jan Kara
2011-10-18 14:35 ` Wu Fengguang
2011-10-19 11:56 ` Jan Kara
2011-10-19 13:25 ` Wu Fengguang
2011-10-19 13:30 ` Wu Fengguang
2011-10-19 13:35 ` Wu Fengguang [this message]
2011-10-20 12:09 ` Wu Fengguang
2011-10-20 12:33 ` Wu Fengguang
2011-10-20 13:39 ` Wu Fengguang
2011-10-20 22:26 ` Jan Kara
2011-10-22 4:20 ` Wu Fengguang
2011-10-24 15:45 ` Jan Kara
[not found] ` <20111027063133.GA10146@localhost>
2011-10-27 20:31 ` Jan Kara
[not found] ` <20111101134231.GA31718@localhost>
2011-11-01 21:53 ` Jan Kara
2011-11-02 17:25 ` Wu Fengguang
[not found] ` <20111102185603.GA4034@localhost>
2011-11-03 1:51 ` Jan Kara
2011-11-03 14:52 ` Wu Fengguang
[not found] ` <20111104152054.GA11577@localhost>
2011-11-08 23:52 ` Jan Kara
2011-11-09 13:51 ` Wu Fengguang
2011-11-10 14:50 ` Jan Kara
2011-12-05 8:02 ` Wu Fengguang
2011-12-07 10:13 ` Jan Kara
2011-12-07 11:45 ` Wu Fengguang
[not found] ` <20111027064745.GA14017@localhost>
2011-10-27 20:50 ` Jan Kara
2011-10-20 9:46 ` Christoph Hellwig
2011-10-20 15:32 ` Jan Kara
2011-10-15 12:41 ` Wu Fengguang
2011-10-12 20:57 ` [PATCH 2/2] writeback: Replace some redirty_tail() calls with requeue_io() Jan Kara
2011-10-13 14:30 ` Wu Fengguang
2011-10-13 14:15 ` [PATCH 0/2 v4] writeback: Improve busyloop prevention and inode requeueing Wu Fengguang
-- strict thread matches above, loose matches on Subject: below --
2011-09-08 0:44 [PATCH 1/2] writeback: Improve busyloop prevention Jan Kara
2011-09-08 0:57 ` Wu Fengguang
2011-09-08 13:49 ` Jan Kara
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=20111019133506.GC13259@localhost \
--to=fengguang.wu@intel.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).