Sorry, some troubles found. Ignore above Ack. 3points now.
1. get_cpu should be after (*)
==mem_cgroup_update_mapped_file_stat()
+ int cpu = get_cpu();
+
+ if (!page_is_file_cache(page))
+ return;
+
+ if (unlikely(!mm))
+ mm = &init_mm;
+
+ mem = try_get_mem_cgroup_from_mm(mm);
+ if (!mem)
+ return;
+ ----------------------------------------(*)
+ stat = &mem->stat;
+ cpustat = &stat->cpustat[cpu];
+
+ __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_MAPPED_FILE, val);
+ put_cpu();
+}
==
2. In above, "mem" shouldn't be got from "mm"....please get "mem" from page_cgroup.
(Because it's file cache, pc->mem_cgroup is not NULL always.)
I saw this very easily.
==
Cache: 4096
mapped_file: 20480
==
3. at force_empty().
==
+
+ cpu = get_cpu();
+ /* Update mapped_file data for mem_cgroup "from" */
+ stat = &from->stat;
+ cpustat = &stat->cpustat[cpu];
+ __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_MAPPED_FILE, -1);
+
+ /* Update mapped_file data for mem_cgroup "to" */
+ stat = &to->stat;
+ cpustat = &stat->cpustat[cpu];
+ __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_MAPPED_FILE, 1);
+ put_cpu();
This just breaks counter when page is not mapped. please check page_mapped().
like this:
==
if (page_is_file_cache(page) && page_mapped(page)) {
modify counter.
}
==
and call lock_page_cgroup() in mem_cgroup_update_mapped_file_stat().
This will be slow, but optimization will be very tricky and need some amount of time.
-Kame
--