All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] memory-hotplug: fix not enough check of valid zones
       [not found] <1409124238-18635-1-git-send-email-zhenzhang.zhang@huawei.com>
@ 2014-08-27 11:16   ` Zhang Zhen
  0 siblings, 0 replies; 8+ messages in thread
From: Zhang Zhen @ 2014-08-27 11:16 UTC (permalink / raw)
  To: Andrew Morton, David Rientjes, Dave Hansen, Yasuaki Ishimatsu,
	Toshi Kani
  Cc: wangnan0, Linux MM, linux-kernel

As Yasuaki Ishimatsu described the check here is not enough
if memory has hole as follows:

PFN       0x00          0xd0          0xe0          0xf0
             +-------------+-------------+-------------+
zone type   |   Normal    |     hole    |   Normal    |
             +-------------+-------------+-------------+
In this case, the check can't guarantee that this is "the last
block of memory".
The check of ZONE_MOVABLE has the same problem.

Signed-off-by: Zhang Zhen <zhenzhang.zhang@huawei.com>
---
 drivers/base/memory.c | 36 ++++++------------------------------
 1 file changed, 6 insertions(+), 30 deletions(-)

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index ccaf37c..0fc1d25 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -374,20 +374,6 @@ static ssize_t show_phys_device(struct device *dev,
 }

 #ifdef CONFIG_MEMORY_HOTREMOVE
-static int __zones_online_to(unsigned long end_pfn,
-				struct page *first_page, unsigned long nr_pages)
-{
-	struct zone *zone_next;
-
-	/* The mem block is the last block of memory. */
-	if (!pfn_valid(end_pfn + 1))
-		return 1;
-	zone_next = page_zone(first_page + nr_pages);
-	if (zone_idx(zone_next) == ZONE_MOVABLE)
-		return 1;
-	return 0;
-}
-
 static ssize_t show_zones_online_to(struct device *dev,
 				struct device_attribute *attr, char *buf)
 {
@@ -407,28 +393,18 @@ static ssize_t show_zones_online_to(struct device *dev,

 	zone = page_zone(first_page);

-#ifdef CONFIG_HIGHMEM
-	if (zone_idx(zone) == ZONE_HIGHMEM) {
-		if (__zones_online_to(end_pfn, first_page, nr_pages))
+	if (zone_idx(zone) == ZONE_MOVABLE - 1) {
+		/*The mem block is the last memoryblock of this zone.*/
+		if (end_pfn == zone_end_pfn(zone))
 			return sprintf(buf, "%s %s\n",
 					zone->name, (zone + 1)->name);
 	}
-#else
-	if (zone_idx(zone) == ZONE_NORMAL) {
-		if (__zones_online_to(end_pfn, first_page, nr_pages))
-			return sprintf(buf, "%s %s\n",
-					zone->name, (zone + 1)->name);
-	}
-#endif

 	if (zone_idx(zone) == ZONE_MOVABLE) {
-		if (!pfn_valid(start_pfn - nr_pages))
-			return sprintf(buf, "%s %s\n",
-						zone->name, (zone - 1)->name);
-		zone_prev = page_zone(first_page - nr_pages);
-		if (zone_idx(zone_prev) != ZONE_MOVABLE)
+		/*The mem block is the first memoryblock of ZONE_MOVABLE.*/
+		if (start_pfn == zone->zone_start_pfn)
 			return sprintf(buf, "%s %s\n",
-						zone->name, (zone - 1)->name);
+					zone->name, (zone - 1)->name);
 	}

 	return sprintf(buf, "%s\n", zone->name);
-- 
1.8.1.4


.





^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 1/2] memory-hotplug: fix not enough check of valid zones
@ 2014-08-27 11:16   ` Zhang Zhen
  0 siblings, 0 replies; 8+ messages in thread
From: Zhang Zhen @ 2014-08-27 11:16 UTC (permalink / raw)
  To: Andrew Morton, David Rientjes, Dave Hansen, Yasuaki Ishimatsu,
	Toshi Kani
  Cc: wangnan0, Linux MM, linux-kernel

As Yasuaki Ishimatsu described the check here is not enough
if memory has hole as follows:

PFN       0x00          0xd0          0xe0          0xf0
             +-------------+-------------+-------------+
zone type   |   Normal    |     hole    |   Normal    |
             +-------------+-------------+-------------+
In this case, the check can't guarantee that this is "the last
block of memory".
The check of ZONE_MOVABLE has the same problem.

Signed-off-by: Zhang Zhen <zhenzhang.zhang@huawei.com>
---
 drivers/base/memory.c | 36 ++++++------------------------------
 1 file changed, 6 insertions(+), 30 deletions(-)

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index ccaf37c..0fc1d25 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -374,20 +374,6 @@ static ssize_t show_phys_device(struct device *dev,
 }

 #ifdef CONFIG_MEMORY_HOTREMOVE
-static int __zones_online_to(unsigned long end_pfn,
-				struct page *first_page, unsigned long nr_pages)
-{
-	struct zone *zone_next;
-
-	/* The mem block is the last block of memory. */
-	if (!pfn_valid(end_pfn + 1))
-		return 1;
-	zone_next = page_zone(first_page + nr_pages);
-	if (zone_idx(zone_next) == ZONE_MOVABLE)
-		return 1;
-	return 0;
-}
-
 static ssize_t show_zones_online_to(struct device *dev,
 				struct device_attribute *attr, char *buf)
 {
@@ -407,28 +393,18 @@ static ssize_t show_zones_online_to(struct device *dev,

 	zone = page_zone(first_page);

-#ifdef CONFIG_HIGHMEM
-	if (zone_idx(zone) == ZONE_HIGHMEM) {
-		if (__zones_online_to(end_pfn, first_page, nr_pages))
+	if (zone_idx(zone) == ZONE_MOVABLE - 1) {
+		/*The mem block is the last memoryblock of this zone.*/
+		if (end_pfn == zone_end_pfn(zone))
 			return sprintf(buf, "%s %s\n",
 					zone->name, (zone + 1)->name);
 	}
-#else
-	if (zone_idx(zone) == ZONE_NORMAL) {
-		if (__zones_online_to(end_pfn, first_page, nr_pages))
-			return sprintf(buf, "%s %s\n",
-					zone->name, (zone + 1)->name);
-	}
-#endif

 	if (zone_idx(zone) == ZONE_MOVABLE) {
-		if (!pfn_valid(start_pfn - nr_pages))
-			return sprintf(buf, "%s %s\n",
-						zone->name, (zone - 1)->name);
-		zone_prev = page_zone(first_page - nr_pages);
-		if (zone_idx(zone_prev) != ZONE_MOVABLE)
+		/*The mem block is the first memoryblock of ZONE_MOVABLE.*/
+		if (start_pfn == zone->zone_start_pfn)
 			return sprintf(buf, "%s %s\n",
-						zone->name, (zone - 1)->name);
+					zone->name, (zone - 1)->name);
 	}

 	return sprintf(buf, "%s\n", zone->name);
-- 
1.8.1.4


.




--
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] 8+ messages in thread

* [PATCH 2/2] memory-hotplug: rename zones_online_to to valid_zones
  2014-08-27 11:16   ` Zhang Zhen
@ 2014-08-27 11:18     ` Zhang Zhen
  -1 siblings, 0 replies; 8+ messages in thread
From: Zhang Zhen @ 2014-08-27 11:18 UTC (permalink / raw)
  To: Andrew Morton, David Rientjes, Dave Hansen, Yasuaki Ishimatsu,
	Toshi Kani
  Cc: wangnan0, Linux MM, linux-kernel

Rename the interface to valid_zones according to most pepole's
suggestion.

Sample output of the sysfs files:
	memory0/valid_zones: none
	memory1/valid_zones: DMA32
	memory2/valid_zones: DMA32
	memory3/valid_zones: DMA32
	memory4/valid_zones: Normal
	memory5/valid_zones: Normal
	memory6/valid_zones: Normal Movable
	memory7/valid_zones: Movable Normal
	memory8/valid_zones: Movable

Signed-off-by: Zhang Zhen <zhenzhang.zhang@huawei.com>
---
 Documentation/ABI/testing/sysfs-devices-memory |  8 ++++----
 Documentation/memory-hotplug.txt               | 13 ++++++++++---
 drivers/base/memory.c                          |  6 +++---
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-devices-memory b/Documentation/ABI/testing/sysfs-devices-memory
index 2b2a1d7..deef3b5 100644
--- a/Documentation/ABI/testing/sysfs-devices-memory
+++ b/Documentation/ABI/testing/sysfs-devices-memory
@@ -61,13 +61,13 @@ Users:		hotplug memory remove tools
 		http://www.ibm.com/developerworks/wikis/display/LinuxP/powerpc-utils


-What:           /sys/devices/system/memory/memoryX/zones_online_to
+What:           /sys/devices/system/memory/memoryX/valid_zones
 Date:           July 2014
 Contact:	Zhang Zhen <zhenzhang.zhang@huawei.com>
 Description:
-		The file /sys/devices/system/memory/memoryX/zones_online_to
-		is read-only and is designed to show which zone this memory block can
-		be onlined to.
+		The file /sys/devices/system/memory/memoryX/valid_zones	is
+		read-only and is designed to show which zone this memory
+		block can be onlined to.

 What:		/sys/devices/system/memoryX/nodeY
 Date:		October 2009
diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt
index 5b34e33..93a25ef 100644
--- a/Documentation/memory-hotplug.txt
+++ b/Documentation/memory-hotplug.txt
@@ -155,7 +155,7 @@ Under each memory block, you can see 4 files:
 /sys/devices/system/memory/memoryXXX/phys_device
 /sys/devices/system/memory/memoryXXX/state
 /sys/devices/system/memory/memoryXXX/removable
-/sys/devices/system/memory/memoryXXX/zones_online_to
+/sys/devices/system/memory/memoryXXX/valid_zones

 'phys_index'      : read-only and contains memory block id, same as XXX.
 'state'           : read-write
@@ -171,8 +171,15 @@ Under each memory block, you can see 4 files:
                     block is removable and a value of 0 indicates that
                     it is not removable. A memory block is removable only if
                     every section in the block is removable.
-'zones_online_to' : read-only: designed to show which zone this memory block
-		    can be onlined to.
+'valid_zones'     : read-only: designed to show which zones this memory block
+		    can be onlined to.
+		    The first column shows it's default zone.
+		    "memory6/valid_zones: Normal Movable" shows this memoryblock
+		    can be onlined to ZONE_NORMAL by default and to ZONE_MOVABLE
+		    by online_movable.
+		    "memory7/valid_zones: Movable Normal" shows this memoryblock
+		    can be onlined to ZONE_MOVABLE by default and to ZONE_NORMAL
+		    by online_kernel.

 NOTE:
   These directories/files appear after physical memory hotplug phase.
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 0fc1d25..efd456c 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -374,7 +374,7 @@ static ssize_t show_phys_device(struct device *dev,
 }

 #ifdef CONFIG_MEMORY_HOTREMOVE
-static ssize_t show_zones_online_to(struct device *dev,
+static ssize_t show_valid_zones(struct device *dev,
 				struct device_attribute *attr, char *buf)
 {
 	struct memory_block *mem = to_memory_block(dev);
@@ -409,7 +409,7 @@ static ssize_t show_zones_online_to(struct device *dev,

 	return sprintf(buf, "%s\n", zone->name);
 }
-static DEVICE_ATTR(zones_online_to, 0444, show_zones_online_to, NULL);
+static DEVICE_ATTR(valid_zones, 0444, show_valid_zones, NULL);
 #endif

 static DEVICE_ATTR(phys_index, 0444, show_mem_start_phys_index, NULL);
@@ -563,7 +563,7 @@ static struct attribute *memory_memblk_attrs[] = {
 	&dev_attr_phys_device.attr,
 	&dev_attr_removable.attr,
 #ifdef CONFIG_MEMORY_HOTREMOVE
-	&dev_attr_zones_online_to.attr,
+	&dev_attr_valid_zones.attr,
 #endif
 	NULL
 };
-- 1.8.1.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] memory-hotplug: rename zones_online_to to valid_zones
@ 2014-08-27 11:18     ` Zhang Zhen
  0 siblings, 0 replies; 8+ messages in thread
From: Zhang Zhen @ 2014-08-27 11:18 UTC (permalink / raw)
  To: Andrew Morton, David Rientjes, Dave Hansen, Yasuaki Ishimatsu,
	Toshi Kani
  Cc: wangnan0, Linux MM, linux-kernel

Rename the interface to valid_zones according to most pepole's
suggestion.

Sample output of the sysfs files:
	memory0/valid_zones: none
	memory1/valid_zones: DMA32
	memory2/valid_zones: DMA32
	memory3/valid_zones: DMA32
	memory4/valid_zones: Normal
	memory5/valid_zones: Normal
	memory6/valid_zones: Normal Movable
	memory7/valid_zones: Movable Normal
	memory8/valid_zones: Movable

Signed-off-by: Zhang Zhen <zhenzhang.zhang@huawei.com>
---
 Documentation/ABI/testing/sysfs-devices-memory |  8 ++++----
 Documentation/memory-hotplug.txt               | 13 ++++++++++---
 drivers/base/memory.c                          |  6 +++---
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-devices-memory b/Documentation/ABI/testing/sysfs-devices-memory
index 2b2a1d7..deef3b5 100644
--- a/Documentation/ABI/testing/sysfs-devices-memory
+++ b/Documentation/ABI/testing/sysfs-devices-memory
@@ -61,13 +61,13 @@ Users:		hotplug memory remove tools
 		http://www.ibm.com/developerworks/wikis/display/LinuxP/powerpc-utils


-What:           /sys/devices/system/memory/memoryX/zones_online_to
+What:           /sys/devices/system/memory/memoryX/valid_zones
 Date:           July 2014
 Contact:	Zhang Zhen <zhenzhang.zhang@huawei.com>
 Description:
-		The file /sys/devices/system/memory/memoryX/zones_online_to
-		is read-only and is designed to show which zone this memory block can
-		be onlined to.
+		The file /sys/devices/system/memory/memoryX/valid_zones	is
+		read-only and is designed to show which zone this memory
+		block can be onlined to.

 What:		/sys/devices/system/memoryX/nodeY
 Date:		October 2009
diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt
index 5b34e33..93a25ef 100644
--- a/Documentation/memory-hotplug.txt
+++ b/Documentation/memory-hotplug.txt
@@ -155,7 +155,7 @@ Under each memory block, you can see 4 files:
 /sys/devices/system/memory/memoryXXX/phys_device
 /sys/devices/system/memory/memoryXXX/state
 /sys/devices/system/memory/memoryXXX/removable
-/sys/devices/system/memory/memoryXXX/zones_online_to
+/sys/devices/system/memory/memoryXXX/valid_zones

 'phys_index'      : read-only and contains memory block id, same as XXX.
 'state'           : read-write
@@ -171,8 +171,15 @@ Under each memory block, you can see 4 files:
                     block is removable and a value of 0 indicates that
                     it is not removable. A memory block is removable only if
                     every section in the block is removable.
-'zones_online_to' : read-only: designed to show which zone this memory block
-		    can be onlined to.
+'valid_zones'     : read-only: designed to show which zones this memory block
+		    can be onlined to.
+		    The first column shows it's default zone.
+		    "memory6/valid_zones: Normal Movable" shows this memoryblock
+		    can be onlined to ZONE_NORMAL by default and to ZONE_MOVABLE
+		    by online_movable.
+		    "memory7/valid_zones: Movable Normal" shows this memoryblock
+		    can be onlined to ZONE_MOVABLE by default and to ZONE_NORMAL
+		    by online_kernel.

 NOTE:
   These directories/files appear after physical memory hotplug phase.
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 0fc1d25..efd456c 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -374,7 +374,7 @@ static ssize_t show_phys_device(struct device *dev,
 }

 #ifdef CONFIG_MEMORY_HOTREMOVE
-static ssize_t show_zones_online_to(struct device *dev,
+static ssize_t show_valid_zones(struct device *dev,
 				struct device_attribute *attr, char *buf)
 {
 	struct memory_block *mem = to_memory_block(dev);
@@ -409,7 +409,7 @@ static ssize_t show_zones_online_to(struct device *dev,

 	return sprintf(buf, "%s\n", zone->name);
 }
-static DEVICE_ATTR(zones_online_to, 0444, show_zones_online_to, NULL);
+static DEVICE_ATTR(valid_zones, 0444, show_valid_zones, NULL);
 #endif

 static DEVICE_ATTR(phys_index, 0444, show_mem_start_phys_index, NULL);
@@ -563,7 +563,7 @@ static struct attribute *memory_memblk_attrs[] = {
 	&dev_attr_phys_device.attr,
 	&dev_attr_removable.attr,
 #ifdef CONFIG_MEMORY_HOTREMOVE
-	&dev_attr_zones_online_to.attr,
+	&dev_attr_valid_zones.attr,
 #endif
 	NULL
 };
-- 1.8.1.4

--
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] 8+ messages in thread

* Re: [PATCH 1/2] memory-hotplug: fix not enough check of valid zones
  2014-08-27 11:16   ` Zhang Zhen
@ 2014-08-27 23:56     ` Yasuaki Ishimatsu
  -1 siblings, 0 replies; 8+ messages in thread
From: Yasuaki Ishimatsu @ 2014-08-27 23:56 UTC (permalink / raw)
  To: Zhang Zhen, Andrew Morton, David Rientjes, Dave Hansen, Toshi Kani
  Cc: wangnan0, Linux MM, linux-kernel

(2014/08/27 20:16), Zhang Zhen wrote:
> As Yasuaki Ishimatsu described the check here is not enough
> if memory has hole as follows:
>
> PFN       0x00          0xd0          0xe0          0xf0
>               +-------------+-------------+-------------+
> zone type   |   Normal    |     hole    |   Normal    |
>               +-------------+-------------+-------------+
> In this case, the check can't guarantee that this is "the last
> block of memory".
> The check of ZONE_MOVABLE has the same problem.
>
> Signed-off-by: Zhang Zhen <zhenzhang.zhang@huawei.com>

Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

Thanks,
Yasuaki Ishimatsu

> ---
>   drivers/base/memory.c | 36 ++++++------------------------------
>   1 file changed, 6 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
> index ccaf37c..0fc1d25 100644
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -374,20 +374,6 @@ static ssize_t show_phys_device(struct device *dev,
>   }
>
>   #ifdef CONFIG_MEMORY_HOTREMOVE
> -static int __zones_online_to(unsigned long end_pfn,
> -				struct page *first_page, unsigned long nr_pages)
> -{
> -	struct zone *zone_next;
> -
> -	/* The mem block is the last block of memory. */
> -	if (!pfn_valid(end_pfn + 1))
> -		return 1;
> -	zone_next = page_zone(first_page + nr_pages);
> -	if (zone_idx(zone_next) == ZONE_MOVABLE)
> -		return 1;
> -	return 0;
> -}
> -
>   static ssize_t show_zones_online_to(struct device *dev,
>   				struct device_attribute *attr, char *buf)
>   {
> @@ -407,28 +393,18 @@ static ssize_t show_zones_online_to(struct device *dev,
>
>   	zone = page_zone(first_page);
>
> -#ifdef CONFIG_HIGHMEM
> -	if (zone_idx(zone) == ZONE_HIGHMEM) {
> -		if (__zones_online_to(end_pfn, first_page, nr_pages))
> +	if (zone_idx(zone) == ZONE_MOVABLE - 1) {
> +		/*The mem block is the last memoryblock of this zone.*/
> +		if (end_pfn == zone_end_pfn(zone))
>   			return sprintf(buf, "%s %s\n",
>   					zone->name, (zone + 1)->name);
>   	}
> -#else
> -	if (zone_idx(zone) == ZONE_NORMAL) {
> -		if (__zones_online_to(end_pfn, first_page, nr_pages))
> -			return sprintf(buf, "%s %s\n",
> -					zone->name, (zone + 1)->name);
> -	}
> -#endif
>
>   	if (zone_idx(zone) == ZONE_MOVABLE) {
> -		if (!pfn_valid(start_pfn - nr_pages))
> -			return sprintf(buf, "%s %s\n",
> -						zone->name, (zone - 1)->name);
> -		zone_prev = page_zone(first_page - nr_pages);
> -		if (zone_idx(zone_prev) != ZONE_MOVABLE)
> +		/*The mem block is the first memoryblock of ZONE_MOVABLE.*/
> +		if (start_pfn == zone->zone_start_pfn)
>   			return sprintf(buf, "%s %s\n",
> -						zone->name, (zone - 1)->name);
> +					zone->name, (zone - 1)->name);
>   	}
>
>   	return sprintf(buf, "%s\n", zone->name);
>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] memory-hotplug: fix not enough check of valid zones
@ 2014-08-27 23:56     ` Yasuaki Ishimatsu
  0 siblings, 0 replies; 8+ messages in thread
From: Yasuaki Ishimatsu @ 2014-08-27 23:56 UTC (permalink / raw)
  To: Zhang Zhen, Andrew Morton, David Rientjes, Dave Hansen, Toshi Kani
  Cc: wangnan0, Linux MM, linux-kernel

(2014/08/27 20:16), Zhang Zhen wrote:
> As Yasuaki Ishimatsu described the check here is not enough
> if memory has hole as follows:
>
> PFN       0x00          0xd0          0xe0          0xf0
>               +-------------+-------------+-------------+
> zone type   |   Normal    |     hole    |   Normal    |
>               +-------------+-------------+-------------+
> In this case, the check can't guarantee that this is "the last
> block of memory".
> The check of ZONE_MOVABLE has the same problem.
>
> Signed-off-by: Zhang Zhen <zhenzhang.zhang@huawei.com>

Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

Thanks,
Yasuaki Ishimatsu

> ---
>   drivers/base/memory.c | 36 ++++++------------------------------
>   1 file changed, 6 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
> index ccaf37c..0fc1d25 100644
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -374,20 +374,6 @@ static ssize_t show_phys_device(struct device *dev,
>   }
>
>   #ifdef CONFIG_MEMORY_HOTREMOVE
> -static int __zones_online_to(unsigned long end_pfn,
> -				struct page *first_page, unsigned long nr_pages)
> -{
> -	struct zone *zone_next;
> -
> -	/* The mem block is the last block of memory. */
> -	if (!pfn_valid(end_pfn + 1))
> -		return 1;
> -	zone_next = page_zone(first_page + nr_pages);
> -	if (zone_idx(zone_next) == ZONE_MOVABLE)
> -		return 1;
> -	return 0;
> -}
> -
>   static ssize_t show_zones_online_to(struct device *dev,
>   				struct device_attribute *attr, char *buf)
>   {
> @@ -407,28 +393,18 @@ static ssize_t show_zones_online_to(struct device *dev,
>
>   	zone = page_zone(first_page);
>
> -#ifdef CONFIG_HIGHMEM
> -	if (zone_idx(zone) == ZONE_HIGHMEM) {
> -		if (__zones_online_to(end_pfn, first_page, nr_pages))
> +	if (zone_idx(zone) == ZONE_MOVABLE - 1) {
> +		/*The mem block is the last memoryblock of this zone.*/
> +		if (end_pfn == zone_end_pfn(zone))
>   			return sprintf(buf, "%s %s\n",
>   					zone->name, (zone + 1)->name);
>   	}
> -#else
> -	if (zone_idx(zone) == ZONE_NORMAL) {
> -		if (__zones_online_to(end_pfn, first_page, nr_pages))
> -			return sprintf(buf, "%s %s\n",
> -					zone->name, (zone + 1)->name);
> -	}
> -#endif
>
>   	if (zone_idx(zone) == ZONE_MOVABLE) {
> -		if (!pfn_valid(start_pfn - nr_pages))
> -			return sprintf(buf, "%s %s\n",
> -						zone->name, (zone - 1)->name);
> -		zone_prev = page_zone(first_page - nr_pages);
> -		if (zone_idx(zone_prev) != ZONE_MOVABLE)
> +		/*The mem block is the first memoryblock of ZONE_MOVABLE.*/
> +		if (start_pfn == zone->zone_start_pfn)
>   			return sprintf(buf, "%s %s\n",
> -						zone->name, (zone - 1)->name);
> +					zone->name, (zone - 1)->name);
>   	}
>
>   	return sprintf(buf, "%s\n", zone->name);
>


--
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] 8+ messages in thread

* Re: [PATCH 2/2] memory-hotplug: rename zones_online_to to valid_zones
  2014-08-27 11:18     ` Zhang Zhen
@ 2014-08-27 23:57       ` Yasuaki Ishimatsu
  -1 siblings, 0 replies; 8+ messages in thread
From: Yasuaki Ishimatsu @ 2014-08-27 23:57 UTC (permalink / raw)
  To: Zhang Zhen, Andrew Morton, David Rientjes, Dave Hansen, Toshi Kani
  Cc: wangnan0, Linux MM, linux-kernel

(2014/08/27 20:18), Zhang Zhen wrote:
> Rename the interface to valid_zones according to most pepole's
> suggestion.
>
> Sample output of the sysfs files:
> 	memory0/valid_zones: none
> 	memory1/valid_zones: DMA32
> 	memory2/valid_zones: DMA32
> 	memory3/valid_zones: DMA32
> 	memory4/valid_zones: Normal
> 	memory5/valid_zones: Normal
> 	memory6/valid_zones: Normal Movable
> 	memory7/valid_zones: Movable Normal
> 	memory8/valid_zones: Movable
>
> Signed-off-by: Zhang Zhen <zhenzhang.zhang@huawei.com>

Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

Thanks,
Yasuaki Ishimatsu

> ---
>   Documentation/ABI/testing/sysfs-devices-memory |  8 ++++----
>   Documentation/memory-hotplug.txt               | 13 ++++++++++---
>   drivers/base/memory.c                          |  6 +++---
>   3 files changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/Documentation/ABI/testing/sysfs-devices-memory b/Documentation/ABI/testing/sysfs-devices-memory
> index 2b2a1d7..deef3b5 100644
> --- a/Documentation/ABI/testing/sysfs-devices-memory
> +++ b/Documentation/ABI/testing/sysfs-devices-memory
> @@ -61,13 +61,13 @@ Users:		hotplug memory remove tools
>   		http://www.ibm.com/developerworks/wikis/display/LinuxP/powerpc-utils
>
>
> -What:           /sys/devices/system/memory/memoryX/zones_online_to
> +What:           /sys/devices/system/memory/memoryX/valid_zones
>   Date:           July 2014
>   Contact:	Zhang Zhen <zhenzhang.zhang@huawei.com>
>   Description:
> -		The file /sys/devices/system/memory/memoryX/zones_online_to
> -		is read-only and is designed to show which zone this memory block can
> -		be onlined to.
> +		The file /sys/devices/system/memory/memoryX/valid_zones	is
> +		read-only and is designed to show which zone this memory
> +		block can be onlined to.
>
>   What:		/sys/devices/system/memoryX/nodeY
>   Date:		October 2009
> diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt
> index 5b34e33..93a25ef 100644
> --- a/Documentation/memory-hotplug.txt
> +++ b/Documentation/memory-hotplug.txt
> @@ -155,7 +155,7 @@ Under each memory block, you can see 4 files:
>   /sys/devices/system/memory/memoryXXX/phys_device
>   /sys/devices/system/memory/memoryXXX/state
>   /sys/devices/system/memory/memoryXXX/removable
> -/sys/devices/system/memory/memoryXXX/zones_online_to
> +/sys/devices/system/memory/memoryXXX/valid_zones
>
>   'phys_index'      : read-only and contains memory block id, same as XXX.
>   'state'           : read-write
> @@ -171,8 +171,15 @@ Under each memory block, you can see 4 files:
>                       block is removable and a value of 0 indicates that
>                       it is not removable. A memory block is removable only if
>                       every section in the block is removable.
> -'zones_online_to' : read-only: designed to show which zone this memory block
> -		    can be onlined to.
> +'valid_zones'     : read-only: designed to show which zones this memory block
> +		    can be onlined to.
> +		    The first column shows it's default zone.
> +		    "memory6/valid_zones: Normal Movable" shows this memoryblock
> +		    can be onlined to ZONE_NORMAL by default and to ZONE_MOVABLE
> +		    by online_movable.
> +		    "memory7/valid_zones: Movable Normal" shows this memoryblock
> +		    can be onlined to ZONE_MOVABLE by default and to ZONE_NORMAL
> +		    by online_kernel.
>
>   NOTE:
>     These directories/files appear after physical memory hotplug phase.
> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
> index 0fc1d25..efd456c 100644
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -374,7 +374,7 @@ static ssize_t show_phys_device(struct device *dev,
>   }
>
>   #ifdef CONFIG_MEMORY_HOTREMOVE
> -static ssize_t show_zones_online_to(struct device *dev,
> +static ssize_t show_valid_zones(struct device *dev,
>   				struct device_attribute *attr, char *buf)
>   {
>   	struct memory_block *mem = to_memory_block(dev);
> @@ -409,7 +409,7 @@ static ssize_t show_zones_online_to(struct device *dev,
>
>   	return sprintf(buf, "%s\n", zone->name);
>   }
> -static DEVICE_ATTR(zones_online_to, 0444, show_zones_online_to, NULL);
> +static DEVICE_ATTR(valid_zones, 0444, show_valid_zones, NULL);
>   #endif
>
>   static DEVICE_ATTR(phys_index, 0444, show_mem_start_phys_index, NULL);
> @@ -563,7 +563,7 @@ static struct attribute *memory_memblk_attrs[] = {
>   	&dev_attr_phys_device.attr,
>   	&dev_attr_removable.attr,
>   #ifdef CONFIG_MEMORY_HOTREMOVE
> -	&dev_attr_zones_online_to.attr,
> +	&dev_attr_valid_zones.attr,
>   #endif
>   	NULL
>   };
> -- 1.8.1.4
>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] memory-hotplug: rename zones_online_to to valid_zones
@ 2014-08-27 23:57       ` Yasuaki Ishimatsu
  0 siblings, 0 replies; 8+ messages in thread
From: Yasuaki Ishimatsu @ 2014-08-27 23:57 UTC (permalink / raw)
  To: Zhang Zhen, Andrew Morton, David Rientjes, Dave Hansen, Toshi Kani
  Cc: wangnan0, Linux MM, linux-kernel

(2014/08/27 20:18), Zhang Zhen wrote:
> Rename the interface to valid_zones according to most pepole's
> suggestion.
>
> Sample output of the sysfs files:
> 	memory0/valid_zones: none
> 	memory1/valid_zones: DMA32
> 	memory2/valid_zones: DMA32
> 	memory3/valid_zones: DMA32
> 	memory4/valid_zones: Normal
> 	memory5/valid_zones: Normal
> 	memory6/valid_zones: Normal Movable
> 	memory7/valid_zones: Movable Normal
> 	memory8/valid_zones: Movable
>
> Signed-off-by: Zhang Zhen <zhenzhang.zhang@huawei.com>

Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

Thanks,
Yasuaki Ishimatsu

> ---
>   Documentation/ABI/testing/sysfs-devices-memory |  8 ++++----
>   Documentation/memory-hotplug.txt               | 13 ++++++++++---
>   drivers/base/memory.c                          |  6 +++---
>   3 files changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/Documentation/ABI/testing/sysfs-devices-memory b/Documentation/ABI/testing/sysfs-devices-memory
> index 2b2a1d7..deef3b5 100644
> --- a/Documentation/ABI/testing/sysfs-devices-memory
> +++ b/Documentation/ABI/testing/sysfs-devices-memory
> @@ -61,13 +61,13 @@ Users:		hotplug memory remove tools
>   		http://www.ibm.com/developerworks/wikis/display/LinuxP/powerpc-utils
>
>
> -What:           /sys/devices/system/memory/memoryX/zones_online_to
> +What:           /sys/devices/system/memory/memoryX/valid_zones
>   Date:           July 2014
>   Contact:	Zhang Zhen <zhenzhang.zhang@huawei.com>
>   Description:
> -		The file /sys/devices/system/memory/memoryX/zones_online_to
> -		is read-only and is designed to show which zone this memory block can
> -		be onlined to.
> +		The file /sys/devices/system/memory/memoryX/valid_zones	is
> +		read-only and is designed to show which zone this memory
> +		block can be onlined to.
>
>   What:		/sys/devices/system/memoryX/nodeY
>   Date:		October 2009
> diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt
> index 5b34e33..93a25ef 100644
> --- a/Documentation/memory-hotplug.txt
> +++ b/Documentation/memory-hotplug.txt
> @@ -155,7 +155,7 @@ Under each memory block, you can see 4 files:
>   /sys/devices/system/memory/memoryXXX/phys_device
>   /sys/devices/system/memory/memoryXXX/state
>   /sys/devices/system/memory/memoryXXX/removable
> -/sys/devices/system/memory/memoryXXX/zones_online_to
> +/sys/devices/system/memory/memoryXXX/valid_zones
>
>   'phys_index'      : read-only and contains memory block id, same as XXX.
>   'state'           : read-write
> @@ -171,8 +171,15 @@ Under each memory block, you can see 4 files:
>                       block is removable and a value of 0 indicates that
>                       it is not removable. A memory block is removable only if
>                       every section in the block is removable.
> -'zones_online_to' : read-only: designed to show which zone this memory block
> -		    can be onlined to.
> +'valid_zones'     : read-only: designed to show which zones this memory block
> +		    can be onlined to.
> +		    The first column shows it's default zone.
> +		    "memory6/valid_zones: Normal Movable" shows this memoryblock
> +		    can be onlined to ZONE_NORMAL by default and to ZONE_MOVABLE
> +		    by online_movable.
> +		    "memory7/valid_zones: Movable Normal" shows this memoryblock
> +		    can be onlined to ZONE_MOVABLE by default and to ZONE_NORMAL
> +		    by online_kernel.
>
>   NOTE:
>     These directories/files appear after physical memory hotplug phase.
> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
> index 0fc1d25..efd456c 100644
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -374,7 +374,7 @@ static ssize_t show_phys_device(struct device *dev,
>   }
>
>   #ifdef CONFIG_MEMORY_HOTREMOVE
> -static ssize_t show_zones_online_to(struct device *dev,
> +static ssize_t show_valid_zones(struct device *dev,
>   				struct device_attribute *attr, char *buf)
>   {
>   	struct memory_block *mem = to_memory_block(dev);
> @@ -409,7 +409,7 @@ static ssize_t show_zones_online_to(struct device *dev,
>
>   	return sprintf(buf, "%s\n", zone->name);
>   }
> -static DEVICE_ATTR(zones_online_to, 0444, show_zones_online_to, NULL);
> +static DEVICE_ATTR(valid_zones, 0444, show_valid_zones, NULL);
>   #endif
>
>   static DEVICE_ATTR(phys_index, 0444, show_mem_start_phys_index, NULL);
> @@ -563,7 +563,7 @@ static struct attribute *memory_memblk_attrs[] = {
>   	&dev_attr_phys_device.attr,
>   	&dev_attr_removable.attr,
>   #ifdef CONFIG_MEMORY_HOTREMOVE
> -	&dev_attr_zones_online_to.attr,
> +	&dev_attr_valid_zones.attr,
>   #endif
>   	NULL
>   };
> -- 1.8.1.4
>


--
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] 8+ messages in thread

end of thread, other threads:[~2014-08-27 23:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1409124238-18635-1-git-send-email-zhenzhang.zhang@huawei.com>
2014-08-27 11:16 ` [PATCH 1/2] memory-hotplug: fix not enough check of valid zones Zhang Zhen
2014-08-27 11:16   ` Zhang Zhen
2014-08-27 11:18   ` [PATCH 2/2] memory-hotplug: rename zones_online_to to valid_zones Zhang Zhen
2014-08-27 11:18     ` Zhang Zhen
2014-08-27 23:57     ` Yasuaki Ishimatsu
2014-08-27 23:57       ` Yasuaki Ishimatsu
2014-08-27 23:56   ` [PATCH 1/2] memory-hotplug: fix not enough check of valid zones Yasuaki Ishimatsu
2014-08-27 23:56     ` Yasuaki Ishimatsu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.