From: Alexandru Avadanii Date: Sun, 15 May 2016 22:16:03 +0200 Subject: [PATCH] AArch64: cpuinfo: Remove redundant cpu caps loop. CPU capabilities should be added only to the current CPU core, and not recursively to all previous CPU cores. For a 48 core node, this parsing added up to 30 seconds (8 lines per core in /proc/cpuinfo resulted in 384 lines to parse). After this change, parsing for the above system takes less than 1 second. Signed-off-by: Alexandru Avadanii --- src/core/cpuinfo.cc | 57 ++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/src/core/cpuinfo.cc b/src/core/cpuinfo.cc index 5c7a6b1..1a3ea9d 100644 --- a/src/core/cpuinfo.cc +++ b/src/core/cpuinfo.cc @@ -74,37 +74,36 @@ static void cpuinfo_aarch64(hwNode & node, if (id == "Features") { - while (value.length() > 0) - { - size_t pos = value.find(' '); - string capability = (pos==string::npos)?value:value.substr(0, pos); - aarch64_features.push_back(capability); - if (pos == string::npos) - value = ""; - else - value = hw::strip(value.substr(pos)); - } - for(int i=0; i<=currentcpu; i++) + hwNode *cpu = getcpu(node, currentcpu); + if (cpu) { - hwNode *cpu = getcpu(node, i); - if (cpu) + cpu->addHint("logo", string("aarch64")); + if (node.getDescription() == "") + node.setDescription(aarch64_processor_name); + cpu->claim(true); + + while (value.length() > 0) + { + size_t pos = value.find(' '); + string capability = (pos==string::npos)?value:value.substr(0, pos); + aarch64_features.push_back(capability); + if (pos == string::npos) + value = ""; + else + value = hw::strip(value.substr(pos)); + } + + for(int i=0; i < aarch64_features.size(); i++) { - cpu->addHint("logo", string("aarch64")); - if (node.getDescription() == "") - node.setDescription(aarch64_processor_name); - cpu->claim(true); - for(int i=0; i < aarch64_features.size(); i++) - { - cpu->addCapability(aarch64_features[i]); - cpu->describeCapability("fp", "Floating point instructions"); - cpu->describeCapability("asimd", "Advanced SIMD"); - cpu->describeCapability("evtstrm", "Event stream"); - cpu->describeCapability("aes", "AES instructions"); - cpu->describeCapability("pmull", "PMULL instruction"); - cpu->describeCapability("sha1", "SHA1 instructions"); - cpu->describeCapability("sha2", "SHA2 instructions"); - cpu->describeCapability("crc32", "CRC extension"); - } + cpu->addCapability(aarch64_features[i]); + cpu->describeCapability("fp", "Floating point instructions"); + cpu->describeCapability("asimd", "Advanced SIMD"); + cpu->describeCapability("evtstrm", "Event stream"); + cpu->describeCapability("aes", "AES instructions"); + cpu->describeCapability("pmull", "PMULL instruction"); + cpu->describeCapability("sha1", "SHA1 instructions"); + cpu->describeCapability("sha2", "SHA2 instructions"); + cpu->describeCapability("crc32", "CRC extension"); } } } -- 1.9.1