[RFC PATCH v0 0/3] CPU hotplug awareness in percpu allocator
From: Bharata B Rao
Date: Tue Jun 01 2021 - 02:52:17 EST
Hi,
This is an attempt to make the percpu allocator CPU hotplug aware.
Currently the percpu allocator allocates memory for all the possible
CPUs. This can lead to wastage of memory when possible number of CPUs
is significantly higher than the number of online CPUs. This can be
avoided if the percpu allocator were to allocate only for the online
CPUs and extend the allocation for other CPUs as and when they become
online.
This early RFC work shows some good memory savings for a powerpc
KVM guest that is booted with 16 online and 1024 possible CPUs.
Here is the comparision of Percpu memory consumption from
/proc/meminfo before and after creating 1000 memcgs.
W/o patch W/ patch
Before 1441792 kB 22528 kB
After 1000 memcgs 4390912 kB 68608 kB
Note that the Percpu reporting in meminfo has been changed in
the patchset to reflect the allocation for online CPUs only.
More details about the approach are present in the patch
descriptions.
Bharata B Rao (3):
percpu: CPU hotplug support for alloc_percpu()
percpu: Limit percpu allocator to online cpus
percpu: Avoid using percpu ptrs of non-existing cpus
fs/namespace.c | 4 +-
include/linux/cpuhotplug.h | 2 +
include/linux/percpu.h | 15 +++
kernel/cgroup/rstat.c | 20 +++-
kernel/sched/cpuacct.c | 10 +-
kernel/sched/psi.c | 14 ++-
lib/percpu-refcount.c | 4 +-
lib/percpu_counter.c | 2 +-
mm/percpu-internal.h | 9 ++
mm/percpu-vm.c | 211 +++++++++++++++++++++++++++++++++-
mm/percpu.c | 229 +++++++++++++++++++++++++++++++++++--
net/ipv4/fib_semantics.c | 2 +-
net/ipv6/route.c | 6 +-
13 files changed, 490 insertions(+), 38 deletions(-)
--
2.31.1