[PATCH] fix preempt-issues with smp_call_function()
[linux-flexiantxendom0-3.2.10.git] / arch / parisc / kernel / smp.c
1 /*
2 ** SMP Support
3 **
4 ** Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
5 ** Copyright (C) 1999 David Mosberger-Tang <davidm@hpl.hp.com>
6 ** Copyright (C) 2001 Grant Grundler <grundler@parisc-linux.org>
7 ** 
8 ** Lots of stuff stolen from arch/alpha/kernel/smp.c
9 ** ...and then parisc stole from arch/ia64/kernel/smp.c. Thanks David! :^)
10 **
11 ** Thanks to John Curry and Ullas Ponnadi. I learned alot from their work.
12 ** -grant (1/12/2001)
13 **
14 **      This program is free software; you can redistribute it and/or modify
15 **      it under the terms of the GNU General Public License as published by
16 **      the Free Software Foundation; either version 2 of the License, or
17 **      (at your option) any later version.
18 */
19 #define __KERNEL_SYSCALLS__
20 #undef ENTRY_SYS_CPUS   /* syscall support for iCOD-like functionality */
21
22 #include <linux/autoconf.h>
23
24 #include <linux/types.h>
25 #include <linux/spinlock.h>
26 #include <linux/slab.h>
27
28 #include <linux/kernel.h>
29 #include <linux/sched.h>
30 #include <linux/init.h>
31 #include <linux/interrupt.h>
32 #include <linux/smp.h>
33 #include <linux/kernel_stat.h>
34 #include <linux/mm.h>
35 #include <linux/delay.h>
36
37 #include <asm/system.h>
38 #include <asm/atomic.h>
39 #include <asm/bitops.h>
40 #include <asm/current.h>
41 #include <asm/delay.h>
42 #include <asm/pgalloc.h>        /* for flush_tlb_all() proto/macro */
43
44 #include <asm/io.h>
45 #include <asm/irq.h>            /* for CPU_IRQ_REGION and friends */
46 #include <asm/mmu_context.h>
47 #include <asm/page.h>
48 #include <asm/pgtable.h>
49 #include <asm/pgalloc.h>
50 #include <asm/processor.h>
51 #include <asm/ptrace.h>
52 #include <asm/unistd.h>
53 #include <asm/cacheflush.h>
54
55 #define kDEBUG 0
56
57 spinlock_t pa_dbit_lock = SPIN_LOCK_UNLOCKED;
58
59 spinlock_t smp_lock = SPIN_LOCK_UNLOCKED;
60
61 volatile struct task_struct *smp_init_current_idle_task;
62
63 static volatile int smp_commenced = 0;   /* Set when the idlers are all forked */
64 static volatile int cpu_now_booting = 0;      /* track which CPU is booting */
65 volatile unsigned long cpu_online_map = 0;   /* Bitmap of online CPUs */
66 #define IS_LOGGED_IN(cpunum) (test_bit(cpunum, (atomic_t *)&cpu_online_map))
67
68 int smp_num_cpus = 1;
69 int smp_threads_ready = 0;
70 unsigned long cache_decay_ticks;
71 static int max_cpus = -1;                            /* Command line */
72 unsigned long cpu_present_mask;
73
74 struct smp_call_struct {
75         void (*func) (void *info);
76         void *info;
77         long wait;
78         atomic_t unstarted_count;
79         atomic_t unfinished_count;
80 };
81 static volatile struct smp_call_struct *smp_call_function_data;
82
83 enum ipi_message_type {
84         IPI_NOP=0,
85         IPI_RESCHEDULE=1,
86         IPI_CALL_FUNC,
87         IPI_CPU_START,
88         IPI_CPU_STOP,
89         IPI_CPU_TEST
90 };
91
92
93 /********** SMP inter processor interrupt and communication routines */
94
95 #undef PER_CPU_IRQ_REGION
96 #ifdef PER_CPU_IRQ_REGION
97 /* XXX REVISIT Ignore for now.
98 **    *May* need this "hook" to register IPI handler
99 **    once we have perCPU ExtIntr switch tables.
100 */
101 static void
102 ipi_init(int cpuid)
103 {
104
105         /* If CPU is present ... */
106 #ifdef ENTRY_SYS_CPUS
107         /* *and* running (not stopped) ... */
108 #error iCOD support wants state checked here.
109 #endif
110
111 #error verify IRQ_OFFSET(IPI_IRQ) is ipi_interrupt() in new IRQ region
112
113         if(IS_LOGGED_IN(cpuid) )
114         {
115                 switch_to_idle_task(current);
116         }
117
118         return;
119 }
120 #endif
121
122
123 /*
124 ** Yoink this CPU from the runnable list... 
125 **
126 */
127 static void
128 halt_processor(void) 
129 {
130 #ifdef ENTRY_SYS_CPUS
131 #error halt_processor() needs rework
132 /*
133 ** o migrate I/O interrupts off this CPU.
134 ** o leave IPI enabled - __cli() will disable IPI.
135 ** o leave CPU in online map - just change the state
136 */
137         cpu_data[this_cpu].state = STATE_STOPPED;
138         mark_bh(IPI_BH);
139 #else
140         /* REVISIT : redirect I/O Interrupts to another CPU? */
141         /* REVISIT : does PM *know* this CPU isn't available? */
142         clear_bit(smp_processor_id(), (void *)&cpu_online_map);
143         local_irq_disable();
144         for (;;)
145                 ;
146 #endif
147 }
148
149
150 void
151 ipi_interrupt(int irq, void *dev_id, struct pt_regs *regs) 
152 {
153         int this_cpu = smp_processor_id();
154         struct cpuinfo_parisc *p = &cpu_data[this_cpu];
155         unsigned long ops;
156         unsigned long flags;
157
158         /* Count this now; we may make a call that never returns. */
159         p->ipi_count++;
160
161         mb();   /* Order interrupt and bit testing. */
162
163         for (;;) {
164                 spin_lock_irqsave(&(p->lock),flags);
165                 ops = p->pending_ipi;
166                 p->pending_ipi = 0;
167                 spin_unlock_irqrestore(&(p->lock),flags);
168
169                 mb(); /* Order bit clearing and data access. */
170
171                 if (!ops)
172                     break;
173
174                 while (ops) {
175                         unsigned long which = ffz(~ops);
176
177                         switch (which) {
178                         case IPI_RESCHEDULE:
179 #if (kDEBUG>=100)
180                                 printk(KERN_DEBUG "CPU%d IPI_RESCHEDULE\n",this_cpu);
181 #endif /* kDEBUG */
182                                 ops &= ~(1 << IPI_RESCHEDULE);
183                                 /*
184                                  * Reschedule callback.  Everything to be
185                                  * done is done by the interrupt return path.
186                                  */
187                                 break;
188
189                         case IPI_CALL_FUNC:
190 #if (kDEBUG>=100)
191                                 printk(KERN_DEBUG "CPU%d IPI_CALL_FUNC\n",this_cpu);
192 #endif /* kDEBUG */
193                                 ops &= ~(1 << IPI_CALL_FUNC);
194                                 {
195                                         volatile struct smp_call_struct *data;
196                                         void (*func)(void *info);
197                                         void *info;
198                                         int wait;
199
200                                         data = smp_call_function_data;
201                                         func = data->func;
202                                         info = data->info;
203                                         wait = data->wait;
204
205                                         mb();
206                                         atomic_dec ((atomic_t *)&data->unstarted_count);
207
208                                         /* At this point, *data can't
209                                          * be relied upon.
210                                          */
211
212                                         (*func)(info);
213
214                                         /* Notify the sending CPU that the
215                                          * task is done.
216                                          */
217                                         mb();
218                                         if (wait)
219                                                 atomic_dec ((atomic_t *)&data->unfinished_count);
220                                 }
221                                 break;
222
223                         case IPI_CPU_START:
224 #if (kDEBUG>=100)
225                                 printk(KERN_DEBUG "CPU%d IPI_CPU_START\n",this_cpu);
226 #endif /* kDEBUG */
227                                 ops &= ~(1 << IPI_CPU_START);
228 #ifdef ENTRY_SYS_CPUS
229                                 p->state = STATE_RUNNING;
230 #endif
231                                 break;
232
233                         case IPI_CPU_STOP:
234 #if (kDEBUG>=100)
235                                 printk(KERN_DEBUG "CPU%d IPI_CPU_STOP\n",this_cpu);
236 #endif /* kDEBUG */
237                                 ops &= ~(1 << IPI_CPU_STOP);
238 #ifdef ENTRY_SYS_CPUS
239 #else
240                                 halt_processor();
241 #endif
242                                 break;
243
244                         case IPI_CPU_TEST:
245 #if (kDEBUG>=100)
246                                 printk(KERN_DEBUG "CPU%d is alive!\n",this_cpu);
247 #endif /* kDEBUG */
248                                 ops &= ~(1 << IPI_CPU_TEST);
249                                 break;
250
251                         default:
252                                 printk(KERN_CRIT "Unknown IPI num on CPU%d: %lu\n",
253                                         this_cpu, which);
254                                 ops &= ~(1 << which);
255                                 return;
256                         } /* Switch */
257                 } /* while (ops) */
258         }
259         return;
260 }
261
262
263 static inline void
264 ipi_send(int cpu, enum ipi_message_type op)
265 {
266         struct cpuinfo_parisc *p = &cpu_data[cpu];
267         unsigned long flags;
268
269         spin_lock_irqsave(&(p->lock),flags);
270         p->pending_ipi |= 1 << op;
271         __raw_writel(IRQ_OFFSET(IPI_IRQ), cpu_data[cpu].hpa);
272         spin_unlock_irqrestore(&(p->lock),flags);
273 }
274
275
276 static inline void
277 send_IPI_single(int dest_cpu, enum ipi_message_type op)
278 {
279         if (dest_cpu == NO_PROC_ID) {
280                 BUG();
281                 return;
282         }
283
284         ipi_send(dest_cpu, op);
285 }
286
287 static inline void
288 send_IPI_allbutself(enum ipi_message_type op)
289 {
290         int i;
291         
292         for (i = 0; i < smp_num_cpus; i++) {
293                 if (i != smp_processor_id())
294                         send_IPI_single(i, op);
295         }
296 }
297
298 inline void 
299 smp_send_stop(void)     { send_IPI_allbutself(IPI_CPU_STOP); }
300
301 static inline void
302 smp_send_start(void)    { send_IPI_allbutself(IPI_CPU_START); }
303
304 void 
305 smp_send_reschedule(int cpu) { send_IPI_single(cpu, IPI_RESCHEDULE); }
306
307
308 /**
309  * Run a function on all other CPUs.
310  *  <func>      The function to run. This must be fast and non-blocking.
311  *  <info>      An arbitrary pointer to pass to the function.
312  *  <retry>     If true, keep retrying until ready.
313  *  <wait>      If true, wait until function has completed on other CPUs.
314  *  [RETURNS]   0 on success, else a negative status code.
315  *
316  * Does not return until remote CPUs are nearly ready to execute <func>
317  * or have executed.
318  */
319
320 int
321 smp_call_function (void (*func) (void *info), void *info, int retry, int wait)
322 {
323         struct smp_call_struct data;
324         long timeout;
325         static spinlock_t lock = SPIN_LOCK_UNLOCKED;
326         
327         data.func = func;
328         data.info = info;
329         data.wait = wait;
330         atomic_set(&data.unstarted_count, smp_num_cpus - 1);
331         atomic_set(&data.unfinished_count, smp_num_cpus - 1);
332
333         if (retry) {
334                 spin_lock (&lock);
335                 while (smp_call_function_data != 0)
336                         barrier();
337         }
338         else {
339                 spin_lock (&lock);
340                 if (smp_call_function_data) {
341                         spin_unlock (&lock);
342                         return -EBUSY;
343                 }
344         }
345
346         smp_call_function_data = &data;
347         spin_unlock (&lock);
348         
349         /*  Send a message to all other CPUs and wait for them to respond  */
350         send_IPI_allbutself(IPI_CALL_FUNC);
351
352         /*  Wait for response  */
353         timeout = jiffies + HZ;
354         while ( (atomic_read (&data.unstarted_count) > 0) &&
355                 time_before (jiffies, timeout) )
356                 barrier ();
357
358         /* We either got one or timed out. Release the lock */
359
360         mb();
361         smp_call_function_data = NULL;
362         if (atomic_read (&data.unstarted_count) > 0) {
363                 printk(KERN_CRIT "SMP CALL FUNCTION TIMED OUT! (cpu=%d)\n",
364                       smp_processor_id());
365                 return -ETIMEDOUT;
366         }
367
368         while (wait && atomic_read (&data.unfinished_count) > 0)
369                         barrier ();
370
371         return 0;
372 }
373
374
375
376 /*
377  *      Setup routine for controlling SMP activation
378  *
379  *      Command-line option of "nosmp" or "maxcpus=0" will disable SMP
380  *      activation entirely (the MPS table probe still happens, though).
381  *
382  *      Command-line option of "maxcpus=<NUM>", where <NUM> is an integer
383  *      greater than 0, limits the maximum number of CPUs activated in
384  *      SMP mode to <NUM>.
385  */
386
387 static int __init nosmp(char *str)
388 {
389         max_cpus = 0;
390         return 1;
391 }
392
393 __setup("nosmp", nosmp);
394
395 static int __init maxcpus(char *str)
396 {
397         get_option(&str, &max_cpus);
398         return 1;
399 }
400
401 __setup("maxcpus=", maxcpus);
402
403 /*
404  * Flush all other CPU's tlb and then mine.  Do this with on_each_cpu()
405  * as we want to ensure all TLB's flushed before proceeding.
406  */
407
408 extern void flush_tlb_all_local(void);
409
410 void
411 smp_flush_tlb_all(void)
412 {
413         on_each_cpu((void (*)(void *))flush_tlb_all_local, NULL, 1, 1);
414 }
415
416
417 void 
418 smp_do_timer(struct pt_regs *regs)
419 {
420         int cpu = smp_processor_id();
421         struct cpuinfo_parisc *data = &cpu_data[cpu];
422
423         if (!--data->prof_counter) {
424                 data->prof_counter = data->prof_multiplier;
425                 update_process_times(user_mode(regs));
426         }
427 }
428
429 /*
430  * Called by secondaries to update state and initialize CPU registers.
431  */
432 static void __init
433 smp_cpu_init(int cpunum)
434 {
435         extern int init_per_cpu(int);  /* arch/parisc/kernel/setup.c */
436         extern void init_IRQ(void);    /* arch/parisc/kernel/irq.c */
437
438         /* Set modes and Enable floating point coprocessor */
439         (void) init_per_cpu(cpunum);
440
441         disable_sr_hashing();
442
443         mb();
444
445         /* Well, support 2.4 linux scheme as well. */
446         if (test_and_set_bit(cpunum, (unsigned long *) (&cpu_online_map)))
447         {
448                 extern void machine_halt(void); /* arch/parisc.../process.c */
449
450                 printk(KERN_CRIT "CPU#%d already initialized!\n", cpunum);
451                 machine_halt();
452         }  
453
454         /* Initialise the idle task for this CPU */
455         atomic_inc(&init_mm.mm_count);
456         current->active_mm = &init_mm;
457         if(current->mm)
458                 BUG();
459         enter_lazy_tlb(&init_mm, current, cpunum);
460
461         init_IRQ();   /* make sure no IRQ's are enabled or pending */
462 }
463
464
465 /*
466  * Slaves start using C here. Indirectly called from smp_slave_stext.
467  * Do what start_kernel() and main() do for boot strap processor (aka monarch)
468  */
469 void __init smp_callin(void)
470 {
471         extern void cpu_idle(void);     /* arch/parisc/kernel/process.c */
472         int slave_id = cpu_now_booting;
473 #if 0
474         void *istack;
475 #endif
476
477         smp_cpu_init(slave_id);
478
479 #if 0   /* NOT WORKING YET - see entry.S */
480         istack = (void *)__get_free_pages(GFP_KERNEL,ISTACK_ORDER);
481         if (istack == NULL) {
482             printk(KERN_CRIT "Failed to allocate interrupt stack for cpu %d\n",slave_id);
483             BUG();
484         }
485         mtctl(istack,31);
486 #endif
487
488         flush_cache_all_local(); /* start with known state */
489         flush_tlb_all_local();
490
491         local_irq_enable();  /* Interrupts have been off until now */
492
493         /* Slaves wait here until Big Poppa daddy say "jump" */
494         mb();   /* PARANOID */
495         while (!smp_commenced) ;
496         mb();   /* PARANOID */
497
498         cpu_idle();      /* Wait for timer to schedule some work */
499
500         /* NOTREACHED */
501         panic("smp_callin() AAAAaaaaahhhh....\n");
502 }
503
504 /*
505  * Create the idle task for a new Slave CPU.  DO NOT use kernel_thread()
506  * because that could end up calling schedule(). If it did, the new idle
507  * task could get scheduled before we had a chance to remove it from the
508  * run-queue...
509  */
510 static struct task_struct *fork_by_hand(void)
511 {
512         struct pt_regs regs;  
513
514         /*
515          * don't care about the regs settings since
516          * we'll never reschedule the forked task.
517          */
518         return do_fork(CLONE_VM|CLONE_IDLETASK, 0, &regs, 0, NULL, NULL);
519 }
520
521
522 /*
523  * Bring one cpu online.
524  */
525 static int smp_boot_one_cpu(int cpuid, int cpunum)
526 {
527         struct task_struct *idle;
528         long timeout;
529
530         /* 
531          * Create an idle task for this CPU.  Note the address wed* give 
532          * to kernel_thread is irrelevant -- it's going to start
533          * where OS_BOOT_RENDEVZ vector in SAL says to start.  But
534          * this gets all the other task-y sort of data structures set
535          * up like we wish.   We need to pull the just created idle task 
536          * off the run queue and stuff it into the init_tasks[] array.  
537          * Sheesh . . .
538          */
539
540         if ((idle = fork_by_hand()) == 0) 
541                 panic("SMP: fork failed for CPU:%d", cpuid);
542
543         init_idle(idle, cpunum);
544         unhash_process(idle);
545         idle->thread_info->cpu = cpunum;
546
547         /* Let _start know what logical CPU we're booting
548         ** (offset into init_tasks[],cpu_data[])
549         */
550         cpu_now_booting = cpunum;
551
552         /* 
553         ** boot strap code needs to know the task address since
554         ** it also contains the process stack.
555         */
556         smp_init_current_idle_task = idle ;
557         mb();
558
559         /*
560         ** This gets PDC to release the CPU from a very tight loop.
561         ** See MEM_RENDEZ comments in head.S.
562         */
563         __raw_writel(IRQ_OFFSET(TIMER_IRQ), cpu_data[cpunum].hpa);
564         mb();
565
566         /* 
567          * OK, wait a bit for that CPU to finish staggering about. 
568          * Slave will set a bit when it reaches smp_cpu_init() and then
569          * wait for smp_commenced to be 1.
570          * Once we see the bit change, we can move on.
571          */
572         for (timeout = 0; timeout < 10000; timeout++) {
573                 if(IS_LOGGED_IN(cpunum)) {
574                         /* Which implies Slave has started up */
575                         cpu_now_booting = 0;
576                         smp_init_current_idle_task = NULL;
577                         goto alive ;
578                 }
579                 udelay(100);
580                 barrier();
581         }
582
583         put_task_struct(idle);
584         idle = NULL;
585
586         printk(KERN_CRIT "SMP: CPU:%d is stuck.\n", cpuid);
587         return -1;
588
589 alive:
590         /* Remember the Slave data */
591 #if (kDEBUG>=100)
592         printk(KERN_DEBUG "SMP: CPU:%d (num %d) came alive after %ld _us\n",
593                 cpuid,  cpunum, timeout * 100);
594 #endif /* kDEBUG */
595 #ifdef ENTRY_SYS_CPUS
596         cpu_data[cpunum].state = STATE_RUNNING;
597 #endif
598         return 0;
599 }
600
601
602
603
604 /*
605 ** inventory.c:do_inventory() has already 'discovered' the additional CPU's.
606 ** We are ready to wrest them from PDC's control now.
607 ** Called by smp_init bring all the secondaries online and hold them.  
608 **
609 ** o Setup of the IPI irq handler is done in irq.c.
610 ** o MEM_RENDEZ is initialzed in head.S:stext()
611 **
612 */
613 void __init smp_boot_cpus(void)
614 {
615         int i, cpu_count = 1;
616         unsigned long bogosum = loops_per_jiffy; /* Count Monarch */
617
618         /* REVISIT - assumes first CPU reported by PAT PDC is BSP */
619         int bootstrap_processor=cpu_data[0].cpuid;      /* CPU ID of BSP */
620
621         /* Setup BSP mappings */
622         printk(KERN_DEBUG "SMP: bootstrap CPU ID is %d\n",bootstrap_processor);
623         init_task.thread_info->cpu = bootstrap_processor; 
624         current->thread_info->cpu = bootstrap_processor;
625         cpu_online_map = 1 << bootstrap_processor; /* Mark Boostrap processor as present */
626         current->active_mm = &init_mm;
627
628 #ifdef ENTRY_SYS_CPUS
629         cpu_data[0].state = STATE_RUNNING;
630 #endif
631         cpu_present_mask = 1UL << bootstrap_processor;
632
633         /* Nothing to do when told not to.  */
634         if (max_cpus == 0) {
635                 printk(KERN_INFO "SMP mode deactivated.\n");
636                 return;
637         }
638
639         if (max_cpus != -1) 
640                 printk(KERN_INFO "Limiting CPUs to %d\n", max_cpus);
641
642         /* We found more than one CPU.... */
643         if (boot_cpu_data.cpu_count > 1) {
644
645                 for (i = 0; i < NR_CPUS; i++) {
646                         if (cpu_data[i].cpuid == NO_PROC_ID || 
647                             cpu_data[i].cpuid == bootstrap_processor)
648                                 continue;
649
650                         if (smp_boot_one_cpu(cpu_data[i].cpuid, cpu_count) < 0)
651                                 continue;
652
653                         bogosum += loops_per_jiffy;
654                         cpu_count++; /* Count good CPUs only... */
655                         
656                         cpu_present_mask |= 1UL << i;
657                         
658                         /* Bail when we've started as many CPUS as told to */
659                         if (cpu_count == max_cpus)
660                                 break;
661                 }
662         }
663         if (cpu_count == 1) {
664                 printk(KERN_INFO "SMP: Bootstrap processor only.\n");
665         }
666
667         /*
668          * FIXME very rough.
669          */
670         cache_decay_ticks = HZ/100;
671
672         printk(KERN_INFO "SMP: Total %d of %d processors activated "
673                "(%lu.%02lu BogoMIPS noticed) (Present Mask: %lu).\n",
674                cpu_count, boot_cpu_data.cpu_count, (bogosum + 25) / 5000,
675                ((bogosum + 25) / 50) % 100, cpu_present_mask);
676
677         smp_num_cpus = cpu_count;
678 #ifdef PER_CPU_IRQ_REGION
679         ipi_init();
680 #endif
681         return;
682 }
683
684 /* 
685  * Called from main.c by Monarch Processor.
686  * After this, any CPU can schedule any task.
687  */
688 void smp_commence(void)
689 {
690         smp_commenced = 1;
691         mb();
692         return;
693 }
694
695 /*
696  * XXX FIXME : do nothing
697  */
698 void smp_cpus_done(unsigned int cpu_max)
699 {
700         smp_threads_ready = 1;
701 }
702
703 void __init smp_prepare_cpus(unsigned int max_cpus)
704 {
705         smp_boot_cpus();
706 }
707
708 void __devinit smp_prepare_boot_cpu(void)
709 {
710         set_bit(smp_processor_id(), &cpu_online_map);
711         set_bit(smp_processor_id(), &cpu_present_mask);
712 }
713
714 int __devinit __cpu_up(unsigned int cpu)
715 {
716         return cpu_online(cpu) ? 0 : -ENOSYS;
717 }
718
719
720
721 #ifdef ENTRY_SYS_CPUS
722 /* Code goes along with:
723 **    entry.s:        ENTRY_NAME(sys_cpus)   / * 215, for cpu stat * /
724 */
725 int sys_cpus(int argc, char **argv)
726 {
727         int i,j=0;
728         extern int current_pid(int cpu);
729
730         if( argc > 2 ) {
731                 printk("sys_cpus:Only one argument supported\n");
732                 return (-1);
733         }
734         if ( argc == 1 ){
735         
736 #ifdef DUMP_MORE_STATE
737                 for(i=0; i<NR_CPUS; i++) {
738                         int cpus_per_line = 4;
739                         if(IS_LOGGED_IN(i)) {
740                                 if (j++ % cpus_per_line)
741                                         printk(" %3d",i);
742                                 else
743                                         printk("\n %3d",i);
744                         }
745                 }
746                 printk("\n"); 
747 #else
748                 printk("\n 0\n"); 
749 #endif
750         } else if((argc==2) && !(strcmp(argv[1],"-l"))) {
751                 printk("\nCPUSTATE  TASK CPUNUM CPUID HARDCPU(HPA)\n");
752 #ifdef DUMP_MORE_STATE
753                 for(i=0;i<NR_CPUS;i++) {
754                         if (!IS_LOGGED_IN(i))
755                                 continue;
756                         if (cpu_data[i].cpuid != NO_PROC_ID) {
757                                 switch(cpu_data[i].state) {
758                                         case STATE_RENDEZVOUS:
759                                                 printk("RENDEZVS ");
760                                                 break;
761                                         case STATE_RUNNING:
762                                                 printk((current_pid(i)!=0) ? "RUNNING  " : "IDLING   ");
763                                                 break;
764                                         case STATE_STOPPED:
765                                                 printk("STOPPED  ");
766                                                 break;
767                                         case STATE_HALTED:
768                                                 printk("HALTED   ");
769                                                 break;
770                                         default:
771                                                 printk("%08x?", cpu_data[i].state);
772                                                 break;
773                                 }
774                                 if(IS_LOGGED_IN(i)) {
775                                         printk(" %4d",current_pid(i));
776                                 }       
777                                 printk(" %6d",cpu_number_map(i));
778                                 printk(" %5d",i);
779                                 printk(" 0x%lx\n",cpu_data[i].hpa);
780                         }       
781                 }
782 #else
783                 printk("\n%s  %4d      0     0 --------",
784                         (current->pid)?"RUNNING ": "IDLING  ",current->pid); 
785 #endif
786         } else if ((argc==2) && !(strcmp(argv[1],"-s"))) { 
787 #ifdef DUMP_MORE_STATE
788                 printk("\nCPUSTATE   CPUID\n");
789                 for (i=0;i<NR_CPUS;i++) {
790                         if (!IS_LOGGED_IN(i))
791                                 continue;
792                         if (cpu_data[i].cpuid != NO_PROC_ID) {
793                                 switch(cpu_data[i].state) {
794                                         case STATE_RENDEZVOUS:
795                                                 printk("RENDEZVS");break;
796                                         case STATE_RUNNING:
797                                                 printk((current_pid(i)!=0) ? "RUNNING " : "IDLING");
798                                                 break;
799                                         case STATE_STOPPED:
800                                                 printk("STOPPED ");break;
801                                         case STATE_HALTED:
802                                                 printk("HALTED  ");break;
803                                         default:
804                                 }
805                                 printk("  %5d\n",i);
806                         }       
807                 }
808 #else
809                 printk("\n%s    CPU0",(current->pid==0)?"RUNNING ":"IDLING  "); 
810 #endif
811         } else {
812                 printk("sys_cpus:Unknown request\n");
813                 return (-1);
814         }
815         return 0;
816 }
817 #endif /* ENTRY_SYS_CPUS */
818
819 #ifdef CONFIG_PROC_FS
820 int __init
821 setup_profiling_timer(unsigned int multiplier)
822 {
823         return -EINVAL;
824 }
825 #endif