You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/09/23 10:00:47 UTC

[GitHub] [cloudstack] davidjumani opened a new pull request #5506: kvm: Use lscpu to get cpu max speed

davidjumani opened a new pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506


   ### Description
   
   Use lscpu to get the cpu max frequency
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [x] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [x] Minor
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on a change in pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on a change in pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#discussion_r798289437



##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -80,16 +82,39 @@ public long getOverCommitMemory() {
     }
 
     protected static long getCpuSpeed(final NodeInfo nodeInfo) {
-        try (Reader reader = new FileReader(cpuInfoMaxFreqFileName)) {
-            Long cpuInfoMaxFreq = Long.parseLong(IOUtils.toString(reader).trim());
-            LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
-            return cpuInfoMaxFreq / 1000;
-        } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
+        try {
+            return getCpuSpeedInternal();
+        } catch (IOException | NumberFormatException ex) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s] and lscpu. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), ex);
             return nodeInfo.mhz;
         }
     }
 
+    private static long getCpuSpeedInternal() throws IOException {
+        try {
+            return getCpuSpeedFromCommandLscpu();
+        } catch (NullPointerException | NumberFormatException e) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from lscpu. Using the value in [%s].", cpuInfoMaxFreqFileName), e);
+            return getCpuSpeedFromFile();
+        }
+    }
+
+    private static long getCpuSpeedFromCommandLscpu() {

Review comment:
       suggestion:
   add try...catch in getCpuSpeedFromCommandLscpu and getCpuSpeedFromFile
   if exception is caught, then return the a default value like 0 or -1.
   
   then the getSpeed method will be simple
   ```
       long speed = getCpuSpeedFromCommandLscpu();
       if (speed == 0L) {
           speed = getCpuSpeedFromFile();
       }
       if (speed == 0L) {
           speed = nodeInfo.mhz;
       }
       return speed;
   ```
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on a change in pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on a change in pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#discussion_r798289437



##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -80,16 +82,39 @@ public long getOverCommitMemory() {
     }
 
     protected static long getCpuSpeed(final NodeInfo nodeInfo) {
-        try (Reader reader = new FileReader(cpuInfoMaxFreqFileName)) {
-            Long cpuInfoMaxFreq = Long.parseLong(IOUtils.toString(reader).trim());
-            LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
-            return cpuInfoMaxFreq / 1000;
-        } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
+        try {
+            return getCpuSpeedInternal();
+        } catch (IOException | NumberFormatException ex) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s] and lscpu. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), ex);
             return nodeInfo.mhz;
         }
     }
 
+    private static long getCpuSpeedInternal() throws IOException {
+        try {
+            return getCpuSpeedFromCommandLscpu();
+        } catch (NullPointerException | NumberFormatException e) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from lscpu. Using the value in [%s].", cpuInfoMaxFreqFileName), e);
+            return getCpuSpeedFromFile();
+        }
+    }
+
+    private static long getCpuSpeedFromCommandLscpu() {

Review comment:
       suggestion:
   add try...catch in getCpuSpeedFromCommandLscpu and getCpuSpeedFromFile
   if exception is caught, then return the a default value like 0 or -1.
   
   then the getSpeed method will be simple
   ```
       long speed = getCpuSpeedFromCommandLscpu();
       if (speed = 0L) {
           speed = getCpuSpeedFromFile();
       }
       if (speed = 0L) {
           speed = nodeInfo.mhz;
       }
       return speed;
   ```
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1027639474


   @davidjumani can you address the outstanding review comments.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani removed a comment on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani removed a comment on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028737365


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1025535661


   @davidjumani a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1023909908


   @sureshanaparti Apologies for the delay. I've addressed most of the comments


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-928946861


   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-925698262


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 1378


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-925723812


   @davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] leolleeooleo edited a comment on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
leolleeooleo edited a comment on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-931250510


   @weizhouapache 
   
   lscpu work on dell servers
   libvirt doesn't work on dell servers.
   
   Dell PowerEdge R740 :
   ```
   [leo@kvm1 ~]$ lscpu 
   Architecture:        x86_64
   CPU op-mode(s):      32-bit, 64-bit
   Byte Order:          Little Endian
   CPU(s):              32
   On-line CPU(s) list: 0-31
   Thread(s) per core:  2
   Core(s) per socket:  8
   Socket(s):           2
   NUMA node(s):        2
   Vendor ID:           GenuineIntel
   CPU family:          6
   Model:               85
   Model name:          Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz                     <<<<< here is ok
   Stepping:            7
   CPU MHz:             1634.801                                                         <<<<< low frequency
   CPU max MHz:         3200.0000
   CPU min MHz:         800.0000
   BogoMIPS:            4200.00
   Virtualization:      VT-x
   L1d cache:           32K
   L1i cache:           32K
   L2 cache:            1024K
   L3 cache:            11264K
   NUMA node0 CPU(s):   0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30
   NUMA node1 CPU(s):   1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31
   Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities
   
   [leo@kvm1 ~]$ sudo virsh nodeinfo 
   CPU model:           x86_64
   CPU(s):              32
   CPU frequency:       1006 MHz                                            <<<<< low frequency
   CPU socket(s):       1
   Core(s) per socket:  8
   Thread(s) per core:  2
   NUMA cell(s):        2
   Memory size:         65364380 KiB
   
   
   [leo@kvm1 ~]$ cat /proc/cpuinfo
   processor       : 0
   vendor_id       : GenuineIntel
   cpu family      : 6
   model           : 85
   model name      : Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz                         <<<<< here is ok
   stepping        : 7
   microcode       : 0x5003102
   cpu MHz         : 823.050                                                           <<<<< low frequency
   cache size      : 11264 KB
   physical id     : 0
   siblings        : 16
   core id         : 0
   cpu cores       : 8
   apicid          : 0
   initial apicid  : 0
   fpu             : yes
   fpu_exception   : yes
   cpuid level     : 22
   wp              : yes
   flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities
   bugs            : spectre_v1 spectre_v2 spec_store_bypass swapgs taa itlb_multihit
   bogomips        : 4200.00
   clflush size    : 64
   cache_alignment : 64
   address sizes   : 46 bits physical, 48 bits virtual
   power management:
   
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1031052491


   @davidjumani I understand these words: "help", "hello", "thanks", "package", "test"
   Test command usage: test [mgmt os] [hypervisor] [keepEnv]
   Mgmt OS options: ['suse15', 'centos7', 'centos6', 'alma8', 'ubuntu18', 'ubuntu20', 'rocky8']
   Hypervisor options: ['kvm-centos6', 'kvm-centos7', 'kvm-rocky8', 'kvm-alma8', 'kvm-ubuntu18', 'kvm-ubuntu20', 'kvm-suse15', 'vmware-55u3', 'vmware-60u2', 'vmware-65u2', 'vmware-67u3', 'vmware-70u1', 'vmware-70u2', 'vmware-70u3', 'xenserver-65sp1', 'xenserver-71', 'xenserver-74', 'xcpng74', 'xcpng76', 'xcpng80', 'xcpng81', 'xcpng82']
   	Note: when keepEnv is passed, you need to specify mgmt server os and hypervisor or use the `matrix` command.
   
   Blessed contributors for kicking Trillian test jobs: ['rohityadavcloud', 'nvazquez', 'borisstoyanov', 'DaanHoogland', 'shwstppr', 'andrijapanicsb', 'Pearl1594', 'davidjumani', 'harikrishna-patnala', 'vladimirpetrov', 'sureshanaparti', 'weizhouapache', 'NuxRo']


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1024925069


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1027666892


   Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 2424


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani removed a comment on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani removed a comment on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028598001


   @blueorangutan test rocky8 kvm-rocky8


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028613630


   @sureshanaparti a Trillian-Jenkins test job (ubuntu20 mgmt + kvm-ubuntu20) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] rohityadavcloud commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
rohityadavcloud commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1029760502


   ping @davidjumani is this ready, or already reviewed/tested manually @sureshanaparti @nvazquez @DaanHoogland ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1029398379


   <b>Trillian test result (tid-3142)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 33254 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5506-t3142-kvm-centos7.zip
   Smoke tests completed. 91 look OK, 1 have errors
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_hostha_enable_ha_when_host_in_maintenance | `Error` | 302.69 | test_hostha_kvm.py
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1016490156


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-934062148


   Agree with the order @weizhouapache proposed


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] leolleeooleo commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
leolleeooleo commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-931250510


   @weizhouapache 
   
   lscpu work on dell servers
   libvirt don't work on dell servers.
   
   Dell PowerEdge R740 :
   ```
   [leo@kvm1 ~]$ lscpu 
   Architecture:        x86_64
   CPU op-mode(s):      32-bit, 64-bit
   Byte Order:          Little Endian
   CPU(s):              32
   On-line CPU(s) list: 0-31
   Thread(s) per core:  2
   Core(s) per socket:  8
   Socket(s):           2
   NUMA node(s):        2
   Vendor ID:           GenuineIntel
   CPU family:          6
   Model:               85
   Model name:          Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz                     <<<<< here is ok
   Stepping:            7
   CPU MHz:             1634.801                                                         <<<<< low frequency
   CPU max MHz:         3200.0000
   CPU min MHz:         800.0000
   BogoMIPS:            4200.00
   Virtualization:      VT-x
   L1d cache:           32K
   L1i cache:           32K
   L2 cache:            1024K
   L3 cache:            11264K
   NUMA node0 CPU(s):   0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30
   NUMA node1 CPU(s):   1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31
   Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities
   
   [leo@kvm1 ~]$ sudo virsh nodeinfo 
   CPU model:           x86_64
   CPU(s):              32
   CPU frequency:       1006 MHz                                            <<<<< low frequency
   CPU socket(s):       1
   Core(s) per socket:  8
   Thread(s) per core:  2
   NUMA cell(s):        2
   Memory size:         65364380 KiB
   
   
   [leo@kvm1 ~]$ cat /proc/cpuinfo
   processor       : 0
   vendor_id       : GenuineIntel
   cpu family      : 6
   model           : 85
   model name      : Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz                         <<<<< here is ok
   stepping        : 7
   microcode       : 0x5003102
   cpu MHz         : 823.050                                                           <<<<< low frequency
   cache size      : 11264 KB
   physical id     : 0
   siblings        : 16
   core id         : 0
   cpu cores       : 8
   apicid          : 0
   initial apicid  : 0
   fpu             : yes
   fpu_exception   : yes
   cpuid level     : 22
   wp              : yes
   flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities
   bugs            : spectre_v1 spectre_v2 spec_store_bypass swapgs taa itlb_multihit
   bogomips        : 4200.00
   clflush size    : 64
   cache_alignment : 64
   address sizes   : 46 bits physical, 48 bits virtual
   power management:
   
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-930033068


   > > tested ok on nested u20 environement.
   > > @leolleeooleo could you please test it ?
   > 
   > lscpu works fine on Intel CPU. So that on the Intel platform can get normal frequency from lscpu.
   > 
   > AMD CPU doesn't have frequency in "Model name". So that on AMD platform will get the maximum frequency from /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq. I don't have AMD server to try it, but that will get the normal frequency from cpuinfo_max_freq I had search from google.
   > 
   > Now all CPUs have boost frequency (IntelĀ® Turbo Boost Technology and AMD Turbo Core). How do you think the server CPU capacity is depend on normal frequency or maximum frequency?
   > 
   > If you think Turbo frequency can get more performance on VMs, I suggest change the order to: cpuinfo_max_freq > lscpu > libvirt
   
   @leolleeooleo 
   lscpu, libvirt, /proc/cpuinfo return almost same value, but cpuinfo_max_freq returns different value if cpu supports Turbo boost or turbo core. 
   as far as I know, only single core can reach the max frequency. we cannot assume all cpu cores can reach the max frequency.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on a change in pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on a change in pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#discussion_r717274823



##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -85,8 +87,18 @@ protected static long getCpuSpeed(final NodeInfo nodeInfo) {
             LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
             return cpuInfoMaxFreq / 1000;
         } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
-            return nodeInfo.mhz;
+            try {
+                LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Trying to fetch it from lscpu",
+                    cpuInfoMaxFreqFileName), e);
+                String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";

Review comment:
       @weizhouapache I'll rearrange the CPU speed fetching stages




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028596361


   @blueorangutan help


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028737365


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1029849934


   2 lgtm and tested; merging


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1027699425


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1024136428


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1016548300


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 2252


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1017240375


   > ping @davidjumani Is this PR ready?
   
   hi @davidjumani any update on this PR?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on a change in pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on a change in pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#discussion_r715489059



##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -85,8 +87,18 @@ protected static long getCpuSpeed(final NodeInfo nodeInfo) {
             LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
             return cpuInfoMaxFreq / 1000;
         } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
-            return nodeInfo.mhz;
+            try {
+                LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Trying to fetch it from lscpu",
+                    cpuInfoMaxFreqFileName), e);
+                String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";

Review comment:
       @rhtyd @davidjumani 
   
   there are multiple ways to get the cpu speed. you can try following commands
   
   ```
   while(true);do cat /proc/cpuinfo |grep 'cpu MHz' |head -n1;sleep 0.1;done
   while(true);do virsh nodeinfo |grep 'CPU frequency';sleep 0.1;done
   ```
   
   it looks the result by `lscpu` is most stable. I am not sure if it works for all cpu models.
   
   it seems we should not get cpu speed from `/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`. If cpu supports Intel Turbo Boost Technology, it is the max cpu frequency not the normal cpu frequency.  for example, on my laptop
   ```
   $ cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
   4700000
   $ virsh nodeinfo |grep 'CPU frequency'
   CPU frequency:       2800 MHz
   $ cat /proc/cpuinfo |grep 'cpu MHz' |head -n1
   cpu MHz		: 2800.000
   $ lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'
   2.80
   ```
   
   my opinion is: lscpu > nodeInfo.mhz (libvirt-java) -> /proc/cpuinfo > cpuinfo_max_freq




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on a change in pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on a change in pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#discussion_r715489059



##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -85,8 +87,18 @@ protected static long getCpuSpeed(final NodeInfo nodeInfo) {
             LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
             return cpuInfoMaxFreq / 1000;
         } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
-            return nodeInfo.mhz;
+            try {
+                LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Trying to fetch it from lscpu",
+                    cpuInfoMaxFreqFileName), e);
+                String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";

Review comment:
       @rhtyd @davidjumani 
   
   there are multiple ways to get the cpu speed. 
   
   while(true);do cat /proc/cpuinfo |grep 'cpu MHz' |head -n1;sleep 0.1;done
   while(true);do virsh nodeinfo |grep 'CPU frequency';sleep 0.1;done
   
   it looks the result by `lscpu` is most stable. I am not sure if it works for all cpu models.
   
   it seems we should not get cpu speed from `/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`. If cpu supports Intel Turbo Boost Technology, it is the max cpu frequency not the normal cpu frequency.  for example, on my laptop
   ```
   $ cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
   4700000
   $ virsh nodeinfo |grep 'CPU frequency'
   CPU frequency:       2800 MHz
   $ cat /proc/cpuinfo |grep 'cpu MHz' |head -n1
   cpu MHz		: 2800.000
   $ lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'
   2.80
   ```
   
   my opinion is: lscpu > nodeInfo.mhz (libvirt-java) -> /proc/cpuinfo > cpuinfo_max_freq




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-926364941


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 1385


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-928913911


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] leolleeooleo commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
leolleeooleo commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-931213800


   @weizhouapache 
   Got it, you're right.
   Only single core can reach the max frequency.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1031051604


   @blueorangutan help


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1024967387


   Packaging result: :heavy_multiplication_x: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_multiplication_x: suse15. SL-JID 2379


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-928914444


   @davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1026492984


   @sureshanaparti a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1023940605


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028597855


   @davidjumani a Trillian-Jenkins test job (ubuntu20 mgmt + kvm-ubuntu20) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028598001


   @blueorangutan test rocky8 kvm-rocky8


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028597584


   @blueorangutan test ubuntu20 ubuntu20


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani removed a comment on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani removed a comment on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028597584


   @blueorangutan test ubuntu20 kvm-ubuntu20


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028787505


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 2445


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1026038983


   <b>Trillian test result (tid-3069)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 28253 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5506-t3069-kvm-centos7.zip
   Smoke tests completed. 75 look OK, 17 have errors
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   ContextSuite context=TestRemoteDiagnostics>:setup | `Error` | 0.00 | test_diagnostics.py
   test_01_deploy_vm_from_direct_download_template_nfs_storage | `Error` | 1.20 | test_direct_download.py
   ContextSuite context=TestDirectDownloadTemplates>:teardown | `Error` | 1.10 | test_direct_download.py
   test_01_add_primary_storage_disabled_host | `Error` | 33.68 | test_primary_storage.py
   test_01_primary_storage_nfs | `Error` | 0.11 | test_primary_storage.py
   ContextSuite context=TestStorageTags>:setup | `Error` | 0.20 | test_primary_storage.py
   test_01_vpc_privategw_acl | `Failure` | 5.68 | test_privategw_acl.py
   test_02_vpc_privategw_static_routes | `Failure` | 4.66 | test_privategw_acl.py
   test_03_vpc_privategw_restart_vpc_cleanup | `Failure` | 5.65 | test_privategw_acl.py
   test_04_rvpc_privategw_static_routes | `Failure` | 7.74 | test_privategw_acl.py
   ContextSuite context=TestLBRuleUsage>:setup | `Error` | 3.89 | test_usage.py
   ContextSuite context=TestNatRuleUsage>:setup | `Error` | 5.56 | test_usage.py
   ContextSuite context=TestPublicIPUsage>:setup | `Error` | 7.31 | test_usage.py
   ContextSuite context=TestSnapshotUsage>:setup | `Error` | 8.98 | test_usage.py
   ContextSuite context=TestVmUsage>:setup | `Error` | 19.64 | test_usage.py
   ContextSuite context=TestVolumeUsage>:setup | `Error` | 21.36 | test_usage.py
   ContextSuite context=TestVpnUsage>:setup | `Error` | 23.17 | test_usage.py
   test_list_vms_metrics | `Error` | 1.37 | test_metrics_api.py
   test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL | `Error` | 7.83 | test_vpc_redundant.py
   test_02_redundant_VPC_default_routes | `Error` | 7.75 | test_vpc_redundant.py
   test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers | `Error` | 5.77 | test_vpc_redundant.py
   test_04_rvpc_network_garbage_collector_nics | `Error` | 8.74 | test_vpc_redundant.py
   test_05_rvpc_multi_tiers | `Error` | 7.72 | test_vpc_redundant.py
   ContextSuite context=TestResetVmOnReboot>:setup | `Error` | 0.00 | test_reset_vm_on_reboot.py
   test_01_so_removal_resource_update | `Error` | 1.31 | test_resource_accounting.py
   test_01_create_delete_portforwarding_fornonvpc | `Error` | 1.82 | test_portforwardingrules.py
   test_03_deploy_vm_domain_service_offering | `Error` | 10.28 | test_domain_service_offerings.py
   test_03_create_vpc_domain_vpc_offering | `Error` | 6.06 | test_domain_vpc_offerings.py
   ContextSuite context=TestRouterDHCPHosts>:setup | `Error` | 0.00 | test_router_dhcphosts.py
   ContextSuite context=TestRouterDHCPOpts>:setup | `Error` | 0.00 | test_router_dhcphosts.py
   ContextSuite context=TestRouterDns>:setup | `Error` | 0.00 | test_router_dns.py
   ContextSuite context=TestRouterDnsService>:setup | `Error` | 0.00 | test_router_dnsservice.py
   ContextSuite context=TestRouterServices>:setup | `Error` | 0.00 | test_routers.py
   test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80 | `Failure` | 5.76 | test_internal_lb.py
   test_03_vpc_internallb_haproxy_stats_on_all_interfaces | `Failure` | 84.38 | test_internal_lb.py
   test_04_rvpc_internallb_haproxy_stats_on_all_interfaces | `Failure` | 8.66 | test_internal_lb.py
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028613244


   @blueorangutan test ubuntu20 kvm-ubuntu20 keepEnv


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan removed a comment on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan removed a comment on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028613630






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on a change in pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on a change in pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#discussion_r798286487



##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -80,16 +82,39 @@ public long getOverCommitMemory() {
     }
 
     protected static long getCpuSpeed(final NodeInfo nodeInfo) {
-        try (Reader reader = new FileReader(cpuInfoMaxFreqFileName)) {
-            Long cpuInfoMaxFreq = Long.parseLong(IOUtils.toString(reader).trim());
-            LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
-            return cpuInfoMaxFreq / 1000;
-        } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
+        try {
+            return getCpuSpeedInternal();
+        } catch (IOException | NumberFormatException ex) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s] and lscpu. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), ex);
             return nodeInfo.mhz;
         }
     }
 
+    private static long getCpuSpeedInternal() throws IOException {
+        try {
+            return getCpuSpeedFromCommandLscpu();
+        } catch (NullPointerException | NumberFormatException e) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from lscpu. Using the value in [%s].", cpuInfoMaxFreqFileName), e);
+            return getCpuSpeedFromFile();
+        }
+    }
+
+    private static long getCpuSpeedFromCommandLscpu() {
+        LOGGER.info("Fetching CPU speed from command \"lscpu\".");
+        String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";
+        String result = Script.runSimpleBashScript(command);
+        long speed = (long) (Float.parseFloat(result) * 1000);
+        LOGGER.info(String.format("Command [%s] resulted in the value [%s] for CPU speed.", command, speed));
+        return speed;
+    }
+
+    private static long getCpuSpeedFromFile() throws IOException {
+        Reader reader = new FileReader(cpuInfoMaxFreqFileName);

Review comment:
       add a log info here ?
   ```
           LOGGER.info("Fetching CPU speed from file \"" + cpuInfoMaxFreqFileName + "\".");
   ```

##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -80,16 +82,39 @@ public long getOverCommitMemory() {
     }
 
     protected static long getCpuSpeed(final NodeInfo nodeInfo) {
-        try (Reader reader = new FileReader(cpuInfoMaxFreqFileName)) {
-            Long cpuInfoMaxFreq = Long.parseLong(IOUtils.toString(reader).trim());
-            LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
-            return cpuInfoMaxFreq / 1000;
-        } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
+        try {
+            return getCpuSpeedInternal();
+        } catch (IOException | NumberFormatException ex) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s] and lscpu. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), ex);
             return nodeInfo.mhz;
         }
     }
 
+    private static long getCpuSpeedInternal() throws IOException {
+        try {
+            return getCpuSpeedFromCommandLscpu();
+        } catch (NullPointerException | NumberFormatException e) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from lscpu. Using the value in [%s].", cpuInfoMaxFreqFileName), e);
+            return getCpuSpeedFromFile();
+        }
+    }
+
+    private static long getCpuSpeedFromCommandLscpu() {

Review comment:
       suggestion:
   add try...catch in getCpuSpeedFromCommandLscpu and getCpuSpeedFromFile
   if exception is caught, then return the a default value like 0 or -1.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028598224


   @davidjumani a Trillian-Jenkins test job (rocky8 mgmt + kvm-rocky8) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028436483


   <b>Trillian test result (tid-3123)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 47269 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5506-t3123-kvm-centos7.zip
   Smoke tests completed. 91 look OK, 1 have errors
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_01_invalid_upgrade_kubernetes_cluster | `Failure` | 3605.57 | test_kubernetes_clusters.py
   ContextSuite context=TestKubernetesCluster>:teardown | `Error` | 101.87 | test_kubernetes_clusters.py
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani edited a comment on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani edited a comment on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028597584


   @blueorangutan test ubuntu20 kvm-ubuntu20


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1027740256


   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-925723655


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] leolleeooleo commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
leolleeooleo commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-929115246


   > tested ok on nested u20 environement.
   > 
   > @leolleeooleo could you please test it ?
   
   lscpu works fine on Intel CPU.
   So that on the Intel platform can get normal frequency from lscpu.
   
   AMD CPU doesn't have frequency in "Model name".
   So that on AMD platform will get the maximum frequency from /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq.
   I don't have AMD server to try it, but that will get the normal frequency from cpuinfo_max_freq I had search from google.
   
   Now all CPUs have boost frequency (IntelĀ® Turbo Boost Technology and AMD Turbo Core).
   How do you think the server CPU capacity is depend on normal frequency or maximum frequency?
   
   If you think Turbo frequency can get more performance on VMs,
   I suggest change the order to:
   cpuinfo_max_freq > lscpu > libvirt
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-926356959


   @davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-930033068


   > > tested ok on nested u20 environement.
   > > @leolleeooleo could you please test it ?
   > 
   > lscpu works fine on Intel CPU. So that on the Intel platform can get normal frequency from lscpu.
   > 
   > AMD CPU doesn't have frequency in "Model name". So that on AMD platform will get the maximum frequency from /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq. I don't have AMD server to try it, but that will get the normal frequency from cpuinfo_max_freq I had search from google.
   > 
   > Now all CPUs have boost frequency (IntelĀ® Turbo Boost Technology and AMD Turbo Core). How do you think the server CPU capacity is depend on normal frequency or maximum frequency?
   > 
   > If you think Turbo frequency can get more performance on VMs, I suggest change the order to: cpuinfo_max_freq > lscpu > libvirt
   
   @leolleeooleo 
   lscpu, libvirt, /proc/cpuinfo return almost same value, but cpuinfo_max_freq returns different value if cpu supports Turbo boost or turbo core. 
   as far as I know, only single core can reach the max frequency. we cannot assume all cpu cores can reach the max frequency.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-928946861


   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1077690510


   @loth hmm, thanks Tyler
   
   cc @davidjumani @nvazquez 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-925669512


   @davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] leolleeooleo commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
leolleeooleo commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-929115246


   > tested ok on nested u20 environement.
   > 
   > @leolleeooleo could you please test it ?
   
   lscpu works fine on Intel CPU.
   So that on the Intel platform can get normal frequency from lscpu.
   
   AMD CPU doesn't have frequency in "Model name".
   So that on AMD platform will get the maximum frequency from /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq.
   I don't have AMD server to try it, but that will get the normal frequency from cpuinfo_max_freq I had search from google.
   
   Now all CPUs have boost frequency (IntelĀ® Turbo Boost Technology and AMD Turbo Core).
   How do you think the server CPU capacity is depend on normal frequency or maximum frequency?
   
   If you think Turbo frequency can get more performance on VMs,
   I suggest change the order to:
   cpuinfo_max_freq > lscpu > libvirt
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-925669293


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-928930863


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 1416


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1024253860


   Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 2370


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1023963305


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1016490823


   @DaanHoogland a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028736888


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028597112


   @davidjumani I understand these words: "help", "hello", "thanks", "package", "test"
   Test command usage: test [mgmt os] [hypervisor] [keepEnv]
   Mgmt OS options: ['centos7', 'centos6', 'alma8', 'ubuntu18', 'suse15', 'ubuntu20', 'rocky8', 'centos8']
   Hypervisor options: ['kvm-centos6', 'kvm-centos7', 'kvm-centos8', 'kvm-rocky8', 'kvm-alma8', 'kvm-ubuntu18', 'kvm-ubuntu20', 'kvm-suse15', 'vmware-55u3', 'vmware-60u2', 'vmware-65u2', 'vmware-67u3', 'vmware-70u1', 'vmware-70u2', 'vmware-70u3', 'xenserver-65sp1', 'xenserver-71', 'xenserver-74', 'xcpng74', 'xcpng76', 'xcpng80', 'xcpng81', 'xcpng82']
   	Note: when keepEnv is passed, you need to specify mgmt server os and hypervisor or use the `matrix` command.
   
   Blessed contributors for kicking Trillian test jobs: ['rohityadavcloud', 'nvazquez', 'borisstoyanov', 'DaanHoogland', 'shwstppr', 'andrijapanicsb', 'Pearl1594', 'davidjumani', 'harikrishna-patnala', 'vladimirpetrov', 'sureshanaparti', 'weizhouapache', 'NuxRo']


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1027728843


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 2426


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1026816320


   <b>Trillian test result (tid-3089)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 25566 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5506-t3089-kvm-centos7.zip
   Smoke tests completed. 82 look OK, 10 have errors
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   ContextSuite context=TestLBRuleUsage>:setup | `Error` | 3.84 | test_usage.py
   ContextSuite context=TestNatRuleUsage>:setup | `Error` | 5.50 | test_usage.py
   ContextSuite context=TestPublicIPUsage>:setup | `Error` | 7.18 | test_usage.py
   ContextSuite context=TestSnapshotUsage>:setup | `Error` | 8.90 | test_usage.py
   ContextSuite context=TestVmUsage>:setup | `Error` | 18.68 | test_usage.py
   ContextSuite context=TestVolumeUsage>:setup | `Error` | 20.41 | test_usage.py
   ContextSuite context=TestVpnUsage>:setup | `Error` | 22.11 | test_usage.py
   test_list_vms_metrics | `Error` | 1.38 | test_metrics_api.py
   test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL | `Error` | 6.70 | test_vpc_redundant.py
   test_02_redundant_VPC_default_routes | `Error` | 7.79 | test_vpc_redundant.py
   test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers | `Error` | 8.76 | test_vpc_redundant.py
   test_04_rvpc_network_garbage_collector_nics | `Error` | 7.76 | test_vpc_redundant.py
   test_05_rvpc_multi_tiers | `Error` | 7.83 | test_vpc_redundant.py
   ContextSuite context=TestRouterDHCPHosts>:setup | `Error` | 0.00 | test_router_dhcphosts.py
   ContextSuite context=TestRouterDHCPOpts>:setup | `Error` | 0.00 | test_router_dhcphosts.py
   ContextSuite context=TestRouterDns>:setup | `Error` | 0.00 | test_router_dns.py
   ContextSuite context=TestRouterDnsService>:setup | `Error` | 0.00 | test_router_dnsservice.py
   ContextSuite context=TestRouterServices>:setup | `Error` | 0.00 | test_routers.py
   test_01_isolate_network_FW_PF_default_routes_egress_true | `Error` | 1.39 | test_routers_network_ops.py
   test_02_isolate_network_FW_PF_default_routes_egress_false | `Error` | 1.31 | test_routers_network_ops.py
   test_01_RVR_Network_FW_PF_SSH_default_routes_egress_true | `Error` | 4.96 | test_routers_network_ops.py
   test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false | `Error` | 5.90 | test_routers_network_ops.py
   test_03_RVR_Network_check_router_state | `Error` | 6.10 | test_routers_network_ops.py
   test_01_deploy_vm_on_specific_host | `Error` | 3.28 | test_vm_deployment_planner.py
   test_02_deploy_vm_on_specific_cluster | `Error` | 4.36 | test_vm_deployment_planner.py
   test_03_deploy_vm_on_specific_pod | `Error` | 4.66 | test_vm_deployment_planner.py
   test_04_deploy_vm_on_host_override_pod_and_cluster | `Error` | 4.71 | test_vm_deployment_planner.py
   test_05_deploy_vm_on_cluster_override_pod | `Error` | 1.44 | test_vm_deployment_planner.py
   test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80 | `Failure` | 6.89 | test_internal_lb.py
   test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80 | `Failure` | 6.79 | test_internal_lb.py
   test_03_vpc_internallb_haproxy_stats_on_all_interfaces | `Failure` | 7.76 | test_internal_lb.py
   test_04_rvpc_internallb_haproxy_stats_on_all_interfaces | `Failure` | 7.60 | test_internal_lb.py
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-928947683


   @weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1025497866


   @davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028608834


   <b>Trillian Build Failed (tid-3132)<b/>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028632650


   Tested on rocky8, suse15 and ubuntu20 as well


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028737284


   @weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani edited a comment on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani edited a comment on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1023910182


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1024137320


   @davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on a change in pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on a change in pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#discussion_r796829292



##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -80,16 +82,39 @@ public long getOverCommitMemory() {
     }
 
     protected static long getCpuSpeed(final NodeInfo nodeInfo) {
-        try (Reader reader = new FileReader(cpuInfoMaxFreqFileName)) {
-            Long cpuInfoMaxFreq = Long.parseLong(IOUtils.toString(reader).trim());
-            LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
-            return cpuInfoMaxFreq / 1000;
-        } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
+        try {
+            return getCpuSpeedInternal();
+        } catch (IOException | NumberFormatException ex) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s] and lscpu. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), ex);
             return nodeInfo.mhz;
         }
     }
 
+    private static long getCpuSpeedInternal() throws IOException {
+        try {
+            return getCpuSpeedByLSCPU();
+        } catch (NullPointerException | NumberFormatException e) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from lscpu. Using the value in [%s].", cpuInfoMaxFreqFileName), e);
+            return getCpuSpeedFromFile();
+        }
+    }
+
+    private static long getCpuSpeedByLSCPU() {

Review comment:
       ```suggestion
       private static long getCpuSpeedFromCommandLscpu() {
   ```

##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -80,16 +82,39 @@ public long getOverCommitMemory() {
     }
 
     protected static long getCpuSpeed(final NodeInfo nodeInfo) {
-        try (Reader reader = new FileReader(cpuInfoMaxFreqFileName)) {
-            Long cpuInfoMaxFreq = Long.parseLong(IOUtils.toString(reader).trim());
-            LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
-            return cpuInfoMaxFreq / 1000;
-        } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
+        try {
+            return getCpuSpeedInternal();
+        } catch (IOException | NumberFormatException ex) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s] and lscpu. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), ex);
             return nodeInfo.mhz;
         }
     }
 
+    private static long getCpuSpeedInternal() throws IOException {
+        try {
+            return getCpuSpeedByLSCPU();
+        } catch (NullPointerException | NumberFormatException e) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from lscpu. Using the value in [%s].", cpuInfoMaxFreqFileName), e);
+            return getCpuSpeedFromFile();
+        }
+    }
+
+    private static long getCpuSpeedByLSCPU() {
+        LOGGER.info("Fetching cpu speed from it from lscpu");

Review comment:
       ```suggestion
           LOGGER.info("Fetching CPU speed from command \"lscpu\".");
   ```

##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -80,16 +82,39 @@ public long getOverCommitMemory() {
     }
 
     protected static long getCpuSpeed(final NodeInfo nodeInfo) {
-        try (Reader reader = new FileReader(cpuInfoMaxFreqFileName)) {
-            Long cpuInfoMaxFreq = Long.parseLong(IOUtils.toString(reader).trim());
-            LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
-            return cpuInfoMaxFreq / 1000;
-        } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
+        try {
+            return getCpuSpeedInternal();
+        } catch (IOException | NumberFormatException ex) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s] and lscpu. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), ex);
             return nodeInfo.mhz;
         }
     }
 
+    private static long getCpuSpeedInternal() throws IOException {
+        try {
+            return getCpuSpeedByLSCPU();
+        } catch (NullPointerException | NumberFormatException e) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from lscpu. Using the value in [%s].", cpuInfoMaxFreqFileName), e);
+            return getCpuSpeedFromFile();
+        }
+    }
+
+    private static long getCpuSpeedByLSCPU() {
+        LOGGER.info("Fetching cpu speed from it from lscpu");
+        String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";
+        String result = Script.runSimpleBashScript(command);
+        long speed = (long) (Float.parseFloat(result) * 1000);
+        LOGGER.info(String.format("Got [%d] speed from lscpu", speed));

Review comment:
       ```suggestion
           LOGGER.info(String.format("Command [%s] resulted in the value [%s] for CPU speed.", command, speed));
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-931243101


   > @weizhouapache Got it, you're right. Only single core can reach the max frequency.
   
   @davidjumani @rhtyd @leolleeooleo @nvazquez 
   can you get a consensus what's the best order ?
   
   my opinion is: lscpu (might not work on dell servers) > nodeInfo.mhz (libvirt-java) = /proc/cpuinfo > cpuinfo_max_freq
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-933282554


   @davidjumani I understand these words: "help", "hello", "thanks", "package", "test"
   Test command usage: test [mgmt os] [hypervisor] [keepEnv]
   Mgmt OS options: ['centos7', 'centos6', 'alma8', 'ubuntu18', 'suse15', 'ubuntu20', 'rocky8', 'centos8']
   Hypervisor options: ['kvm-centos6', 'kvm-centos7', 'kvm-centos8', 'kvm-rocky8', 'kvm-alma8', 'kvm-ubuntu18', 'kvm-ubuntu20', 'kvm-suse15', 'vmware-55u3', 'vmware-60u2', 'vmware-65u2', 'vmware-67u3', 'vmware-70u1', 'xenserver-65sp1', 'xenserver-71', 'xenserver-74', 'xcpng74', 'xcpng76', 'xcpng80', 'xcpng81', 'xcpng82']
   	Note: when keepEnv is passed, you need to specify mgmt server os and hypervisor or use the `matrix` command.
   
   Blessed contributors for kicking Trillian test jobs: ['rhtyd', 'nvazquez', 'PaulAngus', 'borisstoyanov', 'DaanHoogland', 'shwstppr', 'andrijapanicsb', 'Spaceman1984', 'Pearl1594', 'davidjumani', 'harikrishna-patnala', 'vladimirpetrov', 'sureshanaparti', 'weizhouapache', 'NuxRo']


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] s-seitz edited a comment on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
s-seitz edited a comment on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-968060679


   As @weizhouapache mentioned earlier ("lscpu > nodeInfo.mhz (libvirt-java) -> /proc/cpuinfo > cpuinfo_max_freq"), I'ld suggest to outsource the whole logic into a script (at a tbd .../scripts/ .../scriptlets/-folder) to ensure ENV's are set correctly. Keep in mind "lscpu" is usually localized, so at least PATH and LC_ALL are necessary. In my opinion, having a script with defined return-values in place, would also make testing and debugging a lot easier. (Not to mention, the possibility of patching without the need of forking and recompiling cloudstack, maybe if your kvm  runs on arm64?)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on a change in pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on a change in pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#discussion_r717274823



##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -85,8 +87,18 @@ protected static long getCpuSpeed(final NodeInfo nodeInfo) {
             LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
             return cpuInfoMaxFreq / 1000;
         } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
-            return nodeInfo.mhz;
+            try {
+                LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Trying to fetch it from lscpu",
+                    cpuInfoMaxFreqFileName), e);
+                String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";

Review comment:
       @weizhouapache I'll rearrange the CPU speed fetching stages




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1025530065


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 2397


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1024957061


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani edited a comment on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani edited a comment on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028632650


   Manually tested on rocky8, suse15 and ubuntu20 as well


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1027642199


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028886826


   @sureshanaparti a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028886227


   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti removed a comment on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti removed a comment on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028613244


   @blueorangutan test ubuntu20 kvm-ubuntu20 keepEnv


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1023910611


   @davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1023987442


   @sureshanaparti a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1024127626


   Packaging result: :heavy_multiplication_x: el7 :heavy_check_mark: el8 :heavy_multiplication_x: debian :heavy_check_mark: suse15. SL-JID 2362


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-928914444






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-926356736


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] rhtyd commented on a change in pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
rhtyd commented on a change in pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#discussion_r715409750



##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -85,8 +87,18 @@ protected static long getCpuSpeed(final NodeInfo nodeInfo) {
             LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
             return cpuInfoMaxFreq / 1000;
         } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
-            return nodeInfo.mhz;
+            try {
+                LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Trying to fetch it from lscpu",
+                    cpuInfoMaxFreqFileName), e);
+                String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";

Review comment:
       @davidjumani I think standard way is to get from /proc/cpuinfo; `grep "^[c]pu MHz" /proc/cpuinfo`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] s-seitz commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
s-seitz commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-968060679


   As @weizhouapache mentioned earlier ("lscpu > nodeInfo.mhz (libvirt-java) -> /proc/cpuinfo > cpuinfo_max_freq"), I'ld suggest to outsource the whole logic into a script (at a tbd .../scripts/ .../scriptlets/-folder) to ensure ENV's are set correctly. Keep in mind "lscpu" is usually localized, so at least PATH and LC_ALL are necessary. In my opinion, having a script with defined return-values in place, would also make testing and debugging a lot easier.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1027642725


   @davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti removed a comment on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti removed a comment on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1023963305


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1024937451


   Packaging result: :heavy_multiplication_x: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_multiplication_x: suse15. SL-JID 2377


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1026492844


   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on a change in pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on a change in pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#discussion_r797326716



##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -80,16 +82,39 @@ public long getOverCommitMemory() {
     }
 
     protected static long getCpuSpeed(final NodeInfo nodeInfo) {
-        try (Reader reader = new FileReader(cpuInfoMaxFreqFileName)) {
-            Long cpuInfoMaxFreq = Long.parseLong(IOUtils.toString(reader).trim());
-            LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
-            return cpuInfoMaxFreq / 1000;
-        } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
+        try {
+            return getCpuSpeedInternal();
+        } catch (IOException | NumberFormatException ex) {
+            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s] and lscpu. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), ex);
             return nodeInfo.mhz;
         }
     }
 
+    private static long getCpuSpeedInternal() throws IOException {
+        try {
+            return getCpuSpeedByLSCPU();

Review comment:
       ```suggestion
               return getCpuSpeedFromCommandLscpu();
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1027741150


   @sureshanaparti a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1028675146


   Manually verified the CPU speed in CentOS 7.6, Rocky 8.4 and Ubuntu 20.04. Looks good.
   
   Log before changes:
   _2022-02-02 16:28:18,088 ERROR [utils.linux.KVMHostInfo] (Agent-Handler-1:null) (logid:e95232e8) Unable to retrieve the CPU speed from file [/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq]. Using the value [2100] provided by the Libvirt._
   
   Log after changes:
   _2022-02-02 17:00:32,614 INFO  [utils.linux.KVMHostInfo] (Agent-Handler-1:null) (logid:e3ee9c00) Fetching CPU speed from command "lscpu".
   2022-02-02 17:00:32,639 INFO  [utils.linux.KVMHostInfo] (Agent-Handler-1:null) (logid:e3ee9c00) Command [lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'] resulted in the value [2100] for CPU speed._
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1023910182


   cpuInfoMaxFreqFileName


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1025496274


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1025535438


   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1024925380


   @sureshanaparti a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1012104561


   ping @davidjumani Is this PR ready?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-928913911


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on a change in pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on a change in pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#discussion_r715489059



##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -85,8 +87,18 @@ protected static long getCpuSpeed(final NodeInfo nodeInfo) {
             LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
             return cpuInfoMaxFreq / 1000;
         } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
-            return nodeInfo.mhz;
+            try {
+                LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Trying to fetch it from lscpu",
+                    cpuInfoMaxFreqFileName), e);
+                String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";

Review comment:
       @rhtyd @davidjumani 
   
   there are multiple ways to get the cpu speed. 
   
   while(true);do cat /proc/cpuinfo |grep 'cpu MHz' |head -n1;sleep 0.1;done
   while(true);do virsh nodeinfo |grep 'CPU frequency';sleep 0.1;done
   
   it looks the result by `lscpu` is most stable. I am not sure if it works for all cpu models.
   
   it seems we should not get cpu speed from `/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`. If cpu supports Intel Turbo Boost Technology, it is the max cpu frequency not the normal cpu frequency.  for example, on my laptop
   ```
   $ cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
   4700000
   $ virsh nodeinfo |grep 'CPU frequency'
   CPU frequency:       2800 MHz
   $ cat /proc/cpuinfo |grep 'cpu MHz' |head -n1
   cpu MHz		: 2800.000
   ```
   
   my opinion is: lscpu > nodeInfo.mhz (libvirt-java) -> /proc/cpuinfo > cpuinfo_max_freq




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-925738448


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 1380


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland merged pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
DaanHoogland merged pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1029852497


   > ping @davidjumani is this ready, or already reviewed/tested manually @sureshanaparti @nvazquez @DaanHoogland ?
   
   yes, verified the latest changes on CentOS 7.6 and Rocky 8.4.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1024957244


   @sureshanaparti a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1023940894


   @davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1023984735


   Packaging result: :heavy_multiplication_x: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 2359


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1023986567


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on a change in pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on a change in pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#discussion_r797331404



##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -80,13 +82,23 @@ public long getOverCommitMemory() {
     }
 
     protected static long getCpuSpeed(final NodeInfo nodeInfo) {
-        try (Reader reader = new FileReader(cpuInfoMaxFreqFileName)) {
-            Long cpuInfoMaxFreq = Long.parseLong(IOUtils.toString(reader).trim());
-            LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
-            return cpuInfoMaxFreq / 1000;
-        } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
-            return nodeInfo.mhz;
+        try {

Review comment:
       agree with @ravening 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-1027699669


   @sureshanaparti a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] davidjumani commented on pull request #5506: kvm: Use lscpu to get cpu max speed

Posted by GitBox <gi...@apache.org>.
davidjumani commented on pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#issuecomment-933282254


   @blueorangutan help


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org