aboutsummaryrefslogtreecommitdiffstats
path: root/mm/vmstat.c
diff options
context:
space:
mode:
authorMichael Rubin <mrubin@google.com>2010-10-26 17:21:36 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-26 19:52:06 -0400
commit79da826aee6a10902ef411bc65864bd02102fa83 (patch)
tree9cc3602fc53f889d9b7394663d4fdaa94d13a213 /mm/vmstat.c
parent2ac390370aac4aaa49cab17f328b478cbd5b3d8d (diff)
writeback: report dirty thresholds in /proc/vmstat
The kernel already exposes the user desired thresholds in /proc/sys/vm with dirty_background_ratio and background_ratio. But the kernel may alter the number requested without giving the user any indication that is the case. Knowing the actual ratios the kernel is honoring can help app developers understand how their buffered IO will be sent to the disk. $ grep threshold /proc/vmstat nr_dirty_threshold 409111 nr_dirty_background_threshold 818223 Signed-off-by: Michael Rubin <mrubin@google.com> Cc: Wu Fengguang <fengguang.wu@intel.com> Cc: Dave Chinner <david@fromorbit.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/vmstat.c')
-rw-r--r--mm/vmstat.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 44e7ac0fdb66..baa4ab387db7 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -17,6 +17,7 @@
17#include <linux/vmstat.h> 17#include <linux/vmstat.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/math64.h> 19#include <linux/math64.h>
20#include <linux/writeback.h>
20 21
21#ifdef CONFIG_VM_EVENT_COUNTERS 22#ifdef CONFIG_VM_EVENT_COUNTERS
22DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}}; 23DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}};
@@ -747,6 +748,8 @@ static const char * const vmstat_text[] = {
747 "nr_shmem", 748 "nr_shmem",
748 "nr_dirtied", 749 "nr_dirtied",
749 "nr_written", 750 "nr_written",
751 "nr_dirty_threshold",
752 "nr_dirty_background_threshold",
750 753
751#ifdef CONFIG_NUMA 754#ifdef CONFIG_NUMA
752 "numa_hit", 755 "numa_hit",
@@ -907,36 +910,44 @@ static const struct file_operations proc_zoneinfo_file_operations = {
907 .release = seq_release, 910 .release = seq_release,
908}; 911};
909 912
913enum writeback_stat_item {
914 NR_DIRTY_THRESHOLD,
915 NR_DIRTY_BG_THRESHOLD,
916 NR_VM_WRITEBACK_STAT_ITEMS,
917};
918
910static void *vmstat_start(struct seq_file *m, loff_t *pos) 919static void *vmstat_start(struct seq_file *m, loff_t *pos)
911{ 920{
912 unsigned long *v; 921 unsigned long *v;
913#ifdef CONFIG_VM_EVENT_COUNTERS 922 int i, stat_items_size;
914 unsigned long *e;
915#endif
916 int i;
917 923
918 if (*pos >= ARRAY_SIZE(vmstat_text)) 924 if (*pos >= ARRAY_SIZE(vmstat_text))
919 return NULL; 925 return NULL;
926 stat_items_size = NR_VM_ZONE_STAT_ITEMS * sizeof(unsigned long) +
927 NR_VM_WRITEBACK_STAT_ITEMS * sizeof(unsigned long);
920 928
921#ifdef CONFIG_VM_EVENT_COUNTERS 929#ifdef CONFIG_VM_EVENT_COUNTERS
922 v = kmalloc(NR_VM_ZONE_STAT_ITEMS * sizeof(unsigned long) 930 stat_items_size += sizeof(struct vm_event_state);
923 + sizeof(struct vm_event_state), GFP_KERNEL);
924#else
925 v = kmalloc(NR_VM_ZONE_STAT_ITEMS * sizeof(unsigned long),
926 GFP_KERNEL);
927#endif 931#endif
932
933 v = kmalloc(stat_items_size, GFP_KERNEL);
928 m->private = v; 934 m->private = v;
929 if (!v) 935 if (!v)
930 return ERR_PTR(-ENOMEM); 936 return ERR_PTR(-ENOMEM);
931 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) 937 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
932 v[i] = global_page_state(i); 938 v[i] = global_page_state(i);
939 v += NR_VM_ZONE_STAT_ITEMS;
940
941 global_dirty_limits(v + NR_DIRTY_BG_THRESHOLD,
942 v + NR_DIRTY_THRESHOLD);
943 v += NR_VM_WRITEBACK_STAT_ITEMS;
944
933#ifdef CONFIG_VM_EVENT_COUNTERS 945#ifdef CONFIG_VM_EVENT_COUNTERS
934 e = v + NR_VM_ZONE_STAT_ITEMS; 946 all_vm_events(v);
935 all_vm_events(e); 947 v[PGPGIN] /= 2; /* sectors -> kbytes */
936 e[PGPGIN] /= 2; /* sectors -> kbytes */ 948 v[PGPGOUT] /= 2;
937 e[PGPGOUT] /= 2;
938#endif 949#endif
939 return v + *pos; 950 return m->private + *pos;
940} 951}
941 952
942static void *vmstat_next(struct seq_file *m, void *arg, loff_t *pos) 953static void *vmstat_next(struct seq_file *m, void *arg, loff_t *pos)