]> www.infradead.org Git - users/hch/misc.git/commit
x86/cpu: Provide a sane leaf 0xb/0x1f parser
authorThomas Gleixner <tglx@linutronix.de>
Tue, 13 Feb 2024 21:04:07 +0000 (22:04 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 15 Feb 2024 21:07:37 +0000 (22:07 +0100)
commit3d41009425225ca5e09016c634ecee513b4713bb
tree8294723a70c8414ba2ea66c2ff6b92923e1116b3
parent92853a7774f942e3692dbd83bace82333a2b47bd
x86/cpu: Provide a sane leaf 0xb/0x1f parser

detect_extended_topology() along with it's early() variant is a classic
example for duct tape engineering:

  - It evaluates an array of subleafs with a boatload of local variables
    for the relevant topology levels instead of using an array to save the
    enumerated information and propagate it to the right level

  - It has no boundary checks for subleafs

  - It prevents updating the die_id with a crude workaround instead of
    checking for leaf 0xb which does not provide die information.

  - It's broken vs. the number of dies evaluation as it uses:

      num_processors[DIE_LEVEL] / num_processors[CORE_LEVEL]

    which "works" only correctly if there is none of the intermediate
    topology levels (MODULE/TILE) enumerated.

There is zero value in trying to "fix" that code as the only proper fix is
to rewrite it from scratch.

Implement a sane parser with proper code documentation, which will be used
for the consolidated topology evaluation in the next step.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Juergen Gross <jgross@suse.com>
Tested-by: Sohil Mehta <sohil.mehta@intel.com>
Tested-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Tested-by: Wang Wendy <wendy.wang@intel.com>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://lore.kernel.org/r/20240212153624.830571770@linutronix.de
arch/x86/kernel/cpu/Makefile
arch/x86/kernel/cpu/topology.h
arch/x86/kernel/cpu/topology_ext.c [new file with mode: 0644]