From: Karel Zak <kzak@redhat.com>
To: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: util-linux@vger.kernel.org, qcai@redhat.com
Subject: Re: [PATCH 1/1] lscpu: support discontinuous NUMA nodes
Date: Mon, 6 Jan 2014 16:57:18 +0100 [thread overview]
Message-ID: <20140106155718.GH31045@x2.net.home> (raw)
In-Reply-To: <1388655877-18492-1-git-send-email-maddy@linux.vnet.ibm.com>
On Thu, Jan 02, 2014 at 03:14:37PM +0530, Madhavan Srinivasan wrote:
> lscpu fails to print proper NUMA node values in a system
> with discontinuous nodes. This patch adds support by
> creating a nodeidx array to map node numbers.
Good idea. It would be also nice to have a /sys dump from system
with discontinuous nodes. You can generate the dump by
tests/ts/lscpu/mk-input.sh foo
and send me foo.tar.gz. I'll add the dump to lscpu(1) regression
tests.
> sys-utils/lscpu.c | 47 +++++++++++++++++++++++++++++++++++++++++------
I have applied a little different patch..
> +static int
> +check_for_dir(const char *path, const char *file_name)
> +{
> + char buf[100];
> + struct stat file;
> +
> + sprintf(buf, "%s/%s", path, file_name);
this is exactly reason why we have openat/statat/... functions.
> + return stat(buf, &file) == 0 && S_ISDIR(file.st_mode);
> +}
> static void
> read_nodes(struct lscpu_desc *desc)
> {
> - int i;
> + int i=0;
> + DIR *dir=NULL;
> + struct dirent *curdir=NULL;
>
> /* number of NUMA node */
> - while (path_exist(_PATH_SYS_SYSTEM "/node/node%d", desc->nnodes))
> - desc->nnodes++;
> + dir=opendir(_PATH_SYS_NODE);
> + if(dir) {
> + while ((curdir = readdir(dir)) != NULL) {
> + if((strncmp(curdir->d_name, "node", 4) == 0) &&
> + check_for_dir(_PATH_SYS_NODE, curdir->d_name) &&
anyway, you can use dirent->d_type to avoid unnecessary stat()
Thanks!
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
prev parent reply other threads:[~2014-01-06 15:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-02 9:44 [PATCH 1/1] lscpu: support discontinuous NUMA nodes Madhavan Srinivasan
2014-01-06 15:57 ` Karel Zak [this message]
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=20140106155718.GH31045@x2.net.home \
--to=kzak@redhat.com \
--cc=maddy@linux.vnet.ibm.com \
--cc=qcai@redhat.com \
--cc=util-linux@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