• Anju T Sudhakar's avatar
    powerpc/perf: Use cpumask_last() to determine the designated cpu for nest/core units. · 9c9f8fb7
    Anju T Sudhakar authored
    Nest and core IMC (In-Memory Collection counters) assigns a particular
    cpu as the designated target for counter data collection. During
    system boot, the first online cpu in a chip gets assigned as the
    designated cpu for that chip(for nest-imc) and the first online cpu in
    a core gets assigned as the designated cpu for that core(for
    core-imc).
    
    If the designated cpu goes offline, the next online cpu from the same
    chip(for nest-imc)/core(for core-imc) is assigned as the next target,
    and the event context is migrated to the target cpu. Currently,
    cpumask_any_but() function is used to find the target cpu. Though this
    function is expected to return a `random` cpu, this always returns the
    next online cpu.
    
    If all cpus in a chip/core is offlined in a sequential manner,
    starting from the first cpu, the event migration has to happen for all
    the cpus which goes offline. Since the migration process involves a
    grace period, the total time taken to offline all the cpus will be
    significantly high.
    
    Example:
      In a system which has 2 sockets, with
      NUMA node0 CPU(s):     0-87
      NUMA node8 CPU(s):     88-175
    
      Time taken to offline cpu 88-175:
      real    2m56.099s
      user    0m0.191s
      sys     0m0.000s
    
    Use cpumask_last() to choose the target cpu, when the designated cpu
    goes online, so the migration will happen only when the last_cpu in
    the mask goes offline. This way the time taken to offline all cpus in
    a chip/core can be reduced.
    
    With the patch:
    
      Time taken  to offline cpu 88-175:
      real    0m12.207s
      user    0m0.171s
      sys     0m0.000s
    
    Offlining all cpus in reverse order is also taken care because,
    cpumask_any_but() is used to find the designated cpu if the last cpu
    in the mask goes offline. Since cpumask_any_but() always return the
    first cpu in the mask, that becomes the designated cpu and migration
    will happen only when the first_cpu in the mask goes offline.
    
    Example: With the patch,
    
      Time taken to offline cpu from 175-88:
      real    0m9.330s
      user    0m0.110s
      sys     0m0.000s
    Signed-off-by: default avatarAnju T Sudhakar <anju@linux.vnet.ibm.com>
    Reviewed-by: default avatarMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    9c9f8fb7
imc-pmu.c 42.2 KB