public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Possible partial miss in pages needed for zone's memory map?
@ 2008-05-17 12:19 Johannes Weiner
  2008-05-20  6:19 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Weiner @ 2008-05-17 12:19 UTC (permalink / raw)
  To: Linux Kernel Mailing List

Hi,

I stumbled over the following in the zone initialization code.  Please
let me know if I overlooked something here.

---

From: Johannes Weiner <hannes@saeurebad.de>
Subject: [PATCH] Don't drop a partial page in a zone's memory map size

In a zone's present pages number, account for all pages occupied by the
memory map, including a partial.

Signed-off-by: Johannes Weiner <hannes@saeurebad.de>
---

--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3378,7 +3378,8 @@ static void __paginginit free_area_init_
 		 * is used by this zone for memmap. This affects the watermark
 		 * and per-cpu initialisations
 		 */
-		memmap_pages = (size * sizeof(struct page)) >> PAGE_SHIFT;
+		memmap_pages =
+			PAGE_ALIGN(size * sizeof(struct page)) >> PAGE_SHIFT;
 		if (realsize >= memmap_pages) {
 			realsize -= memmap_pages;
 			printk(KERN_DEBUG

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

* Re: Possible partial miss in pages needed for zone's memory map?
  2008-05-17 12:19 Possible partial miss in pages needed for zone's memory map? Johannes Weiner
@ 2008-05-20  6:19 ` Andrew Morton
  2008-05-20  7:02   ` KAMEZAWA Hiroyuki
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2008-05-20  6:19 UTC (permalink / raw)
  To: Johannes Weiner; +Cc: Linux Kernel Mailing List, linux-mm

On Sat, 17 May 2008 14:19:15 +0200 Johannes Weiner <hannes@saeurebad.de> wrote:

> Hi,
> 
> I stumbled over the following in the zone initialization code.  Please
> let me know if I overlooked something here.
> 

hm, no takers.  Let's add linux-mm.

> 
> From: Johannes Weiner <hannes@saeurebad.de>
> Subject: [PATCH] Don't drop a partial page in a zone's memory map size
> 
> In a zone's present pages number, account for all pages occupied by the
> memory map, including a partial.
> 
> Signed-off-by: Johannes Weiner <hannes@saeurebad.de>
> ---
> 
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -3378,7 +3378,8 @@ static void __paginginit free_area_init_
>  		 * is used by this zone for memmap. This affects the watermark
>  		 * and per-cpu initialisations
>  		 */
> -		memmap_pages = (size * sizeof(struct page)) >> PAGE_SHIFT;
> +		memmap_pages =
> +			PAGE_ALIGN(size * sizeof(struct page)) >> PAGE_SHIFT;
>  		if (realsize >= memmap_pages) {
>  			realsize -= memmap_pages;
>  			printk(KERN_DEBUG

I looked in there for 30 seconds and collapsed in confusion over which
variables are in which units.

Hint: never ever name a variable or a /proc file or your cat 
or anything else anything dimensionless like "size".  It can always be
replaced with something which communicates its units.  zones_nrbytes,
zholes_nrpages, etc.


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

* Re: Possible partial miss in pages needed for zone's memory map?
  2008-05-20  6:19 ` Andrew Morton
@ 2008-05-20  7:02   ` KAMEZAWA Hiroyuki
  0 siblings, 0 replies; 3+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-05-20  7:02 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Johannes Weiner, Linux Kernel Mailing List, linux-mm

On Mon, 19 May 2008 23:19:37 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Sat, 17 May 2008 14:19:15 +0200 Johannes Weiner <hannes@saeurebad.de> wrote:
> 
> > Hi,
> > 
> > I stumbled over the following in the zone initialization code.  Please
> > let me know if I overlooked something here.
> > 
> 
> hm, no takers.  Let's add linux-mm.
> 
> > 
> > From: Johannes Weiner <hannes@saeurebad.de>
> > Subject: [PATCH] Don't drop a partial page in a zone's memory map size
> > 
> > In a zone's present pages number, account for all pages occupied by the
> > memory map, including a partial.
> > 
> > Signed-off-by: Johannes Weiner <hannes@saeurebad.de>
> > ---
> > 
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -3378,7 +3378,8 @@ static void __paginginit free_area_init_
> >  		 * is used by this zone for memmap. This affects the watermark
> >  		 * and per-cpu initialisations
> >  		 */
> > -		memmap_pages = (size * sizeof(struct page)) >> PAGE_SHIFT;
> > +		memmap_pages =
> > +			PAGE_ALIGN(size * sizeof(struct page)) >> PAGE_SHIFT;
> >  		if (realsize >= memmap_pages) {
> >  			realsize -= memmap_pages;
> >  			printk(KERN_DEBUG
> 
> I looked in there for 30 seconds and collapsed in confusion over which
> variables are in which units.
> 
Hmm, size * sizeof(struct page) is  multiple of PAGE_SIZE in many case.
Becasue "size" is always alinged to (1 << MAX_ORDER -1) (I believe...).

ex.) In x86 case,
   (1 << (MAX_ORDER(11) - 1)) * 4 (sizeof(long)) = (1 << 12) = PAGE_SIZE.

But not sure on other archs with various params.
I think above fix is correct.

Thanks,
-Kame


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

end of thread, other threads:[~2008-05-20  6:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-17 12:19 Possible partial miss in pages needed for zone's memory map? Johannes Weiner
2008-05-20  6:19 ` Andrew Morton
2008-05-20  7:02   ` KAMEZAWA Hiroyuki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox