DragonFly commits List (threaded) for 2009-06
DragonFly-184.108.40.2060.g7ea07 master sys/platform/pc32/i386 mp_machdep.c
Author: Sepherosa Ziehau <firstname.lastname@example.org>
Date: Wed Jun 17 19:54:22 2009 +0800
Correct the logical_cpus calculation in mptable_hyperthread_fixup()
The original code extracts logical_cpus directly from the output of
According to Intel's #253668, section 7.7
"(CPUID.1:EBX[23:16]) -- Indicates the maximum number of addressable
ID for logical processors in a physical package."
According to AMD's #25481 CPUID Fn0000_0001_EBX
"LogicalProcessorCount is the number of threads per CPU core times the
number of CPU cores per processor."
So what we originally saved in logical_cpus is actually the upper limit
of the logical CPUs per phyical CPU package. It may work correctly if
there is only one logical CPU per physical CPU package detected in MP
table. But if more than one logical CPUs per phyical CPU package are
detected in the MP table, then the missing logical CPUs will not be
detected later, since the code assumed that logical_cpus is the number
of logical CPUs missed between two detected logical CPUs.
We try to fix the problem by calculating the distances between two nearest
APIC IDs. If all such distances for all detect logical CPUs are same,
then the logical_cpus is set the calculated distance. The value extracted
from cpuid(eax=1) just serves as the upper limit of the logical_cpus now.
Reported-and-Tested-by: Robert Luciani <email@example.com>
Summary of changes:
sys/platform/pc32/i386/mp_machdep.c | 78 ++++++++++++++++++++++++++++++++--
1 files changed, 73 insertions(+), 5 deletions(-)
DragonFly BSD source repository