PAPI  5.0.1.0
nmi_watchdog.c File Reference
Include dependency graph for nmi_watchdog.c:

Go to the source code of this file.

Functions

int detect_nmi_watchdog (void)
int main (int argc, char **argv)

Function Documentation

int detect_nmi_watchdog ( void  )

Definition at line 17 of file nmi_watchdog.c.

                              {

  int watchdog_detected=0,watchdog_value=0;
  FILE *fff;

  fff=fopen("/proc/sys/kernel/nmi_watchdog","r");
  if (fff!=NULL) {
    if (fscanf(fff,"%d",&watchdog_value)==1) {
       if (watchdog_value>0) watchdog_detected=1;
    }
    fclose(fff);
  }
  else {
    watchdog_detected=-1;
  }

  return watchdog_detected;
}

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 36 of file nmi_watchdog.c.

                                  {

  int retval,watchdog_active=0;
  
  /* Set TESTS_QUIET variable */
  tests_quiet( argc, argv );    

  /* Init the PAPI library */
  retval = PAPI_library_init( PAPI_VER_CURRENT );
  if ( retval != PAPI_VER_CURRENT ) {
     test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
  }

  watchdog_active=detect_nmi_watchdog();

  if (watchdog_active<0) {
    test_skip( __FILE__, __LINE__, "nmi_watchdog file does not exist\n", 0);
  }

  if (watchdog_active) {
    if (!TESTS_QUIET) {
      printf("\nOn perf_event kernels with the nmi_watchdog enabled\n");
      printf("the watchdog steals an event, but the scheduability code\n");
      printf("is not notified.  Thus adding a full complement of events\n");
      printf("seems to pass, but then fails at read time.\n");
      printf("Because of this, PAPI has to do some slow workarounds.\n");
      printf("For best PAPI performance, you may wish to disable\n");
      printf("the watchdog by running (as root)\n");
      printf("\techo \"0\" > /proc/sys/kernel/nmi_watchdog\n\n");
    }

     test_warn( __FILE__, __LINE__, "NMI Watchdog Active, enabling slow workarounds", 0 );
  }
    
  test_pass( __FILE__, NULL, 0 );
    
  return 0;
}

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines