On Wed, Aug 20, 2025 at 12:46:43AM +0100, Matthew Wilcox wrote: > On Tue, Aug 19, 2025 at 08:53:59AM -0700, Shakeel Butt wrote: > > My initial thinking was based on Qu's original proposal which was using > > root memcg where there will not be any difference between accounted > > file pages and system wide file pages. However with Boris's change, we > > can actually get the estimate, as you pointed out, by subtracting the > > number of accounted file pages from system wide number of file pages. > > > > However I still think we should keep this new metric because of > > performance reason. To get accounted file pages, we need to read > > memory.stat of the root memcg which can be very expensive. Basically it > > may have to flush the rstat update trees on all the CPUs on the system. > > Since this new metric will be used to calculate system overhead, the > > high cost will limit how frequently a user can query the latest stat. > > OK, but couldn't we make that argument for anything else? Like slab, > say. Why's "file" memory different? Good point and I think it does apply to other memory types too. I would call "file" memory to be more important as it is one of the largest consumer of DRAM on, at least, Meta infra. Slab needs a bit more thought. At the system level (i.e. /proc/meminfo), we account at the page (or slab) level while for memcg, we account per-object (plus obj_cgroup pointer).