4 #include "vserver/sched.h"
7 #define VAVAVOOM_RATIO 50
9 #define MAX_PRIO_BIAS 20
10 #define MIN_PRIO_BIAS -20
13 static inline int vx_tokens_avail(struct vx_info *vxi)
15 return atomic_read(&vxi->sched.tokens);
18 static inline void vx_consume_token(struct vx_info *vxi)
20 atomic_dec(&vxi->sched.tokens);
23 static inline int vx_need_resched(struct task_struct *p)
25 #ifdef CONFIG_VSERVER_HARDCPU
26 struct vx_info *vxi = p->vx_info;
28 int slice = --p->time_slice;
30 #ifdef CONFIG_VSERVER_HARDCPU
34 if ((tokens = vx_tokens_avail(vxi)) > 0)
35 vx_consume_token(vxi);
36 /* for tokens > 0, one token was consumed */
45 static inline void vx_onhold_inc(struct vx_info *vxi)
47 int onhold = atomic_read(&vxi->cvirt.nr_onhold);
49 atomic_inc(&vxi->cvirt.nr_onhold);
51 vxi->cvirt.onhold_last = jiffies;
54 static inline void __vx_onhold_update(struct vx_info *vxi)
56 int cpu = smp_processor_id();
57 uint32_t now = jiffies;
58 uint32_t delta = now - vxi->cvirt.onhold_last;
60 vxi->cvirt.onhold_last = now;
61 vxi->sched.cpu[cpu].hold_ticks += delta;
64 static inline void vx_onhold_dec(struct vx_info *vxi)
66 if (atomic_dec_and_test(&vxi->cvirt.nr_onhold))
67 __vx_onhold_update(vxi);
70 static inline void vx_account_user(struct vx_info *vxi,
71 cputime_t cputime, int nice)
73 int cpu = smp_processor_id();
77 vxi->sched.cpu[cpu].user_ticks += cputime;
80 static inline void vx_account_system(struct vx_info *vxi,
81 cputime_t cputime, int idle)
83 int cpu = smp_processor_id();
87 vxi->sched.cpu[cpu].sys_ticks += cputime;
91 #warning duplicate inclusion