aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorBart Samwel <bart@samwel.tk>2006-03-24 06:15:48 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-24 10:33:20 -0500
commitf6ef943813ac3085ece7252ea101d663581219f6 (patch)
treee32d3e57ba6ae235ec1f510b16d77fe9bfa8f96e /mm
parent36f574135e36b86bb6ae794bf1d0fce3efa5601f (diff)
[PATCH] Represent dirty_*_centisecs as jiffies internally
Make that the internal values for: /proc/sys/vm/dirty_writeback_centisecs /proc/sys/vm/dirty_expire_centisecs are stored as jiffies instead of centiseconds. Let the sysctl interface do the conversions with full precision using clock_t_to_jiffies, instead of doing overflow-sensitive on-the-fly conversions every time the values are used. Cons: apparent precision loss if HZ is not a multiple of 100, because of conversion back and forth. This is a common problem for all sysctl values that use proc_dointvec_userhz_jiffies. (There is only one other in-tree use, in net/core/neighbour.c.) Signed-off-by: Bart Samwel <bart@samwel.tk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/page-writeback.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 945559fb63d2..e79107991d20 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -75,12 +75,12 @@ int vm_dirty_ratio = 40;
75 * The interval between `kupdate'-style writebacks, in centiseconds 75 * The interval between `kupdate'-style writebacks, in centiseconds
76 * (hundredths of a second) 76 * (hundredths of a second)
77 */ 77 */
78int dirty_writeback_centisecs = 5 * 100; 78int dirty_writeback_interval = 5 * HZ;
79 79
80/* 80/*
81 * The longest number of centiseconds for which data is allowed to remain dirty 81 * The longest number of centiseconds for which data is allowed to remain dirty
82 */ 82 */
83int dirty_expire_centisecs = 30 * 100; 83int dirty_expire_interval = 30 * HZ;
84 84
85/* 85/*
86 * Flag that makes the machine dump writes/reads and block dirtyings. 86 * Flag that makes the machine dump writes/reads and block dirtyings.
@@ -380,8 +380,8 @@ static DEFINE_TIMER(laptop_mode_wb_timer, laptop_timer_fn, 0, 0);
380 * just walks the superblock inode list, writing back any inodes which are 380 * just walks the superblock inode list, writing back any inodes which are
381 * older than a specific point in time. 381 * older than a specific point in time.
382 * 382 *
383 * Try to run once per dirty_writeback_centisecs. But if a writeback event 383 * Try to run once per dirty_writeback_interval. But if a writeback event
384 * takes longer than a dirty_writeback_centisecs interval, then leave a 384 * takes longer than a dirty_writeback_interval interval, then leave a
385 * one-second gap. 385 * one-second gap.
386 * 386 *
387 * older_than_this takes precedence over nr_to_write. So we'll only write back 387 * older_than_this takes precedence over nr_to_write. So we'll only write back
@@ -406,9 +406,9 @@ static void wb_kupdate(unsigned long arg)
406 sync_supers(); 406 sync_supers();
407 407
408 get_writeback_state(&wbs); 408 get_writeback_state(&wbs);
409 oldest_jif = jiffies - (dirty_expire_centisecs * HZ) / 100; 409 oldest_jif = jiffies - dirty_expire_interval;
410 start_jif = jiffies; 410 start_jif = jiffies;
411 next_jif = start_jif + (dirty_writeback_centisecs * HZ) / 100; 411 next_jif = start_jif + dirty_writeback_interval;
412 nr_to_write = wbs.nr_dirty + wbs.nr_unstable + 412 nr_to_write = wbs.nr_dirty + wbs.nr_unstable +
413 (inodes_stat.nr_inodes - inodes_stat.nr_unused); 413 (inodes_stat.nr_inodes - inodes_stat.nr_unused);
414 while (nr_to_write > 0) { 414 while (nr_to_write > 0) {
@@ -425,7 +425,7 @@ static void wb_kupdate(unsigned long arg)
425 } 425 }
426 if (time_before(next_jif, jiffies + HZ)) 426 if (time_before(next_jif, jiffies + HZ))
427 next_jif = jiffies + HZ; 427 next_jif = jiffies + HZ;
428 if (dirty_writeback_centisecs) 428 if (dirty_writeback_interval)
429 mod_timer(&wb_timer, next_jif); 429 mod_timer(&wb_timer, next_jif);
430} 430}
431 431
@@ -435,11 +435,11 @@ static void wb_kupdate(unsigned long arg)
435int dirty_writeback_centisecs_handler(ctl_table *table, int write, 435int dirty_writeback_centisecs_handler(ctl_table *table, int write,
436 struct file *file, void __user *buffer, size_t *length, loff_t *ppos) 436 struct file *file, void __user *buffer, size_t *length, loff_t *ppos)
437{ 437{
438 proc_dointvec(table, write, file, buffer, length, ppos); 438 proc_dointvec_userhz_jiffies(table, write, file, buffer, length, ppos);
439 if (dirty_writeback_centisecs) { 439 if (dirty_writeback_interval) {
440 mod_timer(&wb_timer, 440 mod_timer(&wb_timer,
441 jiffies + (dirty_writeback_centisecs * HZ) / 100); 441 jiffies + dirty_writeback_interval);
442 } else { 442 } else {
443 del_timer(&wb_timer); 443 del_timer(&wb_timer);
444 } 444 }
445 return 0; 445 return 0;
@@ -544,7 +544,7 @@ void __init page_writeback_init(void)
544 if (vm_dirty_ratio <= 0) 544 if (vm_dirty_ratio <= 0)
545 vm_dirty_ratio = 1; 545 vm_dirty_ratio = 1;
546 } 546 }
547 mod_timer(&wb_timer, jiffies + (dirty_writeback_centisecs * HZ) / 100); 547 mod_timer(&wb_timer, jiffies + dirty_writeback_interval);
548 set_ratelimit(); 548 set_ratelimit();
549 register_cpu_notifier(&ratelimit_nb); 549 register_cpu_notifier(&ratelimit_nb);
550} 550}