ia64/xen-unstable

view linux-2.6.10-xen-sparse/arch/xen/i386/kernel/syscall_stats.c @ 4182:0cf318b324fb

bitkeeper revision 1.1245.1.1 (42386d63YMsPB-xQ5vhzdFj1gbQ5kg)

added counter for pagefaults

Signed-off-by: michael.fetterman@cl.cam.ac.uk
author rneugeba@wyvis.research.intel-research.net
date Wed Mar 16 17:31:15 2005 +0000 (2005-03-16)
parents 47e1cb8a3d38
children cf77cd925ef3
line source
1 /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*-
2 ****************************************************************************
3 * (C) 2005 - Rolf Neugebauer - Intel Research Cambridge
4 ****************************************************************************
5 *
6 * File: syscall_stats.c
7 * Author: Rolf Neugebauer (rolf.neugebauer@intel.com)
8 * Date: Mar 2005
9 *
10 * Description: add a proc interface to get per system call stats
11 */
14 #include <linux/config.h>
15 #include <linux/proc_fs.h>
16 #include <linux/seq_file.h>
17 #include <asm/unistd.h>
19 unsigned long syscall_stats[NR_syscalls];
20 static unsigned char foobar[4];
22 unsigned long c_do_page_fault;
23 unsigned long c_minor_page_fault;
24 unsigned long c_major_page_fault;
26 /* a write just resests the counter */
27 static ssize_t syscall_write(struct file *f, const char *data,
28 size_t size, loff_t *pos)
29 {
30 printk("resetting syscall stats\n");
31 memset(&syscall_stats, 0, sizeof(syscall_stats));
32 c_do_page_fault = 0;
33 c_minor_page_fault = 0;
34 c_major_page_fault = 0;
35 return size;
36 }
38 static int show_syscall(struct seq_file *m, void *v)
39 {
40 int i;
41 for ( i=0; i<NR_syscalls; i++ )
42 {
43 seq_printf(m, "%lu ", syscall_stats[i]);
44 }
45 seq_printf(m, "\n");
46 seq_printf(m, "%lu %lu %lu\n", c_do_page_fault,
47 c_minor_page_fault, c_major_page_fault);
49 return 0;
50 }
52 static void *c_start(struct seq_file *m, loff_t *pos)
53 {
54 return *pos == 0 ? foobar : NULL;
55 }
57 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
58 {
59 ++*pos;
60 return c_start(m, pos);
61 }
63 static void c_stop(struct seq_file *m, void *v)
64 {
65 }
67 static struct seq_operations syscall_op = {
68 start: c_start,
69 next: c_next,
70 stop: c_stop,
71 show: show_syscall,
72 };
74 static int syscall_open(struct inode *inode, struct file *file)
75 {
76 return seq_open(file, &syscall_op);
77 }
79 static struct file_operations proc_syscall_operations = {
80 open: syscall_open,
81 read: seq_read,
82 write: syscall_write,
83 llseek: seq_lseek,
84 release: seq_release,
85 };
88 static struct proc_dir_entry *entry;
90 static int __init syscall_stats_init(void)
91 {
92 printk("Initialising syscall stats.\n");
94 entry = create_proc_entry("syscalls", 0777, NULL);
95 if (entry)
96 entry->proc_fops = &proc_syscall_operations;
97 else
98 printk("Unable to create /proc/syscalls.\n");
99 return 0;
100 }
101 subsys_initcall(syscall_stats_init);