[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201116150309.GA924708@cmpxchg.org>
Date: Mon, 16 Nov 2020 10:03:09 -0500
From: Johannes Weiner <hannes@...xchg.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Roman Gushchin <guro@...com>, linux-mm@...ck.org,
Shakeel Butt <shakeelb@...gle.com>,
Michal Hocko <mhocko@...nel.org>,
Christoph Lameter <cl@...ux.com>, linux-kernel@...r.kernel.org,
kernel-team@...com
Subject: Re: [PATCH 2/2] mm: memcg/slab: pre-allocate obj_cgroups for slab
caches with SLAB_ACCOUNT
On Thu, Nov 12, 2020 at 05:12:39PM -0800, Andrew Morton wrote:
> On Thu, 12 Nov 2020 16:19:26 -0800 Roman Gushchin <guro@...com> wrote:
>
> > >From 8b28d91475d54c552e503e66f169e1e00475c856 Mon Sep 17 00:00:00 2001
> > From: Roman Gushchin <guro@...com>
> > Date: Wed, 16 Sep 2020 15:43:48 -0700
> > Subject: [PATCH v2 2/2] mm: memcg/slab: pre-allocate obj_cgroups for slab
> > caches with SLAB_ACCOUNT
> >
> > In general it's unknown in advance if a slab page will contain
> > accounted objects or not. In order to avoid memory waste, an
> > obj_cgroup vector is allocated dynamically when a need to account
> > of a new object arises. Such approach is memory efficient, but
> > requires an expensive cmpxchg() to set up the memcg/objcgs pointer,
> > because an allocation can race with a different allocation on another
> > cpu.
> >
> > But in some common cases it's known for sure that a slab page will
> > contain accounted objects: if the page belongs to a slab cache with a
> > SLAB_ACCOUNT flag set. It includes such popular objects like
> > vm_area_struct, anon_vma, task_struct, etc.
> >
> > In such cases we can pre-allocate the objcgs vector and simple assign
> > it to the page without any atomic operations, because at this early
> > stage the page is not visible to anyone else.
> >
> > v2: inline set_page_objcgs() and add some comments, by Johannes
>
> Had me confused! I was looking for the inlined function
> set_page_objcgs(). I think "open-code" is a better term here than
> "inline".
>
> Here's the -fix:
>
> From: Roman Gushchin <guro@...com>
> Subject: mm-memcg-slab-pre-allocate-obj_cgroups-for-slab-caches-with-slab_account-v2
>
> open-code set_page_objcgs() and add some comments, by Johannes
>
> Link: https://lkml.kernel.org/r/20201113001926.GA2934489@carbon.dhcp.thefacebook.com
> Signed-off-by: Roman Gushchin <guro@...com>
> Cc: Christoph Lameter <cl@...ux.com>
> Cc: Johannes Weiner <hannes@...xchg.org>
> Cc: Michal Hocko <mhocko@...nel.org>
> Cc: Shakeel Butt <shakeelb@...gle.com>
> Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
Thanks! For the combined patch:
Acked-by: Johannes Weiner <hannes@...xchg.org>
Powered by blists - more mailing lists