PAPI  5.6.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

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

Function Documentation

static int detect_nmi_watchdog ( void  )
static

Definition at line 20 of file nmi_watchdog.c.

20  {
21 
22  int watchdog_detected=0,watchdog_value=0;
23  FILE *fff;
24 
25  fff=fopen("/proc/sys/kernel/nmi_watchdog","r");
26  if (fff!=NULL) {
27  if (fscanf(fff,"%d",&watchdog_value)==1) {
28  if (watchdog_value>0) watchdog_detected=1;
29  }
30  fclose(fff);
31  }
32  else {
33  watchdog_detected=-1;
34  }
35 
36  return watchdog_detected;
37 }
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 39 of file nmi_watchdog.c.

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

Here is the call graph for this function: