This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / linux / vs_sched.h
1 #ifndef _VX_VS_SCHED_H
2 #define _VX_VS_SCHED_H
3
4
5 #include "vserver/sched.h"
6
7
8 #define VAVAVOOM_RATIO           50
9
10 #define MAX_PRIO_BIAS            20
11 #define MIN_PRIO_BIAS           -20
12
13
14 static inline int vx_tokens_avail(struct vx_info *vxi)
15 {
16         return atomic_read(&vxi->sched.tokens);
17 }
18
19 static inline void vx_consume_token(struct vx_info *vxi)
20 {
21         atomic_dec(&vxi->sched.tokens);
22 }
23
24 static inline int vx_need_resched(struct task_struct *p)
25 {
26 #ifdef  CONFIG_VSERVER_HARDCPU
27         struct vx_info *vxi = p->vx_info;
28 #endif
29         int slice = --p->time_slice;
30
31 #ifdef  CONFIG_VSERVER_HARDCPU
32         if (vxi) {
33                 int tokens;
34
35                 if ((tokens = vx_tokens_avail(vxi)) > 0)
36                         vx_consume_token(vxi);
37                 /* for tokens > 0, one token was consumed */
38                 if (tokens < 2)
39                         return 1;
40         }
41 #endif
42         return (slice == 0);
43 }
44
45
46 static inline void vx_onhold_inc(struct vx_info *vxi)
47 {
48         int onhold = atomic_read(&vxi->cvirt.nr_onhold);
49
50         atomic_inc(&vxi->cvirt.nr_onhold);
51         if (!onhold)
52                 vxi->cvirt.onhold_last = jiffies;
53 }
54
55 static inline void __vx_onhold_update(struct vx_info *vxi)
56 {
57         int cpu = smp_processor_id();
58         uint32_t now = jiffies;
59         uint32_t delta = now - vxi->cvirt.onhold_last;
60
61         vxi->cvirt.onhold_last = now;
62         vxi->sched.cpu[cpu].hold_ticks += delta;
63 }
64
65 static inline void vx_onhold_dec(struct vx_info *vxi)
66 {
67         if (atomic_dec_and_test(&vxi->cvirt.nr_onhold))
68                 __vx_onhold_update(vxi);
69 }
70
71 #else
72 #warning duplicate inclusion
73 #endif