X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fpalacios%2Fvmm_perftune.h;h=7876efa19ced886ef22905e87bfd62a971c7d24b;hb=9feccf93cd8327d1d30a404a92f19716bf5a1e96;hp=4346374f3cfa4d84bb98865ff5311b0f9ee8de37;hpb=cbe14745457d9a646157633e1fa8eccffe035953;p=palacios.git diff --git a/palacios/include/palacios/vmm_perftune.h b/palacios/include/palacios/vmm_perftune.h index 4346374..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 { @@ -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