Re: [PATCH 1/1] lscpu: support discontinuous NUMA nodes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux