1 /* _VX_CVIRT_H defined below */
3 #if defined(__KERNEL__) && defined(_VX_INFO_DEF_)
5 #include <linux/utsname.h>
6 #include <linux/rwsem.h>
7 #include <linux/jiffies.h>
8 #include <linux/time.h>
9 #include <asm/atomic.h>
11 /* context sub struct */
16 struct timespec bias_idle;
17 uint64_t bias_jiffies;
19 struct new_utsname utsname;
31 unsigned long total_forks;
33 struct sock_acc sock[5][3];
37 static inline long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
39 return atomic_read(&cacct->sock[type][pos].count);
43 static inline long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
45 return atomic_read(&cacct->sock[type][pos].total);
49 extern uint64_t vx_idle_jiffies(void);
51 static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
53 uint64_t idle_jiffies = vx_idle_jiffies();
55 cvirt->bias_jiffies = get_jiffies_64();
56 jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
59 cvirt->utsname = system_utsname;
63 static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
68 static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
72 atomic_set(&cacct->nr_threads, 1);
75 atomic_set(&cacct->sock[i][j].count, 0);
76 atomic_set(&cacct->sock[i][j].total, 0);
81 static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
86 static inline int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
89 length += sprintf(buffer + length,
90 "BiasJiffies:\t%lld\n", (long long int)cvirt->bias_jiffies);
91 length += sprintf(buffer + length,
98 ,__NEW_UTS_LEN, cvirt->utsname.sysname
99 ,__NEW_UTS_LEN, cvirt->utsname.nodename
100 ,__NEW_UTS_LEN, cvirt->utsname.release
101 ,__NEW_UTS_LEN, cvirt->utsname.version
102 ,__NEW_UTS_LEN, cvirt->utsname.machine
103 ,__NEW_UTS_LEN, cvirt->utsname.domainname
108 static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
111 static char *type[] = { "UNSPEC", "UNIX", "INET", "INET6", "OTHER" };
113 for (i=0; i<5; i++) {
114 length += sprintf(buffer + length,
116 for (j=0; j<3; j++) {
117 length += sprintf(buffer + length,
119 ,vx_sock_count(cacct, i, j)
120 ,vx_sock_total(cacct, i, j)
123 buffer[length++] = '\n';
128 #else /* _VX_INFO_DEF_ */
134 /* cvirt vserver commands */
141 void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle);
143 #endif /* __KERNEL__ */
145 #endif /* _VX_CVIRT_H */