[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3b723bf1-830e-7f47-27ce-98f7808fbc4b@suse.cz>
Date: Wed, 18 Oct 2023 16:23:14 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: Roman Gushchin <roman.gushchin@...ux.dev>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, cgroups@...r.kernel.org,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>, shakeelb@...gle.com,
Muchun Song <muchun.song@...ux.dev>,
Dennis Zhou <dennis@...nel.org>,
David Rientjes <rientjes@...gle.com>,
Naresh Kamboju <naresh.kamboju@...aro.org>
Subject: Re: [PATCH v3 5/5] percpu: scoped objcg protection
On 10/17/23 00:19, Roman Gushchin wrote:
> Similar to slab and kmem, switch to a scope-based protection of the
> objcg pointer to avoid.
>
> Signed-off-by: Roman Gushchin (Cruise) <roman.gushchin@...ux.dev>
> Tested-by: Naresh Kamboju <naresh.kamboju@...aro.org>
> Acked-by: Shakeel Butt <shakeelb@...gle.com>
Reviewed-by: Vlastimil Babka <vbabka@...e.cz>
Do you plan to convert also the bpf users of get_obj_cgroup_from_current()
so it could be removed?
Thanks!
> ---
> mm/percpu.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/mm/percpu.c b/mm/percpu.c
> index a7665de8485f..f53ba692d67a 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -1628,14 +1628,12 @@ static bool pcpu_memcg_pre_alloc_hook(size_t size, gfp_t gfp,
> if (!memcg_kmem_online() || !(gfp & __GFP_ACCOUNT))
> return true;
>
> - objcg = get_obj_cgroup_from_current();
> + objcg = current_obj_cgroup();
> if (!objcg)
> return true;
>
> - if (obj_cgroup_charge(objcg, gfp, pcpu_obj_full_size(size))) {
> - obj_cgroup_put(objcg);
> + if (obj_cgroup_charge(objcg, gfp, pcpu_obj_full_size(size)))
> return false;
> - }
>
> *objcgp = objcg;
> return true;
> @@ -1649,6 +1647,7 @@ static void pcpu_memcg_post_alloc_hook(struct obj_cgroup *objcg,
> return;
>
> if (likely(chunk && chunk->obj_cgroups)) {
> + obj_cgroup_get(objcg);
> chunk->obj_cgroups[off >> PCPU_MIN_ALLOC_SHIFT] = objcg;
>
> rcu_read_lock();
> @@ -1657,7 +1656,6 @@ static void pcpu_memcg_post_alloc_hook(struct obj_cgroup *objcg,
> rcu_read_unlock();
> } else {
> obj_cgroup_uncharge(objcg, pcpu_obj_full_size(size));
> - obj_cgroup_put(objcg);
> }
> }
>
Powered by blists - more mailing lists