lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 19 Aug 2011 10:54:06 +0800
From:	Wu Fengguang <fengguang.wu@...el.com>
To:	Vivek Goyal <vgoyal@...hat.com>
Cc:	"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Jan Kara <jack@...e.cz>, Christoph Hellwig <hch@....de>,
	Dave Chinner <david@...morbit.com>,
	Greg Thelen <gthelen@...gle.com>,
	Minchan Kim <minchan.kim@...il.com>,
	Andrea Righi <arighi@...eler.com>,
	linux-mm <linux-mm@...ck.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 5/5] writeback: IO-less balance_dirty_pages()

Hi Vivek,

> > +		base_rate = bdi->dirty_ratelimit;
> > +		pos_ratio = bdi_position_ratio(bdi, dirty_thresh,
> > +					       background_thresh, nr_dirty,
> > +					       bdi_thresh, bdi_dirty);
> > +		if (unlikely(pos_ratio == 0)) {
> > +			pause = MAX_PAUSE;
> > +			goto pause;
> >  		}
> > +		task_ratelimit = (u64)base_rate *
> > +					pos_ratio >> RATELIMIT_CALC_SHIFT;
> 
> Hi Fenguaang,
> 
> I am little confused here. I see that you have already taken pos_ratio
> into account in bdi_update_dirty_ratelimit() and wondering why to take
> that into account again in balance_diry_pages().
> 
> We calculated the pos_rate and balanced_rate and adjusted the
> bdi->dirty_ratelimit accordingly in bdi_update_dirty_ratelimit().

Good question. There are some inter-dependencies in the calculation,
and the dependency chain is the opposite to the one in your mind:
balance_dirty_pages() used pos_ratio in the first place, so that
bdi_update_dirty_ratelimit() have to use pos_ratio in the calculation
of the balanced dirty rate, too.

Let's return to how the balanced dirty rate is estimated. Please pay
special attention to the last paragraphs below the "......" line.

Start by throttling each dd task at rate

        task_ratelimit = task_ratelimit_0                               (1)
                         (any non-zero initial value is OK)

After 200ms, we measured

        dirty_rate = # of pages dirtied by all dd's / 200ms
        write_bw   = # of pages written to the disk / 200ms

For the aggressive dd dirtiers, the equality holds

        dirty_rate == N * task_rate
                   == N * task_ratelimit
                   == N * task_ratelimit_0                              (2)
Or     
        task_ratelimit_0 = dirty_rate / N                               (3)

Now we conclude that the balanced task ratelimit can be estimated by

        balanced_rate = task_ratelimit_0 * (write_bw / dirty_rate)      (4)

Because with (2) and (3), (4) yields the desired equality (1):

        balanced_rate == (dirty_rate / N) * (write_bw / dirty_rate)
                      == write_bw / N

.............................................................................

Now let's revisit (1). Since balance_dirty_pages() chooses to execute
the ratelimit

        task_ratelimit = task_ratelimit_0
                       = dirty_ratelimit * pos_ratio                    (5)

Put (5) into (4), we get the final form used in
bdi_update_dirty_ratelimit()

        balanced_rate = (dirty_ratelimit * pos_ratio) * (write_bw / dirty_rate)

So you really need to take (dirty_ratelimit * pos_ratio) as a single entity.

Thanks,
Fengguang
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ