Re: [PATCH v2 1/2] mm: memcg: refactor page state unit helpers

From: Johannes Weiner
Date: Tue Oct 03 2023 - 09:03:30 EST


On Fri, Sep 22, 2023 at 05:57:39PM +0000, Yosry Ahmed wrote:
> memcg_page_state_unit() is currently used to identify the unit of a
> memcg state item so that all stats in memory.stat are in bytes. However,
> it lies about the units of WORKINGSET_* stats. These stats actually
> represent pages, but we present them to userspace as a scalar number of
> events. In retrospect, maybe those stats should have been memcg "events"
> rather than memcg "state".
>
> In preparation for using memcg_page_state_unit() for other purposes that
> need to know the truthful units of different stat items, break it down
> into two helpers:
> - memcg_page_state_unit() retuns the actual unit of the item.
> - memcg_page_state_output_unit() returns the unit used for output.
>
> Use the latter instead of the former in memcg_page_state_output() and
> lruvec_page_state_output(). While we are at it, let's show cgroup v1
> some love and add memcg_page_state_local_output() for consistency.
>
> No functional change intended.
>
> Signed-off-by: Yosry Ahmed <yosryahmed@xxxxxxxxxx>

That's a nice cleanup in itself.

Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx>