upgrade to fedora-2.6.12-1.1398.FC4 + vserver 2.0.rc7
[linux-2.6.git] / arch / um / kernel / smp.c
index 7c9737c..72113b0 100644 (file)
@@ -18,10 +18,10 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 #include "linux/threads.h"
 #include "linux/interrupt.h"
 #include "linux/err.h"
+#include "linux/hardirq.h"
 #include "asm/smp.h"
 #include "asm/processor.h"
 #include "asm/spinlock.h"
-#include "asm/hardirq.h"
 #include "user_util.h"
 #include "kern_util.h"
 #include "kern.h"
@@ -29,9 +29,11 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 #include "os.h"
 
 /* CPU online map, set by smp_boot_cpus */
-unsigned long cpu_online_map = CPU_MASK_NONE;
+cpumask_t cpu_online_map = CPU_MASK_NONE;
+cpumask_t cpu_possible_map = CPU_MASK_NONE;
 
 EXPORT_SYMBOL(cpu_online_map);
+EXPORT_SYMBOL(cpu_possible_map);
 
 /* Per CPU bogomips and other parameters
  * The only piece used here is the ipi pipe, which is set before SMP is
@@ -39,23 +41,9 @@ EXPORT_SYMBOL(cpu_online_map);
  */
 struct cpuinfo_um cpu_data[NR_CPUS];
 
-spinlock_t um_bh_lock = SPIN_LOCK_UNLOCKED;
-
-atomic_t global_bh_count;
-
-/* Not used by UML */
-unsigned char global_irq_holder = NO_PROC_ID;
-unsigned volatile long global_irq_lock;
-
-/* Set when the idlers are all forked */
-int smp_threads_ready = 0;
-
 /* A statistic, can be a little off */
 int num_reschedules_sent = 0;
 
-/* Small, random number, never changed */
-unsigned long cache_decay_ticks = 5;
-
 /* Not changed after boot */
 struct task_struct *idle_threads[NR_CPUS];
 
@@ -65,41 +53,6 @@ void smp_send_reschedule(int cpu)
        num_reschedules_sent++;
 }
 
-static void show(char * str)
-{
-       int cpu = smp_processor_id();
-
-       printk(KERN_INFO "\n%s, CPU %d:\n", str, cpu);
-}
-       
-#define MAXCOUNT 100000000
-
-static inline void wait_on_bh(void)
-{
-       int count = MAXCOUNT;
-       do {
-               if (!--count) {
-                       show("wait_on_bh");
-                       count = ~0;
-               }
-               /* nothing .. wait for the other bh's to go away */
-       } while (atomic_read(&global_bh_count) != 0);
-}
-
-/*
- * This is called when we want to synchronize with
- * bottom half handlers. We need to wait until
- * no other CPU is executing any bottom half handler.
- *
- * Don't wait if we're already running in an interrupt
- * context or are inside a bh handler. 
- */
-void synchronize_bh(void)
-{
-       if (atomic_read(&global_bh_count) && !in_interrupt())
-               wait_on_bh();
-}
-
 void smp_send_stop(void)
 {
        int i;
@@ -148,9 +101,8 @@ static struct task_struct *idle_thread(int cpu)
 
         current->thread.request.u.thread.proc = idle_proc;
         current->thread.request.u.thread.arg = (void *) cpu;
-       new_task = copy_process(CLONE_VM | CLONE_IDLETASK, 0, NULL, 0, NULL, 
-                               NULL);
-       if(IS_ERR(new_task)) 
+       new_task = fork_idle(cpu);
+       if(IS_ERR(new_task))
                panic("copy_process failed in idle_thread, error = %ld",
                      PTR_ERR(new_task));
 
@@ -158,10 +110,9 @@ static struct task_struct *idle_thread(int cpu)
                          { .pid =      new_task->thread.mode.tt.extern_pid,
                            .task =     new_task } );
        idle_threads[cpu] = new_task;
-       CHOOSE_MODE(os_write_file(new_task->thread.mode.tt.switch_pipe[1], &c, 
+       CHOOSE_MODE(os_write_file(new_task->thread.mode.tt.switch_pipe[1], &c,
                          sizeof(c)),
                    ({ panic("skas mode doesn't support SMP"); }));
-       wake_up_forked_process(new_task);
        return(new_task);
 }
 
@@ -170,6 +121,10 @@ void smp_prepare_cpus(unsigned int maxcpus)
        struct task_struct *idle;
        unsigned long waittime;
        int err, cpu, me = smp_processor_id();
+       int i;
+
+       for (i = 0; i < ncpus; ++i)
+               cpu_set(i, cpu_possible_map);
 
        cpu_clear(me, cpu_online_map);
        cpu_set(me, cpu_online_map);
@@ -179,7 +134,7 @@ void smp_prepare_cpus(unsigned int maxcpus)
        if(err < 0)
                panic("CPU#0 failed to create IPI pipe, errno = %d", -err);
 
-       activate_ipi(cpu_data[me].ipi_pipe[0], 
+       activate_ipi(cpu_data[me].ipi_pipe[0],
                     current->thread.mode.tt.extern_pid);
 
        for(cpu = 1; cpu < ncpus; cpu++){
@@ -255,7 +210,7 @@ int hard_smp_processor_id(void)
        return(pid_to_processor_id(os_getpid()));
 }
 
-static spinlock_t call_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(call_lock);
 static atomic_t scf_started;
 static atomic_t scf_finished;
 static void (*func)(void *info);
@@ -286,10 +241,8 @@ int smp_call_function(void (*_func)(void *info), void *_info, int nonatomic,
        func = _func;
        info = _info;
 
-       for (i=0;i<NR_CPUS;i++)
-               if((i != current_thread->cpu) && 
-                  cpu_isset(i, cpu_online_map))
-                       os_write_file(cpu_data[i].ipi_pipe[1], "C", 1);
+       for_each_online_cpu(i)
+               os_write_file(cpu_data[i].ipi_pipe[1], "C", 1);
 
        while (atomic_read(&scf_started) != cpus)
                barrier();