linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: a.p.zijlstra@chello.nl
Cc: miklos@szeredi.hu, neilb@suse.de, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	dgc@sgi.com, tomoki.sekiyama.qu@hitachi.com,
	nikita@clusterfs.com, trond.myklebust@fys.uio.no,
	yingchao.zhou@gmail.com
Subject: Re: [PATCH 10/10] mm: per device dirty threshold
Date: Tue, 24 Apr 2007 11:14:09 +0200	[thread overview]
Message-ID: <E1HgH69-0000Fl-00@dorka.pomaz.szeredi.hu> (raw)
In-Reply-To: <1177403494.26937.59.camel@twins> (message from Peter Zijlstra on Tue, 24 Apr 2007 10:31:33 +0200)

> > > > This is probably a
> > > >  reasonable thing to do but it doesn't feel like the right place.  I
> > > >  think get_dirty_limits should return the raw threshold, and
> > > >  balance_dirty_pages should do both tests - the bdi-local test and the
> > > >  system-wide test.
> > > 
> > > Ok, that makes sense I guess.
> > 
> > Well, my narrow minded world view says it's not such a good idea,
> > because it would again introduce the deadlock scenario, we're trying
> > to avoid.
> 
> I was only referring to the placement of the clipping; and exactly where
> that happens does not affect the deadlock.

OK.

> > In a sense allowing a queue to go over the global limit just a little
> > bit is a good thing.  Actually the very original code does that: if
> > writeback was started for "write_chunk" number of pages, then we allow
> > "ratelimit" (8) _new_ pages to be dirtied, effectively ignoring the
> > global limit.
> 
> It might be time to get rid of that rate-limiting.
> balance_dirty_pages()'s fast path is not nearly as heavy as it used to
> be. All these fancy counter systems have removed quite a bit of
> iteration from there.

Hmm.  The rate limiting probably makes lots of sense for
dirty_exceeded==0, when ratelimit can be a nice large value.

For dirty_exceeded==1 it may make sense to disable ratelimiting, OTOH
having a granularity of 8 pages probably doesn't matter, because of
the granularity of the percpu counter is usually larger (except on UP).

> > That's why I've been saying, that the current code is so unfair: if
> > there are lots of dirty pages to be written back to a particular
> > device, then balance_dirty_pages() allows the dirty producer to make
> > even more pages dirty, but if there are _no_ dirty pages for a device,
> > and we are over the limit, then that dirty producer is allowed
> > absolutely no new dirty pages until the global counts subside.
> 
> Well, that got fixed on a per device basis with this patch, it is still
> true for multiple tasks writing to the same device.

Yes, this is the part of this patchset I'm personally interested in ;)

> > I'm still not quite sure what purpose the above "soft" limiting
> > serves.  It seems to just give advantage to writers, which managed to
> > accumulate lots of dirty pages, and then can convert that into even
> > more dirtyings.
> 
> The queues only limit the actual in-flight writeback pages,
> balance_dirty_pages() considers all pages that might become writeback as
> well as those that are.
> 
> > Would it make sense to remove this behavior, and ensure that
> > balance_dirty_pages() doesn't return until the per-queue limits have
> > been complied with?
> 
> I don't think that will help, balance_dirty_pages drives the queues.
> That is, it converts pages from mere dirty to writeback.

Yes.  But current logic says, that if you convert "write_chunk" dirty
to writeback, you are allowed to dirty "ratelimit" more. 

D: number of dirty pages
W: number of writeback pages
L: global limit
C: write_chunk = ratelimit_pages * 1.5
R: ratelimit

If D+W >= L, then R = 8

Let's assume, that D == L and W == 0.  And that all of the dirty pages
belong to a single device.  Also for simplicity, lets assume an
infinite length queue, and a slow device.

Then while converting the dirty pages to writeback, D / C * R new
dirty pages can be created.  So when all existing dirty have been
converted:

  D = L / C * R
  W = L

  D + W = L * (1 + R / C)

So we see, that we're now even more above the limit than before the
conversion.  This means, that we starve writers to other devices,
which don't have as many dirty pages, because until the slow device
doesn't finish these writes they will not get to do anything.

Your patch helps this in that if the other writers have an empty queue
and no dirty, they will be allowed to slowly start writing.  But they
will not gain their full share until the slow dirty-hog goes below the
global limit, which may take some time.

So I think the logical thing to do, is if the dirty-hog is over it's
queue limit, don't let it dirty any more until it's dirty+writeback go
below the limit.  That allowes other devices to more quickly gain
their share of dirty pages.

Miklos

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2007-04-24  9:14 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-20 15:51 [PATCH 00/10] per device dirty throttling -v5 Peter Zijlstra
2007-04-20 15:51 ` [PATCH 01/10] revert per-backing_dev-dirty-and-writeback-page-accounting Peter Zijlstra
2007-04-20 15:51 ` [PATCH 02/10] nfs: remove congestion_end() Peter Zijlstra
2007-04-20 15:51 ` [PATCH 03/10] lib: dampen the percpu_counter FBC_BATCH Peter Zijlstra
2007-04-21  9:55   ` Andrew Morton
2007-04-21 10:58     ` Peter Zijlstra
2007-04-20 15:51 ` [PATCH 04/10] lib: percpu_counter_mod64 Peter Zijlstra
2007-04-21  9:55   ` Andrew Morton
2007-04-21 11:02     ` Peter Zijlstra
2007-04-21 19:21       ` Andrew Morton
2007-04-21 19:30         ` Peter Zijlstra
2007-04-20 15:51 ` [PATCH 05/10] mm: bdi init hooks Peter Zijlstra
2007-04-20 15:52 ` [PATCH 06/10] mm: scalable bdi statistics counters Peter Zijlstra
2007-04-20 15:52 ` [PATCH 07/10] mm: count reclaimable pages per BDI Peter Zijlstra
2007-04-21  9:55   ` Andrew Morton
2007-04-21 11:04     ` Peter Zijlstra
2007-04-20 15:52 ` [PATCH 08/10] mm: count writeback " Peter Zijlstra
2007-04-21  9:55   ` Andrew Morton
2007-04-21 11:07     ` Peter Zijlstra
2007-04-22  7:19       ` Andrew Morton
2007-04-22  9:08         ` Peter Zijlstra
2007-04-20 15:52 ` [PATCH 09/10] mm: expose BDI statistics in sysfs Peter Zijlstra
2007-04-21  9:55   ` Andrew Morton
2007-04-21 11:08     ` Peter Zijlstra
2007-04-20 15:52 ` [PATCH 10/10] mm: per device dirty threshold Peter Zijlstra
2007-04-21  9:55   ` Andrew Morton
2007-04-21 10:38     ` Miklos Szeredi
2007-04-21 10:54       ` Andrew Morton
2007-04-21 20:25         ` Miklos Szeredi
2007-04-23  6:14           ` Peter Zijlstra
2007-04-23  6:29             ` Miklos Szeredi
2007-04-23  6:39               ` Andrew Morton
2007-04-21 12:01     ` Peter Zijlstra
2007-04-21 12:15       ` Peter Zijlstra
2007-04-21 19:50         ` Peter Zijlstra
2007-04-23 15:48         ` Christoph Lameter
2007-04-23 15:58           ` Peter Zijlstra
2007-04-23 16:08             ` Christoph Lameter
2007-04-22  7:26       ` Andrew Morton
2007-04-24  2:58   ` Neil Brown
2007-04-24  7:09     ` Peter Zijlstra
2007-04-24  8:19       ` Miklos Szeredi
2007-04-24  8:31         ` Peter Zijlstra
2007-04-24  9:14           ` Miklos Szeredi [this message]
2007-04-24  9:26             ` Peter Zijlstra
2007-04-24  9:47               ` Miklos Szeredi
2007-04-24 10:00                 ` Andrew Morton
2007-04-24 10:12                   ` Peter Zijlstra
2007-04-24 10:19                     ` Miklos Szeredi
2007-04-24 10:24                       ` Peter Zijlstra
2007-04-24 10:40                     ` Andrew Morton
2007-04-24 11:22                       ` Miklos Szeredi
2007-04-24 11:50                         ` Andrew Morton
2007-04-24 12:07                           ` Miklos Szeredi
2007-04-22  9:57 ` [PATCH 00/10] per device dirty throttling -v5 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=E1HgH69-0000Fl-00@dorka.pomaz.szeredi.hu \
    --to=miklos@szeredi.hu \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=dgc@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=neilb@suse.de \
    --cc=nikita@clusterfs.com \
    --cc=tomoki.sekiyama.qu@hitachi.com \
    --cc=trond.myklebust@fys.uio.no \
    --cc=yingchao.zhou@gmail.com \
    /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