Re: Delaying writes to disk when there's no need

Andrew Morton (akpm@digeo.com)
Mon, 31 Mar 2003 14:45:00 -0800


Nick Piggin <piggin@cyberone.com.au> wrote:
>
> it seems to me that
> doing writeout whenever the disk would otherwise be idle
> (and we have dirty memory to write out) would be a good
> solution.

This is what the recently-removed BDI_read_active flag in backing_dev_info
was supposed to be for. I let it go because I don't think it's terribly
important and it's time to stop fiddling with the vfs writeout code and it
wasn't right anyway.

Note that 2.5 starts pdflush writeout at 10% of memory dirty. Or even lower
if there is a lot of mapped memory around. Whereas 2.4 will start background
writeout at 30% or 40% dirty. That's a fairly significant tuning change.

The algorithm for utilisation of an idle disk should be, in
balance_dirty_pages():

if (ps.nr_dirty + ps.nr_writeback < background_thresh) {
if (time_after(jiffies, bdi->last_read + HZ/100)) {
if (bdi->write_requests_in_flight < 2) {
struct writeback_control wbc = {
.bdi = bdi,
.sync_mode = WB_SYNC_NONE,
.nr_to_write = write_chunk,
};

writeback_inodes(&wbc);
}
}
return;
}

Or something like that. It's pretty close.

It could have pretty bad failure modes. Short-lived files in /tmp now
perform writeout, which needs to be waited on when those files are removed.

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