diff mbox series

[v3,3/8] mm: memcg: account memory used for memcg vmstats and lruvec stats

Message ID 20240430060612.2171650-4-shakeel.butt@linux.dev (mailing list archive)
State New
Headers show
Series memcg: reduce memory consumption by memcg stats | expand

Commit Message

Shakeel Butt April 30, 2024, 6:06 a.m. UTC
From: Roman Gushchin <roman.gushchin@linux.dev>

The percpu memory used by memcg's memory statistics is already accounted.
For consistency, let's enable accounting for vmstats and lruvec stats
as well.

Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
---
 mm/memcontrol.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Yosry Ahmed April 30, 2024, 8:34 a.m. UTC | #1
On Mon, Apr 29, 2024 at 11:06 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
>
> From: Roman Gushchin <roman.gushchin@linux.dev>
>
> The percpu memory used by memcg's memory statistics is already accounted.
> For consistency, let's enable accounting for vmstats and lruvec stats
> as well.
>
> Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
> Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>

Reviewed-by: Yosry Ahmed <yosryahmed@google.com>

> ---
>  mm/memcontrol.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 7126459ec56a..434cff91b65e 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -5545,8 +5545,8 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)
>         if (!pn)
>                 return 1;
>
> -       pn->lruvec_stats = kzalloc_node(sizeof(struct lruvec_stats), GFP_KERNEL,
> -                                       node);
> +       pn->lruvec_stats = kzalloc_node(sizeof(struct lruvec_stats),
> +                                       GFP_KERNEL_ACCOUNT, node);
>         if (!pn->lruvec_stats)
>                 goto fail;
>
> @@ -5617,7 +5617,8 @@ static struct mem_cgroup *mem_cgroup_alloc(struct mem_cgroup *parent)
>                 goto fail;
>         }
>
> -       memcg->vmstats = kzalloc(sizeof(struct memcg_vmstats), GFP_KERNEL);
> +       memcg->vmstats = kzalloc(sizeof(struct memcg_vmstats),
> +                                GFP_KERNEL_ACCOUNT);
>         if (!memcg->vmstats)
>                 goto fail;
>
> --
> 2.43.0
>
T.J. Mercier April 30, 2024, 5:30 p.m. UTC | #2
On Tue, Apr 30, 2024 at 1:34 AM Yosry Ahmed <yosryahmed@google.com> wrote:
>
> On Mon, Apr 29, 2024 at 11:06 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
> >
> > From: Roman Gushchin <roman.gushchin@linux.dev>
> >
> > The percpu memory used by memcg's memory statistics is already accounted.
> > For consistency, let's enable accounting for vmstats and lruvec stats
> > as well.
> >
> > Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
> > Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
>
> Reviewed-by: Yosry Ahmed <yosryahmed@google.com>
>
Reviewed-by: T.J. Mercier <tjmercier@google.com>
diff mbox series

Patch

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7126459ec56a..434cff91b65e 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5545,8 +5545,8 @@  static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)
 	if (!pn)
 		return 1;
 
-	pn->lruvec_stats = kzalloc_node(sizeof(struct lruvec_stats), GFP_KERNEL,
-					node);
+	pn->lruvec_stats = kzalloc_node(sizeof(struct lruvec_stats),
+					GFP_KERNEL_ACCOUNT, node);
 	if (!pn->lruvec_stats)
 		goto fail;
 
@@ -5617,7 +5617,8 @@  static struct mem_cgroup *mem_cgroup_alloc(struct mem_cgroup *parent)
 		goto fail;
 	}
 
-	memcg->vmstats = kzalloc(sizeof(struct memcg_vmstats), GFP_KERNEL);
+	memcg->vmstats = kzalloc(sizeof(struct memcg_vmstats),
+				 GFP_KERNEL_ACCOUNT);
 	if (!memcg->vmstats)
 		goto fail;