linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Gordeev <agordeev@linux.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH 1/3] perf bench numa: fix incorrect NUMA toplogy assumption
Date: Tue, 30 Jun 2020 18:18:37 +0200	[thread overview]
Message-ID: <20200630161837.GA27888@oc3871087118.ibm.com> (raw)
In-Reply-To: <a53eedd6ad2fb46aec4d59066277aad7ace470b7.1593445668.git.agordeev@linux.ibm.com>

On Mon, Jun 29, 2020 at 05:50:07PM +0200, Alexander Gordeev wrote:
> The current code assumes that CPUs are evenly spread among
> NUMA nodes. That is generally incorrect and leads to failure
> on systems that have different NUMA topology.
> 
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
> ---
>  tools/perf/bench/numa.c | 27 +++++++++++++--------------
>  1 file changed, 13 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
> index 5797253..5497c74 100644
> --- a/tools/perf/bench/numa.c
> +++ b/tools/perf/bench/numa.c
> @@ -247,12 +247,13 @@ static int is_node_present(int node)
>   */
>  static bool node_has_cpus(int node)
>  {
> -	struct bitmask *cpu = numa_allocate_cpumask();
> +	struct bitmask *cpumask = numa_allocate_cpumask();
>  	unsigned int i;
>  
> -	if (cpu && !numa_node_to_cpus(node, cpu)) {
> -		for (i = 0; i < cpu->size; i++) {
> -			if (numa_bitmask_isbitset(cpu, i))
> +	BUG_ON(cpumask);

self-nack - should have been !cpumask,
will send the fixed version

> +	if (!numa_node_to_cpus(node, cpumask)) {
> +		for (i = 0; i < cpumask->size; i++) {
> +			if (numa_bitmask_isbitset(cpumask, i))
>  				return true;
>  		}
>  	}
> @@ -288,14 +289,10 @@ static cpu_set_t bind_to_cpu(int target_cpu)
>  
>  static cpu_set_t bind_to_node(int target_node)
>  {
> -	int cpus_per_node = g->p.nr_cpus / nr_numa_nodes();
>  	cpu_set_t orig_mask, mask;
>  	int cpu;
>  	int ret;
>  
> -	BUG_ON(cpus_per_node * nr_numa_nodes() != g->p.nr_cpus);
> -	BUG_ON(!cpus_per_node);
> -
>  	ret = sched_getaffinity(0, sizeof(orig_mask), &orig_mask);
>  	BUG_ON(ret);
>  
> @@ -305,13 +302,15 @@ static cpu_set_t bind_to_node(int target_node)
>  		for (cpu = 0; cpu < g->p.nr_cpus; cpu++)
>  			CPU_SET(cpu, &mask);
>  	} else {
> -		int cpu_start = (target_node + 0) * cpus_per_node;
> -		int cpu_stop  = (target_node + 1) * cpus_per_node;
> -
> -		BUG_ON(cpu_stop > g->p.nr_cpus);
> +		struct bitmask *cpumask = numa_allocate_cpumask();
>  
> -		for (cpu = cpu_start; cpu < cpu_stop; cpu++)
> -			CPU_SET(cpu, &mask);
> +		BUG_ON(!cpumask);
> +		if (!numa_node_to_cpus(target_node, cpumask)) {
> +			for (cpu = 0; cpu < (int)cpumask->size; cpu++) {
> +				if (numa_bitmask_isbitset(cpumask, cpu))
> +					CPU_SET(cpu, &mask);
> +			}
> +		}
>  	}
>  
>  	ret = sched_setaffinity(0, sizeof(mask), &mask);
> -- 
> 1.8.3.1
> 

  reply	other threads:[~2020-06-30 16:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-29 15:50 [PATCH 0/3] perf bench numa: fix few minor issues Alexander Gordeev
2020-06-29 15:50 ` [PATCH 1/3] perf bench numa: fix incorrect NUMA toplogy assumption Alexander Gordeev
2020-06-30 16:18   ` Alexander Gordeev [this message]
2020-06-30 16:18   ` [PATCH v2 " Alexander Gordeev
2020-06-29 15:50 ` [PATCH 2/3] perf bench numa: fix benchmark names Alexander Gordeev
2020-06-29 15:50 ` [PATCH 3/3] perf bench numa: fix wrong benchmark configuration Alexander Gordeev
2020-07-06  9:42 [PATCH 0/3] perf bench numa: fix few minor issues Alexander Gordeev
2020-07-06  9:42 ` [PATCH 1/3] perf bench numa: fix incorrect NUMA toplogy assumption Alexander Gordeev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200630161837.GA27888@oc3871087118.ibm.com \
    --to=agordeev@linux.ibm.com \
    --cc=acme@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).