|
Packit |
577717 |
/* If the NMI watchdog is enabled it will steal a performance counter. */
|
|
Packit |
577717 |
/* There is a bug that if you try to use the maximum number of counters */
|
|
Packit |
577717 |
/* (not counting the stolen one) with a group leader, sys_perf_open() */
|
|
Packit |
577717 |
/* will indicate success, as will starting the count, but you will fail */
|
|
Packit |
577717 |
/* at read time. */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* This bug still exists in 3.x */
|
|
Packit |
577717 |
/* The perf NMI watchdog was not introduced until 2.6.34 */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* This also triggers in the case of the schedulability bug */
|
|
Packit |
577717 |
/* but since that was fixed in 2.6.34 then in theory there is */
|
|
Packit |
577717 |
/* no overlap in the tests. */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <stdio.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include "papi.h"
|
|
Packit |
577717 |
#include "papi_test.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int detect_nmi_watchdog(void) {
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int watchdog_detected=0,watchdog_value=0;
|
|
Packit |
577717 |
FILE *fff;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
fff=fopen("/proc/sys/kernel/nmi_watchdog","r");
|
|
Packit |
577717 |
if (fff!=NULL) {
|
|
Packit |
577717 |
if (fscanf(fff,"%d",&watchdog_value)==1) {
|
|
Packit |
577717 |
if (watchdog_value>0) watchdog_detected=1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
fclose(fff);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
else {
|
|
Packit |
577717 |
watchdog_detected=-1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return watchdog_detected;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int main( int argc, char **argv ) {
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int retval,watchdog_active=0;
|
|
Packit |
577717 |
int quiet;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Set TESTS_QUIET variable */
|
|
Packit |
577717 |
quiet=tests_quiet( argc, argv );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Init the PAPI library */
|
|
Packit |
577717 |
retval = PAPI_library_init( PAPI_VER_CURRENT );
|
|
Packit |
577717 |
if ( retval != PAPI_VER_CURRENT ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
watchdog_active=detect_nmi_watchdog();
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (watchdog_active<0) {
|
|
Packit |
577717 |
test_skip( __FILE__, __LINE__,
|
|
Packit |
577717 |
"nmi_watchdog file does not exist\n", 0);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (watchdog_active) {
|
|
Packit |
577717 |
if (!quiet) {
|
|
Packit |
577717 |
printf("\nOn perf_event kernels with the nmi_watchdog enabled\n");
|
|
Packit |
577717 |
printf("the watchdog steals an event, but the scheduability code\n");
|
|
Packit |
577717 |
printf("is not notified. Thus adding a full complement of events\n");
|
|
Packit |
577717 |
printf("seems to pass, but then fails at read time.\n");
|
|
Packit |
577717 |
printf("Because of this, PAPI has to do some slow workarounds.\n");
|
|
Packit |
577717 |
printf("For best PAPI performance, you may wish to disable\n");
|
|
Packit |
577717 |
printf("the watchdog by running (as root)\n");
|
|
Packit |
577717 |
printf("\techo \"0\" > /proc/sys/kernel/nmi_watchdog\n\n");
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
test_warn( __FILE__, __LINE__,
|
|
Packit |
577717 |
"NMI Watchdog Active, enabling slow workarounds", 0 );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
test_pass( __FILE__ );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|