• Michael Ellerman's avatar
    cpu/SMT: Create topology_smt_thread_allowed() · 38253464
    Michael Ellerman authored
    Some architectures allows partial SMT states, i.e. when not all SMT threads
    are brought online.
    
    To support that, add an architecture helper which checks whether a given
    CPU is allowed to be brought online depending on how many SMT threads are
    currently enabled. Since this is only applicable to architecture supporting
    partial SMT, only these architectures should select the new configuration
    variable CONFIG_SMT_NUM_THREADS_DYNAMIC. For the other architectures, not
    supporting the partial SMT states, there is no need to define
    topology_cpu_smt_allowed(), the generic code assumed that all the threads
    are allowed or only the primary ones.
    
    Call the helper from cpu_smt_enable(), and cpu_smt_allowed() when SMT is
    enabled, to check if the particular thread should be onlined. Notably,
    also call it from cpu_smt_disable() if CPU_SMT_ENABLED, to allow
    offlining some threads to move from a higher to lower number of threads
    online.
    
    [ ldufour: Slightly reword the commit's description ]
    [ ldufour: Introduce CONFIG_SMT_NUM_THREADS_DYNAMIC ]
    Suggested-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: default avatarLaurent Dufour <ldufour@linux.ibm.com>
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Tested-by: default avatarZhang Rui <rui.zhang@intel.com>
    Link: https://lore.kernel.org/r/20230705145143.40545-7-ldufour@linux.ibm.com
    38253464
Kconfig 44.7 KB