All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
To: Zhang Zhen <zhenzhang.zhang@huawei.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Rientjes <rientjes@google.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Toshi Kani <toshi.kani@hp.com>
Cc: wangnan0@huawei.com, Linux MM <linux-mm@kvack.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] memory-hotplug: fix not enough check of valid zones
Date: Thu, 28 Aug 2014 08:56:37 +0900	[thread overview]
Message-ID: <53FE7035.4000807@jp.fujitsu.com> (raw)
In-Reply-To: <53FDBDF0.5000200@huawei.com>

(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>

WARNING: multiple messages have this Message-ID (diff)
From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
To: Zhang Zhen <zhenzhang.zhang@huawei.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Rientjes <rientjes@google.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Toshi Kani <toshi.kani@hp.com>
Cc: <wangnan0@huawei.com>, Linux MM <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] memory-hotplug: fix not enough check of valid zones
Date: Thu, 28 Aug 2014 08:56:37 +0900	[thread overview]
Message-ID: <53FE7035.4000807@jp.fujitsu.com> (raw)
In-Reply-To: <53FDBDF0.5000200@huawei.com>

(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);
>



  parent reply	other threads:[~2014-08-27 23:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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   ` Yasuaki Ishimatsu [this message]
2014-08-27 23:56     ` [PATCH 1/2] memory-hotplug: fix not enough check of valid zones Yasuaki Ishimatsu

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=53FE7035.4000807@jp.fujitsu.com \
    --to=isimatu.yasuaki@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave.hansen@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=toshi.kani@hp.com \
    --cc=wangnan0@huawei.com \
    --cc=zhenzhang.zhang@huawei.com \
    /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 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.