Quad core not detected (only 2 core)

Project:JNode Core
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi,

I have removed the grub option mp=no and starting kvm with -smp 4.

But jnode detect only 2 physical cpu.

I have found the problem, he come from initializeProcessors method.
Cpu are put one an Hashmap physCpus, the Hashmap key is the result of this method : CpuID.getPhysicalPackageId(apicId)
But this method not use the parameter apicId and return always the same result.

I need some help to fix it, thanks...

VmX86Architecture.initializeProcessors method :
...
// Find all physical AP processors
final X86CpuID cpuId = (X86CpuID) bootCpu.getCPUID();
final HashMap physCpus = new HashMap();
for (MPEntry e : mpConfigTable.entries()) {
if (e.getEntryType() == 0) {
final MPProcessorEntry cpuEntry = (MPProcessorEntry) e;
System.out.println("ENtry : "+cpuEntry.toString()+" "+cpuId.getPhysicalPackageId(cpuEntry.getApicID()));
if (cpuEntry.isEnabled() && !cpuEntry.isBootstrap()) {
// Check if it is a physical CPU
int physId = cpuId.getPhysicalPackageId(apicId);
// This algorithme is based on the specification
// that physical processors are listed before logical
// processors.
if (!physCpus.containsKey(physId)) {
// New physical CPU found
physCpus.put(physId, cpuEntry);
}
}
}
}

X86CpuID class :

/**
* Calculate the physical package id for the given APIC id.
*
* @param apicId
* @return the physical package id.
*/
public final int getPhysicalPackageId(int apicId) {
int index_lsb = 0;
int index_msb = 31;
final int numLogicalProcessors = getLogicalProcessors();

int tmp = numLogicalProcessors;
while ((tmp & 1) == 0) {
tmp >>= 1;
index_lsb++;
}
tmp = numLogicalProcessors;
while ((tmp & 0x80000000) == 0) {
tmp <<= 1;
index_msb--;
}
if (index_lsb != index_msb) {
index_msb++;
}

return ((data[5] >> 24) & 0xFF) >> index_msb;
}

#1

Im afraid this is actually a very small part of a much larger issue. That issue at the moment is that SMP/Multi-Core is unsupported and does not function. I believe that main problem is the scheduler, but there are also major synchronization issues within the core of jnode that while they might be single-processor safe, they are not multi-processor safe.

SMP in jnode is something that needs some serious attention. The above issue may also be the reason why the same processor is being returned.

#2

I have read it, I not use Jnode smp on production Eye-wink

>>> SMP in jnode is something that needs some serious attention. The above issue may also be the reason why the same processor is being returned.
I thinks not because one second CPU (after boot cpu) is detected but not cpu 3 and 4.
Actually SMP is disabled with the Grub option mp=no.

I having temporary fix this issue but, I need help to fix correctly this method : getPhysicalPackageId(ApicID)

Now try to debug Monitor class I having this message "Current thread is not the owner of this monitor" on exit method.