On Tue 07-04-20 08:36:24, Michal Hocko wrote: > On Mon 06-04-20 23:48:54, Yafang Shao wrote: > > When I run my memcg testcase which creates lots of memcgs, I found > > there're unexpected out of memory logs while there're still enough > > available free memory. The error log is, > > mkdir: cannot create directory 'foo.65533': Cannot allocate memory > > > > The reason is when we try to create more than MEM_CGROUP_ID_MAX memcgs, an > > -ENOMEM errno will be set by mem_cgroup_css_alloc(), but the right errno > > should be -EBUSY "Device or resource busy". That is same with > > memcg_alloc_cache_id(). > > I do not see EBUSY being listed as expected return value for mkdir(2) > which is the primary way to create a cgroup. > > > As the errno really misled me, we should make it right. After this patch, > > the error log will be, > > mkdir: cannot create directory 'foo.65533': Device or resource busy > > I do see ENOMEM being slightly confusing but if we really need to fix > this then ENOSPC sounds like a better fit to me. Btw. I have just checked 73f576c04b94 ("mm: memcontrol: fix cgroup creation failure after many small jobs") and it explicitly talks about ENOSPC being returned prior to this patch. -- Michal Hocko SUSE Labs