On Wed 20-03-24 18:12:50, Michal Hocko wrote: > On Wed 20-03-24 13:09:07, Waiman Long wrote: > > > > On 3/20/24 06:03, Pavel Tikhomirov wrote: > > > In memory_max_write() we first set memcg->memory.max and only then > > > try to enforce it in loop. What if while we are in loop someone else > > > have changed memcg->memory.max but we are still trying to enforce > > > the old value? I believe this can lead to nasty consequence like getting > > > an oom on perfectly fine cgroup within it's limits or excess reclaim. > > > > Concurrent write to the same cgroup control file is not possible as the > > underlying kernfs_open_file structure has a mutex that serialize access to > > the file. > > This is good to know and I was not aware of that. Thanks! Btw. even if the interface itself is serialized then uncoordinated userspace is still timing dependent so fundamentally racy. -- Michal Hocko SUSE Labs