From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: rusty@rustcorp.com.au
Cc: jens.axboe@oracle.com, mingo@elte.hu, akpm@linux-foundation.org,
schwidefsky@de.ibm.com, linux-kernel@vger.kernel.org,
Heiko Carstens <heiko.carstens@de.ibm.com>
Subject: [PATCH/RFC v2 4/6] stop_machine: special case for one cpu
Date: Mon, 13 Oct 2008 23:50:11 +0200 [thread overview]
Message-ID: <20081013215132.339790493@de.ibm.com> (raw)
In-Reply-To: <20081013215007.634620563@de.ibm.com>
[-- Attachment #1: 004_stopmachine_single.diff --]
[-- Type: text/plain, Size: 1756 bytes --]
From: Heiko Carstens <heiko.carstens@de.ibm.com>
If only one cpu is online we might as well use the non-smp variant of
stop_machine which should be much faster since no scheduling is needed.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
include/linux/stop_machine.h | 16 +++++++++++-----
kernel/stop_machine.c | 3 +++
2 files changed, 14 insertions(+), 5 deletions(-)
Index: linux-2.6/include/linux/stop_machine.h
===================================================================
--- linux-2.6.orig/include/linux/stop_machine.h
+++ linux-2.6/include/linux/stop_machine.h
@@ -8,6 +8,16 @@
#include <linux/cpumask.h>
#include <asm/system.h>
+static inline int stop_machine_simple(int (*fn)(void *), void *data,
+ const cpumask_t *cpus)
+{
+ int ret;
+ local_irq_disable();
+ ret = fn(data);
+ local_irq_enable();
+ return ret;
+}
+
#if defined(CONFIG_STOP_MACHINE) && defined(CONFIG_SMP)
/**
@@ -40,11 +50,7 @@ int __stop_machine(int (*fn)(void *), vo
static inline int stop_machine(int (*fn)(void *), void *data,
const cpumask_t *cpus)
{
- int ret;
- local_irq_disable();
- ret = fn(data);
- local_irq_enable();
- return ret;
+ return stop_machine_simple(fn, data, cpus);
}
#endif /* CONFIG_SMP */
#endif /* _LINUX_STOP_MACHINE */
Index: linux-2.6/kernel/stop_machine.c
===================================================================
--- linux-2.6.orig/kernel/stop_machine.c
+++ linux-2.6/kernel/stop_machine.c
@@ -111,6 +111,9 @@ int __stop_machine(int (*fn)(void *), vo
struct work_struct *sm_work;
int i;
+ if (num_online_cpus() == 1)
+ return stop_machine_simple(fn, data, cpus);
+
/* Set up initial state. */
mutex_lock(&lock);
num_threads = num_online_cpus();
--
next prev parent reply other threads:[~2008-10-13 21:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-13 21:50 [PATCH/RFC v2 0/6] Convert stop_machine to use a workqueue Heiko Carstens
2008-10-13 21:50 ` [PATCH/RFC v2 1/6] Call init_workqueues before pre smp initcalls Heiko Carstens
2008-10-13 21:50 ` [PATCH/RFC v2 2/6] workqueue: introduce create_rt_workqueue Heiko Carstens
2008-10-21 22:15 ` Rusty Russell
2008-10-13 21:50 ` [PATCH/RFC v2 3/6] stop_machine: use workqueues instead of kernel threads Heiko Carstens
2008-10-13 21:50 ` Heiko Carstens [this message]
2008-10-13 21:50 ` [PATCH/RFC v2 5/6] s390: convert etr/stp to stop_machine interface Heiko Carstens
2008-10-13 21:50 ` [PATCH/RFC v2 6/6] s390: convert to generic IPI infrstructure Heiko Carstens
2008-10-16 10:38 ` [PATCH/RFC v2 0/6] Convert stop_machine to use a workqueue Rusty Russell
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=20081013215132.339790493@de.ibm.com \
--to=heiko.carstens@de.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rusty@rustcorp.com.au \
--cc=schwidefsky@de.ibm.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
Powered by JetHome