Re: [PATCH v3 1/3] mm: memcg: don't call propagate_protected_usage() needlessly

From: Johannes Weiner
Date: Fri Jul 26 2024 - 19:08:22 EST


On Fri, Jul 26, 2024 at 08:31:08PM +0000, Roman Gushchin wrote:
> Memory protection (min/low) requires a constant tracking of
> protected memory usage. propagate_protected_usage() is called
> on each page counters update and does a number of operations
> even in cases when the actual memory protection functionality
> is not supported (e.g. hugetlb cgroups or memcg swap counters).
>
> It's obviously inefficient and leads to a waste of CPU cycles.
> It can be addressed by calling propagate_protected_usage() only
> for the counters which do support memory guarantees. As of now
> it's only memcg->memory - the unified memory memcg counter.
>
> Signed-off-by: Roman Gushchin <roman.gushchin@xxxxxxxxx>
> Acked-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>

Makes perfect sense.

Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx>

> @@ -13,6 +13,11 @@
> #include <linux/bug.h>
> #include <asm/page.h>
>
> +static bool track_protection(struct page_counter *c)
> +{
> + return c->protection_support;
> +}

IMO it's a bit easier to follow without this. page_counter.c should be
able to access struct page_counter members directly :)