Re: [PATCH cgroup/for-4.8] cgroup: allow NULL return from ss->css_alloc()

From: Tejun Heo
Date: Tue Jun 21 2016 - 14:57:48 EST


Hello,

On Tue, Jun 21, 2016 at 02:14:04PM -0400, Johannes Weiner wrote:
> Would it be better to remove the error code instead and have everybody
> return NULL? AFAICS, everybody is returning either the object or the
> -ENOMEM error code right now.
>
> What error condition is there for an allocation function?

I already changed cgroup core to interpret NULL return as -ENOMEM.
Maybe we can drop ERR_PTR handling altogether in the future but I'm
not sure. e.g. memcg's id allocation and -ENOSPC check could be in
css_alloc. The thing is css_online is only necessary if there are
requirements around css id or iteration, so css_alloc can easily be
the only alloc / init point and thus should be able to indicate
different failure conditions.

Thanks.

--
tejun