[Devel] [PATCH rh7] mm/memcg: get precise stat2 counters for statistics.
Andrey Ryabinin
aryabinin at virtuozzo.com
Fri Jul 28 19:28:56 MSK 2017
Currently mem_cgroup_read_stat2() imprecise result for performance
reasons. However, for statistics like 'memory.stat' we'd want the precise
results.
Make mem_cgroup_read_stat2() slower but preciser, and add unprecise but
fast mem_cgroup_read_stat2_fast() for performance-sensitive caller - dcache_is_low().
https://jira.sw.ru/browse/PSBM-69332
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
mm/memcontrol.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 19af6a9d9fc8..5ab5e82c924e 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -973,12 +973,19 @@ mem_cgroup_read_stat(struct mem_cgroup *memcg, enum mem_cgroup_stat_index idx)
val = 0;
return val;
}
+
static inline unsigned long
-mem_cgroup_read_stat2(struct mem_cgroup *memcg, enum mem_cgroup_stat2_index idx)
+mem_cgroup_read_stat2_fast(struct mem_cgroup *memcg, enum mem_cgroup_stat2_index idx)
{
return percpu_counter_read_positive(&memcg->stat2.counters[idx]);
}
+static inline unsigned long
+mem_cgroup_read_stat2(struct mem_cgroup *memcg, enum mem_cgroup_stat2_index idx)
+{
+ return percpu_counter_sum_positive(&memcg->stat2.counters[idx]);
+}
+
static void mem_cgroup_update_swap_max(struct mem_cgroup *memcg)
{
long long swap;
@@ -1611,9 +1618,9 @@ bool mem_cgroup_dcache_is_low(struct mem_cgroup *memcg, int vfs_cache_min_ratio)
{
unsigned long anon, file, dcache;
- anon = mem_cgroup_read_stat2(memcg, MEM_CGROUP_STAT_RSS);
- file = mem_cgroup_read_stat2(memcg, MEM_CGROUP_STAT_CACHE);
- dcache = mem_cgroup_read_stat2(memcg, MEM_CGROUP_STAT_SLAB_RECLAIMABLE);
+ anon = mem_cgroup_read_stat2_fast(memcg, MEM_CGROUP_STAT_RSS);
+ file = mem_cgroup_read_stat2_fast(memcg, MEM_CGROUP_STAT_CACHE);
+ dcache = mem_cgroup_read_stat2_fast(memcg, MEM_CGROUP_STAT_SLAB_RECLAIMABLE);
return dcache / vfs_cache_min_ratio <
(anon + file + dcache) / 100;
--
2.13.0
More information about the Devel
mailing list