From: Rusty Russell <rusty@rustcorp.com.au>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org
Cc: Christoph Lameter <cl@linux-foundation.org>
Subject: [PATCH 1/7] Improve alloc_percpu: make the per cpu reserve configurable and larger.
Date: Mon Nov 17 23:48:26 CST 2008 [thread overview]
Message-ID: <20081117132630.33F09DDDF5@ozlabs.org> (raw)
This is based on Christoph Lameter's "cpualloc: make the per cpu
reserve configurable" patch, and his "Increase default reserve percpu
area" patch.
Christoph did the hard work of figuring out what the number should be
(based on convering the slub allocator).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Christoph Lameter <cl@linux-foundation.org>
---
Documentation/kernel-parameters.txt | 7 +++++++
include/linux/percpu.h | 10 ++--------
init/main.c | 2 ++
mm/allocpercpu.c | 5 +++++
4 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1704,6 +1704,13 @@
Format: { 0 | 1 }
See arch/parisc/kernel/pdc_chassis.c
+ percpu= [SMP] Configure the number of percpu bytes that can be
+ dynamically allocated. This is used for per cpu
+ variables of modules and other dynamic per cpu data
+ structures. Creation of per cpu structures after boot
+ may fail if this is set too low.
+ Default is 10k/20k for 32 or 64-bit systems.
+
pf. [PARIDE]
See Documentation/blockdev/paride.txt.
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -41,16 +41,10 @@
#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
-/* Enough to cover all DEFINE_PER_CPUs in kernel, including modules. */
#ifndef PERCPU_ENOUGH_ROOM
-#ifdef CONFIG_MODULES
-#define PERCPU_MODULE_RESERVE 8192
-#else
-#define PERCPU_MODULE_RESERVE 0
-#endif
+extern unsigned int percpu_reserve;
-#define PERCPU_ENOUGH_ROOM \
- (__per_cpu_end - __per_cpu_start + PERCPU_MODULE_RESERVE)
+#define PERCPU_ENOUGH_ROOM (__per_cpu_end - __per_cpu_start + percpu_reserve)
#endif /* PERCPU_ENOUGH_ROOM */
/*
diff --git a/init/main.c b/init/main.c
--- a/init/main.c
+++ b/init/main.c
@@ -401,6 +401,8 @@
/* Copy section for each CPU (we discard the original) */
size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
ptr = alloc_bootmem_pages(size * nr_possible_cpus);
+ printk(KERN_INFO "percpu area: %d bytes total, %d available.\n",
+ size, size - (__per_cpu_end - __per_cpu_start));
for_each_possible_cpu(i) {
__per_cpu_offset[i] = ptr - __per_cpu_start;
diff --git a/mm/allocpercpu.c b/mm/allocpercpu.c
--- a/mm/allocpercpu.c
+++ b/mm/allocpercpu.c
@@ -141,3 +141,8 @@
kfree(__percpu_disguise(__pdata));
}
EXPORT_SYMBOL_GPL(percpu_free);
+
+/* A heuristic based on observation. May need to increase. */
+unsigned int percpu_reserve = (sizeof(unsigned long) * 2500);
+
+core_param(percpu, percpu_reserve, uint, 0644);
reply other threads:[~2008-11-17 13:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20081117132630.33F09DDDF5@ozlabs.org \
--to=rusty@rustcorp.com.au \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/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