<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/mm/backing-dev.c, branch v3.2.38</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/mm/backing-dev.c?h=v3.2.38</id>
<link rel='self' href='https://git.amat.us/linux/atom/mm/backing-dev.c?h=v3.2.38'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2012-02-20T20:46:18Z</updated>
<entry>
<title>backing-dev: fix wakeup timer races with bdi_unregister()</title>
<updated>2012-02-20T20:46:18Z</updated>
<author>
<name>Rabin Vincent</name>
<email>rabin@rab.in</email>
</author>
<published>2012-01-29T18:17:33Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=884d833e27faee8f929f95ca1be53b1997c66c30'/>
<id>urn:sha1:884d833e27faee8f929f95ca1be53b1997c66c30</id>
<content type='text'>
commit 2673b4cf5d59c3ee5e0c12f6d734d38770324dc4 upstream.

While 7a401a972df8e18 ("backing-dev: ensure wakeup_timer is deleted")
addressed the problem of the bdi being freed with a queued wakeup
timer, there are other races that could happen if the wakeup timer
expires after/during bdi_unregister(), before bdi_destroy() is called.

wakeup_timer_fn() could attempt to wakeup a task which has already has
been freed, or could access a NULL bdi-&gt;dev via the wake_forker_thread
tracepoint.

Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Reported-by: Chanho Min &lt;chanho.min@lge.com&gt;
Reviewed-by: Namjae Jeon &lt;linkinjeon@gmail.com&gt;
Signed-off-by: Rabin Vincent &lt;rabin@rab.in&gt;
Signed-off-by: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>backing-dev: ensure wakeup_timer is deleted</title>
<updated>2011-11-11T12:29:04Z</updated>
<author>
<name>Rabin Vincent</name>
<email>rabin.vincent@stericsson.com</email>
</author>
<published>2011-11-11T12:29:04Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=7a401a972df8e184b3d1a3fc958c0a4ddee8d312'/>
<id>urn:sha1:7a401a972df8e184b3d1a3fc958c0a4ddee8d312</id>
<content type='text'>
bdi_prune_sb() in bdi_unregister() attempts to removes the bdi links
from all super_blocks and then del_timer_sync() the writeback timer.

However, this can race with __mark_inode_dirty(), leading to
bdi_wakeup_thread_delayed() rearming the writeback timer on the bdi
we're unregistering, after we've called del_timer_sync().

This can end up with the bdi being freed with an active timer inside it,
as in the case of the following dump after the removal of an SD card.

Fix this by redoing the del_timer_sync() in bdi_destory().

 ------------[ cut here ]------------
 WARNING: at /home/rabin/kernel/arm/lib/debugobjects.c:262 debug_print_object+0x9c/0xc8()
 ODEBUG: free active (active state 0) object type: timer_list hint: wakeup_timer_fn+0x0/0x180
 Modules linked in:
 Backtrace:
 [&lt;c00109dc&gt;] (dump_backtrace+0x0/0x110) from [&lt;c0236e4c&gt;] (dump_stack+0x18/0x1c)
  r6:c02bc638 r5:00000106 r4:c79f5d18 r3:00000000
 [&lt;c0236e34&gt;] (dump_stack+0x0/0x1c) from [&lt;c0025e6c&gt;] (warn_slowpath_common+0x54/0x6c)
 [&lt;c0025e18&gt;] (warn_slowpath_common+0x0/0x6c) from [&lt;c0025f28&gt;] (warn_slowpath_fmt+0x38/0x40)
  r8:20000013 r7:c780c6f0 r6:c031613c r5:c780c6f0 r4:c02b1b29
 r3:00000009
 [&lt;c0025ef0&gt;] (warn_slowpath_fmt+0x0/0x40) from [&lt;c015eb4c&gt;] (debug_print_object+0x9c/0xc8)
  r3:c02b1b29 r2:c02bc662
 [&lt;c015eab0&gt;] (debug_print_object+0x0/0xc8) from [&lt;c015f574&gt;] (debug_check_no_obj_freed+0xac/0x1dc)
  r6:c7964000 r5:00000001 r4:c7964000
 [&lt;c015f4c8&gt;] (debug_check_no_obj_freed+0x0/0x1dc) from [&lt;c00a9e38&gt;] (kmem_cache_free+0x88/0x1f8)
 [&lt;c00a9db0&gt;] (kmem_cache_free+0x0/0x1f8) from [&lt;c014286c&gt;] (blk_release_queue+0x70/0x78)
 [&lt;c01427fc&gt;] (blk_release_queue+0x0/0x78) from [&lt;c015290c&gt;] (kobject_release+0x70/0x84)
  r5:c79641f0 r4:c796420c
 [&lt;c015289c&gt;] (kobject_release+0x0/0x84) from [&lt;c0153ce4&gt;] (kref_put+0x68/0x80)
  r7:00000083 r6:c74083d0 r5:c015289c r4:c796420c
 [&lt;c0153c7c&gt;] (kref_put+0x0/0x80) from [&lt;c01527d0&gt;] (kobject_put+0x48/0x5c)
  r5:c79643b4 r4:c79641f0
 [&lt;c0152788&gt;] (kobject_put+0x0/0x5c) from [&lt;c013ddd8&gt;] (blk_cleanup_queue+0x68/0x74)
  r4:c7964000
 [&lt;c013dd70&gt;] (blk_cleanup_queue+0x0/0x74) from [&lt;c01a6370&gt;] (mmc_blk_put+0x78/0xe8)
  r5:00000000 r4:c794c400
 [&lt;c01a62f8&gt;] (mmc_blk_put+0x0/0xe8) from [&lt;c01a64b4&gt;] (mmc_blk_release+0x24/0x38)
  r5:c794c400 r4:c0322824
 [&lt;c01a6490&gt;] (mmc_blk_release+0x0/0x38) from [&lt;c00de11c&gt;] (__blkdev_put+0xe8/0x170)
  r5:c78d5e00 r4:c74083c0
 [&lt;c00de034&gt;] (__blkdev_put+0x0/0x170) from [&lt;c00de2c0&gt;] (blkdev_put+0x11c/0x12c)
  r8:c79f5f70 r7:00000001 r6:c74083d0 r5:00000083 r4:c74083c0
 r3:00000000
 [&lt;c00de1a4&gt;] (blkdev_put+0x0/0x12c) from [&lt;c00b0724&gt;] (kill_block_super+0x60/0x6c)
  r7:c7942300 r6:c79f4000 r5:00000083 r4:c74083c0
 [&lt;c00b06c4&gt;] (kill_block_super+0x0/0x6c) from [&lt;c00b0a94&gt;] (deactivate_locked_super+0x44/0x70)
  r6:c79f4000 r5:c031af64 r4:c794dc00 r3:c00b06c4
 [&lt;c00b0a50&gt;] (deactivate_locked_super+0x0/0x70) from [&lt;c00b1358&gt;] (deactivate_super+0x6c/0x70)
  r5:c794dc00 r4:c794dc00
 [&lt;c00b12ec&gt;] (deactivate_super+0x0/0x70) from [&lt;c00c88b0&gt;] (mntput_no_expire+0x188/0x194)
  r5:c794dc00 r4:c7942300
 [&lt;c00c8728&gt;] (mntput_no_expire+0x0/0x194) from [&lt;c00c95e0&gt;] (sys_umount+0x2e4/0x310)
  r6:c7942300 r5:00000000 r4:00000000 r3:00000000
 [&lt;c00c92fc&gt;] (sys_umount+0x0/0x310) from [&lt;c000d940&gt;] (ret_fast_syscall+0x0/0x30)
 ---[ end trace e5c83c92ada51c76 ]---

Cc: stable@kernel.org
Signed-off-by: Rabin Vincent &lt;rabin.vincent@stericsson.com&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>Merge branch 'writeback-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/wfg/linux</title>
<updated>2011-11-07T03:02:23Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2011-11-07T03:02:23Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=208bca0860406d16398145ddd950036a737c3c9d'/>
<id>urn:sha1:208bca0860406d16398145ddd950036a737c3c9d</id>
<content type='text'>
* 'writeback-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/wfg/linux:
  writeback: Add a 'reason' to wb_writeback_work
  writeback: send work item to queue_io, move_expired_inodes
  writeback: trace event balance_dirty_pages
  writeback: trace event bdi_dirty_ratelimit
  writeback: fix ppc compile warnings on do_div(long long, unsigned long)
  writeback: per-bdi background threshold
  writeback: dirty position control - bdi reserve area
  writeback: control dirty pause time
  writeback: limit max dirty pause time
  writeback: IO-less balance_dirty_pages()
  writeback: per task dirty rate limit
  writeback: stabilize bdi-&gt;dirty_ratelimit
  writeback: dirty rate control
  writeback: add bg_threshold parameter to __bdi_update_bandwidth()
  writeback: dirty position control
  writeback: account per-bdi accumulated dirtied pages
</content>
</entry>
<entry>
<title>mm-add-comment-explaining-task-state-setting-in-bdi_forker_thread-fix</title>
<updated>2011-11-01T00:30:49Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@linux-foundation.org</email>
</author>
<published>2011-11-01T00:08:54Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=20c8c62891a346e09c8d26de41ce78bd7a76c5b0'/>
<id>urn:sha1:20c8c62891a346e09c8d26de41ce78bd7a76c5b0</id>
<content type='text'>
fiddle wording

Cc: Jan Kara &lt;jack@suse.cz&gt;
Cc: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>writeback: Add a 'reason' to wb_writeback_work</title>
<updated>2011-10-30T16:33:36Z</updated>
<author>
<name>Curt Wohlgemuth</name>
<email>curtw@google.com</email>
</author>
<published>2011-10-08T03:54:10Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=0e175a1835ffc979e55787774e58ec79e41957d7'/>
<id>urn:sha1:0e175a1835ffc979e55787774e58ec79e41957d7</id>
<content type='text'>
This creates a new 'reason' field in a wb_writeback_work
structure, which unambiguously identifies who initiates
writeback activity.  A 'wb_reason' enumeration has been
added to writeback.h, to enumerate the possible reasons.

The 'writeback_work_class' and tracepoint event class and
'writeback_queue_io' tracepoints are updated to include the
symbolic 'reason' in all trace events.

And the 'writeback_inodes_sbXXX' family of routines has had
a wb_stats parameter added to them, so callers can specify
why writeback is being started.

Acked-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Curt Wohlgemuth &lt;curtw@google.com&gt;
Signed-off-by: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
</content>
</entry>
<entry>
<title>writeback: stabilize bdi-&gt;dirty_ratelimit</title>
<updated>2011-10-03T13:08:57Z</updated>
<author>
<name>Wu Fengguang</name>
<email>fengguang.wu@intel.com</email>
</author>
<published>2011-08-26T21:53:24Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=7381131cbcf7e15d201a0ffd782a4698efe4e740'/>
<id>urn:sha1:7381131cbcf7e15d201a0ffd782a4698efe4e740</id>
<content type='text'>
There are some imperfections in balanced_dirty_ratelimit.

1) large fluctuations

The dirty_rate used for computing balanced_dirty_ratelimit is merely
averaged in the past 200ms (very small comparing to the 3s estimation
period for write_bw), which makes rather dispersed distribution of
balanced_dirty_ratelimit.

It's pretty hard to average out the singular points by increasing the
estimation period. Considering that the averaging technique will
introduce very undesirable time lags, I give it up totally. (btw, the 3s
write_bw averaging time lag is much more acceptable because its impact
is one-way and therefore won't lead to oscillations.)

The more practical way is filtering -- most singular
balanced_dirty_ratelimit points can be filtered out by remembering some
prev_balanced_rate and prev_prev_balanced_rate. However the more
reliable way is to guard balanced_dirty_ratelimit with task_ratelimit.

2) due to truncates and fs redirties, the (write_bw &lt;=&gt; dirty_rate)
match could become unbalanced, which may lead to large systematical
errors in balanced_dirty_ratelimit. The truncates, due to its possibly
bumpy nature, can hardly be compensated smoothly. So let's face it. When
some over-estimated balanced_dirty_ratelimit brings dirty_ratelimit
high, dirty pages will go higher than the setpoint. task_ratelimit will
in turn become lower than dirty_ratelimit.  So if we consider both
balanced_dirty_ratelimit and task_ratelimit and update dirty_ratelimit
only when they are on the same side of dirty_ratelimit, the systematical
errors in balanced_dirty_ratelimit won't be able to bring
dirty_ratelimit far away.

The balanced_dirty_ratelimit estimation may also be inaccurate near
@limit or @freerun, however is less an issue.

3) since we ultimately want to

- keep the fluctuations of task ratelimit as small as possible
- keep the dirty pages around the setpoint as long time as possible

the update policy used for (2) also serves the above goals nicely:
if for some reason the dirty pages are high (task_ratelimit &lt; dirty_ratelimit),
and dirty_ratelimit is low (dirty_ratelimit &lt; balanced_dirty_ratelimit),
there is no point to bring up dirty_ratelimit in a hurry only to hurt
both the above two goals.

So, we make use of task_ratelimit to limit the update of dirty_ratelimit
in two ways:

1) avoid changing dirty rate when it's against the position control target
   (the adjusted rate will slow down the progress of dirty pages going
   back to setpoint).

2) limit the step size. task_ratelimit is changing values step by step,
   leaving a consistent trace comparing to the randomly jumping
   balanced_dirty_ratelimit. task_ratelimit also has the nice smaller
   errors in stable state and typically larger errors when there are big
   errors in rate.  So it's a pretty good limiting factor for the step
   size of dirty_ratelimit.

Note that bdi-&gt;dirty_ratelimit is always tracking balanced_dirty_ratelimit.
task_ratelimit is merely used as a limiting factor.

Signed-off-by: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
</content>
</entry>
<entry>
<title>writeback: dirty rate control</title>
<updated>2011-10-03T13:08:56Z</updated>
<author>
<name>Wu Fengguang</name>
<email>fengguang.wu@intel.com</email>
</author>
<published>2011-06-12T16:51:31Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=be3ffa276446e1b691a2bf84e7621e5a6fb49db9'/>
<id>urn:sha1:be3ffa276446e1b691a2bf84e7621e5a6fb49db9</id>
<content type='text'>
It's all about bdi-&gt;dirty_ratelimit, which aims to be (write_bw / N)
when there are N dd tasks.

On write() syscall, use bdi-&gt;dirty_ratelimit
============================================

    balance_dirty_pages(pages_dirtied)
    {
        task_ratelimit = bdi-&gt;dirty_ratelimit * bdi_position_ratio();
        pause = pages_dirtied / task_ratelimit;
        sleep(pause);
    }

On every 200ms, update bdi-&gt;dirty_ratelimit
===========================================

    bdi_update_dirty_ratelimit()
    {
        task_ratelimit = bdi-&gt;dirty_ratelimit * bdi_position_ratio();
        balanced_dirty_ratelimit = task_ratelimit * write_bw / dirty_rate;
        bdi-&gt;dirty_ratelimit = balanced_dirty_ratelimit
    }

Estimation of balanced bdi-&gt;dirty_ratelimit
===========================================

balanced task_ratelimit
-----------------------

balance_dirty_pages() needs to throttle tasks dirtying pages such that
the total amount of dirty pages stays below the specified dirty limit in
order to avoid memory deadlocks. Furthermore we desire fairness in that
tasks get throttled proportionally to the amount of pages they dirty.

IOW we want to throttle tasks such that we match the dirty rate to the
writeout bandwidth, this yields a stable amount of dirty pages:

        dirty_rate == write_bw                                          (1)

The fairness requirement gives us:

        task_ratelimit = balanced_dirty_ratelimit
                       == write_bw / N                                  (2)

where N is the number of dd tasks.  We don't know N beforehand, but
still can estimate balanced_dirty_ratelimit within 200ms.

Start by throttling each dd task at rate

        task_ratelimit = task_ratelimit_0                               (3)
                         (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_0                              (4)
Or
        task_ratelimit_0 == dirty_rate / N                              (5)

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

                                                      write_bw
        balanced_dirty_ratelimit = task_ratelimit_0 * ----------        (6)
                                                      dirty_rate

Because with (4) and (5) we can get the desired equality (1):

                                                       write_bw
        balanced_dirty_ratelimit == (dirty_rate / N) * ----------
                                                       dirty_rate
                                 == write_bw / N

Then using the balanced task ratelimit we can compute task pause times like:

        task_pause = task-&gt;nr_dirtied / task_ratelimit

task_ratelimit with position control
------------------------------------

However, while the above gives us means of matching the dirty rate to
the writeout bandwidth, it at best provides us with a stable dirty page
count (assuming a static system). In order to control the dirty page
count such that it is high enough to provide performance, but does not
exceed the specified limit we need another control.

The dirty position control works by extending (2) to

        task_ratelimit = balanced_dirty_ratelimit * pos_ratio           (7)

where pos_ratio is a negative feedback function that subjects to

1) f(setpoint) = 1.0
2) df/dx &lt; 0

That is, if the dirty pages are ABOVE the setpoint, we throttle each
task a bit more HEAVY than balanced_dirty_ratelimit, so that the dirty
pages are created less fast than they are cleaned, thus DROP to the
setpoints (and the reverse).

Based on (7) and the assumption that both dirty_ratelimit and pos_ratio
remains CONSTANT for the past 200ms, we get

        task_ratelimit_0 = balanced_dirty_ratelimit * pos_ratio         (8)

Putting (8) into (6), we get the formula used in
bdi_update_dirty_ratelimit():

                                                write_bw
        balanced_dirty_ratelimit *= pos_ratio * ----------              (9)
                                                dirty_rate

Signed-off-by: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
</content>
</entry>
<entry>
<title>writeback: account per-bdi accumulated dirtied pages</title>
<updated>2011-10-03T13:08:56Z</updated>
<author>
<name>Wu Fengguang</name>
<email>fengguang.wu@intel.com</email>
</author>
<published>2011-01-23T16:07:47Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=c8e28ce049faa53a470c132893abbc9f2bde9420'/>
<id>urn:sha1:c8e28ce049faa53a470c132893abbc9f2bde9420</id>
<content type='text'>
Introduce the BDI_DIRTIED counter. It will be used for estimating the
bdi's dirty bandwidth.

CC: Jan Kara &lt;jack@suse.cz&gt;
CC: Michael Rubin &lt;mrubin@google.com&gt;
CC: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
</content>
</entry>
<entry>
<title>mm: Add comment explaining task state setting in bdi_forker_thread()</title>
<updated>2011-09-02T23:17:02Z</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2011-09-02T23:04:10Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=09f40f98bfa2ac22a332a713629a2f8f92896834'/>
<id>urn:sha1:09f40f98bfa2ac22a332a713629a2f8f92896834</id>
<content type='text'>
CC: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
CC: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Jens Axboe &lt;jaxboe@fusionio.com&gt;
</content>
</entry>
<entry>
<title>mm: Cleanup clearing of BDI_pending bit in bdi_forker_thread()</title>
<updated>2011-09-02T23:17:02Z</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2011-09-02T23:04:09Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=5a042aa4b8e994a15d2c2ee750219971f0ab3905'/>
<id>urn:sha1:5a042aa4b8e994a15d2c2ee750219971f0ab3905</id>
<content type='text'>
bdi_forker_thread() clears BDI_pending bit at the end of the main loop.
However clearing of this bit must not be done in some cases which is
handled by calling 'continue' from switch statement. That's kind of
unusual construct and without a good reason so change the function into
more intuitive code flow.

CC: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
CC: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Jens Axboe &lt;jaxboe@fusionio.com&gt;
</content>
</entry>
</feed>
