|
|
934cb1 |
commit a5ecda79870b41f5b2ee21975f0f1c931114d258
|
|
|
934cb1 |
Author: sangamesh <sragate@vols.utk.edu>
|
|
|
934cb1 |
Date: Thu Jun 11 17:48:36 2015 -0400
|
|
|
934cb1 |
|
|
|
934cb1 |
Thanks to William Cohen for the patch which does the following:
|
|
|
934cb1 |
Checking the cpu family and module number is not sufficient to determine
|
|
|
934cb1 |
whether RAPL can be used. If the papi is running inside a guest VM,
|
|
|
934cb1 |
the MSR used by the PAPI RAPL component may not be available. There
|
|
|
934cb1 |
should be a simple read test to verify the RAPL MSR registers are
|
|
|
934cb1 |
available. This allows the component to more clearly report that RAPL
|
|
|
934cb1 |
is unsupported rather than just exiting program when the RAPL
|
|
|
934cb1 |
|
|
|
934cb1 |
diff --git a/src/components/rapl/linux-rapl.c b/src/components/rapl/linux-rapl.c
|
|
|
934cb1 |
index f0d376e..8dff3fe 100644
|
|
|
934cb1 |
--- a/src/components/rapl/linux-rapl.c
|
|
|
934cb1 |
+++ b/src/components/rapl/linux-rapl.c
|
|
|
934cb1 |
@@ -447,6 +447,13 @@ _rapl_init_component( int cidx )
|
|
|
934cb1 |
return PAPI_ESYS;
|
|
|
934cb1 |
}
|
|
|
934cb1 |
|
|
|
934cb1 |
+ /* Verify needed MSR is readable. In a guest VM it may not be readable*/
|
|
|
934cb1 |
+ if (pread(fd, &result, sizeof result, MSR_RAPL_POWER_UNIT) != sizeof result ) {
|
|
|
934cb1 |
+ strncpy(_rapl_vector.cmp_info.disabled_reason,
|
|
|
934cb1 |
+ "Unable to access RAPL registers",PAPI_MAX_STR_LEN);
|
|
|
934cb1 |
+ return PAPI_ESYS;
|
|
|
934cb1 |
+ }
|
|
|
934cb1 |
+
|
|
|
934cb1 |
/* Calculate the units used */
|
|
|
934cb1 |
result=read_msr(fd,MSR_RAPL_POWER_UNIT);
|
|
|
934cb1 |
|