vmware.c File Reference

Include dependency graph for vmware.c:

Go to the source code of this file.

Data Structures

struct  _vmware_native_event_entry
struct  _vmware_reg_alloc
struct  _vmware_control_state
struct  _vmware_context

Defines

#define VMWARE_MAX_COUNTERS   256
#define VMWARE_CPU_LIMIT_MHZ   0
#define VMWARE_CPU_RESERVATION_MHZ   1
#define VMWARE_CPU_SHARES   2
#define VMWARE_CPU_STOLEN_MS   3
#define VMWARE_CPU_USED_MS   4
#define VMWARE_ELAPSED_MS   5
#define VMWARE_MEM_ACTIVE_MB   6
#define VMWARE_MEM_BALLOONED_MB   7
#define VMWARE_MEM_LIMIT_MB   8
#define VMWARE_MEM_MAPPED_MB   9
#define VMWARE_MEM_OVERHEAD_MB   10
#define VMWARE_MEM_RESERVATION_MB   11
#define VMWARE_MEM_SHARED_MB   12
#define VMWARE_MEM_SHARES   13
#define VMWARE_MEM_SWAPPED_MB   14
#define VMWARE_MEM_TARGET_SIZE_MB   15
#define VMWARE_MEM_USED_MB   16
#define VMWARE_HOST_CPU_MHZ   17
#define VMWARE_HOST_TSC   18
#define VMWARE_ELAPSED_TIME   19
#define VMWARE_ELAPSED_APPARENT   20

Functions

uint64_t rdpmc (int c)
static int LoadFunctions (void)
static long long _vmware_hardware_read (struct _vmware_context *context, int starting)
int _vmware_init_thread (hwd_context_t *ctx)
int _vmware_init_component (int cidx)
int _vmware_init_control_state (hwd_control_state_t *ctl)
int _vmware_ntv_enum_events (unsigned int *EventCode, int modifier)
int _vmware_ntv_code_to_info (unsigned int EventCode, PAPI_event_info_t *info)
int _vmware_ntv_code_to_name (unsigned int EventCode, char *name, int len)
int _vmware_ntv_code_to_descr (unsigned int EventCode, char *name, int len)
int _vmware_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
int _vmware_start (hwd_context_t *ctx, hwd_control_state_t *ctl)
int _vmware_stop (hwd_context_t *ctx, hwd_control_state_t *ctl)
int _vmware_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long_long **events, int flags)
int _vmware_write (hwd_context_t *ctx, hwd_control_state_t *ctrl, long_long events[])
int _vmware_reset (hwd_context_t *ctx, hwd_control_state_t *ctl)
int _vmware_shutdown_thread (hwd_context_t *ctx)
int _vmware_shutdown_component (void)
int _vmware_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
int _vmware_set_domain (hwd_control_state_t *ctl, int domain)

Variables

papi_vector_t _vmware_vector
void(* _dl_non_dynamic_init )(void)
static struct
_vmware_native_event_entry
_vmware_native_table
static int num_events = 0
static int use_pseudo = 0
static int use_guestlib = 0

Define Documentation

#define VMWARE_CPU_LIMIT_MHZ   0

Definition at line 39 of file vmware.c.

#define VMWARE_CPU_RESERVATION_MHZ   1

Definition at line 40 of file vmware.c.

#define VMWARE_CPU_SHARES   2

Definition at line 41 of file vmware.c.

#define VMWARE_CPU_STOLEN_MS   3

Definition at line 42 of file vmware.c.

#define VMWARE_CPU_USED_MS   4

Definition at line 43 of file vmware.c.

#define VMWARE_ELAPSED_APPARENT   20

Definition at line 64 of file vmware.c.

#define VMWARE_ELAPSED_MS   5

Definition at line 44 of file vmware.c.

#define VMWARE_ELAPSED_TIME   19

Definition at line 63 of file vmware.c.

#define VMWARE_HOST_CPU_MHZ   17

Definition at line 58 of file vmware.c.

#define VMWARE_HOST_TSC   18

Definition at line 62 of file vmware.c.

#define VMWARE_MAX_COUNTERS   256

Definition at line 37 of file vmware.c.

#define VMWARE_MEM_ACTIVE_MB   6

Definition at line 46 of file vmware.c.

#define VMWARE_MEM_BALLOONED_MB   7

Definition at line 47 of file vmware.c.

#define VMWARE_MEM_LIMIT_MB   8

Definition at line 48 of file vmware.c.

#define VMWARE_MEM_MAPPED_MB   9

Definition at line 49 of file vmware.c.

#define VMWARE_MEM_OVERHEAD_MB   10

Definition at line 50 of file vmware.c.

#define VMWARE_MEM_RESERVATION_MB   11

Definition at line 51 of file vmware.c.

#define VMWARE_MEM_SHARED_MB   12

Definition at line 52 of file vmware.c.

#define VMWARE_MEM_SHARES   13

Definition at line 53 of file vmware.c.

#define VMWARE_MEM_SWAPPED_MB   14

Definition at line 54 of file vmware.c.

#define VMWARE_MEM_TARGET_SIZE_MB   15

Definition at line 55 of file vmware.c.

#define VMWARE_MEM_USED_MB   16

Definition at line 56 of file vmware.c.


Function Documentation

int _vmware_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)

This function sets various options in the component

Parameters:
ctx 
code valid are PAPI_SET_DEFDOM, PAPI_SET_DOMAIN, PAPI_SETDEFGRN, PAPI_SET_GRANUL and PAPI_SET_INHERIT
option 

Definition at line 1183 of file vmware.c.

01184 {
01185 
01186     (void) ctx;
01187     (void) code;
01188     (void) option;
01189 
01190     SUBDBG( "_vmware_ctl..." );
01191 
01192     return PAPI_OK;
01193 }

static long long _vmware_hardware_read ( struct _vmware_context context,
int  starting 
) [static]

Code that reads event values. You might replace this with code that accesses hardware or reads values from the operatings system.

Definition at line 302 of file vmware.c.

00303 {
00304 
00305   int i;
00306 
00307     if (use_pseudo) {
00308            context->values[VMWARE_HOST_TSC]=rdpmc(0x10000);
00309            context->values[VMWARE_ELAPSED_TIME]=rdpmc(0x10001);
00310            context->values[VMWARE_ELAPSED_APPARENT]=rdpmc(0x10002);
00311     }
00312 
00313 
00314 #ifdef VMGUESTLIB
00315     static VMSessionId sessionId = 0;
00316     VMSessionId tmpSession;
00317     uint32_t temp32;
00318     uint64_t temp64;
00319     VMGuestLibError glError;
00320 
00321     if (use_guestlib) {
00322 
00323     glError = GuestLib_UpdateInfo(context->glHandle);
00324     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00325        fprintf(stderr,"UpdateInfo failed: %s\n", 
00326            GuestLib_GetErrorText(glError));
00327            return PAPI_ECMP;
00328     }
00329 
00330     /* Retrieve and check the session ID */
00331     glError = GuestLib_GetSessionId(context->glHandle, &tmpSession);
00332     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00333        fprintf(stderr, "Failed to get session ID: %s\n", 
00334            GuestLib_GetErrorText(glError));
00335        return PAPI_ECMP;
00336     }
00337 
00338     if (tmpSession == 0) {
00339        fprintf(stderr, "Error: Got zero sessionId from GuestLib\n");
00340        return PAPI_ECMP;
00341     }
00342 
00343     if (sessionId == 0) {
00344        sessionId = tmpSession;
00345     } else if (tmpSession != sessionId) {
00346        sessionId = tmpSession;
00347     }
00348 
00349     glError = GuestLib_GetCpuLimitMHz(context->glHandle,&temp32);
00350     context->values[VMWARE_CPU_LIMIT_MHZ]=temp32;
00351     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00352        fprintf(stderr,"Failed to get CPU limit: %s\n", 
00353            GuestLib_GetErrorText(glError));
00354        return PAPI_ECMP;
00355     }
00356 
00357     glError = GuestLib_GetCpuReservationMHz(context->glHandle,&temp32); 
00358     context->values[VMWARE_CPU_RESERVATION_MHZ]=temp32;
00359         if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00360        fprintf(stderr,"Failed to get CPU reservation: %s\n", 
00361            GuestLib_GetErrorText(glError));
00362        return PAPI_ECMP;
00363     }
00364     
00365     glError = GuestLib_GetCpuShares(context->glHandle,&temp32);
00366     context->values[VMWARE_CPU_SHARES]=temp32;
00367     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00368        fprintf(stderr,"Failed to get cpu shares: %s\n", 
00369            GuestLib_GetErrorText(glError));
00370        return PAPI_ECMP;
00371     }
00372 
00373     glError = GuestLib_GetCpuStolenMs(context->glHandle,&temp64);
00374     context->values[VMWARE_CPU_STOLEN_MS]=temp64;
00375     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00376        if (glError == VMGUESTLIB_ERROR_UNSUPPORTED_VERSION) {
00377           context->values[VMWARE_CPU_STOLEN_MS]=0;
00378           fprintf(stderr, "Skipping CPU stolen, not supported...\n");
00379        } else {
00380           fprintf(stderr, "Failed to get CPU stolen: %s\n", 
00381               GuestLib_GetErrorText(glError));
00382           return PAPI_ECMP;
00383        }
00384     }
00385 
00386     glError = GuestLib_GetCpuUsedMs(context->glHandle,&temp64);
00387     context->values[VMWARE_CPU_USED_MS]=temp64;
00388     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00389        fprintf(stderr, "Failed to get used ms: %s\n", 
00390            GuestLib_GetErrorText(glError));
00391        return PAPI_ECMP;
00392     }
00393     
00394     glError = GuestLib_GetElapsedMs(context->glHandle, &temp64);
00395     context->values[VMWARE_ELAPSED_MS]=temp64;
00396     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00397        fprintf(stderr, "Failed to get elapsed ms: %s\n",
00398            GuestLib_GetErrorText(glError));
00399        return PAPI_ECMP;
00400     }
00401 
00402     glError = GuestLib_GetMemActiveMB(context->glHandle, &temp32);
00403     context->values[VMWARE_MEM_ACTIVE_MB]=temp32;
00404     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00405        fprintf(stderr, "Failed to get active mem: %s\n", 
00406            GuestLib_GetErrorText(glError));
00407        return PAPI_ECMP;
00408     }
00409     
00410     glError = GuestLib_GetMemBalloonedMB(context->glHandle, &temp32);
00411     context->values[VMWARE_MEM_BALLOONED_MB]=temp32;
00412     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00413        fprintf(stderr, "Failed to get ballooned mem: %s\n", 
00414            GuestLib_GetErrorText(glError));
00415        return PAPI_ECMP;
00416     }
00417     
00418     glError = GuestLib_GetMemLimitMB(context->glHandle, &temp32);
00419     context->values[VMWARE_MEM_LIMIT_MB]=temp32;
00420     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00421        fprintf(stderr,"Failed to get mem limit: %s\n", 
00422            GuestLib_GetErrorText(glError));
00423        return PAPI_ECMP;
00424     }
00425 
00426         glError = GuestLib_GetMemMappedMB(context->glHandle, &temp32);
00427     context->values[VMWARE_MEM_MAPPED_MB]=temp32;
00428     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00429        fprintf(stderr, "Failed to get mapped mem: %s\n", 
00430            GuestLib_GetErrorText(glError));
00431        return PAPI_ECMP;
00432     }
00433 
00434     glError = GuestLib_GetMemOverheadMB(context->glHandle, &temp32);
00435     context->values[VMWARE_MEM_OVERHEAD_MB]=temp32;
00436     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00437        fprintf(stderr, "Failed to get overhead mem: %s\n", 
00438            GuestLib_GetErrorText(glError));
00439        return PAPI_ECMP;
00440     }
00441 
00442     glError = GuestLib_GetMemReservationMB(context->glHandle, &temp32);
00443     context->values[VMWARE_MEM_RESERVATION_MB]=temp32;
00444     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00445        fprintf(stderr, "Failed to get mem reservation: %s\n", 
00446            GuestLib_GetErrorText(glError));
00447        return PAPI_ECMP;
00448     }
00449 
00450         glError = GuestLib_GetMemSharedMB(context->glHandle, &temp32);
00451     context->values[VMWARE_MEM_SHARED_MB]=temp32;
00452     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00453        fprintf(stderr, "Failed to get swapped mem: %s\n", 
00454            GuestLib_GetErrorText(glError));
00455        return PAPI_ECMP;
00456     }
00457 
00458     glError = GuestLib_GetMemShares(context->glHandle, &temp32);
00459     context->values[VMWARE_MEM_SHARES]=temp32;
00460     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00461        if (glError == VMGUESTLIB_ERROR_NOT_AVAILABLE) {
00462           context->values[VMWARE_MEM_SHARES]=0;
00463           fprintf(stderr, "Skipping mem shares, not supported...\n");
00464        } else {
00465           fprintf(stderr, "Failed to get mem shares: %s\n", 
00466               GuestLib_GetErrorText(glError));
00467           return PAPI_ECMP;
00468        }
00469     }
00470 
00471     glError = GuestLib_GetMemSwappedMB(context->glHandle, &temp32);
00472     context->values[VMWARE_MEM_SWAPPED_MB]=temp32;
00473     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00474        fprintf(stderr, "Failed to get swapped mem: %s\n",
00475            GuestLib_GetErrorText(glError));
00476        return PAPI_ECMP;
00477     }
00478     
00479     glError = GuestLib_GetMemTargetSizeMB(context->glHandle, &temp64);
00480     context->values[VMWARE_MEM_TARGET_SIZE_MB]=temp64;
00481         if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00482        if (glError == VMGUESTLIB_ERROR_UNSUPPORTED_VERSION) {
00483           context->values[VMWARE_MEM_TARGET_SIZE_MB]=0;
00484           fprintf(stderr, "Skipping target mem size, not supported...\n");
00485        } else {
00486           fprintf(stderr, "Failed to get target mem size: %s\n", 
00487               GuestLib_GetErrorText(glError));
00488           return PAPI_ECMP;
00489        }
00490     }
00491 
00492         glError = GuestLib_GetMemUsedMB(context->glHandle, &temp32);
00493     context->values[VMWARE_MEM_USED_MB]=temp32;
00494     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00495        fprintf(stderr, "Failed to get swapped mem: %s\n",
00496            GuestLib_GetErrorText(glError));
00497        return PAPI_ECMP;
00498     }
00499 
00500         glError = GuestLib_GetHostProcessorSpeed(context->glHandle, &temp32); 
00501     context->values[VMWARE_HOST_CPU_MHZ]=temp32;
00502     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00503        fprintf(stderr, "Failed to get host proc speed: %s\n", 
00504            GuestLib_GetErrorText(glError));
00505        return PAPI_ECMP;
00506     }
00507     }
00508 
00509 #endif
00510 
00511     if (starting) {
00512 
00513       for(i=0;i<VMWARE_MAX_COUNTERS;i++) {
00514         context->start_values[i]=context->values[i];
00515       }
00516 
00517     }
00518 
00519     return PAPI_OK;
00520 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _vmware_init_component ( int  cidx  ) 

Initialize hardware counters, setup the function vector table and get hardware information, this routine is called when the PAPI process is initialized (IE PAPI_library_init)

Definition at line 560 of file vmware.c.

00561 {
00562 
00563   (void) cidx;
00564 
00565   int result;
00566 
00567     SUBDBG( "_vmware_init_component..." );
00568 
00569     /* Initialize and try to load the VMware library */
00570     /* Try to load the library. */
00571     result=LoadFunctions();
00572 
00573     if (result!=PAPI_OK) {
00574        strncpy(_vmware_vector.cmp_info.disabled_reason,
00575           "GuestLibTest: Failed to load shared library",
00576            PAPI_MAX_STR_LEN);
00577        return PAPI_ECMP;
00578     }
00579 
00580     /* we know in advance how many events we want                       */
00581     /* for actual hardware this might have to be determined dynamically */
00582 
00583     /* Allocate memory for the our event table */
00584     _vmware_native_table = ( struct _vmware_native_event_entry * )
00585       calloc( VMWARE_MAX_COUNTERS, sizeof ( struct _vmware_native_event_entry ));
00586     if ( _vmware_native_table == NULL ) {
00587        return PAPI_ENOMEM;
00588     }
00589 
00590 
00591 #ifdef VMGUESTLIB
00592 
00593     /* Detect if GuestLib works */
00594     {
00595 
00596         VMGuestLibError glError;
00597         VMGuestLibHandle glHandle;
00598 
00599     use_guestlib=0;
00600 
00601     /* try to open */
00602     glError = GuestLib_OpenHandle(&glHandle);
00603     if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00604        fprintf(stderr,"OpenHandle failed: %s\n", 
00605            GuestLib_GetErrorText(glError));
00606     }
00607     else {
00608        /* open worked, try to update */
00609        glError = GuestLib_UpdateInfo(glHandle);
00610        if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00611           fprintf(stderr,"UpdateInfo failed: %s\n", 
00612               GuestLib_GetErrorText(glError));
00613        }
00614        else {
00615           /* update worked, things work! */
00616           use_guestlib=1;
00617        }
00618        /* shut things down */
00619        glError = GuestLib_CloseHandle(glHandle);
00620     }
00621 
00622         }
00623 
00624 
00625 
00626     if (use_guestlib) {
00627 
00628     /* fill in the event table parameters */
00629     strcpy( _vmware_native_table[num_events].name,
00630         "CPU_LIMIT" );
00631     strncpy( _vmware_native_table[num_events].description,
00632         "Retrieves the upper limit of processor use in MHz "
00633         "available to the virtual machine.",
00634         PAPI_HUGE_STR_LEN);
00635     strcpy( _vmware_native_table[num_events].units,"MHz");
00636     _vmware_native_table[num_events].which_counter=
00637             VMWARE_CPU_LIMIT_MHZ;
00638     _vmware_native_table[num_events].report_difference=0;
00639     num_events++;
00640 
00641     strcpy( _vmware_native_table[num_events].name,
00642         "CPU_RESERVATION" );
00643     strncpy( _vmware_native_table[num_events].description,
00644         "Retrieves the minimum processing power in MHz "
00645         "reserved for the virtual machine.",
00646         PAPI_HUGE_STR_LEN);
00647     strcpy( _vmware_native_table[num_events].units,"MHz");
00648     _vmware_native_table[num_events].which_counter=
00649             VMWARE_CPU_RESERVATION_MHZ;
00650     _vmware_native_table[num_events].report_difference=0;
00651     num_events++;
00652 
00653     strcpy( _vmware_native_table[num_events].name,
00654         "CPU_SHARES" );
00655     strncpy( _vmware_native_table[num_events].description,
00656         "Retrieves the number of CPU shares allocated "
00657         "to the virtual machine.",
00658         PAPI_HUGE_STR_LEN);
00659     strcpy( _vmware_native_table[num_events].units,"shares");
00660     _vmware_native_table[num_events].which_counter=
00661             VMWARE_CPU_SHARES;
00662     _vmware_native_table[num_events].report_difference=0;
00663     num_events++;
00664 
00665     strcpy( _vmware_native_table[num_events].name,
00666         "CPU_STOLEN" );
00667     strncpy( _vmware_native_table[num_events].description,
00668         "Retrieves the number of milliseconds that the "
00669         "virtual machine was in a ready state (able to "
00670         "transition to a run state), but was not scheduled to run.",
00671         PAPI_HUGE_STR_LEN);
00672     strcpy( _vmware_native_table[num_events].units,"ms");
00673     _vmware_native_table[num_events].which_counter=
00674             VMWARE_CPU_STOLEN_MS;
00675     _vmware_native_table[num_events].report_difference=0;
00676     num_events++;
00677 
00678     strcpy( _vmware_native_table[num_events].name,
00679         "CPU_USED" );
00680     strncpy( _vmware_native_table[num_events].description,
00681         "Retrieves the number of milliseconds during which "
00682         "the virtual machine has used the CPU. This value "
00683         "includes the time used by the guest operating system "
00684         "and the time used by virtualization code for tasks for "
00685         "this virtual machine. You can combine this value with "
00686         "the elapsed time (VMWARE_ELAPSED) to estimate the "
00687         "effective virtual machine CPU speed. This value is a "
00688         "subset of elapsedMs.",
00689         PAPI_HUGE_STR_LEN );
00690     strcpy( _vmware_native_table[num_events].units,"ms");
00691     _vmware_native_table[num_events].which_counter=
00692             VMWARE_CPU_USED_MS;
00693     _vmware_native_table[num_events].report_difference=1;
00694     num_events++;
00695 
00696     strcpy( _vmware_native_table[num_events].name,
00697         "ELAPSED" );
00698     strncpy( _vmware_native_table[num_events].description,
00699         "Retrieves the number of milliseconds that have passed "
00700         "in the virtual machine since it last started running on "
00701         "the server. The count of elapsed time restarts each time "
00702         "the virtual machine is powered on, resumed, or migrated "
00703         "using VMotion. This value counts milliseconds, regardless "
00704         "of whether the virtual machine is using processing power "
00705         "during that time. You can combine this value with the CPU "
00706         "time used by the virtual machine (VMWARE_CPU_USED) to "
00707         "estimate the effective virtual machine xCPU speed. "
00708         "cpuUsedMS is a subset of this value.",
00709         PAPI_HUGE_STR_LEN );
00710     strcpy( _vmware_native_table[num_events].units,"ms");
00711     _vmware_native_table[num_events].which_counter=
00712             VMWARE_ELAPSED_MS;
00713     _vmware_native_table[num_events].report_difference=1;
00714     num_events++;
00715 
00716     strcpy( _vmware_native_table[num_events].name,
00717         "MEM_ACTIVE" );
00718     strncpy( _vmware_native_table[num_events].description,
00719          "Retrieves the amount of memory the virtual machine is "
00720          "actively using in MB - Its estimated working set size.",
00721          PAPI_HUGE_STR_LEN );
00722     strcpy( _vmware_native_table[num_events].units,"MB");
00723     _vmware_native_table[num_events].which_counter=
00724                  VMWARE_MEM_ACTIVE_MB;
00725     _vmware_native_table[num_events].report_difference=0;
00726     num_events++;
00727 
00728     strcpy( _vmware_native_table[num_events].name,
00729         "MEM_BALLOONED" );
00730     strncpy( _vmware_native_table[num_events].description,
00731         "Retrieves the amount of memory that has been reclaimed "
00732         "from this virtual machine by the vSphere memory balloon "
00733         "driver (also referred to as the 'vmemctl' driver) in MB.",
00734         PAPI_HUGE_STR_LEN );
00735     strcpy( _vmware_native_table[num_events].units,"MB");
00736     _vmware_native_table[num_events].which_counter=
00737             VMWARE_MEM_BALLOONED_MB;
00738     _vmware_native_table[num_events].report_difference=0;
00739     num_events++;
00740 
00741     strcpy( _vmware_native_table[num_events].name,
00742         "MEM_LIMIT" );
00743     strncpy( _vmware_native_table[num_events].description,
00744         "Retrieves the upper limit of memory that is available "
00745         "to the virtual machine in MB.",
00746         PAPI_HUGE_STR_LEN );
00747     strcpy( _vmware_native_table[num_events].units,"MB");
00748     _vmware_native_table[num_events].which_counter=
00749             VMWARE_MEM_LIMIT_MB;
00750     _vmware_native_table[num_events].report_difference=0;
00751     num_events++;
00752 
00753     strcpy( _vmware_native_table[num_events].name,
00754         "MEM_MAPPED" );
00755     strncpy( _vmware_native_table[num_events].description,
00756         "Retrieves the amount of memory that is allocated to "
00757         "the virtual machine in MB. Memory that is ballooned, "
00758         "swapped, or has never been accessed is excluded.",
00759         PAPI_HUGE_STR_LEN );
00760     strcpy( _vmware_native_table[num_events].units,"MB");
00761     _vmware_native_table[num_events].which_counter=
00762             VMWARE_MEM_MAPPED_MB;
00763     _vmware_native_table[num_events].report_difference=0;
00764     num_events++;
00765 
00766     strcpy( _vmware_native_table[num_events].name,
00767         "MEM_OVERHEAD" );
00768     strncpy( _vmware_native_table[num_events].description,
00769         "Retrieves the amount of 'overhead' memory associated "
00770         "with this virtual machine that is currently consumed "
00771         "on the host system in MB. Overhead memory is additional "
00772         "memory that is reserved for data structures required by "
00773         "the virtualization layer.",
00774         PAPI_HUGE_STR_LEN );
00775     strcpy( _vmware_native_table[num_events].units,"MB");
00776     _vmware_native_table[num_events].which_counter=
00777             VMWARE_MEM_OVERHEAD_MB;
00778     _vmware_native_table[num_events].report_difference=0;
00779     num_events++;
00780 
00781     strcpy( _vmware_native_table[num_events].name,
00782         "MEM_RESERVATION" );
00783     strncpy( _vmware_native_table[num_events].description,
00784         "Retrieves the minimum amount of memory that is "
00785         "reserved for the virtual machine in MB.",
00786         PAPI_HUGE_STR_LEN );
00787     strcpy( _vmware_native_table[num_events].units,"MB");
00788     _vmware_native_table[num_events].which_counter=
00789             VMWARE_MEM_RESERVATION_MB;
00790     _vmware_native_table[num_events].report_difference=0;
00791     num_events++;
00792 
00793     strcpy( _vmware_native_table[num_events].name,
00794         "MEM_SHARED" );
00795     strncpy( _vmware_native_table[num_events].description,
00796         "Retrieves the amount of physical memory associated "
00797         "with this virtual machine that is copy-on-write (COW) "
00798         "shared on the host in MB.",
00799         PAPI_HUGE_STR_LEN );
00800     strcpy( _vmware_native_table[num_events].units,"MB");
00801     _vmware_native_table[num_events].which_counter=
00802             VMWARE_MEM_SHARED_MB;
00803     _vmware_native_table[num_events].report_difference=0;
00804     num_events++;
00805 
00806     strcpy( _vmware_native_table[num_events].name,
00807         "MEM_SHARES" );
00808     strncpy( _vmware_native_table[num_events].description,
00809         "Retrieves the number of memory shares allocated to "
00810         "the virtual machine.",
00811         PAPI_HUGE_STR_LEN );
00812     strcpy( _vmware_native_table[num_events].units,"shares");
00813     _vmware_native_table[num_events].which_counter=
00814             VMWARE_MEM_SHARES;
00815     _vmware_native_table[num_events].report_difference=0;
00816     num_events++;
00817 
00818     strcpy( _vmware_native_table[num_events].name,
00819         "MEM_SWAPPED" );
00820     strncpy( _vmware_native_table[num_events].description,
00821         "Retrieves the amount of memory that has been reclaimed "
00822         "from this virtual machine by transparently swapping "
00823         "guest memory to disk in MB.",
00824         PAPI_HUGE_STR_LEN );
00825     strcpy( _vmware_native_table[num_events].units,"MB");
00826     _vmware_native_table[num_events].which_counter=
00827             VMWARE_MEM_SWAPPED_MB;
00828     _vmware_native_table[num_events].report_difference=0;
00829     num_events++;
00830 
00831     strcpy( _vmware_native_table[num_events].name,
00832         "MEM_TARGET_SIZE" );
00833     strncpy( _vmware_native_table[num_events].description,
00834         "Retrieves the size of the target memory allocation "
00835         "for this virtual machine in MB.",
00836         PAPI_HUGE_STR_LEN );
00837     strcpy( _vmware_native_table[num_events].units,"MB");
00838     _vmware_native_table[num_events].which_counter=
00839             VMWARE_MEM_TARGET_SIZE_MB;
00840     _vmware_native_table[num_events].report_difference=0;
00841     num_events++;
00842 
00843     strcpy( _vmware_native_table[num_events].name,
00844         "MEM_USED" );
00845     strncpy( _vmware_native_table[num_events].description,
00846         "Retrieves the estimated amount of physical host memory "
00847         "currently consumed for this virtual machine's "
00848         "physical memory.",
00849         PAPI_HUGE_STR_LEN );
00850     strcpy( _vmware_native_table[num_events].units,"MB");
00851     _vmware_native_table[num_events].which_counter=
00852             VMWARE_MEM_USED_MB;
00853     _vmware_native_table[num_events].report_difference=0;
00854     num_events++;
00855 
00856     strcpy( _vmware_native_table[num_events].name,
00857         "HOST_CPU" );
00858     strncpy( _vmware_native_table[num_events].description,
00859         "Retrieves the speed of the ESX system's physical "
00860         "CPU in MHz.",
00861         PAPI_HUGE_STR_LEN );
00862     strcpy( _vmware_native_table[num_events].units,"MHz");
00863     _vmware_native_table[num_events].which_counter=
00864             VMWARE_HOST_CPU_MHZ;
00865     _vmware_native_table[num_events].report_difference=0;
00866     num_events++;
00867     }
00868 
00869 #endif
00870 
00871     /* For VMWare Pseudo Performance Counters */
00872     if ( getenv( "PAPI_VMWARE_PSEUDOPERFORMANCE" ) ) {
00873 
00874             use_pseudo=1;
00875 
00876         strcpy( _vmware_native_table[num_events].name,
00877             "HOST_TSC" );
00878         strncpy( _vmware_native_table[num_events].description,
00879             "Physical host TSC",
00880             PAPI_HUGE_STR_LEN );
00881         strcpy( _vmware_native_table[num_events].units,"cycles");
00882         _vmware_native_table[num_events].which_counter=
00883                 VMWARE_HOST_TSC;
00884             _vmware_native_table[num_events].report_difference=1;
00885         num_events++;
00886 
00887         strcpy( _vmware_native_table[num_events].name,
00888             "ELAPSED_TIME" );
00889         strncpy( _vmware_native_table[num_events].description,
00890             "Elapsed real time in ns.",
00891             PAPI_HUGE_STR_LEN );
00892             strcpy( _vmware_native_table[num_events].units,"ns");
00893         _vmware_native_table[num_events].which_counter=
00894                 VMWARE_ELAPSED_TIME;
00895             _vmware_native_table[num_events].report_difference=1;
00896         num_events++;
00897 
00898         strcpy( _vmware_native_table[num_events].name,
00899             "ELAPSED_APPARENT" );
00900         strncpy( _vmware_native_table[num_events].description,
00901             "Elapsed apparent time in ns.",
00902             PAPI_HUGE_STR_LEN );
00903             strcpy( _vmware_native_table[num_events].units,"ns");
00904         _vmware_native_table[num_events].which_counter=
00905                 VMWARE_ELAPSED_APPARENT;
00906             _vmware_native_table[num_events].report_difference=1;
00907         num_events++;
00908     }
00909 
00910     if (num_events==0) {
00911        strncpy(_vmware_vector.cmp_info.disabled_reason,
00912           "VMware SDK not installed, and PAPI_VMWARE_PSEUDOPERFORMANCE not set",
00913            PAPI_MAX_STR_LEN);
00914       return PAPI_ECMP;
00915     }
00916 
00917     _vmware_vector.cmp_info.num_native_events = num_events;
00918 
00919     return PAPI_OK;
00920 }

Here is the call graph for this function:

int _vmware_init_control_state ( hwd_control_state_t ctl  ) 

Setup the counter control structure

Definition at line 924 of file vmware.c.

00925 {
00926   (void) ctl;
00927 
00928     return PAPI_OK;
00929 }

int _vmware_init_thread ( hwd_context_t ctx  ) 

This is called whenever a thread is initialized

Definition at line 528 of file vmware.c.

00529 {
00530     (void) ctx;
00531 
00532 
00533 #ifdef VMGUESTLIB
00534 
00535     struct _vmware_context *context;
00536     VMGuestLibError glError;
00537 
00538     context=(struct _vmware_context *)ctx;
00539 
00540     if (use_guestlib) {
00541        glError = GuestLib_OpenHandle(&(context->glHandle));
00542        if (glError != VMGUESTLIB_ERROR_SUCCESS) {
00543           fprintf(stderr,"OpenHandle failed: %s\n", 
00544            GuestLib_GetErrorText(glError));
00545           return PAPI_ECMP;
00546        }
00547     }
00548 
00549 #endif
00550 
00551     return PAPI_OK;
00552 }

int _vmware_ntv_code_to_descr ( unsigned int  EventCode,
char *  name,
int  len 
)

Takes a native event code and passes back the event description

Parameters:
EventCode is the native event code
name is a pointer for the description to be copied to
len is the size of the string

Definition at line 1007 of file vmware.c.

01008 {
01009   int index = EventCode;
01010 
01011     if ( index >= 0 && index < num_events ) {
01012        strncpy( name, _vmware_native_table[index].description, len );
01013     }
01014     return PAPI_OK;
01015 }

int _vmware_ntv_code_to_info ( unsigned int  EventCode,
PAPI_event_info_t info 
)

Definition at line 965 of file vmware.c.

00966 {
00967 
00968   int index = EventCode;
00969 
00970   if ( ( index < 0) || (index >= num_events )) return PAPI_ENOEVNT;
00971 
00972   strncpy( info->symbol, _vmware_native_table[index].name, 
00973            sizeof(info->symbol));
00974 
00975   strncpy( info->long_descr, _vmware_native_table[index].description, 
00976            sizeof(info->symbol));
00977 
00978   strncpy( info->units, _vmware_native_table[index].units, 
00979            sizeof(info->units));
00980 
00981   return PAPI_OK;
00982 }

int _vmware_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)

Takes a native event code and passes back the name

Parameters:
EventCode is the native event code
name is a pointer for the name to be copied to
len is the size of the string

Definition at line 991 of file vmware.c.

00992 {
00993     int index = EventCode;
00994 
00995     if ( index >= 0 && index < num_events ) {
00996        strncpy( name, _vmware_native_table[index].name, len );
00997     }
00998     return PAPI_OK;
00999 }

int _vmware_ntv_enum_events ( unsigned int *  EventCode,
int  modifier 
)

Enumerate Native Events

Parameters:
EventCode is the event of interest
modifier is one of PAPI_ENUM_FIRST, PAPI_ENUM_EVENTS

Definition at line 936 of file vmware.c.

00937 {
00938 
00939     switch ( modifier ) {
00940             /* return EventCode of first event */
00941         case PAPI_ENUM_FIRST:
00942              if (num_events==0) return PAPI_ENOEVNT;
00943              *EventCode = 0;
00944              return PAPI_OK;
00945              break;
00946             /* return EventCode of passed-in Event */
00947         case PAPI_ENUM_EVENTS:{
00948              int index = *EventCode;
00949 
00950              if ( index < num_events - 1 ) {
00951             *EventCode = *EventCode + 1;
00952             return PAPI_OK;
00953              } else {
00954             return PAPI_ENOEVNT;
00955              }
00956              break;
00957         }
00958         default:
00959              return PAPI_EINVAL;
00960     }
00961     return PAPI_EINVAL;
00962 }

int _vmware_read ( hwd_context_t ctx,
hwd_control_state_t ctl,
long_long **  events,
int  flags 
)

Triggered by PAPI_read()

Definition at line 1073 of file vmware.c.

01076 {
01077 
01078     struct _vmware_context *context;
01079     struct _vmware_control_state *control;
01080 
01081     (void) flags;
01082     int i;
01083 
01084     context=(struct _vmware_context *)ctx;
01085     control=(struct _vmware_control_state *)ctl;
01086 
01087     _vmware_hardware_read( context, 0 );
01088 
01089     for (i=0; i<control->num_events; i++) {
01090       
01091       if (_vmware_native_table[
01092               _vmware_native_table[control->which_counter[i]].which_counter].
01093              report_difference) {
01094          control->value[i]=context->values[control->which_counter[i]]-
01095                            context->start_values[control->which_counter[i]];
01096       } else {
01097          control->value[i]=context->values[control->which_counter[i]];
01098       }
01099       //      printf("%d %d %lld-%lld=%lld\n",i,control->which_counter[i],
01100       // context->values[control->which_counter[i]],
01101       //     context->start_values[control->which_counter[i]],
01102       //     control->value[i]);
01103 
01104     }
01105 
01106     *events = control->value;
01107 
01108     return PAPI_OK;
01109 }

Here is the call graph for this function:

int _vmware_reset ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

Triggered by PAPI_reset

Definition at line 1128 of file vmware.c.

01129 {
01130     (void) ctx;
01131     (void) ctl;
01132 
01133     return PAPI_OK;
01134 }

int _vmware_set_domain ( hwd_control_state_t ctl,
int  domain 
)

This function has to set the bits needed to count different domains In particular: PAPI_DOM_USER, PAPI_DOM_KERNEL PAPI_DOM_OTHER By default return PAPI_EINVAL if none of those are specified and PAPI_OK with success PAPI_DOM_USER is only user context is counted PAPI_DOM_KERNEL is only the Kernel/OS context is counted PAPI_DOM_OTHER is Exception/transient mode (like user TLB misses) PAPI_DOM_ALL is all of the domains

Definition at line 1205 of file vmware.c.

01206 {
01207     (void) ctl;
01208 
01209     int found = 0;
01210     SUBDBG( "_vmware_set_domain..." );
01211     if ( PAPI_DOM_USER & domain ) {
01212         SUBDBG( " PAPI_DOM_USER " );
01213         found = 1;
01214     }
01215     if ( PAPI_DOM_KERNEL & domain ) {
01216         SUBDBG( " PAPI_DOM_KERNEL " );
01217         found = 1;
01218     }
01219     if ( PAPI_DOM_OTHER & domain ) {
01220         SUBDBG( " PAPI_DOM_OTHER " );
01221         found = 1;
01222     }
01223     if ( PAPI_DOM_ALL & domain ) {
01224         SUBDBG( " PAPI_DOM_ALL " );
01225         found = 1;
01226     }
01227     if ( !found ) {
01228         return ( PAPI_EINVAL );
01229     }
01230     return PAPI_OK;
01231 }

int _vmware_shutdown_component ( void   ) 

Triggered by PAPI_shutdown()

Definition at line 1163 of file vmware.c.

01164 {
01165 
01166 #ifdef VMGUESTLIB
01167     if (dlclose(dlHandle)) {
01168         fprintf(stderr, "dlclose failed\n");
01169         return EXIT_FAILURE;
01170     }
01171 #endif
01172 
01173     return PAPI_OK;
01174 }

int _vmware_shutdown_thread ( hwd_context_t ctx  ) 

Shutting down a context

Definition at line 1138 of file vmware.c.

01139 {
01140     (void) ctx;
01141 
01142 #ifdef VMGUESTLIB
01143         VMGuestLibError glError;
01144     struct _vmware_context *context;
01145 
01146     context=(struct _vmware_context *)ctx;
01147 
01148     if (use_guestlib) {
01149            glError = GuestLib_CloseHandle(context->glHandle);
01150            if (glError != VMGUESTLIB_ERROR_SUCCESS) {
01151                fprintf(stderr, "Failed to CloseHandle: %s\n", 
01152                GuestLib_GetErrorText(glError));
01153                return PAPI_ECMP;
01154        }
01155     }
01156 #endif
01157 
01158     return PAPI_OK;
01159 }

int _vmware_start ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

Triggered by PAPI_start()

Definition at line 1044 of file vmware.c.

01045 {
01046     struct _vmware_context *context;
01047     (void) ctl;
01048 
01049     context=(struct _vmware_context *)ctx;
01050 
01051     _vmware_hardware_read( context, 1 );
01052 
01053     return PAPI_OK;
01054 }

Here is the call graph for this function:

int _vmware_stop ( hwd_context_t ctx,
hwd_control_state_t ctl 
)

Triggered by PAPI_stop()

Definition at line 1058 of file vmware.c.

01059 {
01060 
01061     struct _vmware_context *context;
01062     (void) ctl;
01063 
01064     context=(struct _vmware_context *)ctx;
01065 
01066     _vmware_hardware_read( context, 0 );    
01067 
01068     return PAPI_OK;
01069 }

Here is the call graph for this function:

int _vmware_update_control_state ( hwd_control_state_t ctl,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)

Triggered by eventset operations like add or remove

Definition at line 1019 of file vmware.c.

01023 {
01024     (void) ctx;
01025 
01026     struct _vmware_control_state *control;
01027 
01028     int i, index;
01029 
01030     control=(struct _vmware_control_state *)ctl;
01031 
01032     for ( i = 0; i < count; i++ ) {
01033         index = native[i].ni_event;
01034         control->which_counter[i]=_vmware_native_table[index].which_counter;
01035         native[i].ni_position = i;
01036     }
01037     control->num_events=count;
01038 
01039     return PAPI_OK;
01040 }

int _vmware_write ( hwd_context_t ctx,
hwd_control_state_t ctrl,
long_long  events[] 
)

Triggered by PAPI_write(), but only if the counters are running

Definition at line 1114 of file vmware.c.

01115 {
01116     (void) ctx;
01117     (void) ctrl;
01118     (void) events;
01119     SUBDBG( "_vmware_write... %p %p", ctx, ctrl );
01120     /* FIXME... this should actually carry out the write, though     */
01121     /*  this is non-trivial as which counter being written has to be */
01122     /*  determined somehow.                                          */
01123     return PAPI_OK;
01124 }

static int LoadFunctions ( void   )  [static]

Definition at line 203 of file vmware.c.

00204 {
00205 
00206 #ifdef VMGUESTLIB
00207     /*
00208      * First, try to load the shared library.
00209      */
00210 
00211     /* Attempt to guess if we were statically linked to libc, if so bail */
00212     if ( _dl_non_dynamic_init != NULL ) {
00213         strncpy(_vmware_vector.cmp_info.disabled_reason, "The VMware component does not support statically linking of libc.", PAPI_MAX_STR_LEN);
00214         return PAPI_ENOSUPP;
00215     }
00216 
00217     char const *dlErrStr;
00218     char filename[BUFSIZ];
00219 
00220     sprintf(filename,"%s","libvmGuestLib.so");
00221     dlHandle = dlopen(filename, RTLD_NOW);
00222     if (!dlHandle) {
00223        dlErrStr = dlerror();
00224        fprintf(stderr, "dlopen of %s failed: \'%s\'\n", filename, 
00225            dlErrStr);
00226 
00227        sprintf(filename,"%s/lib/lib64/libvmGuestLib.so",VMWARE_INCDIR);
00228        dlHandle = dlopen(filename, RTLD_NOW);
00229        if (!dlHandle) {
00230           dlErrStr = dlerror();
00231           fprintf(stderr, "dlopen of %s failed: \'%s\'\n", filename, 
00232            dlErrStr);
00233 
00234           sprintf(filename,"%s/lib/lib32/libvmGuestLib.so",VMWARE_INCDIR);
00235           dlHandle = dlopen(filename, RTLD_NOW);
00236           if (!dlHandle) {
00237              dlErrStr = dlerror();
00238              fprintf(stderr, "dlopen of %s failed: \'%s\'\n", filename, 
00239               dlErrStr);
00240          return PAPI_ECMP;
00241           }
00242        }
00243     }
00244 
00245     /* Load all the individual library functions. */
00246     LOAD_ONE_FUNC(GuestLib_GetErrorText);
00247     LOAD_ONE_FUNC(GuestLib_OpenHandle);
00248     LOAD_ONE_FUNC(GuestLib_CloseHandle);
00249     LOAD_ONE_FUNC(GuestLib_UpdateInfo);
00250     LOAD_ONE_FUNC(GuestLib_GetSessionId);
00251     LOAD_ONE_FUNC(GuestLib_GetCpuReservationMHz);
00252     LOAD_ONE_FUNC(GuestLib_GetCpuLimitMHz);
00253     LOAD_ONE_FUNC(GuestLib_GetCpuShares);
00254     LOAD_ONE_FUNC(GuestLib_GetCpuUsedMs);
00255     LOAD_ONE_FUNC(GuestLib_GetHostProcessorSpeed);
00256     LOAD_ONE_FUNC(GuestLib_GetMemReservationMB);
00257     LOAD_ONE_FUNC(GuestLib_GetMemLimitMB);
00258     LOAD_ONE_FUNC(GuestLib_GetMemShares);
00259     LOAD_ONE_FUNC(GuestLib_GetMemMappedMB);
00260     LOAD_ONE_FUNC(GuestLib_GetMemActiveMB);
00261     LOAD_ONE_FUNC(GuestLib_GetMemOverheadMB);
00262     LOAD_ONE_FUNC(GuestLib_GetMemBalloonedMB);
00263     LOAD_ONE_FUNC(GuestLib_GetMemSwappedMB);
00264     LOAD_ONE_FUNC(GuestLib_GetMemSharedMB);
00265     LOAD_ONE_FUNC(GuestLib_GetMemSharedSavedMB);
00266     LOAD_ONE_FUNC(GuestLib_GetMemUsedMB);
00267     LOAD_ONE_FUNC(GuestLib_GetElapsedMs);
00268     LOAD_ONE_FUNC(GuestLib_GetResourcePoolPath);
00269     LOAD_ONE_FUNC(GuestLib_GetCpuStolenMs);
00270     LOAD_ONE_FUNC(GuestLib_GetMemTargetSizeMB);
00271     LOAD_ONE_FUNC(GuestLib_GetHostNumCpuCores);
00272     LOAD_ONE_FUNC(GuestLib_GetHostCpuUsedMs);
00273     LOAD_ONE_FUNC(GuestLib_GetHostMemSwappedMB);
00274     LOAD_ONE_FUNC(GuestLib_GetHostMemSharedMB);
00275     LOAD_ONE_FUNC(GuestLib_GetHostMemUsedMB);
00276     LOAD_ONE_FUNC(GuestLib_GetHostMemPhysMB);
00277     LOAD_ONE_FUNC(GuestLib_GetHostMemPhysFreeMB);
00278     LOAD_ONE_FUNC(GuestLib_GetHostMemKernOvhdMB);
00279     LOAD_ONE_FUNC(GuestLib_GetHostMemMappedMB);
00280     LOAD_ONE_FUNC(GuestLib_GetHostMemUnmappedMB);
00281 #endif
00282     return PAPI_OK;
00283 }

Here is the caller graph for this function:

uint64_t rdpmc ( int  c  )  [inline]

Definition at line 93 of file vmware.c.

00094 {
00095   uint32_t low, high;
00096   __asm__ __volatile__("rdpmc" : "=a" (low), "=d" (high) : "c" (c));
00097   return (uint64_t)high << 32 | (uint64_t)low;
00098 }

Here is the caller graph for this function:


Variable Documentation

void(* _dl_non_dynamic_init)(void)

Structure that stores private information for each event

< Signifies which counter slot is being used

< Indexed from 1 as 0 has a special meaning

Definition at line 70 of file vmware.c.

00073                         {
00074     unsigned int selector;
00077 };

This table contains the native events

Definition at line 288 of file vmware.c.

Vector that points to entry points for our component

Definition at line 67 of file vmware.c.

int num_events = 0 [static]

number of events in the table

Definition at line 290 of file vmware.c.

int use_guestlib = 0 [static]

Definition at line 292 of file vmware.c.

int use_pseudo = 0 [static]

Definition at line 291 of file vmware.c.


Generated on 8 Sep 2016 for PAPI by  doxygen 1.6.1