aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/proc_misc.c
diff options
context:
space:
mode:
authorHaavard Skinnemoen <haavard.skinnemoen@atmel.com>2008-10-23 09:24:10 -0400
committerHaavard Skinnemoen <haavard.skinnemoen@atmel.com>2008-10-23 09:24:10 -0400
commitd9214556b11a8d18ff588e60824c12041d30f791 (patch)
tree04ab59d13961675811a55c96fb12b2b167b72318 /fs/proc/proc_misc.c
parent72a1419a9d4c859a3345e4b83f8ef7d599d3818c (diff)
parente82c6106b04b85879d802bbbeaed30d9b10a92e2 (diff)
Merge branches 'boards' and 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/hskinnemoen/avr32-2.6
Diffstat (limited to 'fs/proc/proc_misc.c')
-rw-r--r--fs/proc/proc_misc.c156
1 files changed, 76 insertions, 80 deletions
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 29e20c6b1f7f..7ea52c79b2da 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -30,6 +30,7 @@
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/mmzone.h> 31#include <linux/mmzone.h>
32#include <linux/pagemap.h> 32#include <linux/pagemap.h>
33#include <linux/irq.h>
33#include <linux/interrupt.h> 34#include <linux/interrupt.h>
34#include <linux/swap.h> 35#include <linux/swap.h>
35#include <linux/slab.h> 36#include <linux/slab.h>
@@ -45,7 +46,6 @@
45#include <linux/blkdev.h> 46#include <linux/blkdev.h>
46#include <linux/hugetlb.h> 47#include <linux/hugetlb.h>
47#include <linux/jiffies.h> 48#include <linux/jiffies.h>
48#include <linux/sysrq.h>
49#include <linux/vmalloc.h> 49#include <linux/vmalloc.h>
50#include <linux/crash_dump.h> 50#include <linux/crash_dump.h>
51#include <linux/pid_namespace.h> 51#include <linux/pid_namespace.h>
@@ -68,7 +68,6 @@
68extern int get_hardware_list(char *); 68extern int get_hardware_list(char *);
69extern int get_stram_list(char *); 69extern int get_stram_list(char *);
70extern int get_exec_domain_list(char *); 70extern int get_exec_domain_list(char *);
71extern int get_dma_list(char *);
72 71
73static int proc_calc_metrics(char *page, char **start, off_t off, 72static int proc_calc_metrics(char *page, char **start, off_t off,
74 int count, int *eof, int len) 73 int count, int *eof, int len)
@@ -138,6 +137,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
138 unsigned long allowed; 137 unsigned long allowed;
139 struct vmalloc_info vmi; 138 struct vmalloc_info vmi;
140 long cached; 139 long cached;
140 unsigned long pages[NR_LRU_LISTS];
141 int lru;
141 142
142/* 143/*
143 * display in kilobytes. 144 * display in kilobytes.
@@ -156,51 +157,70 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
156 157
157 get_vmalloc_info(&vmi); 158 get_vmalloc_info(&vmi);
158 159
160 for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++)
161 pages[lru] = global_page_state(NR_LRU_BASE + lru);
162
159 /* 163 /*
160 * Tagged format, for easy grepping and expansion. 164 * Tagged format, for easy grepping and expansion.
161 */ 165 */
162 len = sprintf(page, 166 len = sprintf(page,
163 "MemTotal: %8lu kB\n" 167 "MemTotal: %8lu kB\n"
164 "MemFree: %8lu kB\n" 168 "MemFree: %8lu kB\n"
165 "Buffers: %8lu kB\n" 169 "Buffers: %8lu kB\n"
166 "Cached: %8lu kB\n" 170 "Cached: %8lu kB\n"
167 "SwapCached: %8lu kB\n" 171 "SwapCached: %8lu kB\n"
168 "Active: %8lu kB\n" 172 "Active: %8lu kB\n"
169 "Inactive: %8lu kB\n" 173 "Inactive: %8lu kB\n"
174 "Active(anon): %8lu kB\n"
175 "Inactive(anon): %8lu kB\n"
176 "Active(file): %8lu kB\n"
177 "Inactive(file): %8lu kB\n"
178#ifdef CONFIG_UNEVICTABLE_LRU
179 "Unevictable: %8lu kB\n"
180 "Mlocked: %8lu kB\n"
181#endif
170#ifdef CONFIG_HIGHMEM 182#ifdef CONFIG_HIGHMEM
171 "HighTotal: %8lu kB\n" 183 "HighTotal: %8lu kB\n"
172 "HighFree: %8lu kB\n" 184 "HighFree: %8lu kB\n"
173 "LowTotal: %8lu kB\n" 185 "LowTotal: %8lu kB\n"
174 "LowFree: %8lu kB\n" 186 "LowFree: %8lu kB\n"
175#endif 187#endif
176 "SwapTotal: %8lu kB\n" 188 "SwapTotal: %8lu kB\n"
177 "SwapFree: %8lu kB\n" 189 "SwapFree: %8lu kB\n"
178 "Dirty: %8lu kB\n" 190 "Dirty: %8lu kB\n"
179 "Writeback: %8lu kB\n" 191 "Writeback: %8lu kB\n"
180 "AnonPages: %8lu kB\n" 192 "AnonPages: %8lu kB\n"
181 "Mapped: %8lu kB\n" 193 "Mapped: %8lu kB\n"
182 "Slab: %8lu kB\n" 194 "Slab: %8lu kB\n"
183 "SReclaimable: %8lu kB\n" 195 "SReclaimable: %8lu kB\n"
184 "SUnreclaim: %8lu kB\n" 196 "SUnreclaim: %8lu kB\n"
185 "PageTables: %8lu kB\n" 197 "PageTables: %8lu kB\n"
186#ifdef CONFIG_QUICKLIST 198#ifdef CONFIG_QUICKLIST
187 "Quicklists: %8lu kB\n" 199 "Quicklists: %8lu kB\n"
188#endif 200#endif
189 "NFS_Unstable: %8lu kB\n" 201 "NFS_Unstable: %8lu kB\n"
190 "Bounce: %8lu kB\n" 202 "Bounce: %8lu kB\n"
191 "WritebackTmp: %8lu kB\n" 203 "WritebackTmp: %8lu kB\n"
192 "CommitLimit: %8lu kB\n" 204 "CommitLimit: %8lu kB\n"
193 "Committed_AS: %8lu kB\n" 205 "Committed_AS: %8lu kB\n"
194 "VmallocTotal: %8lu kB\n" 206 "VmallocTotal: %8lu kB\n"
195 "VmallocUsed: %8lu kB\n" 207 "VmallocUsed: %8lu kB\n"
196 "VmallocChunk: %8lu kB\n", 208 "VmallocChunk: %8lu kB\n",
197 K(i.totalram), 209 K(i.totalram),
198 K(i.freeram), 210 K(i.freeram),
199 K(i.bufferram), 211 K(i.bufferram),
200 K(cached), 212 K(cached),
201 K(total_swapcache_pages), 213 K(total_swapcache_pages),
202 K(global_page_state(NR_ACTIVE)), 214 K(pages[LRU_ACTIVE_ANON] + pages[LRU_ACTIVE_FILE]),
203 K(global_page_state(NR_INACTIVE)), 215 K(pages[LRU_INACTIVE_ANON] + pages[LRU_INACTIVE_FILE]),
216 K(pages[LRU_ACTIVE_ANON]),
217 K(pages[LRU_INACTIVE_ANON]),
218 K(pages[LRU_ACTIVE_FILE]),
219 K(pages[LRU_INACTIVE_FILE]),
220#ifdef CONFIG_UNEVICTABLE_LRU
221 K(pages[LRU_UNEVICTABLE]),
222 K(global_page_state(NR_MLOCK)),
223#endif
204#ifdef CONFIG_HIGHMEM 224#ifdef CONFIG_HIGHMEM
205 K(i.totalhigh), 225 K(i.totalhigh),
206 K(i.freehigh), 226 K(i.freehigh),
@@ -502,17 +522,13 @@ static const struct file_operations proc_vmalloc_operations = {
502 522
503static int show_stat(struct seq_file *p, void *v) 523static int show_stat(struct seq_file *p, void *v)
504{ 524{
505 int i; 525 int i, j;
506 unsigned long jif; 526 unsigned long jif;
507 cputime64_t user, nice, system, idle, iowait, irq, softirq, steal; 527 cputime64_t user, nice, system, idle, iowait, irq, softirq, steal;
508 cputime64_t guest; 528 cputime64_t guest;
509 u64 sum = 0; 529 u64 sum = 0;
510 struct timespec boottime; 530 struct timespec boottime;
511 unsigned int *per_irq_sum; 531 unsigned int per_irq_sum;
512
513 per_irq_sum = kzalloc(sizeof(unsigned int)*NR_IRQS, GFP_KERNEL);
514 if (!per_irq_sum)
515 return -ENOMEM;
516 532
517 user = nice = system = idle = iowait = 533 user = nice = system = idle = iowait =
518 irq = softirq = steal = cputime64_zero; 534 irq = softirq = steal = cputime64_zero;
@@ -521,8 +537,6 @@ static int show_stat(struct seq_file *p, void *v)
521 jif = boottime.tv_sec; 537 jif = boottime.tv_sec;
522 538
523 for_each_possible_cpu(i) { 539 for_each_possible_cpu(i) {
524 int j;
525
526 user = cputime64_add(user, kstat_cpu(i).cpustat.user); 540 user = cputime64_add(user, kstat_cpu(i).cpustat.user);
527 nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice); 541 nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice);
528 system = cputime64_add(system, kstat_cpu(i).cpustat.system); 542 system = cputime64_add(system, kstat_cpu(i).cpustat.system);
@@ -532,11 +546,10 @@ static int show_stat(struct seq_file *p, void *v)
532 softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq); 546 softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq);
533 steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal); 547 steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal);
534 guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest); 548 guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest);
535 for (j = 0; j < NR_IRQS; j++) { 549
536 unsigned int temp = kstat_cpu(i).irqs[j]; 550 for_each_irq_nr(j)
537 sum += temp; 551 sum += kstat_irqs_cpu(j, i);
538 per_irq_sum[j] += temp; 552
539 }
540 sum += arch_irq_stat_cpu(i); 553 sum += arch_irq_stat_cpu(i);
541 } 554 }
542 sum += arch_irq_stat(); 555 sum += arch_irq_stat();
@@ -578,8 +591,15 @@ static int show_stat(struct seq_file *p, void *v)
578 } 591 }
579 seq_printf(p, "intr %llu", (unsigned long long)sum); 592 seq_printf(p, "intr %llu", (unsigned long long)sum);
580 593
581 for (i = 0; i < NR_IRQS; i++) 594 /* sum again ? it could be updated? */
582 seq_printf(p, " %u", per_irq_sum[i]); 595 for_each_irq_nr(j) {
596 per_irq_sum = 0;
597
598 for_each_possible_cpu(i)
599 per_irq_sum += kstat_irqs_cpu(j, i);
600
601 seq_printf(p, " %u", per_irq_sum);
602 }
583 603
584 seq_printf(p, 604 seq_printf(p,
585 "\nctxt %llu\n" 605 "\nctxt %llu\n"
@@ -593,7 +613,6 @@ static int show_stat(struct seq_file *p, void *v)
593 nr_running(), 613 nr_running(),
594 nr_iowait()); 614 nr_iowait());
595 615
596 kfree(per_irq_sum);
597 return 0; 616 return 0;
598} 617}
599 618
@@ -632,15 +651,14 @@ static const struct file_operations proc_stat_operations = {
632 */ 651 */
633static void *int_seq_start(struct seq_file *f, loff_t *pos) 652static void *int_seq_start(struct seq_file *f, loff_t *pos)
634{ 653{
635 return (*pos <= NR_IRQS) ? pos : NULL; 654 return (*pos <= nr_irqs) ? pos : NULL;
636} 655}
637 656
657
638static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos) 658static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos)
639{ 659{
640 (*pos)++; 660 (*pos)++;
641 if (*pos > NR_IRQS) 661 return (*pos <= nr_irqs) ? pos : NULL;
642 return NULL;
643 return pos;
644} 662}
645 663
646static void int_seq_stop(struct seq_file *f, void *v) 664static void int_seq_stop(struct seq_file *f, void *v)
@@ -648,7 +666,6 @@ static void int_seq_stop(struct seq_file *f, void *v)
648 /* Nothing to do */ 666 /* Nothing to do */
649} 667}
650 668
651
652static const struct seq_operations int_seq_ops = { 669static const struct seq_operations int_seq_ops = {
653 .start = int_seq_start, 670 .start = int_seq_start,
654 .next = int_seq_next, 671 .next = int_seq_next,
@@ -684,6 +701,7 @@ static int cmdline_read_proc(char *page, char **start, off_t off,
684 return proc_calc_metrics(page, start, off, count, eof, len); 701 return proc_calc_metrics(page, start, off, count, eof, len);
685} 702}
686 703
704#ifdef CONFIG_FILE_LOCKING
687static int locks_open(struct inode *inode, struct file *filp) 705static int locks_open(struct inode *inode, struct file *filp)
688{ 706{
689 return seq_open(filp, &locks_seq_operations); 707 return seq_open(filp, &locks_seq_operations);
@@ -695,6 +713,7 @@ static const struct file_operations proc_locks_operations = {
695 .llseek = seq_lseek, 713 .llseek = seq_lseek,
696 .release = seq_release, 714 .release = seq_release,
697}; 715};
716#endif /* CONFIG_FILE_LOCKING */
698 717
699static int execdomains_read_proc(char *page, char **start, off_t off, 718static int execdomains_read_proc(char *page, char **start, off_t off,
700 int count, int *eof, void *data) 719 int count, int *eof, void *data)
@@ -703,28 +722,6 @@ static int execdomains_read_proc(char *page, char **start, off_t off,
703 return proc_calc_metrics(page, start, off, count, eof, len); 722 return proc_calc_metrics(page, start, off, count, eof, len);
704} 723}
705 724
706#ifdef CONFIG_MAGIC_SYSRQ
707/*
708 * writing 'C' to /proc/sysrq-trigger is like sysrq-C
709 */
710static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
711 size_t count, loff_t *ppos)
712{
713 if (count) {
714 char c;
715
716 if (get_user(c, buf))
717 return -EFAULT;
718 __handle_sysrq(c, NULL, 0);
719 }
720 return count;
721}
722
723static const struct file_operations proc_sysrq_trigger_operations = {
724 .write = write_sysrq_trigger,
725};
726#endif
727
728#ifdef CONFIG_PROC_PAGE_MONITOR 725#ifdef CONFIG_PROC_PAGE_MONITOR
729#define KPMSIZE sizeof(u64) 726#define KPMSIZE sizeof(u64)
730#define KPMMASK (KPMSIZE - 1) 727#define KPMMASK (KPMSIZE - 1)
@@ -888,7 +885,9 @@ void __init proc_misc_init(void)
888#ifdef CONFIG_PRINTK 885#ifdef CONFIG_PRINTK
889 proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations); 886 proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations);
890#endif 887#endif
888#ifdef CONFIG_FILE_LOCKING
891 proc_create("locks", 0, NULL, &proc_locks_operations); 889 proc_create("locks", 0, NULL, &proc_locks_operations);
890#endif
892 proc_create("devices", 0, NULL, &proc_devinfo_operations); 891 proc_create("devices", 0, NULL, &proc_devinfo_operations);
893 proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations); 892 proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations);
894#ifdef CONFIG_BLOCK 893#ifdef CONFIG_BLOCK
@@ -931,7 +930,4 @@ void __init proc_misc_init(void)
931#ifdef CONFIG_PROC_VMCORE 930#ifdef CONFIG_PROC_VMCORE
932 proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations); 931 proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations);
933#endif 932#endif
934#ifdef CONFIG_MAGIC_SYSRQ
935 proc_create("sysrq-trigger", S_IWUSR, NULL, &proc_sysrq_trigger_operations);
936#endif
937} 933}