8085865: hs_err improvement: Printing /proc/cpuinfo makes too long hs_err files
Summary: summarize information from linux-x86; it's too long and redundant
Reviewed-by: gtriantafill, dholmes, mgerdin, dcubed
--- a/hotspot/src/os/aix/vm/os_aix.cpp Mon Jun 15 11:50:16 2015 +0200
+++ b/hotspot/src/os/aix/vm/os_aix.cpp Wed Jun 17 11:30:51 2015 -0400
@@ -1653,7 +1653,7 @@
}
}
-void os::pd_print_cpu_info(outputStream* st) {
+void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) {
// cpu
st->print("CPU:");
st->print("total %d", os::processor_count());
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp Mon Jun 15 11:50:16 2015 +0200
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp Wed Jun 17 11:30:51 2015 -0400
@@ -1706,7 +1706,7 @@
os::Posix::print_load_average(st);
}
-void os::pd_print_cpu_info(outputStream* st) {
+void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) {
// Nothing to do for now.
}
--- a/hotspot/src/os/linux/vm/os_linux.cpp Mon Jun 15 11:50:16 2015 +0200
+++ b/hotspot/src/os/linux/vm/os_linux.cpp Wed Jun 17 11:30:51 2015 -0400
@@ -2215,12 +2215,52 @@
st->cr();
}
-void os::pd_print_cpu_info(outputStream* st) {
- st->print("\n/proc/cpuinfo:\n");
- if (!_print_ascii_file("/proc/cpuinfo", st)) {
- st->print(" <Not Available>");
- }
- st->cr();
+// Print the first "model name" line and the first "flags" line
+// that we find and nothing more. We assume "model name" comes
+// before "flags" so if we find a second "model name", then the
+// "flags" field is considered missing.
+static bool print_model_name_and_flags(outputStream* st, char* buf, size_t buflen) {
+#if defined(IA32) || defined(AMD64)
+ // Other platforms have less repetitive cpuinfo files
+ FILE *fp = fopen("/proc/cpuinfo", "r");
+ if (fp) {
+ while (!feof(fp)) {
+ if (fgets(buf, buflen, fp)) {
+ // Assume model name comes before flags
+ bool model_name_printed = false;
+ if (strstr(buf, "model name") != NULL) {
+ if (!model_name_printed) {
+ st->print_raw("\nCPU Model and flags from /proc/cpuinfo:\n");
+ st->print_raw(buf);
+ model_name_printed = true;
+ } else {
+ // model name printed but not flags? Odd, just return
+ fclose(fp);
+ return true;
+ }
+ }
+ // print the flags line too
+ if (strstr(buf, "flags") != NULL) {
+ st->print_raw(buf);
+ fclose(fp);
+ return true;
+ }
+ }
+ }
+ fclose(fp);
+ }
+#endif // x86 platforms
+ return false;
+}
+
+void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) {
+ // Only print the model name if the platform provides this as a summary
+ if (!print_model_name_and_flags(st, buf, buflen)) {
+ st->print("\n/proc/cpuinfo:\n");
+ if (!_print_ascii_file("/proc/cpuinfo", st)) {
+ st->print_cr(" <Not Available>");
+ }
+ }
}
void os::print_siginfo(outputStream* st, void* siginfo) {
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp Mon Jun 15 11:50:16 2015 +0200
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp Wed Jun 17 11:30:51 2015 -0400
@@ -1996,7 +1996,7 @@
return status;
}
-void os::pd_print_cpu_info(outputStream* st) {
+void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) {
// Nothing to do for now.
}
--- a/hotspot/src/os/windows/vm/os_windows.cpp Mon Jun 15 11:50:16 2015 +0200
+++ b/hotspot/src/os/windows/vm/os_windows.cpp Wed Jun 17 11:30:51 2015 -0400
@@ -1732,7 +1732,7 @@
st->cr();
}
-void os::pd_print_cpu_info(outputStream* st) {
+void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) {
// Nothing to do for now.
}
--- a/hotspot/src/share/vm/runtime/os.cpp Mon Jun 15 11:50:16 2015 +0200
+++ b/hotspot/src/share/vm/runtime/os.cpp Wed Jun 17 11:30:51 2015 -0400
@@ -832,7 +832,7 @@
}
}
-void os::print_cpu_info(outputStream* st) {
+void os::print_cpu_info(outputStream* st, char* buf, size_t buflen) {
// cpu
st->print("CPU:");
st->print("total %d", os::processor_count());
@@ -840,7 +840,7 @@
// st->print("(active %d)", os::active_processor_count());
st->print(" %s", VM_Version::cpu_features());
st->cr();
- pd_print_cpu_info(st);
+ pd_print_cpu_info(st, buf, buflen);
}
void os::print_date_and_time(outputStream *st, char* buf, size_t buflen) {
--- a/hotspot/src/share/vm/runtime/os.hpp Mon Jun 15 11:50:16 2015 +0200
+++ b/hotspot/src/share/vm/runtime/os.hpp Wed Jun 17 11:30:51 2015 -0400
@@ -587,8 +587,8 @@
// Output format may be different on different platforms.
static void print_os_info(outputStream* st);
static void print_os_info_brief(outputStream* st);
- static void print_cpu_info(outputStream* st);
- static void pd_print_cpu_info(outputStream* st);
+ static void print_cpu_info(outputStream* st, char* buf, size_t buflen);
+ static void pd_print_cpu_info(outputStream* st, char* buf, size_t buflen);
static void print_memory_info(outputStream* st);
static void print_dll_info(outputStream* st);
static void print_environment_variables(outputStream* st, const char** env_list);
--- a/hotspot/src/share/vm/runtime/vm_version.cpp Mon Jun 15 11:50:16 2015 +0200
+++ b/hotspot/src/share/vm/runtime/vm_version.cpp Wed Jun 17 11:30:51 2015 -0400
@@ -280,7 +280,8 @@
#ifndef PRODUCT
if (PrintMiscellaneous && Verbose) {
- os::print_cpu_info(tty);
+ char buf[512];
+ os::print_cpu_info(tty, buf, sizeof(buf));
}
#endif
}
--- a/hotspot/src/share/vm/utilities/vmError.cpp Mon Jun 15 11:50:16 2015 +0200
+++ b/hotspot/src/share/vm/utilities/vmError.cpp Wed Jun 17 11:30:51 2015 -0400
@@ -816,7 +816,7 @@
STEP(250, "(printing CPU info)" )
if (_verbose) {
- os::print_cpu_info(st);
+ os::print_cpu_info(st, buf, sizeof(buf));
st->cr();
}