Skip to content

Commit

Permalink
lib.numa: gracefully handle failure to read CPU performance governor
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneia committed Mar 17, 2020
1 parent 4b0c18b commit 6b5851a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/lib/numa.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,20 @@ local function assert_irqbalanced_disabled (warn)
end
end

local function read_cpu_performance_governor (cpu)
local path = '/sys/devices/system/cpu/cpu'..cpu..'/cpufreq/scaling_governor'
local f = io.open(path)
if not f then return "unknown" end
local gov = f:read()
f:close()
return gov
end

local function check_cpu_performance_tuning (cpu, strict)
local warn = warn
if strict then warn = die end
assert_irqbalanced_disabled(warn)
local path = '/sys/devices/system/cpu/cpu'..cpu..'/cpufreq/scaling_governor'
local gov = assert(io.open(path)):read()
local gov = read_cpu_performance_governor(cpu)
if not gov:match('performance') then
warn('Expected performance scaling governor for CPU %s, but got "%s"',
cpu, gov)
Expand Down

0 comments on commit 6b5851a

Please sign in to comment.