diff options
-rw-r--r-- | mm/vmstat.c | 39 |
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 |
22 | DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}}; | 23 | DEFINE_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 | ||
913 | enum writeback_stat_item { | ||
914 | NR_DIRTY_THRESHOLD, | ||
915 | NR_DIRTY_BG_THRESHOLD, | ||
916 | NR_VM_WRITEBACK_STAT_ITEMS, | ||
917 | }; | ||
918 | |||
910 | static void *vmstat_start(struct seq_file *m, loff_t *pos) | 919 | static 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 | ||
942 | static void *vmstat_next(struct seq_file *m, void *arg, loff_t *pos) | 953 | static void *vmstat_next(struct seq_file *m, void *arg, loff_t *pos) |