linux-numa.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cliff Wickman <cpw@sgi.com>
To: anton@samba.org
Cc: linux-numa@vger.kernel.org
Subject: [PATCH] libnuma: Fix issue with numactl --hardware on sparse cpumaps
Date: Mon, 31 Aug 2009 07:46:50 -0500	[thread overview]
Message-ID: <20090831124650.GA18951@sgi.com> (raw)

Hi Anton,

Thanks for the fix.

I've started a version 2.0.4 at
ftp://oss.sgi.com/www/projects/libnuma/download/ and this is the first
patch in it.

-Cliff

> Date: Thu, 20 Aug 2009 10:10:34 +1000
> From: Anton Blanchard <anton@samba.org>
> To: linux-numa@vger.kernel.org
> Subject: [PATCH] libnuma: Fix issue with numactl --hardware on sparse cpumaps
> 
> Hi,
> 
> On a machine with sparse cpu ids, numactl fails to print the right cpus:
> 
> # numactl --hardware | grep cpus
> node 0 cpus: 0 2 4 6
> node 1 cpus:
> 
> It turns out we were iterating through 0..nr_cpus, not 0..max_cpuid. The
> following patch fixes it by using a cpumask instead of an open coded bitmask,
> and looping from 0 to the size of the cpumask.
> 
> # numactl --hardware | grep cpus
> node 0 cpus: 0 2 4 6
> node 1 cpus: 8 10 12 14
> 
> Signed-off-by: Anton Blanchard <anton@samba.org>
> ---
> 
> diff -ru numactl-2.0.3~/numactl.c numactl-2.0.3/numactl.c
> --- numactl-2.0.3~/numactl.c	2009-06-10 07:30:03.000000000 -0500
> +++ numactl-2.0.3/numactl.c	2009-08-19 18:57:10.064311316 -0500
> @@ -200,14 +200,13 @@
>  
>  void print_node_cpus(int node)
>  {
> -	int conf_cpus = numa_num_configured_cpus();
>  	int i, err;
>  	struct bitmask *cpus;
>  
> -	cpus = numa_bitmask_alloc(conf_cpus);
> +	cpus = numa_allocate_cpumask();
>  	err = numa_node_to_cpus(node, cpus);
>  	if (err >= 0) 
> -		for (i = 0; i < conf_cpus; i++) 
> +		for (i = 0; i < cpus->size; i++) 
>  			if (numa_bitmask_isbitset(cpus, i))
>  				printf(" %d", i);
>  	putchar('\n');
> 
> -- 

Cliff Wickman
SGI
cpw@sgi.com
(651) 683-3824

             reply	other threads:[~2009-08-31 12:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-31 12:46 Cliff Wickman [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-08-20  0:10 [PATCH] libnuma: Fix issue with numactl --hardware on sparse cpumaps Anton Blanchard

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=20090831124650.GA18951@sgi.com \
    --to=cpw@sgi.com \
    --cc=anton@samba.org \
    --cc=linux-numa@vger.kernel.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).