mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: Neil Brown <neilb@suse.de>, David Chinner <dgc@sgi.com>,
	linux-kernel@vger.kernel.org
Subject: Re: RFC - how to balance Dirty+Writeback in the face of slow writeback.
Date: Thu, 17 Aug 2006 22:49:52 -0700	[thread overview]
Message-ID: <20060817224952.e418c669.akpm@osdl.org> (raw)
In-Reply-To: <1155831779.5620.15.camel@localhost>

On Thu, 17 Aug 2006 12:22:59 -0400
Trond Myklebust <trond.myklebust@fys.uio.no> wrote:

> On Thu, 2006-08-17 at 08:14 -0700, Andrew Morton wrote:
> > Take a look at blk_congestion_wait().  It doesn't know about request
> > queues.  We'd need a new
> > 
> > void writeback_congestion_end(int rw)
> > {
> > 	wake_up(congestion_wqh[rw]);
> > }
> > 
> > or similar.
> 
> ...and how often do you want us to call this? NFS doesn't know much
> about request queues either: it writes out pages on a per-RPC call
> basis. In the worst case that could mean waking up the VM every time we
> write out a single page.
> 

Once per page would work OK, but we'd save some CPU by making it less
frequent.

This stuff isn't very precise.  We could make it precise, but it would
require a really large amount of extra locking, extra locks, etc.

The way this code all works is pretty crude and simple: a process comes
in to to some writeback and it enters a polling loop:

	while (we need to do writeback) {
		for (each superblock) {
			if (the superblock's backing_dev isn't congested) {
				stuff some more IO down it()
			}
		}
		take_a_nap();
	}

so the process remains captured in that polling loop until the
dirty-memory-exceed condition subsides.  The reason why we avoid
congsted queues is so that one thread can keep multiple queues busy: we
don't want to allow writing threads to get stuck on a single queue and
we don't want to have to provision one pdflush per spindle (or, more
precisely, per backing_dev_info).


So the question is: how do we "take a nap"?  That's blk_congestion_wait(). 
The process goes to sleep in there and gets woken up when someone thinks
that a queue might be able to take some more writeout.

A caller into blk_congestion_wait() is _supposed_ to be woken by writeback
completion.  If the timeout actually expires, something isn't right.  If we
had all the new locking in place and correct, the timeout wouldn't actually
be needed.  In theory, the timeout is only there as a fallback to handle
certain races for which we don't want to implement all that new locking to
fix.

It would be good if NFS were to implement a fixed-size "request queue",
so we can't fill all memory with NFS requests.  Then, NFS can implement
a congestion threshold at "75% full" (via its backing_dev_info) and
everything is in place.

As a halfway step it might provide benefit for NFS to poke the
congestion_wq[] every quarter megabyte or so, to kick any processes out
of their sleep so they go back to poll all the superblocks again,
earlier than they otherwise would have.  It might not make any
difference - one would need to get in there and understand the dynamic
behaviour.

  reply	other threads:[~2006-08-18  5:50 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-14 23:40 Neil Brown
2006-08-15  8:06 ` Andrew Morton
2006-08-15 23:00   ` David Chinner
2006-08-17  4:08     ` Neil Brown
2006-08-17  6:14       ` Andrew Morton
2006-08-17 12:36         ` Trond Myklebust
2006-08-17 15:14           ` Andrew Morton
2006-08-17 16:22             ` Trond Myklebust
2006-08-18  5:49               ` Andrew Morton [this message]
2006-08-18 10:43                 ` Nikita Danilov
2006-08-18  0:11         ` David Chinner
2006-08-18  6:29           ` Andrew Morton
2006-08-18  7:03             ` Jens Axboe
2006-08-18  7:11               ` Andrew Morton
2006-08-18 18:57               ` Andi Kleen
2006-08-21  0:35                 ` Neil Brown
2006-08-21  3:15                   ` David Chinner
2006-08-21  7:24                     ` Neil Brown
2006-08-21 13:51                       ` Jens Axboe
2006-08-25  4:36                         ` Neil Brown
2006-08-25  6:37                           ` Jens Axboe
2006-08-28  1:28                             ` David Chinner
2006-08-25 13:16                           ` Trond Myklebust
2006-08-27  8:21                             ` Neil Brown
2006-08-21 14:28                       ` David Chinner
2006-08-25  5:24                         ` Neil Brown
2006-08-28  1:55                           ` David Chinner
2006-08-21  7:47                     ` Andi Kleen
2006-08-18  7:07             ` Neil Brown
2006-08-17 22:17       ` David Chinner
2006-08-17  3:59   ` Neil Brown
2006-08-17  6:22     ` Andrew Morton
2006-08-17  8:36       ` Jens Axboe
2006-08-17 13:21     ` Trond Myklebust
2006-08-17 15:30       ` Andrew Morton
2006-08-17 16:18         ` Trond Myklebust
2006-08-18  5:34           ` Andrew Morton

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=20060817224952.e418c669.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=dgc@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=trond.myklebust@fys.uio.no \
    /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

Powered by JetHome