> On Jan 4, 2019, at 18:12, Michal Hocko <mhocko@xxxxxxxxxx> wrote: > > On Fri 04-01-19 18:02:19, Fam Zheng wrote: >> >> >>> On Jan 4, 2019, at 17:04, Michal Hocko <mhocko@xxxxxxxxxx> wrote: >>> >>> This is a natural side effect of shared memory, I am afraid. Isolated >>> memory cgroups should limit any shared resources to bare minimum. You >>> will get "who touches first gets charged" behavior otherwise and that is >>> not really deterministic. >> >> I don’t quite understand your comment. I think the current behavior >> for the ext4_inode_cachep slab family is just “who touches first >> gets charged”, and later users of the same file from a different mem >> cgroup can benefit from the cache, keep it from being released, but >> doesn’t get charged. > > Yes, this is exactly what I've said. And that leads to non-deterministic > behavior because users from other memcgs are keeping charges alive and > the isolation really doesn't work properly. Think of it as using memory > on behalf of other party that is supposed to be isolated from you. > > Sure this can work reasonably well if the sharing is not really > predominated. OK, I see what you mean. The reality is that the applications want to share files (e.g. docker run -v ...) , and IMO charging accuracy is not the trouble here. The problem is that there are memory usages which are not strictly necessary once a mem cgroup is deleted, such as the biggish struct mem_cgroup and the shadow slabs from which we no longer alloc new objects. Fam > -- > Michal Hocko > SUSE Labs