src/os.cc
// Read the number of hugepages out of the kernel interface in proc.
Read the number of hugepages out of the kernel interface in proc.
Read the number of hugepages out of the kernel interface in proc .
int64 OsLayer::FindHugePages() {
  char buf[65] = "0";
  static const char *hugepages_info_file = "/proc/sys/vm/nr_hugepages";
  int hpfile = open(hugepages_info_file, O_RDONLY);
  ssize_t bytes_read = read(hpfile, buf, 64);
  close(hpfile);
  if (bytes_read <= 0) {
    logprintf(12, "Log: /proc/sys/vm/nr_hugepages "
                  "read did not provide data\n");
    return 0;
  }
  if (bytes_read == 64) {
    logprintf(0, "Process Error: /proc/sys/vm/nr_hugepages "
                 "is surprisingly large\n");
    return 0;
  }
  buf[bytes_read] = '\0';
  int64 pages = strtoull(buf, NULL, 10);  
  return pages;
}
int64 OsLayer :: FindHugePages ( ) { char buf [ 65 ] = " " ; static const char * hugepages_info_file = " " ; int hpfile = open ( hugepages_info_file , O_RDONLY ) ; ssize_t bytes_read = read ( hpfile , buf , 64 ) ; close ( hpfile ) ; if ( bytes_read <= 0 ) { logprintf ( 12 , " " " \n " ) ; return 0 ; } if ( bytes_read == 64 ) { logprintf ( 0 , " " " \n " ) ; return 0 ; } buf [ bytes_read ] = ' \0 ' ; int64 pages = strtoull ( buf , NULL , 10 ) ; return pages ; }
Read the number of hugepages out of the kernel interface in proc.
Read the number of hugepages out of the kernel interface in proc .
// This is a kernel interface to query the numebr of hugepages // available in the system. // Add a null termintation to be string safe. // Read the page count. // NOLINT