Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8259563

The CPU model name is printed multiple times when using -Xlog:os+cpu

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 17
    • Fix Version/s: 17
    • Component/s: hotspot
    • Subcomponent:
    • Resolved In Build:
      b06
    • OS:
      linux

      Description

      The CPU model name will be printed multiple times if the platform only has model name but no flags (such as mips) when using -Xlog:os+cpu. "model_name_printed" should be initialized to "false" before the loop.

      src/hotspot/os/linux/os_linux.cpp:

      // 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("CPU 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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              wangxue Wang Xue
              Reporter:
              wangxue Wang Xue
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: