PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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.

17  {
18 
19  int watchdog_detected=0,watchdog_value=0;
20  FILE *fff;
21 
22  fff=fopen("/proc/sys/kernel/nmi_watchdog","r");
23  if (fff!=NULL) {
24  if (fscanf(fff,"%d",&watchdog_value)==1) {
25  if (watchdog_value>0) watchdog_detected=1;
26  }
27  fclose(fff);
28  }
29  else {
30  watchdog_detected=-1;
31  }
32 
33  return watchdog_detected;
34 }
fclose(thread_wqfd)
FILE * fff[MAX_EVENTS]

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 36 of file nmi_watchdog.c.

36  {
37 
38  int retval,watchdog_active=0;
39 
40  /* Set TESTS_QUIET variable */
41  tests_quiet( argc, argv );
42 
43  /* Init the PAPI library */
45  if ( retval != PAPI_VER_CURRENT ) {
46  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
47  }
48 
49  watchdog_active=detect_nmi_watchdog();
50 
51  if (watchdog_active<0) {
52  test_skip( __FILE__, __LINE__, "nmi_watchdog file does not exist\n", 0);
53  }
54 
55  if (watchdog_active) {
56  if (!TESTS_QUIET) {
57  printf("\nOn perf_event kernels with the nmi_watchdog enabled\n");
58  printf("the watchdog steals an event, but the scheduability code\n");
59  printf("is not notified. Thus adding a full complement of events\n");
60  printf("seems to pass, but then fails at read time.\n");
61  printf("Because of this, PAPI has to do some slow workarounds.\n");
62  printf("For best PAPI performance, you may wish to disable\n");
63  printf("the watchdog by running (as root)\n");
64  printf("\techo \"0\" > /proc/sys/kernel/nmi_watchdog\n\n");
65  }
66 
67  test_warn( __FILE__, __LINE__, "NMI Watchdog Active, enabling slow workarounds", 0 );
68  }
69 
70  test_pass( __FILE__, NULL, 0 );
71 
72  return 0;
73 }
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
void test_warn(char *file, int line, char *call, int retval)
Definition: test_utils.c:578
int detect_nmi_watchdog(void)
Definition: nmi_watchdog.c:17
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:223

Here is the call graph for this function: