Linux smurf7 2.4.21-32.0.1.ELsmp #1 SMP Tue May 17 17:52:23 EDT 2005
cat /usr/src/linux-2.4/kernel/sched.c | grep migration
struct list_head migration_queue;
* (such as the load balancing or the thread migration code), lock
#define migration_thread(cpu) (cpu_int(cpu)->migration_thread)
#define migration_queue(cpu) (&cpu_int(cpu)->migration_queue)
* We wake up one of the migration threads (it
* imbalance. Since we are the migration thread, try to
* This is how migration works:
* 1) we queue a migration_req_t structure in the source CPU's
* runqueue and wake up that CPU's migration thread.
* 3) migration thread wakes up (implicitly it forces the migrated
* 4) it gets the migration request and checks whether the migrated
* 5) if it's in the wrong runqueue then the migration thread removes
* 6) migration thread up()s the semaphore.
* 7) we wake up and the migration is done.
* migration_task - this is a highprio system thread that performs
* thread migration by 'pulling' threads into the target runqueue.
static int migration_task(void * data)
migration_startup_t *startup = data;
sprintf(current->comm, "migration/%d", cpu);
migration_thread(cpu) = current;
head = migration_queue(cpu);
req = list_entry(head->next, migration_req_t, list);
* migration_call - callback that gets triggered when a CPU is added.
* Here we can start up the necessary migration thread for the new CPU.
void migration_call(void *hcpu)
printk("Starting migration thread for cpu %li\n", (long)hcpu);
kernel_thread(migration_task, &startup, CLONE_KERNEL);
__init int migration_init(void)