lkml.org 
[lkml]   [2022]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 13/22] x86: smp: move cpumask_weight() out of for-loop in remove_siblinginfo
    Date
    Because argument of the function is constant inside for_each_cpu()
    loop, the cpumask_weight() does the same work O(NR_CPUS) times, while
    it may be calculated only once.

    This patch moves cpumask_weight() out of the loop and replaces it
    with cpumask_weight_eq(). While here, fix comment format.

    CC: Balbir Singh <sblbir@amazon.com>
    CC: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    CC: Borislav Petkov <bp@alien8.de>
    CC: Dave Hansen <dave.hansen@linux.intel.com>
    CC: H. Peter Anvin <hpa@zytor.com>
    CC: Huang Rui <ray.huang@amd.com>
    CC: Ingo Molnar <mingo@redhat.com>
    CC: Paul E. McKenney <paulmck@kernel.org>
    CC: Peter Zijlstra <peterz@infradead.org>
    CC: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    CC: Sean Christopherson <seanjc@google.com>
    CC: Thomas Gleixner <tglx@linutronix.de>
    CC: Tim Chen <tim.c.chen@linux.intel.com>
    CC: x86@kernel.org
    CC: linux-kernel@vger.kernel.org
    Signed-off-by: Yury Norov <yury.norov@gmail.com>
    ---
    arch/x86/kernel/smpboot.c | 5 +++--
    1 file changed, 3 insertions(+), 2 deletions(-)

    diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
    index 5e7f9532a10d..7d948f79ef31 100644
    --- a/arch/x86/kernel/smpboot.c
    +++ b/arch/x86/kernel/smpboot.c
    @@ -1605,13 +1605,14 @@ static void remove_siblinginfo(int cpu)
    {
    int sibling;
    struct cpuinfo_x86 *c = &cpu_data(cpu);
    + bool last_thread_sibling = cpumask_weight_eq(topology_sibling_cpumask(cpu), 1);

    for_each_cpu(sibling, topology_core_cpumask(cpu)) {
    cpumask_clear_cpu(cpu, topology_core_cpumask(sibling));
    - /*/
    + /*
    * last thread sibling in this cpu core going down
    */
    - if (cpumask_weight(topology_sibling_cpumask(cpu)) == 1)
    + if (last_thread_sibling)
    cpu_data(sibling).booted_cores--;
    }

    --
    2.32.0
    \
     
     \ /
      Last update: 2022-05-10 17:58    [W:6.434 / U:0.072 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site