ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / s390 / appldata / appldata_base.c
1 /*
2  * arch/s390/appldata/appldata_base.c
3  *
4  * Base infrastructure for Linux-z/VM Monitor Stream, Stage 1.
5  * Exports appldata_register_ops() and appldata_unregister_ops() for the
6  * data gathering modules.
7  *
8  * Copyright (C) 2003 IBM Corporation, IBM Deutschland Entwicklung GmbH.
9  *
10  * Author: Gerald Schaefer <geraldsc@de.ibm.com>
11  */
12
13 #include <linux/config.h>
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/slab.h>
17 #include <linux/errno.h>
18 #include <asm/uaccess.h>
19 #include <asm/io.h>
20 #include <linux/interrupt.h>
21 #include <linux/proc_fs.h>
22 #include <linux/page-flags.h>
23 #include <linux/swap.h>
24 #include <linux/pagemap.h>
25 #include <linux/sysctl.h>
26 #include <asm/timer.h>
27 //#include <linux/kernel_stat.h>
28
29 #include "appldata.h"
30
31
32 #define MY_PRINT_NAME   "appldata"              /* for debug messages, etc. */
33 #define APPLDATA_CPU_INTERVAL   10000           /* default (CPU) time for
34                                                    sampling interval in
35                                                    milliseconds */
36
37 #define TOD_MICRO       0x01000                 /* nr. of TOD clock units
38                                                    for 1 microsecond */
39 #ifndef CONFIG_ARCH_S390X
40
41 #define APPLDATA_START_INTERVAL_REC 0x00        /* Function codes for */
42 #define APPLDATA_STOP_REC           0x01        /* DIAG 0xDC      */
43 #define APPLDATA_GEN_EVENT_RECORD   0x02
44 #define APPLDATA_START_CONFIG_REC   0x03
45
46 #else
47
48 #define APPLDATA_START_INTERVAL_REC 0x80
49 #define APPLDATA_STOP_REC           0x81
50 #define APPLDATA_GEN_EVENT_RECORD   0x82
51 #define APPLDATA_START_CONFIG_REC   0x83
52
53 #endif /* CONFIG_ARCH_S390X */
54
55
56 /*
57  * Parameter list for DIAGNOSE X'DC'
58  */
59 #ifndef CONFIG_ARCH_S390X
60 struct appldata_parameter_list {
61         u16 diag;               /* The DIAGNOSE code X'00DC'          */
62         u8  function;           /* The function code for the DIAGNOSE */
63         u8  parlist_length;     /* Length of the parameter list       */
64         u32 product_id_addr;    /* Address of the 16-byte product ID  */
65         u16 reserved;
66         u16 buffer_length;      /* Length of the application data buffer  */
67         u32 buffer_addr;        /* Address of the application data buffer */
68 };
69 #else
70 struct appldata_parameter_list {
71         u16 diag;
72         u8  function;
73         u8  parlist_length;
74         u32 unused01;
75         u16 reserved;
76         u16 buffer_length;
77         u32 unused02;
78         u64 product_id_addr;
79         u64 buffer_addr;
80 };
81 #endif /* CONFIG_ARCH_S390X */
82
83 /*
84  * /proc entries (sysctl)
85  */
86 static const char appldata_proc_name[APPLDATA_PROC_NAME_LENGTH] = "appldata";
87 static int appldata_timer_handler(ctl_table *ctl, int write, struct file *filp,
88                                   void *buffer, size_t *lenp);
89 static int appldata_interval_handler(ctl_table *ctl, int write,
90                                          struct file *filp, void *buffer,
91                                          size_t *lenp);
92
93 static struct ctl_table_header *appldata_sysctl_header;
94 static struct ctl_table appldata_table[] = {
95         {
96                 .ctl_name       = CTL_APPLDATA_TIMER,
97                 .procname       = "timer",
98                 .mode           = S_IRUGO | S_IWUSR,
99                 .proc_handler   = &appldata_timer_handler,
100         },
101         {
102                 .ctl_name       = CTL_APPLDATA_INTERVAL,
103                 .procname       = "interval",
104                 .mode           = S_IRUGO | S_IWUSR,
105                 .proc_handler   = &appldata_interval_handler,
106         },
107         { .ctl_name = 0 }
108 };
109
110 static struct ctl_table appldata_dir_table[] = {
111         {
112                 .ctl_name       = CTL_APPLDATA,
113                 .procname       = appldata_proc_name,
114                 .maxlen         = 0,
115                 .mode           = S_IRUGO | S_IXUGO,
116                 .child          = appldata_table,
117         },
118         { .ctl_name = 0 }
119 };
120
121 /*
122  * Timer
123  */
124 DEFINE_PER_CPU(struct vtimer_list, appldata_timer);
125 static atomic_t appldata_expire_count = ATOMIC_INIT(0);
126 static struct appldata_mod_vtimer_args {
127         struct vtimer_list *timer;
128         u64    expires;
129 } appldata_mod_vtimer_args;
130
131 static spinlock_t appldata_timer_lock = SPIN_LOCK_UNLOCKED;
132 static int appldata_interval = APPLDATA_CPU_INTERVAL;
133 static int appldata_timer_active;
134
135 /*
136  * Tasklet
137  */
138 static struct tasklet_struct appldata_tasklet_struct;
139
140 /*
141  * Ops list
142  */
143 static spinlock_t appldata_ops_lock = SPIN_LOCK_UNLOCKED;
144 static LIST_HEAD(appldata_ops_list);
145
146
147 /************************* timer, tasklet, DIAG ******************************/
148 /*
149  * appldata_timer_function()
150  *
151  * schedule tasklet and reschedule timer
152  */
153 static void appldata_timer_function(unsigned long data, struct pt_regs *regs)
154 {
155         P_DEBUG("   -= Timer =-\n");
156         P_DEBUG("CPU: %i, expire: %i\n", smp_processor_id(),
157                 atomic_read(&appldata_expire_count));
158         if (atomic_dec_and_test(&appldata_expire_count)) {
159                 atomic_set(&appldata_expire_count, num_online_cpus());
160                 tasklet_schedule((struct tasklet_struct *) data);
161         }
162 }
163
164 /*
165  * appldata_tasklet_function()
166  *
167  * call data gathering function for each (active) module
168  */
169 static void appldata_tasklet_function(unsigned long data)
170 {
171         struct list_head *lh;
172         struct appldata_ops *ops;
173         int i;
174
175         P_DEBUG("  -= Tasklet =-\n");
176         i = 0;
177         spin_lock(&appldata_ops_lock);
178         list_for_each(lh, &appldata_ops_list) {
179                 ops = list_entry(lh, struct appldata_ops, list);
180                 P_DEBUG("list_for_each loop: %i) active = %u, name = %s\n",
181                         ++i, ops->active, ops->name);
182                 if (ops->active == 1) {
183                         ops->callback(ops->data);
184                 }
185         }
186         spin_unlock(&appldata_ops_lock);
187 }
188
189 /*
190  * appldata_mod_vtimer_wrap()
191  *
192  * wrapper function for mod_virt_timer(), because smp_call_function_on()
193  * accepts only one parameter.
194  */
195 static void appldata_mod_vtimer_wrap(struct appldata_mod_vtimer_args *args) {
196         mod_virt_timer(args->timer, args->expires);
197 }
198
199 /*
200  * appldata_diag()
201  *
202  * prepare parameter list, issue DIAG 0xDC
203  */
204 static int appldata_diag(char record_nr, u16 function, unsigned long buffer,
205                         u16 length)
206 {
207         unsigned long ry;
208         struct appldata_product_id {
209                 char prod_nr[7];                        /* product nr. */
210                 char prod_fn[2];                        /* product function */
211                 char record_nr;                         /* record nr. */
212                 char version_nr[2];                     /* version */
213                 char release_nr[2];                     /* release */
214                 char mod_lvl[2];                        /* modification lvl. */
215         } appldata_product_id = {
216         /* all strings are EBCDIC, record_nr is byte */
217                 .prod_nr    = {0xD3, 0xC9, 0xD5, 0xE4,
218                                 0xE7, 0xD2, 0xD9},      /* "LINUXKR" */
219                 .prod_fn    = {0xD5, 0xD3},             /* "NL" */
220                 .record_nr  = record_nr,
221                 .version_nr = {0xF2, 0xF6},             /* "26" */
222                 .release_nr = {0xF0, 0xF1},             /* "01" */
223                 .mod_lvl    = {0xF0, 0xF0},             /* "00" */
224         };
225         struct appldata_parameter_list appldata_parameter_list = {
226                                 .diag = 0xDC,
227                                 .function = function,
228                                 .parlist_length =
229                                         sizeof(appldata_parameter_list),
230                                 .buffer_length = length,
231                                 .product_id_addr =
232                                         (unsigned long) &appldata_product_id,
233                                 .buffer_addr = virt_to_phys((void *) buffer)
234         };
235
236         if (!MACHINE_IS_VM)
237                 return -ENOSYS;
238         ry = -1;
239         asm volatile(
240                         "diag %1,%0,0xDC\n\t"
241                         : "=d" (ry) : "d" (&(appldata_parameter_list)) : "cc");
242         return (int) ry;
243 }
244 /********************** timer, tasklet, DIAG <END> ***************************/
245
246
247 /****************************** /proc stuff **********************************/
248 /*
249  * appldata_timer_handler()
250  *
251  * Start/Stop timer, show status of timer (0 = not active, 1 = active)
252  */
253 static int
254 appldata_timer_handler(ctl_table *ctl, int write, struct file *filp,
255                            void *buffer, size_t *lenp)
256 {
257         int len, i;
258         char buf[2];
259         u64 per_cpu_interval;
260
261         if (!*lenp || filp->f_pos) {
262                 *lenp = 0;
263                 return 0;
264         }
265         if (!write) {
266                 len = sprintf(buf, appldata_timer_active ? "1\n" : "0\n");
267                 if (len > *lenp)
268                         len = *lenp;
269                 if (copy_to_user(buffer, buf, len))
270                         return -EFAULT;
271                 goto out;
272         }
273         per_cpu_interval = (u64) (appldata_interval*1000 /
274                                  num_online_cpus()) * TOD_MICRO;
275         len = *lenp;
276         if (copy_from_user(buf, buffer, len > sizeof(buf) ? sizeof(buf) : len))
277                 return -EFAULT;
278         spin_lock(&appldata_timer_lock);
279         per_cpu_interval = (u64) (appldata_interval*1000 /
280                                  num_online_cpus()) * TOD_MICRO;
281         if ((buf[0] == '1') && (!appldata_timer_active)) {
282                 for (i = 0; i < num_online_cpus(); i++) {
283                         per_cpu(appldata_timer, i).expires = per_cpu_interval;
284                         smp_call_function_on(add_virt_timer_periodic,
285                                                 &per_cpu(appldata_timer, i),
286                                                 0, 1, i);
287                 }
288                 appldata_timer_active = 1;
289                 P_INFO("Monitoring timer started.\n");
290         } else if ((buf[0] == '0') && (appldata_timer_active)) {
291                 for (i = 0; i < num_online_cpus(); i++) {
292                         del_virt_timer(&per_cpu(appldata_timer, i));
293                 }
294                 appldata_timer_active = 0;
295                 P_INFO("Monitoring timer stopped.\n");
296         }
297         spin_unlock(&appldata_timer_lock);
298 out:
299         *lenp = len;
300         filp->f_pos += len;
301         return 0;
302 }
303
304 /*
305  * appldata_interval_handler()
306  *
307  * Set (CPU) timer interval for collection of data (in milliseconds), show
308  * current timer interval.
309  */
310 static int
311 appldata_interval_handler(ctl_table *ctl, int write, struct file *filp,
312                            void *buffer, size_t *lenp)
313 {
314         int len, i, interval;
315         char buf[16];
316         u64 per_cpu_interval;
317
318         if (!*lenp || filp->f_pos) {
319                 *lenp = 0;
320                 return 0;
321         }
322         if (!write) {
323                 len = sprintf(buf, "%i\n", appldata_interval);
324                 if (len > *lenp)
325                         len = *lenp;
326                 if (copy_to_user(buffer, buf, len))
327                         return -EFAULT;
328                 goto out;
329         }
330         len = *lenp;
331         if (copy_from_user(buf, buffer, len > sizeof(buf) ? sizeof(buf) : len)) {
332                 return -EFAULT;
333         }
334         sscanf(buf, "%i", &interval);
335         if (interval <= 0) {
336                 P_ERROR("Timer CPU interval has to be > 0!\n");
337                 return -EINVAL;
338         }
339
340         spin_lock(&appldata_timer_lock);
341         per_cpu_interval = (u64) (interval*1000 / num_online_cpus()) * TOD_MICRO;
342         appldata_interval = interval;
343         if (appldata_timer_active) {
344                 for (i = 0; i < num_online_cpus(); i++) {
345                         appldata_mod_vtimer_args.timer =
346                                         &per_cpu(appldata_timer, i);
347                         appldata_mod_vtimer_args.expires =
348                                         per_cpu_interval;
349                         smp_call_function_on(
350                                 (void *) appldata_mod_vtimer_wrap,
351                                 &appldata_mod_vtimer_args,
352                                 0, 1, i);
353                 }
354         }
355         spin_unlock(&appldata_timer_lock);
356
357         P_INFO("Monitoring CPU interval set to %u milliseconds.\n",
358                  interval);
359 out:
360         *lenp = len;
361         filp->f_pos += len;
362         return 0;
363 }
364
365 /*
366  * appldata_generic_handler()
367  *
368  * Generic start/stop monitoring and DIAG, show status of
369  * monitoring (0 = not in process, 1 = in process)
370  */
371 static int
372 appldata_generic_handler(ctl_table *ctl, int write, struct file *filp,
373                            void *buffer, size_t *lenp)
374 {
375         struct appldata_ops *ops = NULL, *tmp_ops;
376         int rc, len, found;
377         char buf[2];
378         struct list_head *lh;
379
380         found = 0;
381         spin_lock_bh(&appldata_ops_lock);
382         list_for_each(lh, &appldata_ops_list) {
383                 tmp_ops = list_entry(lh, struct appldata_ops, list);
384                 if (&tmp_ops->ctl_table[2] == ctl) {
385                         found = 1;
386                 }
387         }
388         if (!found) {
389                 spin_unlock_bh(&appldata_ops_lock);
390                 return -ENODEV;
391         }
392         ops = ctl->data;
393         if (!try_module_get(ops->owner)) {      // protect this function
394                 spin_unlock_bh(&appldata_ops_lock);
395                 return -ENODEV;
396         }
397         spin_unlock_bh(&appldata_ops_lock);
398
399         if (!*lenp || filp->f_pos) {
400                 *lenp = 0;
401                 module_put(ops->owner);
402                 return 0;
403         }
404         if (!write) {
405                 len = sprintf(buf, ops->active ? "1\n" : "0\n");
406                 if (len > *lenp)
407                         len = *lenp;
408                 if (copy_to_user(buffer, buf, len)) {
409                         module_put(ops->owner);
410                         return -EFAULT;
411                 }
412                 goto out;
413         }
414         len = *lenp;
415         if (copy_from_user(buf, buffer,
416                            len > sizeof(buf) ? sizeof(buf) : len)) {
417                 module_put(ops->owner);
418                 return -EFAULT;
419         }
420
421         spin_lock_bh(&appldata_ops_lock);
422         if ((buf[0] == '1') && (ops->active == 0)) {
423                 if (!try_module_get(ops->owner)) {      // protect tasklet
424                         spin_unlock_bh(&appldata_ops_lock);
425                         module_put(ops->owner);
426                         return -ENODEV;
427                 }
428                 ops->active = 1;
429                 ops->callback(ops->data);       // init record
430                 rc = appldata_diag(ops->record_nr,
431                                         APPLDATA_START_INTERVAL_REC,
432                                         (unsigned long) ops->data, ops->size);
433                 if (rc != 0) {
434                         P_ERROR("START DIAG 0xDC for %s failed, "
435                                 "return code: %d\n", ops->name, rc);
436                         module_put(ops->owner);
437                         ops->active = 0;
438                 } else {
439                         P_INFO("Monitoring %s data enabled, "
440                                 "DIAG 0xDC started.\n", ops->name);
441                 }
442         } else if ((buf[0] == '0') && (ops->active == 1)) {
443                 ops->active = 0;
444                 rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC,
445                                 (unsigned long) ops->data, ops->size);
446                 if (rc != 0) {
447                         P_ERROR("STOP DIAG 0xDC for %s failed, "
448                                 "return code: %d\n", ops->name, rc);
449                 } else {
450                         P_INFO("Monitoring %s data disabled, "
451                                 "DIAG 0xDC stopped.\n", ops->name);
452                 }
453                 module_put(ops->owner);
454         }
455         spin_unlock_bh(&appldata_ops_lock);
456 out:
457         *lenp = len;
458         filp->f_pos += len;
459         module_put(ops->owner);
460         return 0;
461 }
462
463 /*************************** /proc stuff <END> *******************************/
464
465
466 /************************* module-ops management *****************************/
467 /*
468  * appldata_register_ops()
469  *
470  * update ops list, register /proc/sys entries
471  */
472 int appldata_register_ops(struct appldata_ops *ops)
473 {
474         struct list_head *lh;
475         struct appldata_ops *tmp_ops;
476         int i;
477
478         i = 0;
479
480         if ((ops->size > APPLDATA_MAX_REC_SIZE) ||
481                 (ops->size < 0)){
482                 P_ERROR("Invalid size of %s record = %i, maximum = %i!\n",
483                         ops->name, ops->size, APPLDATA_MAX_REC_SIZE);
484                 return -ENOMEM;
485         }
486         if ((ops->ctl_nr == CTL_APPLDATA) ||
487             (ops->ctl_nr == CTL_APPLDATA_TIMER) ||
488             (ops->ctl_nr == CTL_APPLDATA_INTERVAL)) {
489                 P_ERROR("ctl_nr %i already in use!\n", ops->ctl_nr);
490                 return -EBUSY;
491         }
492         ops->ctl_table = kmalloc(4*sizeof(struct ctl_table), GFP_KERNEL);
493         if (ops->ctl_table == NULL) {
494                 P_ERROR("Not enough memory for %s ctl_table!\n", ops->name);
495                 return -ENOMEM;
496         }
497         memset(ops->ctl_table, 0, 4*sizeof(struct ctl_table));
498
499         spin_lock_bh(&appldata_ops_lock);
500         list_for_each(lh, &appldata_ops_list) {
501                 tmp_ops = list_entry(lh, struct appldata_ops, list);
502                 P_DEBUG("register_ops loop: %i) name = %s, ctl = %i\n",
503                         ++i, tmp_ops->name, tmp_ops->ctl_nr);
504                 P_DEBUG("Comparing %s (ctl %i) with %s (ctl %i)\n",
505                         tmp_ops->name, tmp_ops->ctl_nr, ops->name,
506                         ops->ctl_nr);
507                 if (strncmp(tmp_ops->name, ops->name,
508                                 APPLDATA_PROC_NAME_LENGTH) == 0) {
509                         P_ERROR("Name \"%s\" already registered!\n", ops->name);
510                         kfree(ops->ctl_table);
511                         spin_unlock_bh(&appldata_ops_lock);
512                         return -EBUSY;
513                 }
514                 if (tmp_ops->ctl_nr == ops->ctl_nr) {
515                         P_ERROR("ctl_nr %i already registered!\n", ops->ctl_nr);
516                         kfree(ops->ctl_table);
517                         spin_unlock_bh(&appldata_ops_lock);
518                         return -EBUSY;
519                 }
520         }
521         list_add(&ops->list, &appldata_ops_list);
522         spin_unlock_bh(&appldata_ops_lock);
523
524         ops->ctl_table[0].ctl_name = CTL_APPLDATA;
525         ops->ctl_table[0].procname = appldata_proc_name;
526         ops->ctl_table[0].maxlen   = 0;
527         ops->ctl_table[0].mode     = S_IRUGO | S_IXUGO;
528         ops->ctl_table[0].child    = &ops->ctl_table[2];
529
530         ops->ctl_table[1].ctl_name = 0;
531
532         ops->ctl_table[2].ctl_name = ops->ctl_nr;
533         ops->ctl_table[2].procname = ops->name;
534         ops->ctl_table[2].mode     = S_IRUGO | S_IWUSR;
535         ops->ctl_table[2].proc_handler = appldata_generic_handler;
536         ops->ctl_table[2].data = ops;
537
538         ops->ctl_table[3].ctl_name = 0;
539
540         ops->sysctl_header = register_sysctl_table(ops->ctl_table,1);
541
542         P_INFO("%s-ops registered!\n", ops->name);
543         return 0;
544 }
545
546 /*
547  * appldata_unregister_ops()
548  *
549  * update ops list, unregister /proc entries, stop DIAG if necessary
550  */
551 void appldata_unregister_ops(struct appldata_ops *ops)
552 {
553         spin_lock_bh(&appldata_ops_lock);
554         unregister_sysctl_table(ops->sysctl_header);
555         list_del(&ops->list);
556         kfree(ops->ctl_table);
557         ops->ctl_table = NULL;
558         spin_unlock_bh(&appldata_ops_lock);
559         P_INFO("%s-ops unregistered!\n", ops->name);
560 }
561 /********************** module-ops management <END> **************************/
562
563
564 /******************************* init / exit *********************************/
565 /*
566  * appldata_init()
567  *
568  * init timer and tasklet, register /proc entries
569  */
570 static int __init appldata_init(void)
571 {
572         int i;
573
574         P_DEBUG("sizeof(parameter_list) = %lu\n",
575                 sizeof(struct appldata_parameter_list));
576
577         for (i = 0; i < num_online_cpus(); i++) {
578                 init_virt_timer(&per_cpu(appldata_timer, i));
579                 per_cpu(appldata_timer, i).function = appldata_timer_function;
580                 per_cpu(appldata_timer, i).data = (unsigned long)
581                                                 &appldata_tasklet_struct;
582         }
583         atomic_set(&appldata_expire_count, num_online_cpus());
584
585         appldata_sysctl_header = register_sysctl_table(appldata_dir_table, 1);
586 #ifdef MODULE
587         appldata_dir_table[0].de->owner = THIS_MODULE;
588         appldata_table[0].de->owner = THIS_MODULE;
589         appldata_table[1].de->owner = THIS_MODULE;
590 #endif
591
592         tasklet_init(&appldata_tasklet_struct, appldata_tasklet_function, 0);
593         P_DEBUG("Base interface initialized.\n");
594         return 0;
595 }
596
597 /*
598  * appldata_exit()
599  *
600  * stop timer and tasklet, unregister /proc entries
601  */
602 static void __exit appldata_exit(void)
603 {
604         struct list_head *lh;
605         struct appldata_ops *ops;
606         int rc, i;
607
608         P_DEBUG("Unloading module ...\n");
609         /*
610          * ops list should be empty, but just in case something went wrong...
611          */
612         spin_lock_bh(&appldata_ops_lock);
613         list_for_each(lh, &appldata_ops_list) {
614                 ops = list_entry(lh, struct appldata_ops, list);
615                 rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC,
616                                 (unsigned long) ops->data, ops->size);
617                 if (rc != 0) {
618                         P_ERROR("STOP DIAG 0xDC for %s failed, "
619                                 "return code: %d\n", ops->name, rc);
620                 }
621         }
622         spin_unlock_bh(&appldata_ops_lock);
623
624         for (i = 0; i < num_online_cpus(); i++) {
625                 del_virt_timer(&per_cpu(appldata_timer, i));
626         }
627         appldata_timer_active = 0;
628
629         unregister_sysctl_table(appldata_sysctl_header);
630
631         tasklet_kill(&appldata_tasklet_struct);
632         P_DEBUG("... module unloaded!\n");
633 }
634 /**************************** init / exit <END> ******************************/
635
636
637 module_init(appldata_init);
638 module_exit(appldata_exit);
639 MODULE_LICENSE("GPL");
640 MODULE_AUTHOR("Gerald Schaefer");
641 MODULE_DESCRIPTION("Linux-VM Monitor Stream, base infrastructure");
642
643 EXPORT_SYMBOL_GPL(appldata_register_ops);
644 EXPORT_SYMBOL_GPL(appldata_unregister_ops);
645
646 #ifdef MODULE
647 /*
648  * Kernel symbols needed by appldata_mem and appldata_os modules.
649  * However, if this file is compiled as a module (for testing only), these
650  * symbols are not exported. In this case, we define them locally and export
651  * those.
652  */
653 void si_swapinfo(struct sysinfo *val)
654 {
655         val->freeswap = -1ul;
656         val->totalswap = -1ul;
657 }
658
659 unsigned long avenrun[3] = {-1 - FIXED_1/200, -1 - FIXED_1/200,
660                                 -1 - FIXED_1/200};
661 int nr_threads = -1;
662
663 void get_full_page_state(struct page_state *ps)
664 {
665         memset(ps, -1, sizeof(struct page_state));
666 }
667
668 unsigned long nr_running(void)
669 {
670         return -1;
671 }
672
673 unsigned long nr_iowait(void)
674 {
675         return -1;
676 }
677
678 /*unsigned long nr_context_switches(void)
679 {
680         return -1;
681 }*/
682 #endif /* MODULE */
683 EXPORT_SYMBOL_GPL(si_swapinfo);
684 EXPORT_SYMBOL_GPL(nr_threads);
685 EXPORT_SYMBOL_GPL(avenrun);
686 EXPORT_SYMBOL_GPL(get_full_page_state);
687 EXPORT_SYMBOL_GPL(nr_running);
688 EXPORT_SYMBOL_GPL(nr_iowait);
689 //EXPORT_SYMBOL_GPL(nr_context_switches);