This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / kernel / sched_mon.h
1
2 #include <linux/vserver/monitor.h>
3
4 #ifdef  CONFIG_VSERVER_MONITOR
5
6 #ifdef  CONFIG_VSERVER_HARDCPU
7 #define HARDCPU(x) (x)
8 #else
9 #define HARDCPU(x) (0)
10 #endif
11
12 #ifdef  CONFIG_VSERVER_IDLETIME
13 #define IDLETIME(x) (x)
14 #else
15 #define IDLETIME(x) (0)
16 #endif
17
18 struct _vx_mon_entry *vxm_advance(int cpu);
19
20
21 static inline
22 void    __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
23 {
24         entry->type = type;
25         entry->xid = xid;
26 }
27
28 static inline
29 void    __vxm_sync(int cpu)
30 {
31         struct _vx_mon_entry *entry = vxm_advance(cpu);
32
33         __vxm_basic(entry, 0, VXM_SYNC);
34         entry->ev.sec = xtime.tv_sec;
35         entry->ev.nsec = xtime.tv_nsec;
36 }
37
38 static inline
39 void    __vxm_task(struct task_struct *p, int type)
40 {
41         struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
42
43         __vxm_basic(entry, p->xid, type);
44         entry->ev.tsk.pid = p->pid;
45         entry->ev.tsk.state = p->state;
46 }
47
48 static inline
49 void    __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
50 {
51         struct _vx_mon_entry *entry = vxm_advance(cpu);
52
53         __vxm_basic(entry, vxi->vx_id, (VXM_SCHED | s->flags));
54         entry->sd.tokens = s->tokens;
55         entry->sd.norm_time = s->norm_time;
56         entry->sd.idle_time = s->idle_time;
57 }
58
59 static inline
60 void    __vxm_rqinfo1(struct rq *q, int cpu)
61 {
62         struct _vx_mon_entry *entry = vxm_advance(cpu);
63
64         entry->type = VXM_RQINFO_1;
65         entry->xid = ((unsigned long)q >> 16) & 0xffff;
66         entry->q1.running = q->nr_running;
67         entry->q1.onhold = HARDCPU(q->nr_onhold);
68         entry->q1.iowait = atomic_read(&q->nr_iowait);
69         entry->q1.uintr = q->nr_uninterruptible;
70         entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
71 }
72
73 static inline
74 void    __vxm_rqinfo2(struct rq *q, int cpu)
75 {
76         struct _vx_mon_entry *entry = vxm_advance(cpu);
77
78         entry->type = VXM_RQINFO_2;
79         entry->xid = (unsigned long)q & 0xffff;
80         entry->q2.norm_time = q->norm_time;
81         entry->q2.idle_time = q->idle_time;
82         entry->q2.idle_skip = IDLETIME(q->idle_skip);
83 }
84
85 static inline
86 void    __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
87 {
88         struct _vx_mon_entry *entry = vxm_advance(cpu);
89
90         __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
91         entry->ev.tokens = s->tokens;
92 }
93
94 static inline
95 void    __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
96 {
97         struct _vx_mon_entry *entry = vxm_advance(cpu);
98
99         __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
100         entry->u1.tokens_max = s->tokens_max;
101         entry->u1.fill_rate = s->fill_rate[0];
102         entry->u1.interval = s->interval[0];
103 }
104
105 static inline
106 void    __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
107 {
108         struct _vx_mon_entry *entry = vxm_advance(cpu);
109
110         __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
111         entry->u2.tokens_min = s->tokens_min;
112         entry->u2.fill_rate = s->fill_rate[1];
113         entry->u2.interval = s->interval[1];
114 }
115
116
117 #define vxm_activate_task(p,q)          __vxm_task(p, VXM_ACTIVATE)
118 #define vxm_activate_idle(p,q)          __vxm_task(p, VXM_IDLE)
119 #define vxm_deactivate_task(p,q)        __vxm_task(p, VXM_DEACTIVATE)
120 #define vxm_hold_task(p,q)              __vxm_task(p, VXM_HOLD)
121 #define vxm_unhold_task(p,q)            __vxm_task(p, VXM_UNHOLD)
122
123 static inline
124 void    vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
125 {
126         __vxm_task(p, VXM_MIGRATE);
127         __vxm_rqinfo1(rq, task_cpu(p));
128         __vxm_rqinfo2(rq, task_cpu(p));
129 }
130
131 static inline
132 void    vxm_idle_skip(struct rq *rq, int cpu)
133 {
134         __vxm_rqinfo1(rq, cpu);
135         __vxm_rqinfo2(rq, cpu);
136 }
137
138 static inline
139 void    vxm_need_resched(struct task_struct *p, int slice, int cpu)
140 {
141         if (slice)
142                 return;
143
144         __vxm_task(p, VXM_RESCHED);
145 }
146
147 static inline
148 void    vxm_sync(unsigned long now, int cpu)
149 {
150         if (!CONFIG_VSERVER_MONITOR_SYNC ||
151                 (now % CONFIG_VSERVER_MONITOR_SYNC))
152                 return;
153
154         __vxm_sync(cpu);
155 }
156
157 #define vxm_sched_info(s,v,c)           __vxm_sched(s,v,c)
158
159 static inline
160 void    vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
161         struct vx_info *vxi, int cpu)
162 {
163         __vxm_sched(s, vxi, cpu);
164         __vxm_rqinfo2(rq, cpu);
165 }
166
167 static inline
168 void    vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
169 {
170         __vxm_sched(s, vxi, cpu);
171         __vxm_update(s, vxi, cpu);
172         __vxm_update1(s, vxi, cpu);
173         __vxm_update2(s, vxi, cpu);
174 }
175
176 static inline
177 void    vxm_rq_max_min(struct rq *rq, int cpu)
178 {
179         __vxm_rqinfo1(rq, cpu);
180         __vxm_rqinfo2(rq, cpu);
181 }
182
183 #else  /* CONFIG_VSERVER_MONITOR */
184
185 #define vxm_activate_task(t,q)          do { } while (0)
186 #define vxm_activate_idle(t,q)          do { } while (0)
187 #define vxm_deactivate_task(t,q)        do { } while (0)
188 #define vxm_hold_task(t,q)              do { } while (0)
189 #define vxm_unhold_task(t,q)            do { } while (0)
190 #define vxm_migrate_task(t,q,d)         do { } while (0)
191 #define vxm_idle_skip(q,c)              do { } while (0)
192 #define vxm_need_resched(t,s,c)         do { } while (0)
193 #define vxm_sync(s,c)                   do { } while (0)
194 #define vxm_sched_info(s,v,c)           do { } while (0)
195 #define vxm_tokens_recalc(s,q,v,c)      do { } while (0)
196 #define vxm_update_sched(s,v,c)         do { } while (0)
197 #define vxm_rq_max_min(q,c)             do { } while (0)
198
199 #endif /* CONFIG_VSERVER_MONITOR */
200