From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
x86@kernel.org, Andi Kleen <andi@firstfloor.org>,
Nick Piggin <nickpiggin@yahoo.com.au>,
Jens Axboe <jens.axboe@oracle.com>
Subject: [PATCH 9 of 9] smp function calls: add kernel parameter to disable multiple queues
Date: Mon, 18 Aug 2008 11:23:46 -0700 [thread overview]
Message-ID: <550e974a4de69f976426.1219083826@localhost> (raw)
In-Reply-To: <patchbomb.1219083817@localhost>
There was some concern that using multiple queues - and their
associated APIC vectors - may trigger bugs in various dubious APIC
implementations. This patch adds a command line option to force the
kernel to use a single queue, even if the architecture can support
more.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
Documentation/kernel-parameters.txt | 5 +++++
arch/x86/kernel/smp.c | 2 +-
arch/x86/xen/smp.c | 6 ++++--
include/linux/smp.h | 26 ++++++++++++++++++++++++++
kernel/smp.c | 14 +++++++++++++-
5 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1901,6 +1901,11 @@
simeth= [IA-64]
simscsi=
+ single_ipi_queue [X86]
+ Force the use of a single queue for smp function calls.
+ This means that only a single vector is used, which may avoid
+ bugs in some APIC implementations.
+
slram= [HW,MTD]
slub_debug[=options[,slabs]] [MM, SLUB]
diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
--- a/arch/x86/kernel/smp.c
+++ b/arch/x86/kernel/smp.c
@@ -129,7 +129,7 @@
void native_send_call_func_ipi(cpumask_t mask)
{
cpumask_t allbutself;
- unsigned queue = smp_processor_id() % CONFIG_GENERIC_SMP_QUEUES;
+ unsigned queue = smp_ipi_choose_queue();
allbutself = cpu_online_map;
cpu_clear(smp_processor_id(), allbutself);
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -373,7 +373,7 @@
static void xen_smp_send_call_function_ipi(cpumask_t mask)
{
int cpu;
- unsigned queue = smp_processor_id() % CONFIG_GENERIC_SMP_QUEUES;
+ unsigned queue = smp_ipi_choose_queue();
/*
* We can't afford to allocate N callfunc vectors * M cpu
@@ -411,10 +411,12 @@
unsigned queue;
irq_enter();
+
queue = start_queue;
do {
generic_smp_call_function_interrupt(queue);
- queue = (queue + 1) % CONFIG_GENERIC_SMP_QUEUES;
+ if (++queue == smp_ipi_nqueues())
+ queue = 0;
} while(queue != start_queue);
#ifdef CONFIG_X86_32
diff --git a/include/linux/smp.h b/include/linux/smp.h
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -170,4 +170,30 @@
void smp_setup_processor_id(void);
+#ifdef CONFIG_USE_GENERIC_SMP_HELPERS
+extern bool __read_mostly smp_single_ipi_queue;
+
+static inline unsigned smp_ipi_nqueues(void)
+{
+ unsigned nqueues = 1;
+
+#ifdef CONFIG_GENERIC_SMP_QUEUES
+ nqueues = CONFIG_GENERIC_SMP_QUEUES;
+#endif
+
+ return nqueues;
+}
+
+static inline unsigned smp_ipi_choose_queue(void)
+{
+ unsigned cpu = smp_processor_id();
+ unsigned nqueues = smp_ipi_nqueues();
+
+ if (nqueues == 1 || smp_single_ipi_queue)
+ return 0;
+
+ return cpu % nqueues;
+}
+#endif
+
#endif /* __LINUX_SMP_H */
diff --git a/kernel/smp.c b/kernel/smp.c
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -10,6 +10,8 @@
#include <linux/rcupdate.h>
#include <linux/rculist.h>
#include <linux/smp.h>
+
+bool __read_mostly smp_single_ipi_queue = false;
#ifdef CONFIG_GENERIC_SMP_QUEUES
#define NQUEUES CONFIG_GENERIC_SMP_QUEUES
@@ -347,7 +349,7 @@
cpus_and(mask, mask, allbutself);
num_cpus = cpus_weight(mask);
- queue_no = cpu % NQUEUES;
+ queue_no = smp_ipi_choose_queue();
queue = &call_function_queues[queue_no];
/*
@@ -466,6 +468,16 @@
spin_lock_init(&call_function_queues[i].lock);
}
+ printk(KERN_INFO "smp function calls: using %d/%d queues\n",
+ smp_ipi_nqueues(), NQUEUES);
+
return 0;
}
early_initcall(init_smp_function_call);
+
+static __init int set_single_ipi_queue(char *str)
+{
+ smp_single_ipi_queue = true;
+ return 0;
+}
+early_param("single_ipi_queue", set_single_ipi_queue);
next prev parent reply other threads:[~2008-08-18 21:53 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-18 18:23 [PATCH 0 of 9] x86/smp function calls: convert x86 tlb flushes to use function calls [POST 2] Jeremy Fitzhardinge
2008-08-18 18:23 ` [PATCH 1 of 9] x86: put tlb_flush_others() stats in debugfs Jeremy Fitzhardinge
2008-08-18 18:23 ` [PATCH 2 of 9] x86-32: use smp_call_function_mask for SMP TLB invalidations Jeremy Fitzhardinge
2008-08-18 18:23 ` [PATCH 3 of 9] x86-64: " Jeremy Fitzhardinge
2008-08-18 18:23 ` [PATCH 4 of 9] x86: make tlb_32|64 closer Jeremy Fitzhardinge
2008-08-18 18:23 ` [PATCH 5 of 9] x86: unify tlb.c Jeremy Fitzhardinge
2008-08-18 18:23 ` [PATCH 6 of 9] smp_function_call: add multiple queues for scalability Jeremy Fitzhardinge
2008-08-18 18:23 ` [PATCH 7 of 9] x86: add multiple smp_call_function queues Jeremy Fitzhardinge
2008-08-18 18:23 ` [PATCH 8 of 9] x86: make number of smp_call_function queues truely configurable Jeremy Fitzhardinge
2008-08-18 18:23 ` Jeremy Fitzhardinge [this message]
2008-08-19 0:45 ` [PATCH 0 of 9] x86/smp function calls: convert x86 tlb flushes to use function calls [POST 2] Ingo Molnar
2008-08-19 1:28 ` Ingo Molnar
2008-08-19 6:18 ` Jeremy Fitzhardinge
2008-08-19 9:27 ` Ingo Molnar
2008-08-19 14:58 ` Jeremy Fitzhardinge
2008-08-19 9:45 ` Peter Zijlstra
2008-08-19 14:58 ` Jeremy Fitzhardinge
2008-08-19 5:37 ` Jeremy Fitzhardinge
2008-08-19 9:31 ` Ingo Molnar
2008-08-19 9:56 ` Nick Piggin
2008-08-19 10:20 ` Ingo Molnar
2008-08-19 11:08 ` Nick Piggin
2008-08-19 11:44 ` Ingo Molnar
2008-08-19 10:24 ` Ingo Molnar
2008-08-19 10:49 ` Nick Piggin
2008-08-19 10:31 ` Andi Kleen
2008-08-19 11:04 ` Nick Piggin
2008-08-19 11:20 ` Andi Kleen
2008-08-19 7:32 ` Andi Kleen
2008-08-19 7:44 ` Jeremy Fitzhardinge
2008-08-19 7:48 ` Andi Kleen
2008-08-19 8:04 ` Jeremy Fitzhardinge
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=550e974a4de69f976426.1219083826@localhost \
--to=jeremy@goop.org \
--cc=andi@firstfloor.org \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=nickpiggin@yahoo.com.au \
--cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.