1 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
2 Date: Sun, 15 Jan 2017 08:09:10 +0100
3 Subject: [PATCH] AArch64: Add CPU details detection
6 Based on Stan's previous patch for ohai, extend fuel-nailgun-agent
7 to properly support AArch64 CPUs.
10 There is currently little human readable detail in /proc/cpuinfo on
11 arm64 so this patch tries to enchance this information by parsing the
12 DMI data (using `dmidecode`) and fail gracefully to empty strings
13 if no information could not be read from there. By no means this
14 parsing is to be taken as a standardised way of discovering an
15 arm64 CPU, it is just a suggestion.
17 Signed-off-by: Stanislaw Kardach <stanislaw.kardach@cavium.com>
18 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
20 agent | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 1 file changed, 90 insertions(+)
23 diff --git a/agent b/agent
24 index 0c56264..eeb4d26 100755
27 @@ -340,6 +340,15 @@ class NodeAgent
30 def _get_detailed_cpuinfo
33 + _get_detailed_cpuinfo_for_arm64
34 + else # default to x86
35 + _get_detailed_cpuinfo_for_x86
39 + def _get_detailed_cpuinfo_for_x86
43 @@ -371,6 +380,87 @@ class NodeAgent
47 + def _get_detailed_cpuinfo_for_arm64
48 + cpu_implementers = {
50 + "0x53" => "Samsung",
51 + "0x51" => "Qualcom",
56 + "0xd04" => "cortex-a35",
57 + "0xd03" => "cortex-a53",
58 + "0xd07" => "cortex-a57",
59 + "0xd08" => "cortex-a72",
60 + "0x001" => "exynos-m1",
61 + "0x800" => "qdf24xx",
62 + "0x0a1" => "thunderx",
63 + "0x000" => "xgene1",
64 + "0xd07.0xd03" => "cortex-a57.cortex-a53",
65 + "0xd08.0xd03" => "cortex-a72.cortex-a53"
71 + `dmidecode -t 4 -q`.each_line do |line|
73 + when /Processor Information/
75 + real_cpus[cpu_number] = {}
76 + when /\s*Manufacturer:\s(.+)/
77 + real_cpus[cpu_number][:vendor_id] = $1
78 + when /\s*Family:\s(.+)/
79 + real_cpus[cpu_number][:family] = $1
80 + when /\s*Max Speed:\s(.+)\s*MHz/
81 + real_cpus[cpu_number][:mhz] = $1.strip
82 + when /\s*Core Enabled:\s(.+)/
83 + real_cpus[cpu_number][:cores] = $1
88 + File.open("/proc/cpuinfo").each do |line|
90 + when /processor\s+:\s(.+)/
94 + phys_id = File.read(
95 + "/sys/devices/system/cpu/cpu%d/topology/physical_package_id" %
98 + cpuinfo[$1][:core_id] =
99 + File.read("/sys/devices/system/cpu/cpu%d/topology/core_id" %
100 + $1).strip rescue ""
101 + cpuinfo[$1][:physical_id] = phys_id if not phys_id.empty?
102 + if real_cpus[i].nil?
105 + if not real_cpus[i].nil?
106 + cpuinfo[$1][:family] = real_cpus[i][:family] rescue ""
107 + cpuinfo[$1][:cores] = real_cpus[i][:cores] rescue ""
108 + cpuinfo[$1][:mhz] = real_cpus[i][:mhz] rescue ""
110 + when /CPU implementer\s+:\s(.+)/
111 + cpuinfo[current_cpu][:vendor_id] = cpu_implementers[$1]
112 + cpuinfo[current_cpu][:vendor_id] ||= real_cpus[cpuinfo[current_cpu][:physical_id].to_i][:vendor_id] rescue nil
113 + cpuinfo[current_cpu][:vendor_id] ||= real_cpus[0][:vendor_id] rescue nil
114 + cpuinfo[current_cpu][:vendor_id] ||= $1
115 + when /CPU part\s+:\s(.+)/
116 + cpuinfo[current_cpu][:model] = $1
117 + cpuinfo[current_cpu][:model_name] = core_models[$1]
118 + cpuinfo[current_cpu][:model_name] ||= ""
119 + when /Features\s+:\s(.+)/
120 + cpuinfo[current_cpu][:flags] = $1.split(' ')
123 + cpuinfo[:total] = cpu_number
124 + cpuinfo[:real] = real_cpus.keys.length
130 if File.directory?('/sys/block/')