Commit f6ef943813ac3085ece7252ea101d663581219f6

Authored by Bart Samwel
Committed by Linus Torvalds
1 parent 36f574135e

[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>

Showing 3 changed files with 19 additions and 19 deletions Side-by-side Diff

include/linux/writeback.h
... ... @@ -88,8 +88,8 @@
88 88 /* These are exported to sysctl. */
89 89 extern int dirty_background_ratio;
90 90 extern int vm_dirty_ratio;
91   -extern int dirty_writeback_centisecs;
92   -extern int dirty_expire_centisecs;
  91 +extern int dirty_writeback_interval;
  92 +extern int dirty_expire_interval;
93 93 extern int block_dump;
94 94 extern int laptop_mode;
95 95  
... ... @@ -742,18 +742,18 @@
742 742 {
743 743 .ctl_name = VM_DIRTY_WB_CS,
744 744 .procname = "dirty_writeback_centisecs",
745   - .data = &dirty_writeback_centisecs,
746   - .maxlen = sizeof(dirty_writeback_centisecs),
  745 + .data = &dirty_writeback_interval,
  746 + .maxlen = sizeof(dirty_writeback_interval),
747 747 .mode = 0644,
748 748 .proc_handler = &dirty_writeback_centisecs_handler,
749 749 },
750 750 {
751 751 .ctl_name = VM_DIRTY_EXPIRE_CS,
752 752 .procname = "dirty_expire_centisecs",
753   - .data = &dirty_expire_centisecs,
754   - .maxlen = sizeof(dirty_expire_centisecs),
  753 + .data = &dirty_expire_interval,
  754 + .maxlen = sizeof(dirty_expire_interval),
755 755 .mode = 0644,
756   - .proc_handler = &proc_dointvec,
  756 + .proc_handler = &proc_dointvec_userhz_jiffies,
757 757 },
758 758 {
759 759 .ctl_name = VM_NR_PDFLUSH_THREADS,
... ... @@ -75,12 +75,12 @@
75 75 * The interval between `kupdate'-style writebacks, in centiseconds
76 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 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 86 * Flag that makes the machine dump writes/reads and block dirtyings.
... ... @@ -380,8 +380,8 @@
380 380 * just walks the superblock inode list, writing back any inodes which are
381 381 * older than a specific point in time.
382 382 *
383   - * Try to run once per dirty_writeback_centisecs. But if a writeback event
384   - * takes longer than a dirty_writeback_centisecs interval, then leave a
  383 + * Try to run once per dirty_writeback_interval. But if a writeback event
  384 + * takes longer than a dirty_writeback_interval interval, then leave a
385 385 * one-second gap.
386 386 *
387 387 * older_than_this takes precedence over nr_to_write. So we'll only write back
388 388  
... ... @@ -406,9 +406,9 @@
406 406 sync_supers();
407 407  
408 408 get_writeback_state(&wbs);
409   - oldest_jif = jiffies - (dirty_expire_centisecs * HZ) / 100;
  409 + oldest_jif = jiffies - dirty_expire_interval;
410 410 start_jif = jiffies;
411   - next_jif = start_jif + (dirty_writeback_centisecs * HZ) / 100;
  411 + next_jif = start_jif + dirty_writeback_interval;
412 412 nr_to_write = wbs.nr_dirty + wbs.nr_unstable +
413 413 (inodes_stat.nr_inodes - inodes_stat.nr_unused);
414 414 while (nr_to_write > 0) {
... ... @@ -425,7 +425,7 @@
425 425 }
426 426 if (time_before(next_jif, jiffies + HZ))
427 427 next_jif = jiffies + HZ;
428   - if (dirty_writeback_centisecs)
  428 + if (dirty_writeback_interval)
429 429 mod_timer(&wb_timer, next_jif);
430 430 }
431 431  
432 432  
... ... @@ -435,11 +435,11 @@
435 435 int dirty_writeback_centisecs_handler(ctl_table *table, int write,
436 436 struct file *file, void __user *buffer, size_t *length, loff_t *ppos)
437 437 {
438   - proc_dointvec(table, write, file, buffer, length, ppos);
439   - if (dirty_writeback_centisecs) {
  438 + proc_dointvec_userhz_jiffies(table, write, file, buffer, length, ppos);
  439 + if (dirty_writeback_interval) {
440 440 mod_timer(&wb_timer,
441   - jiffies + (dirty_writeback_centisecs * HZ) / 100);
442   - } else {
  441 + jiffies + dirty_writeback_interval);
  442 + } else {
443 443 del_timer(&wb_timer);
444 444 }
445 445 return 0;
... ... @@ -544,7 +544,7 @@
544 544 if (vm_dirty_ratio <= 0)
545 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 548 set_ratelimit();
549 549 register_cpu_notifier(&ratelimit_nb);
550 550 }