• Athira Rajeev's avatar
    perf bench: Fix numa bench to fix usage of affinity for machines with #CPUs > 1K · f58faed7
    Athira Rajeev authored
    The 'perf bench numa' testcase fails on systems with more than 1K CPUs.
    
    Testcase: perf bench numa mem -p 1 -t 3 -P 512 -s 100 -zZ0qcm --thp  1
    
    Snippet of code:
    
      <<>>
      perf: bench/numa.c:302: bind_to_node: Assertion `!(ret)' failed.
      Aborted (core dumped)
      <<>>
    
    bind_to_node() uses "sched_getaffinity" to save the original cpumask and
    this call is returning EINVAL ((invalid argument).
    
    This happens because the default mask size in glibc is 1024.  To
    overcome this 1024 CPUs mask size limitation of cpu_set_t, change the
    mask size using the CPU_*_S macros ie, use CPU_ALLOC to allocate
    cpumask, CPU_ALLOC_SIZE for size.
    
    Apart from fixing this for "orig_mask", apply same logic to "mask" as
    well which is used to setaffinity so that mask size is large enough to
    represent number of possible CPU's in the system.
    
    sched_getaffinity is used in one more place in perf numa bench. It is in
    "bind_to_cpu" function. Apply the same logic there also. Though
    currently no failure is reported from there, it is ideal to change
    getaffinity to work with such system configurations having CPU's more
    than default mask size supported by glibc.
    
    Also fix "sched_setaffinity" to use mask size which is large enough to
    represent number of possible CPU's in the system.
    
    Fixed all places where "bind_cpumask" which is part of "struct
    thread_data" is used such that bind_cpumask works in all configuration.
    Reported-by: default avatarDisha Goel <disgoel@linux.vnet.ibm.com>
    Signed-off-by: default avatarAthira Jajeev <atrajeev@linux.vnet.ibm.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kajol Jain <kjain@linux.ibm.com>
    Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Nageswara R Sastry <rnsastry@linux.ibm.com>
    Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
    Cc: linuxppc-dev@lists.ozlabs.org
    Link: https://lore.kernel.org/r/20220412164059.42654-3-atrajeev@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    f58faed7
numa.c 46.3 KB