Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Resource control extensions to host OS interface
[palacios.git] / palacios / include / palacios / vmm_perftune.h
1 /*
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2012, Peter Dinda <pdinda@northwestern.edu> 
11  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Peter Dinda <pdinda@northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20 #ifndef __VM_PERFTUNE_H__
21 #define __VM_PERFTUNE_H__
22
23 #ifdef __V3VEE__
24
25 #include <palacios/vmm_types.h>
26
27 #include <palacios/vmm_time.h>
28
29 struct v3_yield_strategy {
30     enum {
31         V3_YIELD_STRATEGY_GREEDY=0,     // always untimed yields  
32         V3_YIELD_STRATEGY_FRIENDLY,     // always timed yields with the following
33         V3_YIELD_STRATEGY_ADAPTIVE,     // switch from untimed to timed after the threshold
34     }         strategy;
35
36     uint64_t  threshold_usec;   // the point at which we transiton from untimed to timed yield
37     uint64_t  time_usec;        // the amount of time for a timed yield call
38
39 #define V3_DEFAULT_YIELD_STRATEGY       V3_YIELD_STRATEGY_FRIENDLY
40 #define V3_DEFAULT_YIELD_THRESHOLD_USEC 100
41 #define V3_DEFAULT_YIELD_TIME_USEC      10000
42 };
43
44
45
46 //
47 //  The idea is that the performance tuning knobs in the system are in the following 
48 //  structure, which is configured when the VM is created, right after extensions,
49 //  using the <perftune/> subtree
50 //
51 struct v3_perf_options {
52     struct v3_yield_strategy yield_strategy;
53 };
54
55
56 int      v3_setup_performance_tuning(struct v3_vm_info *vm, v3_cfg_tree_t *cfg);
57
58 void     v3_strategy_driven_yield(struct guest_info *core, uint64_t time_since_last_did_work_usec);
59
60 uint64_t v3_cycle_diff_in_usec(struct guest_info *core, uint64_t earlier_cycles, uint64_t later_cycles);
61
62 // The following three macros are intended to make it easy to
63 // use strategy-driven yield.  Call the first one when you are out of work
64 // then call the second when each time that you want to yield because you are
65 // out of work, and then call the third one when you have work to do again
66 //
67 // This assumes the thread is locked to a core and may behave strangely if 
68 // this is not the case.   
69
70 #define  V3_NO_WORK(core) {                                \
71   uint64_t _v3_strat_local_first=0, _v3_strat_local_cur=0; \
72   _v3_strat_local_first=v3_get_host_time(core ? &(core->time_state) : 0); 
73   
74   
75 #define  V3_STILL_NO_WORK(core)            \
76   _v3_strat_local_cur=v3_get_host_time(core ? &(core->time_state) : 0);              \
77   v3_strategy_driven_yield(core,v3_cycle_diff_in_usec(core,_v3_strat_local_first,_v3_strat_local_cur)); 
78
79 #define  V3_HAVE_WORK_AGAIN(core) }
80
81 #endif
82
83 #endif