[ARM] pxa/cm-x300: add rtc-v3020 device registration
[linux-2.6/mini2440.git] / fs / proc / loadavg.c
blob9bca39cf99eeb56d6c32c4f0f9f4c49073683f19
1 #include <linux/fs.h>
2 #include <linux/init.h>
3 #include <linux/pid_namespace.h>
4 #include <linux/proc_fs.h>
5 #include <linux/sched.h>
6 #include <linux/seq_file.h>
7 #include <linux/seqlock.h>
8 #include <linux/time.h>
10 #define LOAD_INT(x) ((x) >> FSHIFT)
11 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
13 static int loadavg_proc_show(struct seq_file *m, void *v)
15 int a, b, c;
16 unsigned long seq;
18 do {
19 seq = read_seqbegin(&xtime_lock);
20 a = avenrun[0] + (FIXED_1/200);
21 b = avenrun[1] + (FIXED_1/200);
22 c = avenrun[2] + (FIXED_1/200);
23 } while (read_seqretry(&xtime_lock, seq));
25 seq_printf(m, "%d.%02d %d.%02d %d.%02d %ld/%d %d\n",
26 LOAD_INT(a), LOAD_FRAC(a),
27 LOAD_INT(b), LOAD_FRAC(b),
28 LOAD_INT(c), LOAD_FRAC(c),
29 nr_running(), nr_threads,
30 task_active_pid_ns(current)->last_pid);
31 return 0;
34 static int loadavg_proc_open(struct inode *inode, struct file *file)
36 return single_open(file, loadavg_proc_show, NULL);
39 static const struct file_operations loadavg_proc_fops = {
40 .open = loadavg_proc_open,
41 .read = seq_read,
42 .llseek = seq_lseek,
43 .release = single_release,
46 static int __init proc_loadavg_init(void)
48 proc_create("loadavg", 0, NULL, &loadavg_proc_fops);
49 return 0;
51 module_init(proc_loadavg_init);