2 #include <linux/vserver/monitor.h>
4 #ifdef CONFIG_VSERVER_MONITOR
6 #ifdef CONFIG_VSERVER_HARDCPU
12 #ifdef CONFIG_VSERVER_IDLETIME
13 #define IDLETIME(x) (x)
15 #define IDLETIME(x) (0)
18 struct _vx_mon_entry *vxm_advance(int cpu);
22 void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
29 void __vxm_sync(int cpu)
31 struct _vx_mon_entry *entry = vxm_advance(cpu);
33 __vxm_basic(entry, 0, VXM_SYNC);
34 entry->ev.sec = xtime.tv_sec;
35 entry->ev.nsec = xtime.tv_nsec;
39 void __vxm_task(struct task_struct *p, int type)
41 struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
43 __vxm_basic(entry, p->xid, type);
44 entry->ev.tsk.pid = p->pid;
45 entry->ev.tsk.state = p->state;
49 void __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
51 struct _vx_mon_entry *entry = vxm_advance(cpu);
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;
60 void __vxm_rqinfo1(struct rq *q, int cpu)
62 struct _vx_mon_entry *entry = vxm_advance(cpu);
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);
74 void __vxm_rqinfo2(struct rq *q, int cpu)
76 struct _vx_mon_entry *entry = vxm_advance(cpu);
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);
86 void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
88 struct _vx_mon_entry *entry = vxm_advance(cpu);
90 __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
91 entry->ev.tokens = s->tokens;
95 void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
97 struct _vx_mon_entry *entry = vxm_advance(cpu);
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];
106 void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
108 struct _vx_mon_entry *entry = vxm_advance(cpu);
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];
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)
124 void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
126 __vxm_task(p, VXM_MIGRATE);
127 __vxm_rqinfo1(rq, task_cpu(p));
128 __vxm_rqinfo2(rq, task_cpu(p));
132 void vxm_idle_skip(struct rq *rq, int cpu)
134 __vxm_rqinfo1(rq, cpu);
135 __vxm_rqinfo2(rq, cpu);
139 void vxm_need_resched(struct task_struct *p, int slice, int cpu)
144 __vxm_task(p, VXM_RESCHED);
148 void vxm_sync(unsigned long now, int cpu)
150 if (!CONFIG_VSERVER_MONITOR_SYNC ||
151 (now % CONFIG_VSERVER_MONITOR_SYNC))
157 #define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
160 void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
161 struct vx_info *vxi, int cpu)
163 __vxm_sched(s, vxi, cpu);
164 __vxm_rqinfo2(rq, cpu);
168 void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
170 __vxm_sched(s, vxi, cpu);
171 __vxm_update(s, vxi, cpu);
172 __vxm_update1(s, vxi, cpu);
173 __vxm_update2(s, vxi, cpu);
177 void vxm_rq_max_min(struct rq *rq, int cpu)
179 __vxm_rqinfo1(rq, cpu);
180 __vxm_rqinfo2(rq, cpu);
183 #else /* CONFIG_VSERVER_MONITOR */
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)
199 #endif /* CONFIG_VSERVER_MONITOR */