All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Hugh Dickins <hugh@veritas.com>, Mel Gorman <mel@csn.ul.ie>,
	Shi Weihua <shiwh@cn.fujitsu.com>,
	balbir@linux.vnet.ibm.com, xemul@openvz.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [BUGFIX][PATCH] Fix usemap initialization v3
Date: Sun, 27 Apr 2008 12:18:17 -0700	[thread overview]
Message-ID: <20080427121817.03b432ca.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080423134621.6020dd83.kamezawa.hiroyu@jp.fujitsu.com>

On Wed, 23 Apr 2008 13:46:21 +0900 KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:

> fixed typos.
> ==
> usemap must be initialized only when pfn is within zone.
> If not, it corrupts memory.
> 
> And this patch also reduces the number of calls to set_pageblock_migratetype()
> from
> 	(pfn & (pageblock_nr_pages -1)
> to
> 	!(pfn & (pageblock_nr_pages-1)
> it should be called once per pageblock.
> 
> Changelog.
> v2->v3
>  - Fixed typos.
> v1->v2
>  - Fixed boundary check.
>  - Move calculation of pointer for zone struct to out of loop.
> 
> 
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> 
> ---
>  mm/page_alloc.c |   14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> Index: linux-2.6.25/mm/page_alloc.c
> ===================================================================
> --- linux-2.6.25.orig/mm/page_alloc.c
> +++ linux-2.6.25/mm/page_alloc.c
> @@ -2518,7 +2518,9 @@ void __meminit memmap_init_zone(unsigned
>  	struct page *page;
>  	unsigned long end_pfn = start_pfn + size;
>  	unsigned long pfn;
> +	struct zone *z;
>  
> +	z = &NODE_DATA(nid)->node_zones[zone];
>  	for (pfn = start_pfn; pfn < end_pfn; pfn++) {
>  		/*
>  		 * There can be holes in boot-time mem_map[]s
> @@ -2536,7 +2538,6 @@ void __meminit memmap_init_zone(unsigned
>  		init_page_count(page);
>  		reset_page_mapcount(page);
>  		SetPageReserved(page);
> -
>  		/*
>  		 * Mark the block movable so that blocks are reserved for
>  		 * movable at startup. This will force kernel allocations
> @@ -2545,8 +2546,15 @@ void __meminit memmap_init_zone(unsigned
>  		 * kernel allocations are made. Later some blocks near
>  		 * the start are marked MIGRATE_RESERVE by
>  		 * setup_zone_migrate_reserve()
> +		 *
> +		 * bitmap is created for zone's valid pfn range. but memmap
> +		 * can be created for invalid pages (for alignment)
> +		 * check here not to call set_pageblock_migratetype() against
> +		 * pfn out of zone.
>  		 */
> -		if ((pfn & (pageblock_nr_pages-1)))
> +		if ((z->zone_start_pfn <= pfn)
> +		    && (pfn < z->zone_start_pfn + z->spanned_pages)
> +		    && !(pfn & (pageblock_nr_pages - 1)))
>  			set_pageblock_migratetype(page, MIGRATE_MOVABLE);
>  
>  		INIT_LIST_HEAD(&page->lru);
> @@ -4460,6 +4468,8 @@ void set_pageblock_flags_group(struct pa
>  	pfn = page_to_pfn(page);
>  	bitmap = get_pageblock_bitmap(zone, pfn);
>  	bitidx = pfn_to_bitidx(zone, pfn);
> +	VM_BUG_ON(pfn < zone->zone_start_pfn);
> +	VM_BUG_ON(pfn >= zone->zone_start_pfn + zone->spanned_pages);
>  
>  	for (; start_bitidx <= end_bitidx; start_bitidx++, value <<= 1)
>  		if (flags & value)

Do we think this is needed in 2.6.25.x?



WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Hugh Dickins <hugh@veritas.com>, Mel Gorman <mel@csn.ul.ie>,
	Shi Weihua <shiwh@cn.fujitsu.com>,
	balbir@linux.vnet.ibm.com, xemul@openvz.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [BUGFIX][PATCH] Fix usemap initialization v3
Date: Sun, 27 Apr 2008 12:18:17 -0700	[thread overview]
Message-ID: <20080427121817.03b432ca.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080423134621.6020dd83.kamezawa.hiroyu@jp.fujitsu.com>

On Wed, 23 Apr 2008 13:46:21 +0900 KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:

> fixed typos.
> ==
> usemap must be initialized only when pfn is within zone.
> If not, it corrupts memory.
> 
> And this patch also reduces the number of calls to set_pageblock_migratetype()
> from
> 	(pfn & (pageblock_nr_pages -1)
> to
> 	!(pfn & (pageblock_nr_pages-1)
> it should be called once per pageblock.
> 
> Changelog.
> v2->v3
>  - Fixed typos.
> v1->v2
>  - Fixed boundary check.
>  - Move calculation of pointer for zone struct to out of loop.
> 
> 
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> 
> ---
>  mm/page_alloc.c |   14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> Index: linux-2.6.25/mm/page_alloc.c
> ===================================================================
> --- linux-2.6.25.orig/mm/page_alloc.c
> +++ linux-2.6.25/mm/page_alloc.c
> @@ -2518,7 +2518,9 @@ void __meminit memmap_init_zone(unsigned
>  	struct page *page;
>  	unsigned long end_pfn = start_pfn + size;
>  	unsigned long pfn;
> +	struct zone *z;
>  
> +	z = &NODE_DATA(nid)->node_zones[zone];
>  	for (pfn = start_pfn; pfn < end_pfn; pfn++) {
>  		/*
>  		 * There can be holes in boot-time mem_map[]s
> @@ -2536,7 +2538,6 @@ void __meminit memmap_init_zone(unsigned
>  		init_page_count(page);
>  		reset_page_mapcount(page);
>  		SetPageReserved(page);
> -
>  		/*
>  		 * Mark the block movable so that blocks are reserved for
>  		 * movable at startup. This will force kernel allocations
> @@ -2545,8 +2546,15 @@ void __meminit memmap_init_zone(unsigned
>  		 * kernel allocations are made. Later some blocks near
>  		 * the start are marked MIGRATE_RESERVE by
>  		 * setup_zone_migrate_reserve()
> +		 *
> +		 * bitmap is created for zone's valid pfn range. but memmap
> +		 * can be created for invalid pages (for alignment)
> +		 * check here not to call set_pageblock_migratetype() against
> +		 * pfn out of zone.
>  		 */
> -		if ((pfn & (pageblock_nr_pages-1)))
> +		if ((z->zone_start_pfn <= pfn)
> +		    && (pfn < z->zone_start_pfn + z->spanned_pages)
> +		    && !(pfn & (pageblock_nr_pages - 1)))
>  			set_pageblock_migratetype(page, MIGRATE_MOVABLE);
>  
>  		INIT_LIST_HEAD(&page->lru);
> @@ -4460,6 +4468,8 @@ void set_pageblock_flags_group(struct pa
>  	pfn = page_to_pfn(page);
>  	bitmap = get_pageblock_bitmap(zone, pfn);
>  	bitidx = pfn_to_bitidx(zone, pfn);
> +	VM_BUG_ON(pfn < zone->zone_start_pfn);
> +	VM_BUG_ON(pfn >= zone->zone_start_pfn + zone->spanned_pages);
>  
>  	for (; start_bitidx <= end_bitidx; start_bitidx++, value <<= 1)
>  		if (flags & value)

Do we think this is needed in 2.6.25.x?


--
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:[~2008-04-27 19:19 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <48080706.50305@cn.fujitsu.com>
     [not found] ` <48080930.5090905@cn.fujitsu.com>
2008-04-18  2:46   ` [PATCH] memcgroup: check and initialize page->cgroup in memmap_init_zone Shi Weihua
2008-04-18  2:46     ` Shi Weihua
2008-04-18  3:04     ` KAMEZAWA Hiroyuki
2008-04-18  3:04       ` KAMEZAWA Hiroyuki
2008-04-18  3:14       ` Shi Weihua
2008-04-18  3:14     ` Andrew Morton
2008-04-18  3:14       ` Andrew Morton
2008-04-18  3:32       ` KAMEZAWA Hiroyuki
2008-04-18  3:32         ` KAMEZAWA Hiroyuki
2008-04-18  5:09         ` KAMEZAWA Hiroyuki
2008-04-18  5:09           ` KAMEZAWA Hiroyuki
2008-04-18  5:43           ` Shi Weihua
2008-04-18  5:43             ` Shi Weihua
2008-04-18  5:57             ` KAMEZAWA Hiroyuki
2008-04-18  5:57               ` KAMEZAWA Hiroyuki
2008-04-18  6:47             ` KAMEZAWA Hiroyuki
2008-04-18  6:47               ` KAMEZAWA Hiroyuki
2008-04-18  3:37       ` Balbir Singh
2008-04-18  3:37         ` Balbir Singh
2008-04-18  3:49         ` Shi Weihua
2008-04-18  3:49           ` Shi Weihua
2008-04-18 12:12     ` [PATCH]Fix usemap for DISCONTIG/FLATMEM with not-aligned zone initilaization KAMEZAWA Hiroyuki
2008-04-18 12:12       ` KAMEZAWA Hiroyuki
2008-04-18 16:15       ` Mel Gorman
2008-04-18 16:15         ` Mel Gorman
2008-04-18 17:25         ` kamezawa.hiroyu
2008-04-18 17:25           ` kamezawa.hiroyu
2008-04-21  2:20           ` KAMEZAWA Hiroyuki
2008-04-21  2:20             ` KAMEZAWA Hiroyuki
2008-04-21 10:12             ` Mel Gorman
2008-04-21 10:12               ` Mel Gorman
2008-04-21 10:29               ` KAMEZAWA Hiroyuki
2008-04-21 10:29                 ` KAMEZAWA Hiroyuki
2008-04-21 11:56             ` Hugh Dickins
2008-04-21 11:56               ` Hugh Dickins
2008-04-21 13:02               ` kamezawa.hiroyu
2008-04-21 13:02                 ` kamezawa.hiroyu
2008-04-22  1:40               ` [BUGFIX][PATCH] Fix usemap initialization v2 KAMEZAWA Hiroyuki
2008-04-22  1:40                 ` KAMEZAWA Hiroyuki
2008-04-22 10:12                 ` Hugh Dickins
2008-04-22 10:12                   ` Hugh Dickins
2008-04-23  1:45                   ` KAMEZAWA Hiroyuki
2008-04-23  1:45                     ` KAMEZAWA Hiroyuki
2008-04-23  2:17                   ` Shi Weihua
2008-04-23  2:17                     ` Shi Weihua
2008-04-23  4:46                 ` [BUGFIX][PATCH] Fix usemap initialization v3 KAMEZAWA Hiroyuki
2008-04-23  4:46                   ` KAMEZAWA Hiroyuki
2008-04-23  6:19                   ` Shi Weihua
2008-04-23  6:19                     ` Shi Weihua
2008-04-23  8:04                     ` KAMEZAWA Hiroyuki
2008-04-23  8:04                       ` KAMEZAWA Hiroyuki
2008-04-23 12:46                   ` Mel Gorman
2008-04-23 12:46                     ` Mel Gorman
2008-04-27 19:18                   ` Andrew Morton [this message]
2008-04-27 19:18                     ` Andrew Morton
2008-04-27 19:30                     ` Balbir Singh
2008-04-27 19:30                       ` Balbir Singh
2008-04-27 22:50                       ` Hugh Dickins
2008-04-27 22:50                         ` Hugh Dickins
2008-04-28  0:39                     ` KAMEZAWA Hiroyuki
2008-04-28  0:39                       ` KAMEZAWA Hiroyuki
2008-04-18 17:41         ` [PATCH]Fix usemap for DISCONTIG/FLATMEM with not-aligned zone initilaization Dave Hansen
2008-04-18 17:41           ` Dave Hansen

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=20080427121817.03b432ca.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=hugh@veritas.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    --cc=shiwh@cn.fujitsu.com \
    --cc=xemul@openvz.org \
    /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.