Warning, cross-references for /kernel/include/sched/vcpu.h need to be fixed.
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef _SCHED_VCPU_H_
0019 #define _SCHED_VCPU_H_
0020
0021 #include "kernel.h"
0022 #include "arch/i386-percpu.h"
0023 #include "util/cassert.h"
0024
0025 #define VCPU_ALIGNMENT (LOCK_ALIGNMENT<<3)
0026
0027 typedef enum {
0028 MAIN_VCPU = 0, IO_VCPU
0029 } vcpu_type;
0030
0031 typedef enum {
0032 IOVCPU_CLASS_ALL = 0,
0033 IOVCPU_CLASS_ATA = (1<<0),
0034 IOVCPU_CLASS_NET = (1<<1),
0035 IOVCPU_CLASS_USB = (1<<2),
0036 IOVCPU_CLASS_DISK = (1<<3),
0037 IOVCPU_CLASS_CDROM = (1<<4),
0038 } iovcpu_class;
0039
0040 typedef struct _replenishment {
0041 u64 t, b;
0042 struct _replenishment *next;
0043 } replenishment;
0044
0045 #define MAX_REPL 32
0046 typedef struct {
0047 replenishment array[MAX_REPL];
0048 replenishment *head;
0049 u32 size;
0050 } repl_queue;
0051 void repl_queue_pop (repl_queue *Q);
0052 void repl_queue_add (repl_queue *Q, u64 b, u64 t);
0053
0054 struct _vcpu;
0055 typedef struct {
0056 void (*update_replenishments) (struct _vcpu *, u64 tcur);
0057 u64 (*next_event) (struct _vcpu *);
0058 void (*end_timeslice) (struct _vcpu *, u64 delta);
0059 void (*unblock) (struct _vcpu *);
0060 } vcpu_hooks;
0061
0062
0063 typedef struct _vcpu
0064 {
0065 union {
0066 struct {
0067 spinlock lock;
0068 vcpu_type type;
0069 vcpu_hooks *hooks;
0070 struct _vcpu *next;
0071 bool runnable, running;
0072 u16 cpu;
0073 u16 tr;
0074 u16 runqueue;
0075 u32 quantum;
0076 u64 next_schedule;
0077 u64 prev_tsc;
0078 u64 virtual_tsc;
0079
0080 u64 C, T, b, usage;
0081
0082
0083 union {
0084
0085 struct {
0086 u64 a;
0087 repl_queue Q;
0088 } main;
0089
0090 struct {
0091 u64 e;
0092 replenishment r;
0093 u32 Unum, Uden;
0094 bool budgeted;
0095 iovcpu_class class;
0096 } io;
0097 };
0098
0099
0100 u64 timestamps_counted;
0101 u64 prev_pmc[2];
0102 u64 pmc_total[2];
0103 u64 local_miss_count;
0104 u64 global_miss_count;
0105 u64 sched_overflow;
0106 u64 sched_overhead;
0107 u64 prev_usage;
0108 u64 prev_delta;
0109 u32 prev_count;
0110
0111
0112 u64 acnt_tsc;
0113 u64 cache_occupancy;
0114 u64 mpki;
0115 u64 prev_local_miss;
0116 u64 prev_global_miss;
0117 u64 prev_inst_ret;
0118 };
0119 u8 raw[VCPU_ALIGNMENT];
0120 };
0121 } vcpu;
0122 CASSERT (sizeof (vcpu) == VCPU_ALIGNMENT, vcpu);
0123
0124 extern u64 vcpu_current_vtsc (void);
0125
0126 extern void iovcpu_job_wakeup (task_id job, u64 T);
0127 extern void iovcpu_job_wakeup_for_me (task_id job);
0128 extern void iovcpu_job_completion (void);
0129
0130 extern uint lowest_priority_vcpu (void);
0131 extern uint select_iovcpu (iovcpu_class);
0132 extern void set_iovcpu (task_id, iovcpu_class);
0133
0134 extern DEF_PER_CPU (vcpu*, vcpu_current);
0135
0136 #endif
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147