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

On Windows CPUPerformanceInterface::CPUPerformance::initialize() returns the wrong value

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 14
    • Fix Version/s: 15
    • Component/s: hotspot
    • Subcomponent:
      jfr
    • CPU:
      x86
    • OS:
      windows

      Description

      I think the Windows version is broken and returning true when it should be returning false! Certainly this logic makes no sense to me:

      bool CPUPerformanceInterface::CPUPerformance::initialize() {
        if (!pdh_acquire()) {
          return true;
        }
        _context_switches = create_counter_query(PDH_SYSTEM_IDX, PDH_CONTEXT_SWITCH_RATE_IDX);
        _process_cpu_load = create_process_query();
        if (_process_cpu_load == NULL) {
          return true;
        }
        allocate_counters(_process_cpu_load, 2);
        if (initialize_process_counter(_process_cpu_load, 0, PDH_PROCESSOR_TIME_IDX) != OS_OK) {
          return true;
        }
        if (initialize_process_counter(_process_cpu_load, 1, PDH_PRIV_PROCESSOR_TIME_IDX) != OS_OK) {
          return true;
        }
        _process_cpu_load->set.initialized = true;
        _machine_cpu_load = create_multi_counter_query();
        if (_machine_cpu_load == NULL) {
          return true;
        }
        initialize_cpu_query(_machine_cpu_load, PDH_PROCESSOR_TIME_IDX);
        return true;
      }

      Only the final return should return true; all the others should return false.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mgronlun Markus Grönlund
              Reporter:
              dholmes David Holmes
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: