• Thomas Gleixner's avatar
    x86/cpu: Provide cpu_init/parse_topology() · ebdb2036
    Thomas Gleixner authored
    Topology evaluation is a complete disaster and impenetrable mess. It's
    scattered all over the place with some vendor implementations doing early
    evaluation and some not. The most horrific part is the permanent
    overwriting of smt_max_siblings and __max_die_per_package, instead of
    establishing them once on the boot CPU and validating the result on the
    APs.
    
    The goals are:
    
      - One topology evaluation entry point
    
      - Proper sharing of pointlessly duplicated code
    
      - Proper structuring of the evaluation logic and preferences.
    
      - Evaluating important system wide information only once on the boot CPU
    
      - Making the 0xb/0x1f leaf parsing less convoluted and actually fixing
        the short comings of leaf 0x1f evaluation.
    
    Start to consolidate the topology evaluation code by providing the entry
    points for the early boot CPU evaluation and for the final parsing on the
    boot CPU and the APs.
    
    Move the trivial pieces into that new code:
    
       - The initialization of cpuinfo_x86::topo
    
       - The evaluation of CPUID leaf 1, which presets topo::initial_apicid
    
       - topo_apicid is set to topo::initial_apicid when invoked from early
         boot. When invoked for the final evaluation on the boot CPU it reads
         the actual APIC ID, which makes apic_get_initial_apicid() obsolete
         once everything is converted over.
    
    Provide a temporary helper function topo_converted() which shields off the
    not yet converted CPU vendors from invoking code which would break them.
    This shielding covers all vendor CPUs which support SMP, but not the
    historical pure UP ones as they only need the topology info init and
    eventually the initial APIC initialization.
    
    Provide two new members in cpuinfo_x86::topo to store the maximum number of
    SMT siblings and the number of dies per package and add them to the debugfs
    readout. These two members will be used to populate this information on the
    boot CPU and to validate the APs against it.
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Tested-by: default avatarJuergen Gross <jgross@suse.com>
    Tested-by: default avatarSohil Mehta <sohil.mehta@intel.com>
    Tested-by: default avatarMichael Kelley <mhklinux@outlook.com>
    Tested-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Tested-by: default avatarZhang Rui <rui.zhang@intel.com>
    Tested-by: default avatarWang Wendy <wendy.wang@intel.com>
    Tested-by: default avatarK Prateek Nayak <kprateek.nayak@amd.com>
    Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lore.kernel.org/r/20240212153624.581436579@linutronix.de
    
    
    
    ebdb2036
Makefile 1.96 KB