Date: Sun, 29 Aug 2010 12:25:22 +0300 From: Andriy Gapon <avg@freebsd.org> To: freebsd-current@freebsd.org Subject: patch for topology detection of Intel CPUs Message-ID: <4C7A2782.5040009@freebsd.org> In-Reply-To: <4C7835E6.6070309@icyb.net.ua> References: <201007141414.o6EEEUx9014690@lurza.secnetix.de> <AANLkTinYUz0V%2B2nSWBMYLf2fL8HnUQ-fvXT0q-5WY4bb@mail.gmail.com> <4C782D3B.6020407@icyb.net.ua> <201008271743.29393.jkim@FreeBSD.org> <4C7835E6.6070309@icyb.net.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
[Reposted from stable@; edited] The below patch is against sources in FreeBSD tree, it should be applied either to sys/amd64/amd64/mp_machdep.c or sys/i386/i386/mp_machdep.c depending on the desired architecture: http://people.freebsd.org/~avg/intel-cpu-topo.diff The patch is substantially based on the Junk-uk's patch, but with some changes and additions: - topo_prob_0x4() is rewritten so that it does APIC ID matching against masks as described in the Intel article. The code still heavily depends on the assumption of the uniform topology, it discovers number of cores in BSP package and number of threads in BSP core and extrapolates that to global topology. The difference with current code and Junk-uk's patch is that actual APIC ID matching is done as opposed to deriving counts purely from max. values. - topo_prob_0x4() is invoked for 1 <= cpu_high < 4 case as well as for 4 <= cpu_high < 11 case as done in the current code, but unlike Junk-uk's patch. The code should be able to properly handle that class of CPUs and either detect hyperthreading topology or fallback to one processor per package topology. - added a few comments that describe uniformity assumption, plus couple other useful things. - changed "final fallback" code, so that each logical CPU is considered to be in its own physical package as opposed to current code placing all logical CPUs as cores of a single package. The rest is Junk-uk's work. Concerns: - about my code: ilog2_round_pow2 name is ugly; looking for suggestions on a better name or re-arranging/writing that code, so that the function is not needed. - about current code: logical_cpus variable (don't confuse with cpu_logical) doesn't seem to be consistently used; e.g. it is not set at all by topo_probo_0xb(); also, the method of using it for setting logical_cpus_mask doesn't seem to be reliable - BSP may be missed. Reviews, comments and test reports are very welcome! Please test the patch if you have any problems with how CPU topology is reported by the current code. Please test even if everything is OK, to avoid regressions. Thanks! -- Andriy Gapon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C7A2782.5040009>