diff options
author | Bart Samwel <bart@samwel.tk> | 2006-03-24 06:15:48 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-24 10:33:20 -0500 |
commit | f6ef943813ac3085ece7252ea101d663581219f6 (patch) | |
tree | e32d3e57ba6ae235ec1f510b16d77fe9bfa8f96e | |
parent | 36f574135e36b86bb6ae794bf1d0fce3efa5601f (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>
-rw-r--r-- | include/linux/writeback.h | 4 | ||||
-rw-r--r-- | kernel/sysctl.c | 10 | ||||
-rw-r--r-- | mm/page-writeback.c | 24 |
3 files changed, 19 insertions, 19 deletions
diff --git a/include/linux/writeback.h b/include/linux/writeback.h index beaef5c7a0ea..609565961494 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h | |||
@@ -88,8 +88,8 @@ void throttle_vm_writeout(void); | |||
88 | /* These are exported to sysctl. */ | 88 | /* These are exported to sysctl. */ |
89 | extern int dirty_background_ratio; | 89 | extern int dirty_background_ratio; |
90 | extern int vm_dirty_ratio; | 90 | extern int vm_dirty_ratio; |
91 | extern int dirty_writeback_centisecs; | 91 | extern int dirty_writeback_interval; |
92 | extern int dirty_expire_centisecs; | 92 | extern int dirty_expire_interval; |
93 | extern int block_dump; | 93 | extern int block_dump; |
94 | extern int laptop_mode; | 94 | extern int laptop_mode; |
95 | 95 | ||
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 32b48e8ee36e..817ba25517eb 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -742,18 +742,18 @@ static ctl_table vm_table[] = { | |||
742 | { | 742 | { |
743 | .ctl_name = VM_DIRTY_WB_CS, | 743 | .ctl_name = VM_DIRTY_WB_CS, |
744 | .procname = "dirty_writeback_centisecs", | 744 | .procname = "dirty_writeback_centisecs", |
745 | .data = &dirty_writeback_centisecs, | 745 | .data = &dirty_writeback_interval, |
746 | .maxlen = sizeof(dirty_writeback_centisecs), | 746 | .maxlen = sizeof(dirty_writeback_interval), |
747 | .mode = 0644, | 747 | .mode = 0644, |
748 | .proc_handler = &dirty_writeback_centisecs_handler, | 748 | .proc_handler = &dirty_writeback_centisecs_handler, |
749 | }, | 749 | }, |
750 | { | 750 | { |
751 | .ctl_name = VM_DIRTY_EXPIRE_CS, | 751 | .ctl_name = VM_DIRTY_EXPIRE_CS, |
752 | .procname = "dirty_expire_centisecs", | 752 | .procname = "dirty_expire_centisecs", |
753 | .data = &dirty_expire_centisecs, | 753 | .data = &dirty_expire_interval, |
754 | .maxlen = sizeof(dirty_expire_centisecs), | 754 | .maxlen = sizeof(dirty_expire_interval), |
755 | .mode = 0644, | 755 | .mode = 0644, |
756 | .proc_handler = &proc_dointvec, | 756 | .proc_handler = &proc_dointvec_userhz_jiffies, |
757 | }, | 757 | }, |
758 | { | 758 | { |
759 | .ctl_name = VM_NR_PDFLUSH_THREADS, | 759 | .ctl_name = VM_NR_PDFLUSH_THREADS, |
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 | */ |
78 | int dirty_writeback_centisecs = 5 * 100; | 78 | int 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 | */ |
83 | int dirty_expire_centisecs = 30 * 100; | 83 | int 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) | |||
435 | int dirty_writeback_centisecs_handler(ctl_table *table, int write, | 435 | int 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 | } |