bdi: use deferable timer for sync_supers task
Subsystems (2)
PATCH 1/1 bdi: use deferable timer for sync_supers task
sync_supers task currently wakes up periodically for superblock writeback. This hurts power on battery driven devices. This patch turns this housekeeping timer into a deferable timer so that it does not fire when system is really idle.
--- mm/backing-dev.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
mm/backing-dev.c +3 -1
@@ -238,7 +238,9 @@ static int __init default_bdi_init(void) sync_supers_tsk =kthread_run (bdi_sync_supers,NULL ,"sync_supers" );BUG_ON (IS_ERR (sync_supers_tsk)); -setup_timer (&sync_supers_timer, sync_supers_timer_fn,0 ); +init_timer_deferrable (&sync_supers_timer); + sync_supers_timer.function = sync_supers_timer_fn; + sync_supers_timer.data =0 ;bdi_arm_supers_timer (); err =bdi_init (&default_backing_dev_info);
Signature · 7 lines
1.5.5.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 4 lines · Yong Wang
sync_superstask currently wakes up periodically for superblock writeback. This hurts power on battery driven devices. This patch turns this housekeeping timer into a deferable timer so that it does not fire when system is really idle.
How long can the timer be defereed? We can't simply stop writing out data for a long time. I think the current timer value should be the upper bound, but allowing to fire earlier to run during the same wakeup cycle as others is fine.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 10 lines · ext Christoph Hellwig
Quoted 4 lines · Yong Wang
sync_superstask currently wakes up periodically for superblock writeback. This hurts power on battery driven devices. This patch turns this housekeeping timer into a deferable timer so that it does not fire when system is really idle.How long can the timer be defereed? We can't simply stop writing out data for a long time. I think the current timer value should be the upper bound, but allowing to fire earlier to run during the same wakeup cycle as others is fine.
Infinitely.
There are range hrtimers which can do exactly what you said - you specify the hard and soft limits there.
Signature · 8 lines
Best Regards, Artem Bityutskiy (D?N?N?N?D 1/4 D?D,N?N?N?DoD,D1) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 9 lines · Yong Wang
Quoted 4 lines
sync_superstask currently wakes up periodically for superblock writeback. This hurts power on battery driven devices. This patch turns this housekeeping timer into a deferable timer so that it does not fire when system is really idle.How long can the timer be defereed? We can't simply stop writing out data for a long time. I think the current timer value should be the upper bound, but allowing to fire earlier to run during the same wakeup cycle as others is fine.
If the system is in sleep state, this timer can be deferred to the next wake-up interrupt. If the system is busy, this timer will fire at the scheduled time.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 6 lines · Xia
Quoted 4 lines · Yong Wang
Quoted 4 lines
sync_superstask currently wakes up periodically for superblock writeback. This hurts power on battery driven devices. This patch turns this housekeeping timer into a deferable timer so that it does not fire when system is really idle.
Quoted 7 lines
Quoted 4 lines
How long can the timer be defereed? We can't simply stop writing out data for a long time. I think the current timer value should be the upper bound, but allowing to fire earlier to run during the same wakeup cycle as others is fine.
If the system is in sleep state, this timer can be deferred to the next wake-up interrupt. If the system is busy, this timer will fire at the scheduled time.
However, when the next wake-up interrupt happens is not defined. It can happen 1ms after, or 1 minute after, or 1 hour after. What Christoph says is that there should be some guarantee that sb writeout starts, say, within 5 to 10 seconds interval. Deferrable timers do not guarantee this. But take a look at the range hrtimers - they do exactly this.
Signature · 8 lines
Best Regards, Artem Bityutskiy (D?N?N?N?D 1/4 D?D,N?N?N?DoD,D1) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
DQo+IE9uIEZyaSwgMjAxMC0xMC0wOCBhdCAxMjowNCArMDIwMCwgZXh0IF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kdWxlZCB0aW1lLg0KDQo+IEhvd2V2ZXIsIHdoZW4g dGhlIG5leHQgd2FrZS11cCBpbnRlcnJ1cHQgaGFwcGVucyBpcyBub3QgZGVmaW5lZC4gSXQgY2Fu DQo+IGhhcHBlbiAxbXMgYWZ0ZXIsIG9yIDEgbWludXRlIGFmdGVyLCBvciAxIGhvdXIgYWZ0ZXIu IFdoYXQgQ2hyaXN0b3BoDQo+IHNheXMgaXMgdGhhdCB0aGVyZSBzaG91bGQgYmUgc29tZSBndWFy YW50ZWUgdGhhdCBzYiB3cml0ZW91dCBzdGFydHMsDQo+IHNheSwgd2l0aGluIDUgdG8gMTAgc2Vj b25kcyBpbnRlcnZhbC4gRGVmZXJyYWJsZSB0aW1lcnMgZG8gbm90IGd1YXJhbnRlZQ0KPiB0aGlz LiBCdXQgdGFrZSBhIGxvb2sgYXQgdGhlIHJhbmdlIGhydGltZXJzIC0gdGhleSBkbyBleGFjdGx5 IHRoaXMuDQoNCklmIHRoZSBzeXN0ZW0gaXMgaW4gc2xlZXAgc3RhdGUsIGlzIHRoZXJlIGFueSBk YXRhIHdoaWNoIHNob3VsZCBiZSB3cml0dGVuPyBNdXN0IA0Kc2Igd3JpdGVvdXQgc3RhcnQgZXZl biB0aGVyZSBpc24ndCBhbnkgZGF0YT8gDQoNCg==
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · Xia
Quoted 5 lines
However, when the next wake-up interrupt happens is not defined. It can happen 1ms after, or 1 minute after, or 1 hour after. What Christoph says is that there should be some guarantee that sb writeout starts, say, within 5 to 10 seconds interval. Deferrable timers do not guarantee this. But take a look at the range hrtimers - they do exactly this.
If the system is in sleep state, is there any data which should be written?
May be yes, may be no.
Quoted 2 lines
Must
sb writeout start even there isn't any data?
No.
Signature · 8 lines
Best Regards, Artem Bityutskiy (D?N?N?N?D 1/4 D?D,N?N?N?DoD,D1) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · Artem Bityutskiy
Quoted 7 lines · Xia
Quoted 5 lines
However, when the next wake-up interrupt happens is not defined. It can happen 1ms after, or 1 minute after, or 1 hour after. What Christoph says is that there should be some guarantee that sb writeout starts, say, within 5 to 10 seconds interval. Deferrable timers do not guarantee this. But take a look at the range hrtimers - they do exactly this.
If the system is in sleep state, is there any data which should be written?
May be yes, may be no.
Thanks for the quick response, Artem. May I know what might need to be written out when system is really idle?
-Yong
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · Yong Wang
Quoted 7 lines · Artem Bityutskiy
Quoted 6 lines · Xia
Quoted 5 lines
However, when the next wake-up interrupt happens is not defined. It can happen 1ms after, or 1 minute after, or 1 hour after. What Christoph says is that there should be some guarantee that sb writeout starts, say, within 5 to 10 seconds interval. Deferrable timers do not guarantee this. But take a look at the range hrtimers - they do exactly this.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
If the system is in sleep state, is there any data which should be written?
May be yes, may be no.
Thanks for the quick response, Artem. May I know what might need to be written out when system is really idle?
system idle != no dirty inodes
Imagine an application dirties 100MB data and quits. The system then goes quiet for very long time. In this case we still want the flusher thread to wake up within 30 seconds to flush the 100MB dirty data. It's a contract that dirty data will be synced to disk after 30s (which is the default value of /proc/sys/vm/dirty_expire_centisecs).
Note that 30s is not an exact value. A dirty page may be synced to disk when it's been dirtied for 35s. The 5s error comes from the flusher wakeup interval (/proc/sys/vm/dirty_writeback_centisecs).
Thanks,
Fengguang
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · Wu Fengguang
Quoted 10 lines · Yong Wang
Quoted 9 lines · Artem Bityutskiy
Quoted 7 lines · Xia
Quoted 5 lines
However, when the next wake-up interrupt happens is not defined. It can happen 1ms after, or 1 minute after, or 1 hour after. What Christoph says is that there should be some guarantee that sb writeout starts, say, within 5 to 10 seconds interval. Deferrable timers do not guarantee this. But take a look at the range hrtimers - they do exactly this.
If the system is in sleep state, is there any data which should be written?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
May be yes, may be no.
Thanks for the quick response, Artem. May I know what might need to be written out when system is really idle?
system idle != no dirty inodes
Ah sorry -- I missed the context. Please ignore the following paragraphs for sync_supers..
Thanks,
Fengguang
Quoted 12 lines
Imagine an application dirties 100MB data and quits. The system then goes quiet for very long time. In this case we still want the flusher thread to wake up within 30 seconds to flush the 100MB dirty data. It's a contract that dirty data will be synced to disk after 30s (which is the default value of
/proc/sys/vm/dirty_expire_centisecs).Note that 30s is not an exact value. A dirty page may be synced to disk when it's been dirtied for 35s. The 5s error comes from the flusher wakeup interval (
/proc/sys/vm/dirty_writeback_centisecs).Thanks,
Fengguang
Quoted 8 lines · Yong Wang
Quoted 7 lines · Artem Bityutskiy
Quoted 6 lines · Xia
Quoted 5 lines
However, when the next wake-up interrupt happens is not defined. It can happen 1ms after, or 1 minute after, or 1 hour after. What Christoph says is that there should be some guarantee that sb writeout starts, say, within 5 to 10 seconds interval. Deferrable timers do not guarantee this. But take a look at the range hrtimers - they do exactly this.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
If the system is in sleep state, is there any data which should be written?
May be yes, may be no.
Thanks for the quick response, Artem. May I know what might need to be written out when system is really idle?
I do not understand the question. There is dirty data, and it should be flushed within some time interval.
Anyway, to make the long story short, I made an attempt to optimize this and stop arming the timer when we have no dirty data. But my solution was not accepted and Al asked me to just get rid of this timer and whole sync_supers(). He said this should be pushed down to individual FSes. I guess the idea is that
1) some FSes actually abuse sb synching, e.g., JFFS2.
2) other FSes can eventually optimize things for themselves.
But I did not find time to do this so far.
Signature · 8 lines
Best Regards, Artem Bityutskiy (D?N?N?N?D 1/4 D?D,N?N?N?DoD,D1) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>