From: Shakeel Butt <shakeelb@google.com>
To: Roman Gushchin <roman.gushchin@linux.dev>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
cgroups@vger.kernel.org, Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Muchun Song <muchun.song@linux.dev>,
Dennis Zhou <dennis@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
David Rientjes <rientjes@google.com>,
Vlastimil Babka <vbabka@suse.cz>,
Naresh Kamboju <naresh.kamboju@linaro.org>
Subject: Re: [PATCH v2 4/5] mm: kmem: scoped objcg protection
Date: Thu, 12 Oct 2023 13:47:26 +0000 [thread overview]
Message-ID: <20231012134726.kx3rcm7vkgxe3nib@google.com> (raw)
In-Reply-To: <20231010000929.450702-5-roman.gushchin@linux.dev>
On Mon, Oct 09, 2023 at 05:09:28PM -0700, Roman Gushchin wrote:
> Switch to a scope-based protection of the objcg pointer on slab/kmem
> allocation paths. Instead of using the get_() semantics in the
> pre-allocation hook and put the reference afterwards, let's rely
> on the fact that objcg is pinned by the scope.
>
> It's possible because:
> 1) if the objcg is received from the current task struct, the task is
> keeping a reference to the objcg.
> 2) if the objcg is received from an active memcg (remote charging),
> the memcg is pinned by the scope and has a reference to the
> corresponding objcg.
>
> Signed-off-by: Roman Gushchin (Cruise) <roman.gushchin@linux.dev>
Other than one nit below:
Acked-by: Shakeel Butt <shakeelb@google.com>
> ---
> include/linux/memcontrol.h | 6 +++++
> mm/memcontrol.c | 47 ++++++++++++++++++++++++++++++++++++--
> mm/slab.h | 10 +++-----
> 3 files changed, 54 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 277690af383d..0e53b890f063 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -1769,6 +1769,12 @@ bool mem_cgroup_kmem_disabled(void);
> int __memcg_kmem_charge_page(struct page *page, gfp_t gfp, int order);
> void __memcg_kmem_uncharge_page(struct page *page, int order);
>
> +/*
> + * The returned objcg pointer is safe to use without additional
> + * protection within a scope, refer to the implementation for the
> + * additional details.
> + */
Let's add the definition of scope in the above comment as well like
set_active_memcg and slab memcg hooks.
next prev parent reply other threads:[~2023-10-12 13:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 0:09 [PATCH v2 0/5] mm: improve performance of accounted kernel memory allocations Roman Gushchin
2023-10-10 0:09 ` [PATCH v2 1/5] mm: kmem: optimize get_obj_cgroup_from_current() Roman Gushchin
2023-10-10 0:09 ` [PATCH v2 2/5] mm: kmem: add direct objcg pointer to task_struct Roman Gushchin
2023-10-11 18:01 ` Shakeel Butt
2023-10-11 18:05 ` Roman Gushchin
2023-10-10 0:09 ` [PATCH v2 3/5] mm: kmem: make memcg keep a reference to the original objcg Roman Gushchin
2023-10-11 19:51 ` Shakeel Butt
2023-10-10 0:09 ` [PATCH v2 4/5] mm: kmem: scoped objcg protection Roman Gushchin
2023-10-12 13:47 ` Shakeel Butt [this message]
2023-10-10 0:09 ` [PATCH v2 5/5] percpu: " Roman Gushchin
2023-10-12 13:48 ` Shakeel Butt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231012134726.kx3rcm7vkgxe3nib@google.com \
--to=shakeelb@google.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=dennis@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=naresh.kamboju@linaro.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox