updated to 2.6.13.3-vs2.1.0-rc4 headers
[util-vserver.git] / util-vserver / kernel / cvirt_def.h
1 #ifndef _VX_CVIRT_DEF_H
2 #define _VX_CVIRT_DEF_H
3
4 #include <linux/jiffies.h>
5 #include <linux/utsname.h>
6 #include <linux/spinlock.h>
7 #include <linux/wait.h>
8 #include <linux/time.h>
9 #include <asm/atomic.h>
10
11
12 struct _vx_usage_stat {
13         uint64_t user;
14         uint64_t nice;
15         uint64_t system;
16         uint64_t softirq;
17         uint64_t irq;
18         uint64_t idle;
19         uint64_t iowait;
20 };
21
22 struct _vx_syslog {
23         wait_queue_head_t log_wait;
24         spinlock_t logbuf_lock;         /* lock for the log buffer */
25
26         unsigned long log_start;        /* next char to be read by syslog() */
27         unsigned long con_start;        /* next char to be sent to consoles */
28         unsigned long log_end;  /* most-recently-written-char + 1 */
29         unsigned long logged_chars;     /* #chars since last read+clear operation */
30
31         char log_buf[1024];
32 };
33
34
35 /* context sub struct */
36
37 struct _vx_cvirt {
38 //      int max_threads;                /* maximum allowed threads */
39         atomic_t nr_threads;            /* number of current threads */
40         atomic_t nr_running;            /* number of running threads */
41         atomic_t nr_uninterruptible;    /* number of uninterruptible threads */
42
43         atomic_t nr_onhold;             /* processes on hold */
44         uint32_t onhold_last;           /* jiffies when put on hold */
45
46         struct timespec bias_idle;
47         struct timespec bias_uptime;    /* context creation point */
48         uint64_t bias_clock;            /* offset in clock_t */
49
50         struct new_utsname utsname;
51
52         spinlock_t load_lock;           /* lock for the load averages */
53         atomic_t load_updates;          /* nr of load updates done so far */
54         uint32_t load_last;             /* last time load was cacled */
55         uint32_t load[3];               /* load averages 1,5,15 */
56
57         atomic_t total_forks;           /* number of forks so far */
58
59         struct _vx_usage_stat cpustat[NR_CPUS];
60
61         struct _vx_syslog syslog;
62 };
63
64
65 #ifdef CONFIG_VSERVER_DEBUG
66
67 static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
68 {
69         printk("\t_vx_cvirt:\n");
70         printk("\t threads: %4d, %4d, %4d, %4d\n",
71                 atomic_read(&cvirt->nr_threads),
72                 atomic_read(&cvirt->nr_running),
73                 atomic_read(&cvirt->nr_uninterruptible),
74                 atomic_read(&cvirt->nr_onhold));
75         /* add rest here */
76         printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
77 }
78
79 #endif
80
81
82 struct _vx_sock_acc {
83         atomic_t count;
84         atomic_t total;
85 };
86
87 /* context sub struct */
88
89 struct _vx_cacct {
90         struct _vx_sock_acc sock[5][3];
91 };
92
93 #ifdef CONFIG_VSERVER_DEBUG
94
95 static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
96 {
97         int i,j;
98
99         printk("\t_vx_cacct:");
100         for (i=0; i<5; i++) {
101                 struct _vx_sock_acc *ptr = cacct->sock[i];
102
103                 printk("\t [%d] =", i);
104                 for (j=0; j<3; j++) {
105                         printk(" [%d] = %8d, %8d", j,
106                                 atomic_read(&ptr[j].count),
107                                 atomic_read(&ptr[j].total));
108                 }
109                 printk("\n");
110         }
111 }
112
113 #endif
114
115 #endif  /* _VX_CVIRT_DEF_H */