{"record":{"id":"37ed0f9cbebc4c96","repo":"nodejs/node","slug":"could-not-set-cpu-governor-present-value-is-s","errorCode":null,"errorMessage":"Could not set CPU governor. Present value is %s","messagePattern":"Could not set CPU governor\\. Present value is (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"deps/v8/tools/run_perf.py","lineNumber":1147,"sourceCode":"      raise\n\n  @staticmethod\n  def SetCPUGovernor(value):\n    try:\n      cpu_indices = CustomMachineConfiguration.GetCPUCoresRange()\n      for cpu_index in cpu_indices:\n        cpu_device = CustomMachineConfiguration.GetCPUPathForId(cpu_index)\n        with open(cpu_device, 'w') as f:\n          f.write(value)\n\n    except Exception:\n      logging.exception('Failed to change CPU governor to %s. Are we '\n                        'running under sudo?', value)\n      raise\n\n    cur_value = CustomMachineConfiguration.GetCPUGovernor()\n    if cur_value != value:\n      raise Exception('Could not set CPU governor. Present value is %s'\n                      % cur_value )\n\n\nclass MaxTotalDurationReachedError(Exception):\n  \"\"\"Exception used to stop running tests when max total duration is reached.\"\"\"\n  pass\n\n\ndef Main(argv):\n  parser = argparse.ArgumentParser(epilog=\"\"\"example:\n      ./run_perf.py --d8-path=out/Release/d8 $V8_PERF/benchmarks/JetStream/JetStream2.json\n    \"\"\")\n  parser.add_argument('--arch',\n                      help='The architecture to run tests for. Pass \"auto\" '\n                      'to auto-detect.', default='x64',\n                      choices=SUPPORTED_ARCHS + ['auto'])\n  parser.add_argument('--buildbot',\n                      help='Deprecated',","sourceCodeStart":1129,"sourceCodeEnd":1165,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/v8/tools/run_perf.py#L1129-L1165","documentation":"Thrown by CustomMachineConfiguration.SetCPUGovernor in run_perf.py after writing the requested governor string to every core's scaling_governor sysfs file: it re-reads via GetCPUGovernor and the value still does not match, so the write did not take effect.","triggerScenarios":"SetCPUGovernor(value) writes without IOError but GetCPUGovernor() returns a different value. Happens when not root (write appears to succeed but is discarded), when the requested governor is not in scaling_available_governors for the driver, when a BIOS/management engine or thermal daemon overrides the setting, or in a container with a read-only/virtualized sysfs.","commonSituations":"Running perf tests without sudo; requesting 'performance' when only 'powersave' is available on intel_pstate; a power daemon (thermald, TLP, power-profiles-daemon) re-applying its policy immediately; containerized runs.","solutions":["Run the harness as root (sudo) so the sysfs write persists.","Confirm the requested governor is listed: cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors, and pick one that is present.","Stop conflicting daemons (thermald, TLP, power-profiles-daemon, cpufrequtils) that revert the governor, then re-run.","If the BIOS locks frequency control, enable OS frequency control in BIOS/UEFI."],"exampleFix":"# before\n./run_perf.py suite.json\n# after\nsudo systemctl stop thermald power-profiles-daemon\nsudo cpupower frequency-set -g performance\nsudo ./run_perf.py suite.json","handlingStrategy":"validation","validationCode":"def can_set_governor(value: str) -> bool:\n    import glob, os\n    avail = open('/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors').read().split()\n    return value in avail and os.geteuid() == 0","typeGuard":"null","tryCatchPattern":"try:\n    CustomMachineConfiguration.SetCPUGovernor('performance')\nexcept Exception as e:\n    logging.warning('Could not pin CPU governor (%s); stop thermald/TLP/power-profiles-daemon and re-run with sudo.', e)","preventionTips":["Run as root and stop conflicting power daemons (thermald, TLP, power-profiles-daemon).","Verify the requested governor is in scaling_available_governors.","Confirm success by reading scaling_governor back on every core after setting."],"tags":["v8","perf-test","cpu","governor","privilege","linux"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}