Re: [PATCH 7/7] mm: memcontrol: consolidate lruvec stat flushing

From: Johannes Weiner
Date: Fri Feb 05 2021 - 14:38:49 EST


On Fri, Feb 05, 2021 at 04:17:27PM +0100, Michal Hocko wrote:
> On Tue 02-02-21 13:47:46, Johannes Weiner wrote:
> > There are two functions to flush the per-cpu data of an lruvec into
> > the rest of the cgroup tree: when the cgroup is being freed, and when
> > a CPU disappears during hotplug. The difference is whether all CPUs or
> > just one is being collected, but the rest of the flushing code is the
> > same. Merge them into one function and share the common code.
>
> IIUC the only reason for the cpu == -1 special case is to avoid
> zeroying, right? Is this optimization worth the special case? The code
> would be slightly easier to follow without this.

Hm, it was less about the optimization and more about which CPU(s)
need(s) to be handled. But it's pretty silly the way it's written,
indeed. I'll move the for_each_online_cpu() to the caller and drop the
cpu==-1 special casing, it makes things much simpler and more obvious.

> > Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>
>
> Anyway the above is not really a fundamental objection. It is more important
> to unify the flushing.
>
> Acked-by: Michal Hocko <mhocko@xxxxxxxx>

Thanks. v2 is different, so I'll wait with taking the ack.