[PATCH] kthread: update stop_machine to use kthread_bind

From: Serge E . Hallyn
Date: Tue Jun 20 2006 - 12:01:08 EST


Update stop_machine to use the more efficient kthread_bind()
before running task in place of set_cpus_allowed() after.

Signed-off-by: Serge E. Hallyn <serue@xxxxxxxxxx>

---

kernel/stop_machine.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)

fe140b494141aefae45a4fa12a4b4e8fef5d8ee3
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 2dd5a48..698b842 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -26,15 +26,13 @@ static unsigned int stopmachine_num_thre
static atomic_t stopmachine_thread_ack;
static DECLARE_MUTEX(stopmachine_mutex);

-static int stopmachine(void *cpu)
+static int stopmachine(void)
{
int irqs_disabled = 0;
int prepared = 0;

- set_cpus_allowed(current, cpumask_of_cpu((int)(long)cpu));
-
/* Ack: we are alive */
- smp_mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */
+ smp_mb();
atomic_inc(&stopmachine_thread_ack);

/* Simple state machine */
@@ -86,7 +84,8 @@ static void stopmachine_set_state(enum s

static int stop_machine(void)
{
- int i, ret = 0;
+ int ret = 0;
+ unsigned int i;
struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };

/* One high-prio thread per cpu. We'll do this one. */
@@ -100,11 +99,13 @@ static int stop_machine(void)
struct task_struct *tsk;
if (i == raw_smp_processor_id())
continue;
- tsk = kthread_run(stopmachine, (void *)(long)i, "stopmachine");
+ tsk = kthread_create(stopmachine, NULL, "stopmachine");
if (IS_ERR(tsk)) {
ret = PTR_ERR(tsk);
break;
}
+ kthread_bind(tsk, i);
+ wake_up_process(tsk);
stopmachine_num_threads++;
}

--
1.3.3

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/