* [PART2 Patch] some cleanups
@ 2012-10-31 6:55 Wen Congyang
2012-10-31 6:55 ` [PART2 Patch] node: cleanup node_state_attr Wen Congyang
0 siblings, 1 reply; 5+ messages in thread
From: Wen Congyang @ 2012-10-31 6:55 UTC (permalink / raw)
To: linux-kernel, linux-mm, linux-doc
Cc: Rob Landley, Andrew Morton, Yasuaki Ishimatsu, Lai Jiangshan,
Jiang Liu, KOSAKI Motohiro, Minchan Kim, Mel Gorman,
David Rientjes, Yinghai Lu, rusty@rustcorp.com.au
From: Lai Jiangshan <laijs@cn.fujitsu.com>
This patch is part2 of the following patchset:
https://lkml.org/lkml/2012/10/29/319
Part1 is here:
https://lkml.org/lkml/2012/10/31/30
This patch only does some cleanup, and no logic change. It can be applied
without the other parts.
Lai Jiangshan (1):
node: cleanup node_state_attr
drivers/base/node.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
--
1.8.0
--
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PART2 Patch] node: cleanup node_state_attr
2012-10-31 6:55 [PART2 Patch] some cleanups Wen Congyang
@ 2012-10-31 6:55 ` Wen Congyang
2012-10-31 18:29 ` David Rientjes
0 siblings, 1 reply; 5+ messages in thread
From: Wen Congyang @ 2012-10-31 6:55 UTC (permalink / raw)
To: linux-kernel, linux-mm, linux-doc
Cc: Rob Landley, Andrew Morton, Yasuaki Ishimatsu, Lai Jiangshan,
Jiang Liu, KOSAKI Motohiro, Minchan Kim, Mel Gorman,
David Rientjes, Yinghai Lu, rusty@rustcorp.com.au
From: Lai Jiangshan <laijs@cn.fujitsu.com>
use [index] = init_value
use N_xxxxx instead of hardcode.
Make it more readability and easier to add new state.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
drivers/base/node.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/base/node.c b/drivers/base/node.c
index af1a177..5d7731e 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -614,23 +614,23 @@ static ssize_t show_node_state(struct device *dev,
{ __ATTR(name, 0444, show_node_state, NULL), state }
static struct node_attr node_state_attr[] = {
- _NODE_ATTR(possible, N_POSSIBLE),
- _NODE_ATTR(online, N_ONLINE),
- _NODE_ATTR(has_normal_memory, N_NORMAL_MEMORY),
- _NODE_ATTR(has_cpu, N_CPU),
+ [N_POSSIBLE] = _NODE_ATTR(possible, N_POSSIBLE),
+ [N_ONLINE] = _NODE_ATTR(online, N_ONLINE),
+ [N_NORMAL_MEMORY] = _NODE_ATTR(has_normal_memory, N_NORMAL_MEMORY),
#ifdef CONFIG_HIGHMEM
- _NODE_ATTR(has_high_memory, N_HIGH_MEMORY),
+ [N_HIGH_MEMORY] = _NODE_ATTR(has_high_memory, N_HIGH_MEMORY),
#endif
+ [N_CPU] = _NODE_ATTR(has_cpu, N_CPU),
};
static struct attribute *node_state_attrs[] = {
- &node_state_attr[0].attr.attr,
- &node_state_attr[1].attr.attr,
- &node_state_attr[2].attr.attr,
- &node_state_attr[3].attr.attr,
+ &node_state_attr[N_POSSIBLE].attr.attr,
+ &node_state_attr[N_ONLINE].attr.attr,
+ &node_state_attr[N_NORMAL_MEMORY].attr.attr,
#ifdef CONFIG_HIGHMEM
- &node_state_attr[4].attr.attr,
+ &node_state_attr[N_HIGH_MEMORY].attr.attr,
#endif
+ &node_state_attr[N_CPU].attr.attr,
NULL
};
--
1.8.0
--
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>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PART2 Patch] node: cleanup node_state_attr
2012-10-31 6:55 ` [PART2 Patch] node: cleanup node_state_attr Wen Congyang
@ 2012-10-31 18:29 ` David Rientjes
2012-11-01 5:52 ` Wen Congyang
0 siblings, 1 reply; 5+ messages in thread
From: David Rientjes @ 2012-10-31 18:29 UTC (permalink / raw)
To: Wen Congyang
Cc: linux-kernel, linux-mm, linux-doc, Rob Landley, Andrew Morton,
Yasuaki Ishimatsu, Lai Jiangshan, Jiang Liu, KOSAKI Motohiro,
Minchan Kim, Mel Gorman, Yinghai Lu, rusty@rustcorp.com.au
On Wed, 31 Oct 2012, Wen Congyang wrote:
> diff --git a/drivers/base/node.c b/drivers/base/node.c
> index af1a177..5d7731e 100644
> --- a/drivers/base/node.c
> +++ b/drivers/base/node.c
> @@ -614,23 +614,23 @@ static ssize_t show_node_state(struct device *dev,
> { __ATTR(name, 0444, show_node_state, NULL), state }
>
> static struct node_attr node_state_attr[] = {
> - _NODE_ATTR(possible, N_POSSIBLE),
> - _NODE_ATTR(online, N_ONLINE),
> - _NODE_ATTR(has_normal_memory, N_NORMAL_MEMORY),
> - _NODE_ATTR(has_cpu, N_CPU),
> + [N_POSSIBLE] = _NODE_ATTR(possible, N_POSSIBLE),
> + [N_ONLINE] = _NODE_ATTR(online, N_ONLINE),
> + [N_NORMAL_MEMORY] = _NODE_ATTR(has_normal_memory, N_NORMAL_MEMORY),
> #ifdef CONFIG_HIGHMEM
> - _NODE_ATTR(has_high_memory, N_HIGH_MEMORY),
> + [N_HIGH_MEMORY] = _NODE_ATTR(has_high_memory, N_HIGH_MEMORY),
> #endif
> + [N_CPU] = _NODE_ATTR(has_cpu, N_CPU),
> };
>
Why change the index for N_CPU?
> static struct attribute *node_state_attrs[] = {
> - &node_state_attr[0].attr.attr,
> - &node_state_attr[1].attr.attr,
> - &node_state_attr[2].attr.attr,
> - &node_state_attr[3].attr.attr,
> + &node_state_attr[N_POSSIBLE].attr.attr,
> + &node_state_attr[N_ONLINE].attr.attr,
> + &node_state_attr[N_NORMAL_MEMORY].attr.attr,
> #ifdef CONFIG_HIGHMEM
> - &node_state_attr[4].attr.attr,
> + &node_state_attr[N_HIGH_MEMORY].attr.attr,
> #endif
> + &node_state_attr[N_CPU].attr.attr,
> NULL
> };
>
--
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PART2 Patch] node: cleanup node_state_attr
2012-10-31 18:29 ` David Rientjes
@ 2012-11-01 5:52 ` Wen Congyang
2012-11-01 21:29 ` David Rientjes
0 siblings, 1 reply; 5+ messages in thread
From: Wen Congyang @ 2012-11-01 5:52 UTC (permalink / raw)
To: David Rientjes
Cc: linux-kernel, linux-mm, linux-doc, Rob Landley, Andrew Morton,
Yasuaki Ishimatsu, Lai Jiangshan, Jiang Liu, KOSAKI Motohiro,
Minchan Kim, Mel Gorman, Yinghai Lu, rusty@rustcorp.com.au
At 11/01/2012 02:29 AM, David Rientjes Wrote:
> On Wed, 31 Oct 2012, Wen Congyang wrote:
>
>> diff --git a/drivers/base/node.c b/drivers/base/node.c
>> index af1a177..5d7731e 100644
>> --- a/drivers/base/node.c
>> +++ b/drivers/base/node.c
>> @@ -614,23 +614,23 @@ static ssize_t show_node_state(struct device *dev,
>> { __ATTR(name, 0444, show_node_state, NULL), state }
>>
>> static struct node_attr node_state_attr[] = {
>> - _NODE_ATTR(possible, N_POSSIBLE),
>> - _NODE_ATTR(online, N_ONLINE),
>> - _NODE_ATTR(has_normal_memory, N_NORMAL_MEMORY),
>> - _NODE_ATTR(has_cpu, N_CPU),
>> + [N_POSSIBLE] = _NODE_ATTR(possible, N_POSSIBLE),
>> + [N_ONLINE] = _NODE_ATTR(online, N_ONLINE),
>> + [N_NORMAL_MEMORY] = _NODE_ATTR(has_normal_memory, N_NORMAL_MEMORY),
>> #ifdef CONFIG_HIGHMEM
>> - _NODE_ATTR(has_high_memory, N_HIGH_MEMORY),
>> + [N_HIGH_MEMORY] = _NODE_ATTR(has_high_memory, N_HIGH_MEMORY),
>> #endif
>> + [N_CPU] = _NODE_ATTR(has_cpu, N_CPU),
>> };
>>
>
> Why change the index for N_CPU?
N_CPU > N_HIGH_MEMORY
We use this array to create attr file in sysfs. So changing the index for N_CPU
doesn't cause any other problem.
Thanks
Wen Congyang
>
>> static struct attribute *node_state_attrs[] = {
>> - &node_state_attr[0].attr.attr,
>> - &node_state_attr[1].attr.attr,
>> - &node_state_attr[2].attr.attr,
>> - &node_state_attr[3].attr.attr,
>> + &node_state_attr[N_POSSIBLE].attr.attr,
>> + &node_state_attr[N_ONLINE].attr.attr,
>> + &node_state_attr[N_NORMAL_MEMORY].attr.attr,
>> #ifdef CONFIG_HIGHMEM
>> - &node_state_attr[4].attr.attr,
>> + &node_state_attr[N_HIGH_MEMORY].attr.attr,
>> #endif
>> + &node_state_attr[N_CPU].attr.attr,
>> NULL
>> };
>>
>
--
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PART2 Patch] node: cleanup node_state_attr
2012-11-01 5:52 ` Wen Congyang
@ 2012-11-01 21:29 ` David Rientjes
0 siblings, 0 replies; 5+ messages in thread
From: David Rientjes @ 2012-11-01 21:29 UTC (permalink / raw)
To: Wen Congyang
Cc: linux-kernel, linux-mm, linux-doc, Rob Landley, Andrew Morton,
Yasuaki Ishimatsu, Lai Jiangshan, Jiang Liu, KOSAKI Motohiro,
Minchan Kim, Mel Gorman, Yinghai Lu, rusty@rustcorp.com.au
On Thu, 1 Nov 2012, Wen Congyang wrote:
> >> diff --git a/drivers/base/node.c b/drivers/base/node.c
> >> index af1a177..5d7731e 100644
> >> --- a/drivers/base/node.c
> >> +++ b/drivers/base/node.c
> >> @@ -614,23 +614,23 @@ static ssize_t show_node_state(struct device *dev,
> >> { __ATTR(name, 0444, show_node_state, NULL), state }
> >>
> >> static struct node_attr node_state_attr[] = {
> >> - _NODE_ATTR(possible, N_POSSIBLE),
> >> - _NODE_ATTR(online, N_ONLINE),
> >> - _NODE_ATTR(has_normal_memory, N_NORMAL_MEMORY),
> >> - _NODE_ATTR(has_cpu, N_CPU),
> >> + [N_POSSIBLE] = _NODE_ATTR(possible, N_POSSIBLE),
> >> + [N_ONLINE] = _NODE_ATTR(online, N_ONLINE),
> >> + [N_NORMAL_MEMORY] = _NODE_ATTR(has_normal_memory, N_NORMAL_MEMORY),
> >> #ifdef CONFIG_HIGHMEM
> >> - _NODE_ATTR(has_high_memory, N_HIGH_MEMORY),
> >> + [N_HIGH_MEMORY] = _NODE_ATTR(has_high_memory, N_HIGH_MEMORY),
> >> #endif
> >> + [N_CPU] = _NODE_ATTR(has_cpu, N_CPU),
> >> };
> >>
> >
> > Why change the index for N_CPU?
>
> N_CPU > N_HIGH_MEMORY
>
> We use this array to create attr file in sysfs. So changing the index for N_CPU
> doesn't cause any other problem.
>
Acked-by: David Rientjes <rientjes@google.com>
--
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-11-01 21:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-31 6:55 [PART2 Patch] some cleanups Wen Congyang
2012-10-31 6:55 ` [PART2 Patch] node: cleanup node_state_attr Wen Congyang
2012-10-31 18:29 ` David Rientjes
2012-11-01 5:52 ` Wen Congyang
2012-11-01 21:29 ` David Rientjes
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).