summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/vmstat.h20
-rw-r--r--mm/page-writeback.c6
2 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 3e5d9075960f..aed05ca3e911 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -160,6 +160,26 @@ static inline unsigned long zone_page_state_snapshot(struct zone *zone,
return x;
}
+static inline unsigned long global_page_state_snapshot(enum zone_stat_item item)
+{
+ long x = atomic_long_read(&vm_stat[item]);
+
+#ifdef CONFIG_SMP
+ struct zone *zone;
+ int cpu;
+
+ for_each_online_cpu(cpu) {
+ for_each_populated_zone(zone)
+ x += per_cpu_ptr(zone->pageset,
+ cpu)->vm_stat_diff[item];
+ }
+
+ if (x < 0)
+ x = 0;
+#endif
+ return x;
+}
+
#ifdef CONFIG_NUMA
extern unsigned long node_page_state(int node, enum zone_stat_item item);
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index d15d88c8efa1..112c0bebfff3 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1938,6 +1938,12 @@ void throttle_vm_writeout(gfp_t gfp_mask)
if (global_page_state(NR_UNSTABLE_NFS) +
global_page_state(NR_WRITEBACK) <= dirty_thresh)
break;
+ /* Try safe version */
+ else if (unlikely(global_page_state_snapshot(NR_UNSTABLE_NFS) +
+ global_page_state_snapshot(NR_WRITEBACK) <=
+ dirty_thresh))
+ break;
+
congestion_wait(BLK_RW_ASYNC, HZ/10);
/*