X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fkernel%2Fsched.h;h=60569ab94b33650d0391081836a5150c7caf45a7;hb=faa778968d1a7dfeaebc9fe4b847e691dc62fd15;hp=3841639b4d37d8daa198711a59ac65584845f690;hpb=0b275c5a23d6c49d61559504e4dedfc4cc284414;p=util-vserver.git diff --git a/util-vserver/kernel/sched.h b/util-vserver/kernel/sched.h index 3841639..60569ab 100644 --- a/util-vserver/kernel/sched.h +++ b/util-vserver/kernel/sched.h @@ -1,136 +1,25 @@ -#if defined(__KERNEL__) && defined(_VX_INFO_DEF_) - -#include -#include -#include -#include - -/* context sub struct */ - -struct _vx_sched { - spinlock_t tokens_lock; /* lock for this structure */ - - int fill_rate; /* Fill rate: add X tokens... */ - int interval; /* Divisor: per Y jiffies */ - int tokens; /* number of CPU tokens in this context */ - int tokens_min; /* Limit: minimum for unhold */ - int tokens_max; /* Limit: no more than N tokens */ - uint32_t jiffies; /* add an integral multiple of Y to this */ - - uint64_t ticks; /* token tick events */ - cpumask_t cpus_allowed; /* cpu mask for context */ -}; - -static inline void vx_info_init_sched(struct _vx_sched *sched) -{ - /* scheduling; hard code starting values as constants */ - sched->fill_rate = 1; - sched->interval = 4; - sched->tokens = HZ >> 2; - sched->tokens_min = HZ >> 4; - sched->tokens_max = HZ >> 1; - sched->jiffies = jiffies; - sched->tokens_lock = SPIN_LOCK_UNLOCKED; -} - -static inline int vx_info_proc_sched(struct _vx_sched *sched, char *buffer) -{ - return sprintf(buffer, - "Ticks:\t%16lld\n" - "Token:\t\t%8d\n" - "FillRate:\t%8d\n" - "Interval:\t%8d\n" - "TokensMin:\t%8d\n" - "TokensMax:\t%8d\n" - ,sched->ticks - ,sched->tokens - ,sched->fill_rate - ,sched->interval - ,sched->tokens_min - ,sched->tokens_max - ); -} - - -#else /* _VX_INFO_DEF_ */ #ifndef _VX_SCHED_H #define _VX_SCHED_H -#include "switch.h" - -/* sched vserver commands */ - -#define VCMD_set_sched_v1 VC_CMD(SYSTEST, 1, 1) - -struct vcmd_set_sched_v1 { - int32_t fill_rate; - int32_t period; - int32_t fill_level; - int32_t bucket_size; -}; - -#define VCMD_set_sched VC_CMD(SCHED, 1, 2) - -struct vcmd_set_sched_v2 { - int32_t fill_rate; - int32_t interval; - int32_t tokens; - int32_t tokens_min; - int32_t tokens_max; - uint64_t cpu_mask; -}; - -#define SCHED_KEEP (-2) - #ifdef __KERNEL__ -extern int vc_set_sched_v1(uint32_t, void *); -extern int vc_set_sched(uint32_t, void *); - - -#define VAVAVOOM_RATIO 50 +struct timespec; -#include "context.h" +void vx_vsi_uptime(struct timespec *, struct timespec *); -/* scheduling stuff */ +struct vx_info; -int effective_vavavoom(struct task_struct *, int); +void vx_update_load(struct vx_info *); -int vx_tokens_recalc(struct vx_info *); - -/* update the token allocation for a process */ -static inline int vx_tokens_avail(struct task_struct *tsk) -{ - struct vx_info *vxi = tsk->vx_info; - int tokens; - - spin_lock(&vxi->sched.tokens_lock); - tokens = vx_tokens_recalc(vxi); - spin_unlock(&vxi->sched.tokens_lock); - return tokens; -} -/* new stuff ;) */ +struct task_struct; -static inline int vx_need_resched(struct task_struct *p, struct vx_info *vxi) -{ - p->time_slice--; - if (vxi) { - int tokens = 0; - - if (vxi->sched.tokens > 0) { - spin_lock(&vxi->sched.tokens_lock); - tokens = --vxi->sched.tokens; - spin_unlock(&vxi->sched.tokens_lock); - } - return ((p->time_slice == 0) || (tokens == 0)); - } else - return (p->time_slice == 0); -} +int vx_effective_vavavoom(struct vx_info *, int); +int vx_tokens_recalc(struct vx_info *); #endif /* __KERNEL__ */ - +#else /* _VX_SCHED_H */ +#warning duplicate inclusion #endif /* _VX_SCHED_H */ -#endif