|
@@ -3897,6 +3897,22 @@ struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb)
|
|
|
return &memcg->cgwb_domain;
|
|
return &memcg->cgwb_domain;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/*
|
|
|
|
|
+ * idx can be of type enum memcg_stat_item or node_stat_item.
|
|
|
|
|
+ * Keep in sync with memcg_exact_page().
|
|
|
|
|
+ */
|
|
|
|
|
+static unsigned long memcg_exact_page_state(struct mem_cgroup *memcg, int idx)
|
|
|
|
|
+{
|
|
|
|
|
+ long x = atomic_long_read(&memcg->stat[idx]);
|
|
|
|
|
+ int cpu;
|
|
|
|
|
+
|
|
|
|
|
+ for_each_online_cpu(cpu)
|
|
|
|
|
+ x += per_cpu_ptr(memcg->stat_cpu, cpu)->count[idx];
|
|
|
|
|
+ if (x < 0)
|
|
|
|
|
+ x = 0;
|
|
|
|
|
+ return x;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* mem_cgroup_wb_stats - retrieve writeback related stats from its memcg
|
|
* mem_cgroup_wb_stats - retrieve writeback related stats from its memcg
|
|
|
* @wb: bdi_writeback in question
|
|
* @wb: bdi_writeback in question
|
|
@@ -3922,10 +3938,10 @@ void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
|
|
|
struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css);
|
|
struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css);
|
|
|
struct mem_cgroup *parent;
|
|
struct mem_cgroup *parent;
|
|
|
|
|
|
|
|
- *pdirty = memcg_page_state(memcg, NR_FILE_DIRTY);
|
|
|
|
|
|
|
+ *pdirty = memcg_exact_page_state(memcg, NR_FILE_DIRTY);
|
|
|
|
|
|
|
|
/* this should eventually include NR_UNSTABLE_NFS */
|
|
/* this should eventually include NR_UNSTABLE_NFS */
|
|
|
- *pwriteback = memcg_page_state(memcg, NR_WRITEBACK);
|
|
|
|
|
|
|
+ *pwriteback = memcg_exact_page_state(memcg, NR_WRITEBACK);
|
|
|
*pfilepages = mem_cgroup_nr_lru_pages(memcg, (1 << LRU_INACTIVE_FILE) |
|
|
*pfilepages = mem_cgroup_nr_lru_pages(memcg, (1 << LRU_INACTIVE_FILE) |
|
|
|
(1 << LRU_ACTIVE_FILE));
|
|
(1 << LRU_ACTIVE_FILE));
|
|
|
*pheadroom = PAGE_COUNTER_MAX;
|
|
*pheadroom = PAGE_COUNTER_MAX;
|