X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=include%2Flinux%2Fvserver%2Fsched.h;h=0bf6dbaa637cc6be912c3c7c38256ee34da69d77;hb=refs%2Fheads%2Fvserver;hp=d1a2068004621bf7d7222173e0b4e264d96e57ed;hpb=b76fcd5f0c655b6e3e9bf534594357025421c66a;p=linux-2.6.git diff --git a/include/linux/vserver/sched.h b/include/linux/vserver/sched.h index d1a206800..0bf6dbaa6 100644 --- a/include/linux/vserver/sched.h +++ b/include/linux/vserver/sched.h @@ -1,139 +1,26 @@ -#if defined(__KERNEL__) && defined(_VX_INFO_DEF_) - -#include -#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 */ - atomic_t 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_min = HZ >> 4; - sched->tokens_max = HZ >> 1; - sched->jiffies = jiffies; - sched->tokens_lock = SPIN_LOCK_UNLOCKED; - - atomic_set(&sched->tokens, HZ >> 2); - sched->cpus_allowed = CPU_MASK_ALL; -} - -static inline void vx_info_exit_sched(struct _vx_sched *sched) -{ - return; -} - -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 - ,atomic_read(&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 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 __user *); -extern int vc_set_sched(uint32_t, void __user *); - - -#define VAVAVOOM_RATIO 50 - -#include "context.h" +struct timespec; +void vx_vsi_uptime(struct timespec *, struct timespec *); -/* scheduling stuff */ -int effective_vavavoom(struct task_struct *, int); +struct vx_info; -int vx_tokens_recalc(struct vx_info *); +void vx_update_load(struct vx_info *); -/* new stuff ;) */ -static inline int vx_tokens_avail(struct vx_info *vxi) -{ - return atomic_read(&vxi->sched.tokens); -} - -static inline void vx_consume_token(struct vx_info *vxi) -{ - atomic_dec(&vxi->sched.tokens); -} - -static inline int vx_need_resched(struct task_struct *p) -{ -#ifdef CONFIG_VSERVER_HARDCPU - struct vx_info *vxi = p->vx_info; - - if (vxi) { - int tokens; - - p->time_slice--; - if (atomic_read(&vxi->vx_refcount) < 1) - printk("need_resched: p=%p, s=%ld, ref=%d, id=%d/%d\n", - p, p->state, atomic_read(&vxi->vx_refcount), - vxi->vx_id, p->xid); - if ((tokens = vx_tokens_avail(vxi)) > 0) - vx_consume_token(vxi); - return ((p->time_slice == 0) || (tokens < 1)); - } -#endif - p->time_slice--; - return (p->time_slice == 0); -} +int vx_tokens_recalc(struct _vx_sched_pc *, + unsigned long *, unsigned long *, int [2]); +void vx_update_sched_param(struct _vx_sched *sched, + struct _vx_sched_pc *sched_pc); #endif /* __KERNEL__ */ - +#else /* _VX_SCHED_H */ +#warning duplicate inclusion #endif /* _VX_SCHED_H */ -#endif