Re: [PATCH] mm: memcomtrol: add warning in case of rtpn = NULL

From: Matthew Wilcox
Date: Mon Aug 21 2023 - 10:26:10 EST


On Mon, Aug 21, 2023 at 05:20:51PM +0300, Anastasia Belova wrote:
> kzalloc_node may return NULL. So rtpn should be
> checked before dereference in mem_cgroup_init.

What good will this do?

>
> rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL, node);
> + WARN_ON(!rtpn);
>
> rtpn->rb_root = RB_ROOT;

so you'll get a warning right before you get a crash, which will provide
exactly the same information. And you'd already have a warning that
the memory allocation had failed (because __GFP_NOWARN wasn't set).
So you've increased the amount of data from 2 dumps to 3 without providing
any neww information.

If you _did_ something to avoid the crash, there might be a point to
this, but the fact is that small GFP_KERNEL allocations _don't_ fail.
You need to teach your tool that, or you'll be overwhelmed with
false positives.