Re: [PATCH v6 20/29] memcg: skip memcg kmem allocations in specified code regions

Andrew Morton
2012-11-06T00:33:16Z

On Thu, 1 Nov 2012 16:07:36 +0400
Glauber Costa <glommer@parallels.com> wrote:

> This patch creates a mechanism that skip memcg allocations during
> certain pieces of our core code. It basically works in the same way
> as preempt_disable()/preempt_enable(): By marking a region under
> which all allocations will be accounted to the root memcg.
>
> We need this to prevent races in early cache creation, when we
> allocate data using caches that are not necessarily created already.
>
> ...
>
> +static inline void memcg_stop_kmem_account(void)
> +{
> + if (!current->mm)
> + return;

It is utterly unobvious to this reader why the code tests ->mm in this
fashion. So we need either smarter readers or a code comment.