Re: [PATCH v2] memcg: workingset: remove folio_memcg_rcu usage

From: Shakeel Butt
Date: Sun Oct 27 2024 - 02:55:34 EST


On Sat, Oct 26, 2024 at 09:37:07AM GMT, Shakeel Butt wrote:
> The function workingset_activation() is called from
> folio_mark_accessed() with the guarantee that the given folio can not be
> freed under us in workingset_activation(). In addition, the association
> of the folio and its memcg can not be broken here because charge
> migration is no more. There is no need to use folio_memcg_rcu. Simply
> use folio_memcg_charged() because that is what this function cares
> about.
>
> Signed-off-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>
> Suggested-by: Yu Zhao <yuzhao@xxxxxxxxxx>
> ---
> Andrew, please put this patch after charge migration deprecation series.
>
> Changes since v1:
> - Fix for mem_cgroup_disabled(). (Yu Zhao)
>

It seems like folio_memcg_charged() is not defined for CONFIG_MEMCG=n
config option. The following stub should fix the build for such config.


diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 89a1e9f10e1b..5502aa8e138e 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1055,6 +1055,11 @@ static inline struct mem_cgroup *folio_memcg(struct folio *folio)
return NULL;
}

+static inline bool folio_memcg_charged(struct folio *folio)
+{
+ return false;
+}
+
static inline struct mem_cgroup *folio_memcg_check(struct folio *folio)
{
return NULL;