From: Jan Kara <jack@suse.cz>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
hch@infradead.org, akpm@linux-foundation.org,
wfg@mail.ustc.edu.cn
Subject: Re: [PATCH RFC] mm: Implement balance_dirty_pages() through waiting for flusher thread
Date: Mon, 21 Jun 2010 16:02:37 +0200 [thread overview]
Message-ID: <20100621140236.GF3828@quack.suse.cz> (raw)
In-Reply-To: <1276856496.27822.1698.camel@twins>
On Fri 18-06-10 12:21:36, Peter Zijlstra wrote:
> On Thu, 2010-06-17 at 20:04 +0200, Jan Kara wrote:
> > +/* Wait until write_chunk is written or we get below dirty limits */
> > +void bdi_wait_written(struct backing_dev_info *bdi, long write_chunk)
> > +{
> > + struct bdi_written_count wc = {
> > + .list = LIST_HEAD_INIT(wc.list),
> > + .written = write_chunk,
> > + };
> > + DECLARE_WAITQUEUE(wait, current);
> > + int pause = 1;
> > +
> > + bdi_add_writer(bdi, &wc, &wait);
> > + for (;;) {
> > + if (signal_pending_state(TASK_KILLABLE, current))
> > + break;
> > +
> > + /*
> > + * Make the task just killable so that tasks cannot circumvent
> > + * throttling by sending themselves non-fatal signals...
> > + */
> > + __set_current_state(TASK_KILLABLE);
> > + io_schedule_timeout(pause);
> > +
> > + /*
> > + * The following check is save without wb_written_wait.lock
> > + * because once bdi_remove_writer removes us from the list
> > + * noone will touch us and it's impossible for list_empty check
> > + * to trigger as false positive. The barrier is there to avoid
> > + * missing the wakeup when we are removed from the list.
> > + */
> > + smp_rmb();
> > + if (list_empty(&wc.list))
> > + break;
> > +
> > + if (!dirty_limits_exceeded(bdi))
> > + break;
> > +
> > + /*
> > + * Increase the delay for each loop, up to our previous
> > + * default of taking a 100ms nap.
> > + */
> > + pause <<= 1;
> > + if (pause > HZ / 10)
> > + pause = HZ / 10;
> > + }
> > +
> > + spin_lock_irq(&bdi->wb_written_wait.lock);
> > + __remove_wait_queue(&bdi->wb_written_wait, &wait);
> > + if (!list_empty(&wc.list))
> > + bdi_remove_writer(bdi, &wc);
> > + spin_unlock_irq(&bdi->wb_written_wait.lock);
> > +}
>
> OK, so the whole pause thing is simply because we don't get a wakeup
> when we drop below the limit, right?
Yes. I will write a comment about it before the loop. I was also thinking
about sending a wakeup when we get below limits but then all threads would
start thundering the device at the same time and likely cause a congestion
again. This way we might get a smoother start. But I'll have to measure
whether we aren't too unfair with this approach...
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2010-06-21 14:03 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-17 18:04 [PATCH RFC] mm: Implement balance_dirty_pages() through waiting for flusher thread Jan Kara
2010-06-18 6:09 ` Dave Chinner
2010-06-18 9:11 ` Peter Zijlstra
2010-06-18 23:29 ` Dave Chinner
2010-06-21 23:36 ` Jan Kara
2010-06-22 5:44 ` Dave Chinner
2010-06-22 6:14 ` Andrew Morton
2010-06-22 7:45 ` Peter Zijlstra
2010-06-22 8:24 ` Andrew Morton
2010-06-22 8:52 ` Peter Zijlstra
2010-06-22 10:09 ` Dave Chinner
2010-06-22 13:17 ` Jan Kara
2010-06-22 13:52 ` Wu Fengguang
2010-06-22 13:59 ` Peter Zijlstra
2010-06-22 14:00 ` Peter Zijlstra
2010-06-22 14:36 ` Wu Fengguang
2010-06-22 14:02 ` Jan Kara
2010-06-22 14:24 ` Wu Fengguang
2010-06-22 22:29 ` Dave Chinner
2010-06-23 13:15 ` Jan Kara
2010-06-23 23:06 ` Dave Chinner
2010-06-22 14:31 ` Christoph Hellwig
2010-06-22 14:38 ` Jan Kara
2010-06-22 22:45 ` Dave Chinner
2010-06-23 1:34 ` Wu Fengguang
2010-06-23 3:06 ` Dave Chinner
2010-06-23 3:22 ` Wu Fengguang
2010-06-23 6:03 ` Dave Chinner
2010-06-23 6:25 ` Wu Fengguang
2010-06-23 23:42 ` Dave Chinner
2010-06-22 14:41 ` Wu Fengguang
2010-06-22 11:19 ` Jan Kara
2010-06-18 10:21 ` Peter Zijlstra
2010-06-21 13:31 ` Jan Kara
2010-06-18 10:21 ` Peter Zijlstra
2010-06-21 14:02 ` Jan Kara [this message]
2010-06-21 14:10 ` Jan Kara
2010-06-21 14:12 ` Peter Zijlstra
2010-06-18 10:21 ` Peter Zijlstra
2010-06-21 13:42 ` Jan Kara
2010-06-22 4:07 ` Wu Fengguang
2010-06-22 13:27 ` Jan Kara
2010-06-22 13:33 ` 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=20100621140236.GF3828@quack.suse.cz \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterz@infradead.org \
--cc=wfg@mail.ustc.edu.cn \
/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).