From: Peter Zijlstra <peterz@infradead.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@redhat.com>, Ingo Molnar <mingo@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
LKML <linux-kernel@vger.kernel.org>,
Stephane Eranian <eranian@google.com>,
Andi Kleen <ak@linux.intel.com>, Ian Rogers <irogers@google.com>,
David Rientjes <rientjes@google.com>,
Namhyung Kim <namhyung@google.com>
Subject: Re: [PATCH 1/2] perf core: Add a kmem_cache for struct perf_event
Date: Thu, 11 Mar 2021 13:29:08 +0100 [thread overview]
Message-ID: <YEoNFA5gI0jp/zlF@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20210311115413.444407-1-namhyung@kernel.org>
On Thu, Mar 11, 2021 at 08:54:12PM +0900, Namhyung Kim wrote:
> From: Namhyung Kim <namhyung@google.com>
>
> The kernel can allocate a lot of struct perf_event when profiling. For
> example, 256 cpu x 8 events x 20 cgroups = 40K instances of the struct
> would be allocated on a large system.
>
> The size of struct perf_event in my setup is 1152 byte. As it's
> allocated by kmalloc, the actual allocation size would be rounded up
> to 2K.
>
> Then there's 896 byte (~43%) of waste per instance resulting in total
> ~35MB with 40K instances. We can create a dedicated kmem_cache to
> avoid such a big unnecessary memory consumption.
>
> With this change, I can see below (note this machine has 112 cpus).
>
> # grep perf_event /proc/slabinfo
> perf_event 224 784 1152 7 2 : tunables 24 12 8 : slabdata 112 112 0
>
> The sixth column is pages-per-slab which is 2, and the fifth column is
> obj-per-slab which is 7. Thus actually it can use 1152 x 7 = 8064
> byte in the 8K, and wasted memory is (8192 - 8064) / 7 = ~18 byte per
> instance.
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Thanks for both!
next prev parent reply other threads:[~2021-03-11 12:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-11 11:54 Namhyung Kim
2021-03-11 11:54 ` [PATCH 2/2] perf core: Allocate perf_event in the target node memory Namhyung Kim
2021-03-17 12:38 ` [tip: perf/core] " tip-bot2 for Namhyung Kim
2021-03-11 12:29 ` Peter Zijlstra [this message]
2021-03-17 12:38 ` [tip: perf/core] perf core: Add a kmem_cache for struct perf_event tip-bot2 for Namhyung Kim
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=YEoNFA5gI0jp/zlF@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=namhyung@google.com \
--cc=namhyung@kernel.org \
--cc=rientjes@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
all inboxes | Powered by JetHome®