[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241109010307.74840-1-sj@kernel.org>
Date: Fri, 8 Nov 2024 17:03:07 -0800
From: SeongJae Park <sj@...nel.org>
To: Joshua Hahn <joshua.hahnjy@...il.com>
Cc: SeongJae Park <sj@...nel.org>,
shakeel.butt@...ux.dev,
hannes@...xchg.org,
mhocko@...nel.org,
roman.gushchin@...ux.dev,
muchun.song@...ux.dev,
akpm@...ux-foundation.org,
cgroups@...r.kernel.org,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
kernel-team@...a.com
Subject: Re: [PATCH 2/3] memcg/hugetlb: Introduce mem_cgroup_charge_hugetlb
Hi Joshua,
On Fri, 8 Nov 2024 13:29:45 -0800 Joshua Hahn <joshua.hahnjy@...il.com> wrote:
> This patch introduces mem_cgroup_charge_hugetlb, which combines the
> logic of mem_cgroup{try,commit}_hugetlb. This reduces the footprint of
Nit. Seems the regular expression is not technically correct?
> memcg in hugetlb code, and also consolidates the error path that memcg
> can take into just one point.
>
> Signed-off-by: Joshua Hahn <joshua.hahnjy@...il.com>
>
> ---
> include/linux/memcontrol.h | 2 ++
> mm/hugetlb.c | 34 ++++++++++++----------------------
> mm/memcontrol.c | 19 +++++++++++++++++++
> 3 files changed, 33 insertions(+), 22 deletions(-)
[...]
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 97f63ec9c9fb..95ee77fe27af 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4529,6 +4529,25 @@ int mem_cgroup_hugetlb_try_charge(struct mem_cgroup *memcg, gfp_t gfp,
> return 0;
> }
>
> +int mem_cgroup_charge_hugetlb(struct folio *folio, gfp_t gfp)
Can we add a kernel-doc comment for this function? Maybe that for
mem_cgroup_hugetlb_try_charge() can be stolen with only small updates?
> +{
> + struct mem_cgroup *memcg = get_mem_cgroup_from_current();
> + int ret = 0;
> +
> + if (mem_cgroup_disabled() || !memcg_accounts_hugetlb() ||
> + !memcg || !cgroup_subsys_on_dfl(memory_cgrp_subsys)) {
> + ret = -EOPNOTSUPP;
> + goto out;
> + }
> +
> + if (charge_memcg(folio, memcg, gfp))
> + ret = -ENOMEM;
> +
> +out:
> + mem_cgroup_put(memcg);
> + return ret;
> +}
> +
> /**
> * mem_cgroup_swapin_charge_folio - Charge a newly allocated folio for swapin.
> * @folio: folio to charge.
> --
> 2.43.5
Thanks,
SJ
Powered by blists - more mailing lists