linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn
@ 2013-03-19  5:15 Joonsoo Kim
  2013-03-19  5:16 ` [PATCH 2/3] mm, nobootmem: clean-up of free_low_memory_core_early() Joonsoo Kim
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Joonsoo Kim @ 2013-03-19  5:15 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, linux-mm, Yinghai Lu, Johannes Weiner, Jiang Liu,
	Joonsoo Kim

max_low_pfn reflect the number of _pages_ in the system,
not the maximum PFN. You can easily find that fact in init_bootmem().
So fix it.

Additionally, if 'start_pfn == end_pfn', we don't need to go futher,
so change range check.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 5e07d36..4711e91 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -110,9 +110,9 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
 {
 	unsigned long start_pfn = PFN_UP(start);
 	unsigned long end_pfn = min_t(unsigned long,
-				      PFN_DOWN(end), max_low_pfn);
+				      PFN_DOWN(end), min_low_pfn);
 
-	if (start_pfn > end_pfn)
+	if (start_pfn >= end_pfn)
 		return 0;
 
 	__free_pages_memory(start_pfn, end_pfn);
-- 
1.7.9.5

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

* [PATCH 2/3] mm, nobootmem: clean-up of free_low_memory_core_early()
  2013-03-19  5:15 [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn Joonsoo Kim
@ 2013-03-19  5:16 ` Joonsoo Kim
  2013-03-19  5:50   ` Joonsoo Kim
  2013-03-19  5:51   ` Yinghai Lu
  2013-03-19  5:16 ` [PATCH 3/3] mm, nobootmem: do memset() after memblock_reserve() Joonsoo Kim
  2013-03-19  5:47 ` [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn Yinghai Lu
  2 siblings, 2 replies; 14+ messages in thread
From: Joonsoo Kim @ 2013-03-19  5:16 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, linux-mm, Yinghai Lu, Johannes Weiner, Jiang Liu,
	Joonsoo Kim

Remove unused argument and make function static,
because there is no user outside of nobootmem.c

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index cdc3bab..5f0b0e1 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -44,7 +44,6 @@ extern unsigned long init_bootmem_node(pg_data_t *pgdat,
 				       unsigned long endpfn);
 extern unsigned long init_bootmem(unsigned long addr, unsigned long memend);
 
-extern unsigned long free_low_memory_core_early(int nodeid);
 extern unsigned long free_all_bootmem_node(pg_data_t *pgdat);
 extern unsigned long free_all_bootmem(void);
 
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 4711e91..589c673 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -120,7 +120,7 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
 	return end_pfn - start_pfn;
 }
 
-unsigned long __init free_low_memory_core_early(int nodeid)
+static unsigned long __init free_low_memory_core_early()
 {
 	unsigned long count = 0;
 	phys_addr_t start, end, size;
@@ -170,7 +170,7 @@ unsigned long __init free_all_bootmem(void)
 	 *  because in some case like Node0 doesn't have RAM installed
 	 *  low ram will be on Node1
 	 */
-	return free_low_memory_core_early(MAX_NUMNODES);
+	return free_low_memory_core_early();
 }
 
 /**
-- 
1.7.9.5

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

* [PATCH 3/3] mm, nobootmem: do memset() after memblock_reserve()
  2013-03-19  5:15 [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn Joonsoo Kim
  2013-03-19  5:16 ` [PATCH 2/3] mm, nobootmem: clean-up of free_low_memory_core_early() Joonsoo Kim
@ 2013-03-19  5:16 ` Joonsoo Kim
  2013-03-19  5:53   ` Yinghai Lu
  2013-03-19  5:47 ` [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn Yinghai Lu
  2 siblings, 1 reply; 14+ messages in thread
From: Joonsoo Kim @ 2013-03-19  5:16 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, linux-mm, Yinghai Lu, Johannes Weiner, Jiang Liu,
	Joonsoo Kim

Currently, we do memset() before reserving the area.
This may not cause any problem, but it is somewhat weird.
So change execution order.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 589c673..f11ec1c 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -46,8 +46,8 @@ static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
 		return NULL;
 
 	ptr = phys_to_virt(addr);
-	memset(ptr, 0, size);
 	memblock_reserve(addr, size);
+	memset(ptr, 0, size);
 	/*
 	 * The min_count is set to 0 so that bootmem allocated blocks
 	 * are never reported as leaks.
-- 
1.7.9.5

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

* Re: [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn
  2013-03-19  5:15 [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn Joonsoo Kim
  2013-03-19  5:16 ` [PATCH 2/3] mm, nobootmem: clean-up of free_low_memory_core_early() Joonsoo Kim
  2013-03-19  5:16 ` [PATCH 3/3] mm, nobootmem: do memset() after memblock_reserve() Joonsoo Kim
@ 2013-03-19  5:47 ` Yinghai Lu
  2013-03-19  6:25   ` Joonsoo Kim
  2 siblings, 1 reply; 14+ messages in thread
From: Yinghai Lu @ 2013-03-19  5:47 UTC (permalink / raw)
  To: Joonsoo Kim
  Cc: Andrew Morton, linux-kernel, linux-mm, Johannes Weiner, Jiang Liu

On Mon, Mar 18, 2013 at 10:15 PM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
> max_low_pfn reflect the number of _pages_ in the system,
> not the maximum PFN. You can easily find that fact in init_bootmem().
> So fix it.

I'm confused. for x86, we have max_low_pfn defined in ...

#ifdef CONFIG_X86_32
        /* max_low_pfn get updated here */
        find_low_pfn_range();
#else
        num_physpages = max_pfn;

        check_x2apic();

        /* How many end-of-memory variables you have, grandma! */
        /* need this before calling reserve_initrd */
        if (max_pfn > (1UL<<(32 - PAGE_SHIFT)))
                max_low_pfn = e820_end_of_low_ram_pfn();
        else
                max_low_pfn = max_pfn;

and under max_low_pfn is bootmem.

>
> Additionally, if 'start_pfn == end_pfn', we don't need to go futher,
> so change range check.
>
> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>
> diff --git a/mm/nobootmem.c b/mm/nobootmem.c
> index 5e07d36..4711e91 100644
> --- a/mm/nobootmem.c
> +++ b/mm/nobootmem.c
> @@ -110,9 +110,9 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
>  {
>         unsigned long start_pfn = PFN_UP(start);
>         unsigned long end_pfn = min_t(unsigned long,
> -                                     PFN_DOWN(end), max_low_pfn);
> +                                     PFN_DOWN(end), min_low_pfn);

what is min_low_pfn ?  is it 0 for x86?

Thanks

Yinghai

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

* Re: [PATCH 2/3] mm, nobootmem: clean-up of free_low_memory_core_early()
  2013-03-19  5:16 ` [PATCH 2/3] mm, nobootmem: clean-up of free_low_memory_core_early() Joonsoo Kim
@ 2013-03-19  5:50   ` Joonsoo Kim
  2013-03-19  5:51   ` Yinghai Lu
  1 sibling, 0 replies; 14+ messages in thread
From: Joonsoo Kim @ 2013-03-19  5:50 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, linux-mm, Yinghai Lu, Johannes Weiner, Jiang Liu

On Tue, Mar 19, 2013 at 02:16:00PM +0900, Joonsoo Kim wrote:
> Remove unused argument and make function static,
> because there is no user outside of nobootmem.c
> 
> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> 
> diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
> index cdc3bab..5f0b0e1 100644
> --- a/include/linux/bootmem.h
> +++ b/include/linux/bootmem.h
> @@ -44,7 +44,6 @@ extern unsigned long init_bootmem_node(pg_data_t *pgdat,
>  				       unsigned long endpfn);
>  extern unsigned long init_bootmem(unsigned long addr, unsigned long memend);
>  
> -extern unsigned long free_low_memory_core_early(int nodeid);
>  extern unsigned long free_all_bootmem_node(pg_data_t *pgdat);
>  extern unsigned long free_all_bootmem(void);
>  
> diff --git a/mm/nobootmem.c b/mm/nobootmem.c
> index 4711e91..589c673 100644
> --- a/mm/nobootmem.c
> +++ b/mm/nobootmem.c
> @@ -120,7 +120,7 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
>  	return end_pfn - start_pfn;
>  }
>  
> -unsigned long __init free_low_memory_core_early(int nodeid)
> +static unsigned long __init free_low_memory_core_early()
>  {
>  	unsigned long count = 0;
>  	phys_addr_t start, end, size;
> @@ -170,7 +170,7 @@ unsigned long __init free_all_bootmem(void)
>  	 *  because in some case like Node0 doesn't have RAM installed
>  	 *  low ram will be on Node1
>  	 */
> -	return free_low_memory_core_early(MAX_NUMNODES);
> +	return free_low_memory_core_early();
>  }
>  
>  /**
> -- 
> 1.7.9.5
> 
> --
> 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>

Sorry, this patch makes build warning.
Below is fixed version.

-------------------->&------------------------

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

* Re: [PATCH 2/3] mm, nobootmem: clean-up of free_low_memory_core_early()
  2013-03-19  5:16 ` [PATCH 2/3] mm, nobootmem: clean-up of free_low_memory_core_early() Joonsoo Kim
  2013-03-19  5:50   ` Joonsoo Kim
@ 2013-03-19  5:51   ` Yinghai Lu
  2013-03-19  5:58     ` Joonsoo Kim
  1 sibling, 1 reply; 14+ messages in thread
From: Yinghai Lu @ 2013-03-19  5:51 UTC (permalink / raw)
  To: Joonsoo Kim
  Cc: Andrew Morton, linux-kernel, linux-mm, Johannes Weiner, Jiang Liu

On Mon, Mar 18, 2013 at 10:16 PM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
> Remove unused argument and make function static,
> because there is no user outside of nobootmem.c
>
> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>
> diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
> index cdc3bab..5f0b0e1 100644
> --- a/include/linux/bootmem.h
> +++ b/include/linux/bootmem.h
> @@ -44,7 +44,6 @@ extern unsigned long init_bootmem_node(pg_data_t *pgdat,
>                                        unsigned long endpfn);
>  extern unsigned long init_bootmem(unsigned long addr, unsigned long memend);
>
> -extern unsigned long free_low_memory_core_early(int nodeid);
>  extern unsigned long free_all_bootmem_node(pg_data_t *pgdat);
>  extern unsigned long free_all_bootmem(void);
>
> diff --git a/mm/nobootmem.c b/mm/nobootmem.c
> index 4711e91..589c673 100644
> --- a/mm/nobootmem.c
> +++ b/mm/nobootmem.c
> @@ -120,7 +120,7 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
>         return end_pfn - start_pfn;
>  }
>
> -unsigned long __init free_low_memory_core_early(int nodeid)
> +static unsigned long __init free_low_memory_core_early()

(void) ?

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

* Re: [PATCH 3/3] mm, nobootmem: do memset() after memblock_reserve()
  2013-03-19  5:16 ` [PATCH 3/3] mm, nobootmem: do memset() after memblock_reserve() Joonsoo Kim
@ 2013-03-19  5:53   ` Yinghai Lu
  2013-03-19  5:58     ` Joonsoo Kim
  0 siblings, 1 reply; 14+ messages in thread
From: Yinghai Lu @ 2013-03-19  5:53 UTC (permalink / raw)
  To: Joonsoo Kim
  Cc: Andrew Morton, linux-kernel, linux-mm, Johannes Weiner, Jiang Liu

On Mon, Mar 18, 2013 at 10:16 PM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
> Currently, we do memset() before reserving the area.
> This may not cause any problem, but it is somewhat weird.
> So change execution order.
>
> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>
> diff --git a/mm/nobootmem.c b/mm/nobootmem.c
> index 589c673..f11ec1c 100644
> --- a/mm/nobootmem.c
> +++ b/mm/nobootmem.c
> @@ -46,8 +46,8 @@ static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
>                 return NULL;
>
>         ptr = phys_to_virt(addr);
> -       memset(ptr, 0, size);
>         memblock_reserve(addr, size);
> +       memset(ptr, 0, size);

move down ptr = ... too ?

>         /*
>          * The min_count is set to 0 so that bootmem allocated blocks
>          * are never reported as leaks.
> --
> 1.7.9.5
>

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

* Re: [PATCH 3/3] mm, nobootmem: do memset() after memblock_reserve()
  2013-03-19  5:53   ` Yinghai Lu
@ 2013-03-19  5:58     ` Joonsoo Kim
  0 siblings, 0 replies; 14+ messages in thread
From: Joonsoo Kim @ 2013-03-19  5:58 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Andrew Morton, linux-kernel, linux-mm, Johannes Weiner, Jiang Liu

On Mon, Mar 18, 2013 at 10:53:04PM -0700, Yinghai Lu wrote:
> On Mon, Mar 18, 2013 at 10:16 PM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
> > Currently, we do memset() before reserving the area.
> > This may not cause any problem, but it is somewhat weird.
> > So change execution order.
> >
> > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> >
> > diff --git a/mm/nobootmem.c b/mm/nobootmem.c
> > index 589c673..f11ec1c 100644
> > --- a/mm/nobootmem.c
> > +++ b/mm/nobootmem.c
> > @@ -46,8 +46,8 @@ static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
> >                 return NULL;
> >
> >         ptr = phys_to_virt(addr);
> > -       memset(ptr, 0, size);
> >         memblock_reserve(addr, size);
> > +       memset(ptr, 0, size);
> 
> move down ptr = ... too ?
Okay.
I will send v2 soon.

> 
> >         /*
> >          * The min_count is set to 0 so that bootmem allocated blocks
> >          * are never reported as leaks.
> > --
> > 1.7.9.5
> >
> 
> --
> 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>

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

* Re: [PATCH 2/3] mm, nobootmem: clean-up of free_low_memory_core_early()
  2013-03-19  5:51   ` Yinghai Lu
@ 2013-03-19  5:58     ` Joonsoo Kim
  0 siblings, 0 replies; 14+ messages in thread
From: Joonsoo Kim @ 2013-03-19  5:58 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Andrew Morton, linux-kernel, linux-mm, Johannes Weiner, Jiang Liu

On Mon, Mar 18, 2013 at 10:51:43PM -0700, Yinghai Lu wrote:
> On Mon, Mar 18, 2013 at 10:16 PM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
> > Remove unused argument and make function static,
> > because there is no user outside of nobootmem.c
> >
> > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> >
> > diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
> > index cdc3bab..5f0b0e1 100644
> > --- a/include/linux/bootmem.h
> > +++ b/include/linux/bootmem.h
> > @@ -44,7 +44,6 @@ extern unsigned long init_bootmem_node(pg_data_t *pgdat,
> >                                        unsigned long endpfn);
> >  extern unsigned long init_bootmem(unsigned long addr, unsigned long memend);
> >
> > -extern unsigned long free_low_memory_core_early(int nodeid);
> >  extern unsigned long free_all_bootmem_node(pg_data_t *pgdat);
> >  extern unsigned long free_all_bootmem(void);
> >
> > diff --git a/mm/nobootmem.c b/mm/nobootmem.c
> > index 4711e91..589c673 100644
> > --- a/mm/nobootmem.c
> > +++ b/mm/nobootmem.c
> > @@ -120,7 +120,7 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
> >         return end_pfn - start_pfn;
> >  }
> >
> > -unsigned long __init free_low_memory_core_early(int nodeid)
> > +static unsigned long __init free_low_memory_core_early()
> 
> (void) ?

Yes, fixed version is already sent.
Thanks.

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

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

* Re: [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn
  2013-03-19  5:47 ` [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn Yinghai Lu
@ 2013-03-19  6:25   ` Joonsoo Kim
  2013-03-19  6:42     ` Joonsoo Kim
  0 siblings, 1 reply; 14+ messages in thread
From: Joonsoo Kim @ 2013-03-19  6:25 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Andrew Morton, linux-kernel, linux-mm, Johannes Weiner, Jiang Liu

On Mon, Mar 18, 2013 at 10:47:41PM -0700, Yinghai Lu wrote:
> On Mon, Mar 18, 2013 at 10:15 PM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
> > max_low_pfn reflect the number of _pages_ in the system,
> > not the maximum PFN. You can easily find that fact in init_bootmem().
> > So fix it.
> 
> I'm confused. for x86, we have max_low_pfn defined in ...

Below is queote from Russell King in 'https://lkml.org/lkml/2013/3/13/123'


 Now, max_low_pfn is initialized this way:
 
 /**
  * init_bootmem - register boot memory
  * @start: pfn where the bitmap is to be placed
  * @pages: number of available physical pages
  *
  * Returns the number of bytes needed to hold the bitmap.
  */
 unsigned long __init init_bootmem(unsigned long start, unsigned long pages)
 {
        max_low_pfn = pages;
        min_low_pfn = start;
        return init_bootmem_core(NODE_DATA(0)->bdata, start, 0, pages);
 }
 So, min_low_pfn is the PFN offset of the start of physical memory (so
 3GB >> PAGE_SHIFT) and max_low_pfn ends up being the number of pages,
 _not_ the maximum PFN value

So, if physical address doesn't start at 0, max_low_pfn doesn't represent 
the maximum PFN value. This is a case for ARM.

> 
> #ifdef CONFIG_X86_32
>         /* max_low_pfn get updated here */
>         find_low_pfn_range();
> #else
>         num_physpages = max_pfn;
> 
>         check_x2apic();
> 
>         /* How many end-of-memory variables you have, grandma! */
>         /* need this before calling reserve_initrd */
>         if (max_pfn > (1UL<<(32 - PAGE_SHIFT)))
>                 max_low_pfn = e820_end_of_low_ram_pfn();
>         else
>                 max_low_pfn = max_pfn;
> 
> and under max_low_pfn is bootmem.
> 
> >
> > Additionally, if 'start_pfn == end_pfn', we don't need to go futher,
> > so change range check.
> >
> > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> >
> > diff --git a/mm/nobootmem.c b/mm/nobootmem.c
> > index 5e07d36..4711e91 100644
> > --- a/mm/nobootmem.c
> > +++ b/mm/nobootmem.c
> > @@ -110,9 +110,9 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
> >  {
> >         unsigned long start_pfn = PFN_UP(start);
> >         unsigned long end_pfn = min_t(unsigned long,
> > -                                     PFN_DOWN(end), max_low_pfn);
> > +                                     PFN_DOWN(end), min_low_pfn);
> 
> what is min_low_pfn ?  is it 0 for x86?

My implementation is totally wrong. :)
min_low_pfn is not proper value for this purpose.

I will fix it.
Sorry for noise.

Thanks.

> 
> Thanks
> 
> Yinghai
> 
> --
> 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>

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

* Re: [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn
  2013-03-19  6:25   ` Joonsoo Kim
@ 2013-03-19  6:42     ` Joonsoo Kim
  2013-03-19  7:35       ` Yinghai Lu
  0 siblings, 1 reply; 14+ messages in thread
From: Joonsoo Kim @ 2013-03-19  6:42 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Andrew Morton, linux-kernel, linux-mm, Johannes Weiner, Jiang Liu

On Tue, Mar 19, 2013 at 03:25:22PM +0900, Joonsoo Kim wrote:
> On Mon, Mar 18, 2013 at 10:47:41PM -0700, Yinghai Lu wrote:
> > On Mon, Mar 18, 2013 at 10:15 PM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
> > > max_low_pfn reflect the number of _pages_ in the system,
> > > not the maximum PFN. You can easily find that fact in init_bootmem().
> > > So fix it.
> > 
> > I'm confused. for x86, we have max_low_pfn defined in ...
> 
> Below is queote from Russell King in 'https://lkml.org/lkml/2013/3/13/123'
> 
> 
>  Now, max_low_pfn is initialized this way:
>  
>  /**
>   * init_bootmem - register boot memory
>   * @start: pfn where the bitmap is to be placed
>   * @pages: number of available physical pages
>   *
>   * Returns the number of bytes needed to hold the bitmap.
>   */
>  unsigned long __init init_bootmem(unsigned long start, unsigned long pages)
>  {
>         max_low_pfn = pages;
>         min_low_pfn = start;
>         return init_bootmem_core(NODE_DATA(0)->bdata, start, 0, pages);
>  }
>  So, min_low_pfn is the PFN offset of the start of physical memory (so
>  3GB >> PAGE_SHIFT) and max_low_pfn ends up being the number of pages,
>  _not_ the maximum PFN value
> 
> So, if physical address doesn't start at 0, max_low_pfn doesn't represent 
> the maximum PFN value. This is a case for ARM.
> 
> > 
> > #ifdef CONFIG_X86_32
> >         /* max_low_pfn get updated here */
> >         find_low_pfn_range();
> > #else
> >         num_physpages = max_pfn;
> > 
> >         check_x2apic();
> > 
> >         /* How many end-of-memory variables you have, grandma! */
> >         /* need this before calling reserve_initrd */
> >         if (max_pfn > (1UL<<(32 - PAGE_SHIFT)))
> >                 max_low_pfn = e820_end_of_low_ram_pfn();
> >         else
> >                 max_low_pfn = max_pfn;
> > 
> > and under max_low_pfn is bootmem.
> > 
> > >
> > > Additionally, if 'start_pfn == end_pfn', we don't need to go futher,
> > > so change range check.
> > >
> > > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> > >
> > > diff --git a/mm/nobootmem.c b/mm/nobootmem.c
> > > index 5e07d36..4711e91 100644
> > > --- a/mm/nobootmem.c
> > > +++ b/mm/nobootmem.c
> > > @@ -110,9 +110,9 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
> > >  {
> > >         unsigned long start_pfn = PFN_UP(start);
> > >         unsigned long end_pfn = min_t(unsigned long,
> > > -                                     PFN_DOWN(end), max_low_pfn);
> > > +                                     PFN_DOWN(end), min_low_pfn);
> > 
> > what is min_low_pfn ?  is it 0 for x86?
> 
> My implementation is totally wrong. :)
> min_low_pfn is not proper value for this purpose.
> 
> I will fix it.
> Sorry for noise.
> 
> Thanks.

How about using "memblock.current_limit"?

unsigned long end_pfn = min_t(unsigned long, PFN_DOWN(end),
					memblock.current_limit);

Thanks.

> 
> > 
> > Thanks
> > 
> > Yinghai
> > 
> > --
> > 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>
> 
> --
> 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>

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

* Re: [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn
  2013-03-19  6:42     ` Joonsoo Kim
@ 2013-03-19  7:35       ` Yinghai Lu
  2013-03-19  8:07         ` Joonsoo Kim
  0 siblings, 1 reply; 14+ messages in thread
From: Yinghai Lu @ 2013-03-19  7:35 UTC (permalink / raw)
  To: Joonsoo Kim
  Cc: Yinghai Lu, Andrew Morton, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, Johannes Weiner, Jiang Liu

[-- Attachment #1: Type: text/plain, Size: 110 bytes --]

Can you check why sparc do not need to change interface during converting
to use memblock to replace bootmem?

[-- Attachment #2: Type: text/html, Size: 123 bytes --]

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

* Re: [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn
  2013-03-19  7:35       ` Yinghai Lu
@ 2013-03-19  8:07         ` Joonsoo Kim
  2013-03-20 20:18           ` Sam Ravnborg
  0 siblings, 1 reply; 14+ messages in thread
From: Joonsoo Kim @ 2013-03-19  8:07 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Andrew Morton, linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Johannes Weiner, Jiang Liu

On Tue, Mar 19, 2013 at 12:35:45AM -0700, Yinghai Lu wrote:
> Can you check why sparc do not need to change interface during converting
> to use memblock to replace bootmem?

Sure.
According to my understanding to sparc32 code(arch/sparc/mm/init_32.c),
they already use max_low_pfn as the maximum PFN value,
not as the number of pages.

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

* Re: [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn
  2013-03-19  8:07         ` Joonsoo Kim
@ 2013-03-20 20:18           ` Sam Ravnborg
  0 siblings, 0 replies; 14+ messages in thread
From: Sam Ravnborg @ 2013-03-20 20:18 UTC (permalink / raw)
  To: Joonsoo Kim
  Cc: Yinghai Lu, Andrew Morton, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, Johannes Weiner, Jiang Liu

On Tue, Mar 19, 2013 at 05:07:21PM +0900, Joonsoo Kim wrote:
> On Tue, Mar 19, 2013 at 12:35:45AM -0700, Yinghai Lu wrote:
> > Can you check why sparc do not need to change interface during converting
> > to use memblock to replace bootmem?
> 
> Sure.
> According to my understanding to sparc32 code(arch/sparc/mm/init_32.c),
> they already use max_low_pfn as the maximum PFN value,
> not as the number of pages.

I assume you already know...
sparc64 uses memblock, but sparc32 does not.
I looked at using memblock for sparc32 some time ago but got
distracted by other stuff.
I recall from back then that these ackward named variables confused me,
and some of my confusion was likely rooted in sparc32 using
max_low_pfn for something elase than others do.

I have no plans to look into adding memblock support for sparc32
right now. But may eventually do so when I get some spare time.

	Sam

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

end of thread, other threads:[~2013-03-20 20:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-19  5:15 [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn Joonsoo Kim
2013-03-19  5:16 ` [PATCH 2/3] mm, nobootmem: clean-up of free_low_memory_core_early() Joonsoo Kim
2013-03-19  5:50   ` Joonsoo Kim
2013-03-19  5:51   ` Yinghai Lu
2013-03-19  5:58     ` Joonsoo Kim
2013-03-19  5:16 ` [PATCH 3/3] mm, nobootmem: do memset() after memblock_reserve() Joonsoo Kim
2013-03-19  5:53   ` Yinghai Lu
2013-03-19  5:58     ` Joonsoo Kim
2013-03-19  5:47 ` [PATCH 1/3] mm, nobootmem: fix wrong usage of max_low_pfn Yinghai Lu
2013-03-19  6:25   ` Joonsoo Kim
2013-03-19  6:42     ` Joonsoo Kim
2013-03-19  7:35       ` Yinghai Lu
2013-03-19  8:07         ` Joonsoo Kim
2013-03-20 20:18           ` Sam Ravnborg

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).