This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / kernel / vserver / cvirt_proc.h
1 #ifndef _VX_CVIRT_PROC_H
2 #define _VX_CVIRT_PROC_H
3
4 #include <linux/sched.h>
5
6
7 #define LOAD_INT(x) ((x) >> FSHIFT)
8 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
9
10 static inline int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
11 {
12         int length = 0;
13         int a, b, c;
14
15         length += sprintf(buffer + length,
16                 "BiasUptime:\t%lu.%02lu\n",
17                         (unsigned long)cvirt->bias_uptime.tv_sec,
18                         (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19         length += sprintf(buffer + length,
20                 "SysName:\t%.*s\n"
21                 "NodeName:\t%.*s\n"
22                 "Release:\t%.*s\n"
23                 "Version:\t%.*s\n"
24                 "Machine:\t%.*s\n"
25                 "DomainName:\t%.*s\n"
26                 ,__NEW_UTS_LEN, cvirt->utsname.sysname
27                 ,__NEW_UTS_LEN, cvirt->utsname.nodename
28                 ,__NEW_UTS_LEN, cvirt->utsname.release
29                 ,__NEW_UTS_LEN, cvirt->utsname.version
30                 ,__NEW_UTS_LEN, cvirt->utsname.machine
31                 ,__NEW_UTS_LEN, cvirt->utsname.domainname
32                 );
33
34         a = cvirt->load[0] + (FIXED_1/200);
35         b = cvirt->load[1] + (FIXED_1/200);
36         c = cvirt->load[2] + (FIXED_1/200);
37         length += sprintf(buffer + length,
38                 "nr_threads:\t%d\n"
39                 "nr_running:\t%d\n"
40                 "nr_unintr:\t%d\n"
41                 "nr_onhold:\t%d\n"
42                 "load_updates:\t%d\n"
43                 "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
44                 ,atomic_read(&cvirt->nr_threads)
45                 ,atomic_read(&cvirt->nr_running)
46                 ,atomic_read(&cvirt->nr_uninterruptible)
47                 ,atomic_read(&cvirt->nr_onhold)
48                 ,atomic_read(&cvirt->load_updates)
49                 ,LOAD_INT(a), LOAD_FRAC(a)
50                 ,LOAD_INT(b), LOAD_FRAC(b)
51                 ,LOAD_INT(c), LOAD_FRAC(c)
52                 );
53         return length;
54 }
55
56
57 static inline long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
58 {
59         return atomic_read(&cacct->sock[type][pos].count);
60 }
61
62
63 static inline long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
64 {
65         return atomic_read(&cacct->sock[type][pos].total);
66 }
67
68 static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
69 {
70         int i,j, length = 0;
71         static char *type[] = { "UNSPEC", "UNIX", "INET", "INET6", "OTHER" };
72
73         for (i=0; i<5; i++) {
74                 length += sprintf(buffer + length,
75                         "%s:", type[i]);
76                 for (j=0; j<3; j++) {
77                         length += sprintf(buffer + length,
78                                 "\t%12lu/%-12lu"
79                                 ,vx_sock_count(cacct, i, j)
80                                 ,vx_sock_total(cacct, i, j)
81                                 );
82                 }
83                 buffer[length++] = '\n';
84         }
85         length += sprintf(buffer + length,
86                 "forks:\t%lu\n", cacct->total_forks);
87         return length;
88 }
89
90 #endif  /* _VX_CVIRT_PROC_H */