linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roman Gushchin <guro@fb.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, Shakeel Butt <shakeelb@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	Christoph Lameter <cl@linux.com>, <linux-kernel@vger.kernel.org>,
	<kernel-team@fb.com>
Subject: Re: [PATCH 2/2] mm: memcg/slab: pre-allocate obj_cgroups for slab caches with SLAB_ACCOUNT
Date: Tue, 10 Nov 2020 13:51:52 -0800	[thread overview]
Message-ID: <20201110215152.GA2713540@carbon.dhcp.thefacebook.com> (raw)
In-Reply-To: <20201110125008.003fb018e74c40109fd6723f@linux-foundation.org>

On Tue, Nov 10, 2020 at 12:50:08PM -0800, Andrew Morton wrote:
> On Tue, 10 Nov 2020 11:57:53 -0800 Roman Gushchin <guro@fb.com> wrote:
> 
> > 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.
> 
> Was there any measurable performance change from this?

A very simplistic benchmark (allocating 10000000 64-bytes objects in a row)
shows ~15% win. In the real life it seems that most workloads are not very
sensitive to the speed of (accounted) slab allocations.

  reply	other threads:[~2020-11-10 21:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10 19:57 [PATCH 1/2] mm: slub: call account_slab_page() after slab page initialization Roman Gushchin
2020-11-10 19:57 ` [PATCH 2/2] mm: memcg/slab: pre-allocate obj_cgroups for slab caches with SLAB_ACCOUNT Roman Gushchin
2020-11-10 20:50   ` Andrew Morton
2020-11-10 21:51     ` Roman Gushchin [this message]
2020-11-12 16:23   ` Johannes Weiner
2020-11-13  0:19     ` Roman Gushchin
2020-11-13  1:12       ` Andrew Morton
2020-11-13  1:46         ` Roman Gushchin
2020-11-16 15:03         ` Johannes Weiner
2020-11-17 17:42       ` Shakeel Butt
2020-11-17 20:15         ` Roman Gushchin
2020-11-12 15:18 ` [PATCH 1/2] mm: slub: call account_slab_page() after slab page initialization Johannes Weiner
2020-11-17 17:16 ` 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=20201110215152.GA2713540@carbon.dhcp.thefacebook.com \
    --to=guro@fb.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=shakeelb@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).