You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
confirmed bugConfirmed bugs. Highest priority to fix.containersIssues associated with containers like Dockerfirst-timers-onlyIssues reserved for brand new GitHub usersgood first issueGood issues for new contributors to work on
Hmm. I see what's happening and am surprised this hasn't been reported before now.
OSHI is counting up the 4 unique physical id values (0, 1, 2, 3) and assuming 4 cpu sockets/packages, but is only seeing one value for core id. In LinuxCentralProcessor starting on line 145, we do this:
Set<Integer> physProcs = new HashSet<>();
Set<Integer> physPkgs = new HashSet<>();
for (LogicalProcessor logProc : logProcs) {
physProcs.add(logProc.getPhysicalProcessorNumber());
physPkgs.add(logProc.getPhysicalPackageNumber());
}
This is clearly a bug: physical processor 0 on package 0 is a distinct CPU from physical processor 0 on package 1 but using a Set to count only distinct values of the core id is wrong. We need to count distinct pairs of physical id+core id.
I'm marking this issue for first-timers-only. That means that I will only accept a PR for this one from someone who's never contributed to open source before. This one is easy (but don't make that statement make you feel bad if you have a hard time with it, there's more to contributing to open source than changing lines of code, especially if it's your first time). I'll hold your hand through this if you need me to. :-) Here are the steps to get a PR merged here.
Read the CONTRIBUTING file for reference. I'll walk you through anything you don't understand.
Find the LinuxCentralProcessor.java class. Beginning at Line 145, the code populates the physical processor count by counting unique values of logProc.getPhysicalProcessorNumber() added to a Set.
Alter the code to instead count unique pairs of logProc.getPhysicalPackageNumber() and logProc.getPhysicalProcessorNumber(). One option is to combine these two integers into a String using some delimiter, and storing the unique String values in the set. Another option would be to create a 64-bit Long out of the two 32-bit values. Other options would include better ways of counting unique pairs, that don't involve using a Set. Note the package counting is still correct, you only have to alter the physical processor count by including the package-core combination rather than just the core.
Actually, rereading this question, let me clarify. If you clone the OSHI repository you won't be able to commit directly to it. Where it says contributor you should put your user name.
I have a mac, so when I run tests, it uses the mac code. Any advice on how to reproduce this bug from the linux/unix code, so I can make sure my code actually fixes it? Should I use VirtualBox?
One suggestion is to test the changed code on a “main” method in the class and run it locally. Save the /proc/cpuinfo extract above to a file on your Mac in that location.
Okay, I am having real trouble reproducing the error.. However, my travis tests show an unspecified error for oracle jdk 11, which may be due to an old link as it doesn't get past downloading the jdk--although I see the travis script should automatically update this link. Anyway, should I just do a PR now and if approved, have @cycchow test it?
In order to reproduce the error you need to be on hardware with multiple CPU sockets. You should be able to reproduce the CPU count values by reading in from the text file rather than the real /proc/cpu. In any case, go ahead and submit the PR and we can review it!
confirmed bugConfirmed bugs. Highest priority to fix.containersIssues associated with containers like Dockerfirst-timers-onlyIssues reserved for brand new GitHub usersgood first issueGood issues for new contributors to work on
Activity
dbwiddis commentedon Jun 28, 2019
Line 83 is:
assertTrue(p.getPhysicalProcessorCount() >= p.getPhysicalPackageCount());These numbers are populated by counting values in
/proc/cpuinfo.Can you provide the output of
cat /proc/cpuinforun from inside the container?cycchow commentedon Jun 28, 2019
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
stepping : 9
cpu MHz : 4200.000
cache size : 8192 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
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 mmx fxsr sse sse2 ss ht pbe syscall nx pdpe1gb lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq dtes64 ds_cpl ssse3 sdbg fma cx16 xtpr pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch kaiser fsgsbase bmi1 hle avx2 bmi2 erms rtm xsaveopt arat
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
bogomips : 8400.00
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
stepping : 9
cpu MHz : 4200.000
cache size : 8192 KB
physical id : 1
siblings : 1
core id : 0
cpu cores : 1
apicid : 1
initial apicid : 1
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 mmx fxsr sse sse2 ss ht pbe syscall nx pdpe1gb lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq dtes64 ds_cpl ssse3 sdbg fma cx16 xtpr pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch kaiser fsgsbase bmi1 hle avx2 bmi2 erms rtm xsaveopt arat
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
bogomips : 8979.59
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
processor : 2
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
stepping : 9
cpu MHz : 4200.000
cache size : 8192 KB
physical id : 2
siblings : 1
core id : 0
cpu cores : 1
apicid : 2
initial apicid : 2
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 mmx fxsr sse sse2 ss ht pbe syscall nx pdpe1gb lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq dtes64 ds_cpl ssse3 sdbg fma cx16 xtpr pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch kaiser fsgsbase bmi1 hle avx2 bmi2 erms rtm xsaveopt arat
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
bogomips : 8364.34
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
processor : 3
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
stepping : 9
cpu MHz : 4200.000
cache size : 8192 KB
physical id : 3
siblings : 1
core id : 0
cpu cores : 1
apicid : 3
initial apicid : 3
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 mmx fxsr sse sse2 ss ht pbe syscall nx pdpe1gb lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq dtes64 ds_cpl ssse3 sdbg fma cx16 xtpr pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch kaiser fsgsbase bmi1 hle avx2 bmi2 erms rtm xsaveopt arat
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
bogomips : 8988.29
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
dbwiddis commentedon Jun 28, 2019
Hmm. I see what's happening and am surprised this hasn't been reported before now.
OSHI is counting up the 4 unique
physical idvalues (0, 1, 2, 3) and assuming 4 cpu sockets/packages, but is only seeing one value forcore id. In LinuxCentralProcessor starting on line 145, we do this:This is clearly a bug: physical processor 0 on package 0 is a distinct CPU from physical processor 0 on package 1 but using a
Setto count only distinct values of thecore idis wrong. We need to count distinct pairs of physical id+core id.[-]Fail to build in docker container[/-][+]Incorrect physical processor count on Linux[/+]dbwiddis commentedon Jun 28, 2019
I'm marking this issue for first-timers-only. That means that I will only accept a PR for this one from someone who's never contributed to open source before. This one is easy (but don't make that statement make you feel bad if you have a hard time with it, there's more to contributing to open source than changing lines of code, especially if it's your first time). I'll hold your hand through this if you need me to. :-) Here are the steps to get a PR merged here.
logProc.getPhysicalProcessorNumber()added to aSet.logProc.getPhysicalPackageNumber()andlogProc.getPhysicalProcessorNumber(). One option is to combine these two integers into aStringusing some delimiter, and storing the uniqueStringvalues in the set. Another option would be to create a 64-bitLongout of the two 32-bit values. Other options would include better ways of counting unique pairs, that don't involve using aSet. Note the package counting is still correct, you only have to alter the physical processor count by including the package-core combination rather than just the core.ellemcfarlane commentedon Jun 28, 2019
Hi, I'd like to start working on this (never contributed to open source before), but I am having trouble with cloning the url indicated in the CONTRIBUTING file. It says to clone https://github.com/contributor/oshi.git, but this webpage doesn't exist. Should I instead clone https://github.com/oshi/oshi.git?
spyhunter99 commentedon Jun 28, 2019
yes
ellemcfarlane commentedon Jun 28, 2019
Cool--thanks.
dbwiddis commentedon Jun 28, 2019
Actually, rereading this question, let me clarify. If you clone the OSHI repository you won't be able to commit directly to it. Where it says
contributoryou should put your user name.So the first step is to fork the repository on the GitHub website, into your own account. Then you will be able to clone (from the command line) https://github.com/ellesummer/oshi.git
You can then make the changes, and push to your own repository; when you're ready for the PR you'll do that from your own fork on GitHub.
ellemcfarlane commentedon Jun 29, 2019
Ah okay, will do!
ellemcfarlane commentedon Jun 29, 2019
I have a mac, so when I run tests, it uses the mac code. Any advice on how to reproduce this bug from the linux/unix code, so I can make sure my code actually fixes it? Should I use VirtualBox?
dbwiddis commentedon Jun 29, 2019
Virtualbox or some other vm is the best. Travis tests run on Linux. Ideally @cycchow can test on the same hardware that was reported here.
dbwiddis commentedon Jun 29, 2019
One suggestion is to test the changed code on a “main” method in the class and run it locally. Save the /proc/cpuinfo extract above to a file on your Mac in that location.
ellemcfarlane commentedon Jun 29, 2019
Okay, I am having real trouble reproducing the error.. However, my travis tests show an unspecified error for oracle jdk 11, which may be due to an old link as it doesn't get past downloading the jdk--although I see the travis script should automatically update this link. Anyway, should I just do a PR now and if approved, have @cycchow test it?
dbwiddis commentedon Jun 29, 2019
In order to reproduce the error you need to be on hardware with multiple CPU sockets. You should be able to reproduce the CPU count values by reading in from the text file rather than the real
/proc/cpu. In any case, go ahead and submit the PR and we can review it!ellemcfarlane commentedon Jun 29, 2019
Didn't realize I could do that--makes sense. Just submitted the PR!
dbwiddis commentedon Jun 30, 2019
Fixed in #901