linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yasunori Goto <y-goto@jp.fujitsu.com>
To: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
Cc: linux-mm <linux-mm@kvack.org>,
	clameter@sgi.com, mel@skynet.ie,
	Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Eric Whitney <eric.whitney@hp.com>
Subject: Re: [PATCH/RFC]  Add node 'states' sysfs class attribute - V2
Date: Tue, 28 Aug 2007 10:16:34 +0900	[thread overview]
Message-ID: <20070828100633.8150.Y-GOTO@jp.fujitsu.com> (raw)
In-Reply-To: <1188248528.5952.95.camel@localhost>

Hi.

> Add a sysfs class attribute file to /sys/devices/system/node
> to display node state masks.

IIRC, sysfs has the policy that each file shows only one value,
and all files keep it.

But, this states file shows 4 values.
I think you should  make 4 files which show just one value like
followings.
  /sys/devices/system/node/possible
                          /online
                          /has_normal_memory
                          /has_cpu

Thanks.

> 
> Signed-off-by:  Lee Schermerhorn <lee.schermerhorn@hp.com>
> 
>  drivers/base/node.c |   71 +++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 70 insertions(+), 1 deletion(-)
> 
> Index: Linux/drivers/base/node.c
> ===================================================================
> --- Linux.orig/drivers/base/node.c	2007-08-27 12:31:32.000000000 -0400
> +++ Linux/drivers/base/node.c	2007-08-27 16:30:18.000000000 -0400
> @@ -12,6 +12,7 @@
>  #include <linux/topology.h>
>  #include <linux/nodemask.h>
>  #include <linux/cpu.h>
> +#include <linux/device.h>
>  
>  static struct sysdev_class node_class = {
>  	set_kset_name("node"),
> @@ -232,8 +233,76 @@ void unregister_one_node(int nid)
>  	unregister_node(&node_devices[nid]);
>  }
>  
> +/*
> + * [node] states attribute
> + */
> +static char * node_state_names[] = {
> +	"possible:",
> +	"on-line:",
> +	"normal memory:",
> +#ifdef CONFIG_HIGHMEM
> +	"high memory:",
> +#endif
> +	"cpu:",
> +};
> +
> +static ssize_t
> +print_node_states(struct class *class, char *buf)
> +{
> +	int i;
> +	int n;
> +	ssize_t  size = PAGE_SIZE;
> +
> +	for (i = 0; i < NR_NODE_STATES; i++) {
> +		n = snprintf(buf, size, "%14s  ", node_state_names[i]);
> +		if (n <= 0)
> +			break;
> +		buf += n;
> +		size -= n;
> +		if (size <= 0)
> +			break;
> +
> +		n = nodelist_scnprintf(buf, size, node_states[i]);
> +		if (n <= 0)
> +			break;
> +		buf += n;
> +		size -=n;
> +		if (size <= 0)
> +			break;
> +
> +		n = snprintf(buf, size, "\n");
> +		if (n <= 0)
> +			break;
> +		buf += n;
> +		size -= n;
> +		if (size <= 0)
> +			break;
> +	}
> +
> +	if (n > 0) {
> +		n = PAGE_SIZE;
> +		if (size > 0)
> +			n -= size;
> +	}
> +	return n;
> +}
> +
> +static CLASS_ATTR(states, 0444, print_node_states, NULL);
> +
> +static int node_states_init(void)
> +{
> +	return sysfs_create_file(&node_class.kset.kobj,
> +				&class_attr_states.attr);
> +}
> +
>  static int __init register_node_type(void)
>  {
> -	return sysdev_class_register(&node_class);
> +	int ret;
> +
> +	ret = sysdev_class_register(&node_class);
> +	if (!ret)
> +		ret = node_states_init();
> +
> +	return ret;
>  }
>  postcore_initcall(register_node_type);
> 

-- 
Yasunori Goto 


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2007-08-28  1:16 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200708242228.l7OMS5fU017948@imap1.linux-foundation.org>
2007-08-27 15:58 ` [PATCH] 2.6.23-rc3-mm1 - update N_HIGH_MEMORY node state for memory hotadd Lee Schermerhorn
2007-08-27 17:48 ` [PATCH/RFC] Add node 'states' sysfs class attribute Lee Schermerhorn
2007-08-27 19:11   ` Christoph Lameter
2007-08-27 20:08     ` Lee Schermerhorn
2007-08-27 20:15       ` Christoph Lameter
2007-08-27 21:02 ` [PATCH/RFC] Add node 'states' sysfs class attribute - V2 Lee Schermerhorn
2007-08-27 21:04   ` Christoph Lameter
2007-08-28  0:01   ` Andrew Morton
2007-08-28  0:08     ` Christoph Lameter
2007-08-28  1:14       ` Andrew Morton
2007-08-28  1:29         ` Christoph Lameter
2007-08-28  3:18           ` Andrew Morton
2007-08-28  5:15             ` Christoph Lameter
2007-08-28  5:29               ` Andrew Morton
2007-08-28  5:34                 ` Andrew Morton
2007-08-28  5:53                 ` Christoph Lameter
2007-08-28  6:12                   ` Andrew Morton
2007-08-28 14:05                     ` Lee Schermerhorn
2007-08-28 22:02                       ` Christoph Lameter
2007-08-28 22:13                         ` Nish Aravamudan
2007-08-29 14:43                           ` Lee Schermerhorn
2007-08-29 17:39                             ` Christoph Lameter
2007-08-29 21:31                               ` [PATCH/RFC] Add node states sysfs class attributeS - V3 Lee Schermerhorn
2007-08-29 22:14                                 ` Christoph Lameter
2007-08-30 13:34                                   ` Lee Schermerhorn
2007-08-29 22:36                                 ` Nish Aravamudan
2007-08-30 15:19                               ` [PATCH/RFC] Add node states sysfs class attributeS - V4 Lee Schermerhorn
2007-08-30 16:44                                 ` Nish Aravamudan
2007-08-30 18:20                                   ` Christoph Lameter
2007-08-30 18:19                                 ` Christoph Lameter
2007-08-30 18:41                                   ` Lee Schermerhorn
2007-09-11 13:56                               ` [PATCH/RFC] Add node states sysfs class attributeS - V5 Lee Schermerhorn
2007-09-11 20:25                                 ` Christoph Lameter
2007-09-14 10:50                                 ` Andrew Morton
2007-09-14 11:35                                   ` Andy Whitcroft
2007-09-14 14:34                                     ` Lee Schermerhorn
2007-09-14 14:43                                   ` Mel Gorman
2007-09-14 15:00                                     ` Paul Mundt
2007-09-16 12:10                                       ` Mel Gorman
2007-09-14 16:00                                     ` Martin J. Bligh
2007-08-28 19:34                     ` [PATCH/RFC] Add node 'states' sysfs class attribute - V2 Christoph Lameter
2007-08-28  1:16   ` Yasunori Goto [this message]
2007-08-28  1:21     ` Yasunori Goto

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=20070828100633.8150.Y-GOTO@jp.fujitsu.com \
    --to=y-goto@jp.fujitsu.com \
    --cc=Lee.Schermerhorn@hp.com \
    --cc=akpm@linux-foundation.org \
    --cc=clameter@sgi.com \
    --cc=eric.whitney@hp.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=mel@skynet.ie \
    /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