hotspot/src/os/linux/vm/os_linux.cpp
changeset 31356 55ee785c49c5
parent 31026 b87ccf34b54c
child 31357 0cef600ba9b7
equal deleted inserted replaced
31350:b856c6918480 31356:55ee785c49c5
  2213   st->print("(" UINT64_FORMAT "k free)",
  2213   st->print("(" UINT64_FORMAT "k free)",
  2214             ((jlong)si.freeswap * si.mem_unit) >> 10);
  2214             ((jlong)si.freeswap * si.mem_unit) >> 10);
  2215   st->cr();
  2215   st->cr();
  2216 }
  2216 }
  2217 
  2217 
  2218 void os::pd_print_cpu_info(outputStream* st) {
  2218 // Print the first "model name" line and the first "flags" line
  2219   st->print("\n/proc/cpuinfo:\n");
  2219 // that we find and nothing more. We assume "model name" comes
  2220   if (!_print_ascii_file("/proc/cpuinfo", st)) {
  2220 // before "flags" so if we find a second "model name", then the
  2221     st->print("  <Not Available>");
  2221 // "flags" field is considered missing.
  2222   }
  2222 static bool print_model_name_and_flags(outputStream* st, char* buf, size_t buflen) {
  2223   st->cr();
  2223 #if defined(IA32) || defined(AMD64)
       
  2224   // Other platforms have less repetitive cpuinfo files
       
  2225   FILE *fp = fopen("/proc/cpuinfo", "r");
       
  2226   if (fp) {
       
  2227     while (!feof(fp)) {
       
  2228       if (fgets(buf, buflen, fp)) {
       
  2229         // Assume model name comes before flags
       
  2230         bool model_name_printed = false;
       
  2231         if (strstr(buf, "model name") != NULL) {
       
  2232           if (!model_name_printed) {
       
  2233             st->print_raw("\nCPU Model and flags from /proc/cpuinfo:\n");
       
  2234             st->print_raw(buf);
       
  2235             model_name_printed = true;
       
  2236           } else {
       
  2237             // model name printed but not flags?  Odd, just return
       
  2238             fclose(fp);
       
  2239             return true;
       
  2240           }
       
  2241         }
       
  2242         // print the flags line too
       
  2243         if (strstr(buf, "flags") != NULL) {
       
  2244           st->print_raw(buf);
       
  2245           fclose(fp);
       
  2246           return true;
       
  2247         }
       
  2248       }
       
  2249     }
       
  2250     fclose(fp);
       
  2251   }
       
  2252 #endif // x86 platforms
       
  2253   return false;
       
  2254 }
       
  2255 
       
  2256 void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) {
       
  2257   // Only print the model name if the platform provides this as a summary
       
  2258   if (!print_model_name_and_flags(st, buf, buflen)) {
       
  2259     st->print("\n/proc/cpuinfo:\n");
       
  2260     if (!_print_ascii_file("/proc/cpuinfo", st)) {
       
  2261       st->print_cr("  <Not Available>");
       
  2262     }
       
  2263   }
  2224 }
  2264 }
  2225 
  2265 
  2226 void os::print_siginfo(outputStream* st, void* siginfo) {
  2266 void os::print_siginfo(outputStream* st, void* siginfo) {
  2227   const siginfo_t* si = (const siginfo_t*)siginfo;
  2267   const siginfo_t* si = (const siginfo_t*)siginfo;
  2228 
  2268