X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fpalacios%2Fvmm_perftune.h;h=7876efa19ced886ef22905e87bfd62a971c7d24b;hb=4d1d8fadad33de7d3ebce2083d9782048f78b44e;hp=0a60d6c68f2ac242fa382f7b2abc6d94d4fa1ae9;hpb=a0bff8bd6b7f6dcfc840b41aa428904f251fba7e;p=palacios.git diff --git a/palacios/include/palacios/vmm_perftune.h b/palacios/include/palacios/vmm_perftune.h index 0a60d6c..7876efa 100644 --- a/palacios/include/palacios/vmm_perftune.h +++ b/palacios/include/palacios/vmm_perftune.h @@ -24,6 +24,7 @@ #include +#include struct v3_yield_strategy { enum { @@ -35,9 +36,9 @@ struct v3_yield_strategy { uint64_t threshold_usec; // the point at which we transiton from untimed to timed yield uint64_t time_usec; // the amount of time for a timed yield call -#define V3_DEFAULT_YIELD_STRATEGY V3_YIELD_STRATEGY_GREEDY +#define V3_DEFAULT_YIELD_STRATEGY V3_YIELD_STRATEGY_FRIENDLY #define V3_DEFAULT_YIELD_THRESHOLD_USEC 100 -#define V3_DEFAULT_YIELD_TIME_USEC 1000 +#define V3_DEFAULT_YIELD_TIME_USEC 10000 }; @@ -58,6 +59,24 @@ void v3_strategy_driven_yield(struct guest_info *core, uint64_t time_since_l uint64_t v3_cycle_diff_in_usec(struct guest_info *core, uint64_t earlier_cycles, uint64_t later_cycles); +// The following three macros are intended to make it easy to +// use strategy-driven yield. Call the first one when you are out of work +// then call the second when each time that you want to yield because you are +// out of work, and then call the third one when you have work to do again +// +// This assumes the thread is locked to a core and may behave strangely if +// this is not the case. + +#define V3_NO_WORK(core) { \ + uint64_t _v3_strat_local_first=0, _v3_strat_local_cur=0; \ + _v3_strat_local_first=v3_get_host_time(core ? &(core->time_state) : 0); + + +#define V3_STILL_NO_WORK(core) \ + _v3_strat_local_cur=v3_get_host_time(core ? &(core->time_state) : 0); \ + v3_strategy_driven_yield(core,v3_cycle_diff_in_usec(core,_v3_strat_local_first,_v3_strat_local_cur)); + +#define V3_HAVE_WORK_AGAIN(core) } #endif